<?php
define('Admin_USER',true);
session_start();
if(!isset($_SESSION['adm1n']) || $_SESSION['adm1n']['Nbr'] == ''){
  
       header("Location: ../misc/default.php");
       exit;
       
}
require_once("../../includes/php/defines.php");
require_once("../../includes/php/classes/mainClass.php");
require_once("../../includes/php/classes/cmsClass.php");

$cms = new cmsClass();
$pages = $cms->getPages();
?>
<section>
<div class="container-fluid">
    <div class="container">
            <div class="col-md-12 result-heading">
                <h1>Content Managed Pages</h1>&nbsp;
                  <div id="Animation">
                  <div class="blockG" id="rotateG_01"></div>
                  <div class="blockG" id="rotateG_02"></div>
                  <div class="blockG" id="rotateG_03"></div>
                  <div class="blockG" id="rotateG_04"></div>
                  <div class="blockG" id="rotateG_05"></div>
                  <div class="blockG" id="rotateG_06"></div>
                  <div class="blockG" id="rotateG_07"></div>
                  <div class="blockG" id="rotateG_08"></div>                                            
              </div>
              <div id="Result" style="margin-bottom:25px;"></div>  
            </div>
        <div id="RowContainer">
       <?php
       if($pages[0]['Nbr'] != ''){
           
           for($i=0;$i<count($pages);$i++){
               
                echo '<div class="col-md-12 ';
                if($i == 0 || $i%2 == 0) { echo ' light-white'; }
                echo '" id="Row_'.$pages[$i]['Nbr'].'" name="Row_'.$pages[$i]['Nbr'].'">';
                echo '<div class="result-form">';
                if($pages[$i]['Status'] == '1'){
                    
                    echo '<span class="active">ACTIVE</span>';
                    
                }else{
                    
                    echo '<span class="inactive">INACTIVE</span>';
                    
                }                  
                echo '<h2 class="listing-header-link" onclick="contentChanger(\'content-manager/edit-page.php\',\''.$pages[$i]['Nbr'].'\',\'\',\'content-manager/manage-pages.php\');" title="Edit '.$pages[$i]['Name'].'">'.$pages[$i]['Name'].'</h2>';            
                echo '<p style="clear:both;">';
                echo '<strong>Last Updated:</strong> '.date("l F d, Y @ g:i a",$pages[$i]['Last_Updated']).'<br/>';
                echo '<strong>Title Tag:</strong> '.$pages[$i]['Title_Tag'].'<br/>';
                echo '<strong>Keywords Tag:</strong> '.$pages[$i]['Keywords_Tag'].'<br/>';
                echo '<strong>Description Tag:</strong> '.$pages[$i]['Description_Tag'].'<br/>';
                echo '</p>';
                echo '<p style="padding-top:20px;">';
                echo '[ <span class="edit" title="Edit '.$pages[$i]['Name'].'" onclick="contentChanger(\'content-manager/edit-page.php\',\''.$pages[$i]['Nbr'].'\',\'\',\'content-manager/manage-pages.php\');">EDIT</span> ]';                
                if($_SESSION['adm1n']['Nbr'] == '1'){
                    
                    echo ' &nbsp;|&nbsp; [ <span class="delete" title="Delete '.$pages[$i]['Name'].'" onclick="deleteRow(\'Delete-CMP\',\''.$pages[$i]['Nbr'].'\')">DELETE</span> ]';                            
               
                }
                echo '</p>';                
                echo '</div>';
                echo '</div>';
                
           }
        
       }else{
           
           echo '<div class="col-md-12 light-white><div class="result-form"><h2>There are no content manageable pages to manage at this time.</h2></div></div>';
           
       }
     ?>
    </div>
    </div>
</div>
</section>