Location: PHPKode > projects > phpAWE > phpAWE.0.4.beta.demo-page/awe/aweManager/index.php
<?php

$PHP_AWE_DIR  = "../";
$PHP_AWE_BASE_FUNC = "base.php";
$PHP_AWE_UTILS_FUNC= "utils.php";
$PHP_AWE_CONFIG_DIR = $PHP_AWE_DIR."aweManager/config/";    
$PHP_AWE_CONF_FILE = "config.php";
$PHP_AWE_DB_CONFIG = "db.php";

set_include_path($PHP_AWE_DIR."classes");

// INCLUDE BASE ENGINE //
if (!file_exists($PHP_AWE_DIR.$PHP_AWE_BASE_FUNC) or !file_exists($PHP_AWE_CONFIG_DIR.$PHP_AWE_CONF_FILE))
   die ("phpAWE critical error: main files cannot be found");
   
require($PHP_AWE_DIR.$PHP_AWE_BASE_FUNC);
require($PHP_AWE_DIR.$PHP_AWE_UTILS_FUNC);
require($PHP_AWE_CONFIG_DIR.$PHP_AWE_CONF_FILE);
require($PHP_AWE_CONFIG_DIR.$PHP_AWE_DB_CONFIG);



//session_start();

if (!isset($_GET[id1])) $_GET[id1] = 0;

$aweManView = new TawePageView("ManView");
$awePageMenu = new TawePageMenu("PageMenu", "id");
$awePageItem = new TawePageItem("PageItem", "itemid", $awePageMenu);
//$awePageMenu->updateNewItem("Dodatkowy katalog",1000,0,0,0);
//

$body = $aweManView->view($_GET[mode]);

$body = str_replace("%tree%", $awePageMenu->view(
                                    "getChildren",
                                    array(0,"pos"),
                                    $_GET,
                                    array("tree","subtree"),
                                    "distinct_expandable|distinct_last",
                                    array("expand_all"),
                                    "",
                                    5,
                                    ".jpg"
                                    )
                    , $body);


if (!strcmp($_GET[mode], "1")) {

  switch ($_GET[edit]) {
    case 'PageItem':
      switch($_GET[action]) {
        case 'add': 
          $awePageItem->updateNewItem($_POST[name], $_GET[id1]);
        break;
        case 'edit': 
          if (isset($_POST[zapisz])) $awePageItem->updateChangeItem($_GET[toedit], $_POST[name]);
        break;
        case 'chdir': 
          if (isset($_POST[zapisz])) $awePageItem->updateChangeParent($_GET[toedit],$_POST[chdir]);
        break;
        case 'remove':
          $awePageItem->updateRemoveItem($_GET[toedit]);
        break;
        case 'top':
          $awePageItem->updateMoveTop($_GET[toedit]);  
        break;
        case 'up': 
          $awePageItem->updateMoveUp($_GET[toedit]); 
        break;
        case 'down': 
          $awePageItem->updateMoveDown($_GET[toedit]); 
        break;
        case 'bottom': 
          $awePageItem->updateMoveBottom($_GET[toedit]);
        break;
      } 
    break;
    case 'PageMenu':
      switch($_GET[action]) {
        case 'add': 
          if (isset($_POST[zapisz])) $awePageMenu->updateNewItem($_POST[name], $_GET[id1]);
        break;
        case 'edit': 
          if (isset($_POST[zapisz])) $awePageMenu->updateChangeItem($_GET[toedit], $_POST[name]);
        break;
        case 'chdir': 
          if (isset($_POST[zapisz])) $awePageMenu->updateChangeParent($_GET[toedit], $_POST[chdir]);
        break;
        case 'remove':
          $awePageMenu->updateRemoveItem($_GET[toedit]);
        break;
        case 'top':
          $awePageMenu->updateMoveTop($_GET[toedit]); 
        break;
        case 'up':
          $awePageMenu->updateMoveUp($_GET[toedit]);  
        break;
        case 'down':
          $awePageMenu->updateMoveDown($_GET[toedit]); 
        break;
          
        case 'bottom':
          $awePageMenu->updateMoveBottom($_GET[toedit]); 
        break;
      } 
    break;
  }


$content .= $awePageMenu->view(
                         "getChildren", 
                         array($awePageMenu->itemTopSelectedId($_GET),"pos"),
                         $_GET,
                         array("list"),
                         "distinct_last|distinct_first",
                         "",
                         "",
                         0,
                         ".jpg"
                         );
                         

                         
$content .= $awePageItem->view(
                                "getDirlist",
                                array($awePageMenu->itemTopSelectedId($_GET), 0), 
                                $_GET,
                                "list",
                                "distinct_last|distinct_first",
                                ".jpg"
                                );

$body = str_replace("%list%", $content, $body);
    

    
}

if (!strcmp($_GET[mode], "2")) { 
  switch ($_GET[edit]) {
    case 'PageItem':
      switch($_GET[action]) {
        case 'add':
          $body = str_replace("%edit%", file_get_contents(getItemTemplate("PageItem" ,"addForm")), $body); 
        break;
        case 'edit':
        $body = str_replace("%edit%", $awePageItem->view(
                                "getItem",
                                array($_GET[toedit]), 
                                $_GET,
                                "editForm",
                                "",
                                ".jpg"
                                ) 
                            ,$body);
        break;
        case 'chdir':
          $body = str_replace("%edit%", $awePageMenu->view(
                                    "getChildren",
                                    array(0,"pos"),
                                    $_GET,
                                    array("chdirFormItem","subchdirFormItem"),
                                    "",
                                    array("expand_all"),
                                    "",
                                    5,
                                    ".jpg"
                                    )
                    , $body);
          $body = str_replace("%selected%", $_GET[toedit], $body); 
        break;
      } 
    break;
    case 'PageMenu':
      switch($_GET[action]) {
        case 'add':
          $body = str_replace("%edit%", file_get_contents(getItemTemplate("PageMenu" ,"addForm")), $body);         
        break;
        case 'edit':
          
          $body = str_replace("%edit%", $awePageMenu->view(
                                      "getItem",
                                      array($_GET[toedit]),
                                      $_GET,
                                      array("editForm"),
                                      "",
                                      "",
                                      "",
                                      0,
                                      ".jpg"
                                      )
                      , $body);

          
        break;
        case 'chdir':
        $_GET[id1] = $_GET[toedit];
          $body = str_replace("%edit%", $awePageMenu->view(
                                    "getChildren",
                                    array(0,"pos"),
                                    $_GET,
                                    array("chdirForm","subchdirForm"),
                                    "",
                                    array("expand_all"),
                                    "",
                                    5,
                                    ".jpg"
                                    )
                    , $body);
          $body = str_replace("%selected%", $awePageMenu->itemTopSelectedId($_GET), $body);
         
        break;
      } 
    break;
  }

}

$body = str_replace("%action%", $_GET[action], $body);

echo $body;

?>
Return current item: phpAWE