Exemplo n.º 1
0
 /**
  * Constructs the IcfTemplating object
  */
 function IcfTemplating($page = "")
 {
     // Load configuration
     $icfConfig = new IcfConfig();
     $this->tpl =& new Savant2();
     // add a template path
     $this->tpl->addPath("template", $icfConfig->cfg_site_beTemplatePath);
     $this->tpl->assign("templatePath", $icfConfig->cfg_site_beTemplateUrl);
     $this->tpl->assign("basePath", $icfConfig->cfg_site_feBaseUrl);
     // multilingual support
     require_once $this->getStringsFile($icfConfig);
     // Session support
     $session = new Session();
     $this->tpl->assign("user", $session->getSessionUser());
     // basic toolbar support
     $toolbarItem = new icfToolbarItem();
     $toolbarItem->setName("exit");
     $toolbarItem->setTitle($text["exit"]);
     $toolbarItem->setUrl("login.php");
     $toolbarItem->setImage("/images/exit.png");
     $toolbarItem->setImage2("/images/exit_f2.png");
     $toolbar = new IcfToolbar();
     $toolbar->addToolbarItem($toolbarItem);
     // Menu support
     $menu = new IcfMenu();
     // Only work it if the session is valid
     $session = new Session();
     if ($session->isValid() == true) {
         $user = $session->getSessionUser();
         // Classes whose objects the user can create
         $baseClassMapper = new BaseClassMapper();
         $classes = $baseClassMapper->findByPermission(Action::ADD_OBJECTS_ACTION(), $user);
         $menu->setContents($classes);
         // The folders
         $folderMapper = new FolderMapper();
         $rootFolder = $folderMapper->getRoot();
         $folderArray = array(0 => $rootFolder);
         $menu->setFolders($folderArray);
     }
     // Set the generated content in the context of this request (available for client pages to change it)
     $this->setText($text);
     $this->setToolbar($toolbar);
     $this->setMenu($menu);
 }
Exemplo n.º 2
0
 /**
  * Constructs HomeController, executing the method given as parameter
  *
  * @param $method Name of the method to execute
  * @param &tpl Template method implementation
  */
 function HomeController($method = null, $icfTemplating)
 {
     $this->tpl = $icfTemplating->getTpl();
     $this->text = $icfTemplating->getText();
     // Title of the page
     $this->tpl->assign('pageTitle', $this->text['home']);
     // Pending contents
     $objectMapper = new ObjectMapper();
     $objects = $objectMapper->findPending();
     $objectsCount = count($objects);
     $this->controllerData["pending"] = $objectsCount;
     // Allowed classes to add
     $session = new Session();
     $baseClassMapper = new BaseClassMapper();
     $classArray = $baseClassMapper->findByPermission(Action::ADD_OBJECTS_ACTION(), $session->getSessionUser());
     $this->tpl->assign("classArray", $classArray);
     switch ($method) {
         default:
             $this->show_view();
     }
 }
Exemplo n.º 3
0
 /**
  * Only to be called from getFolderArray, provides the recursive feature
  * @param $childrenArray array of children folders
  * @param $class The class being displayed
  * @param $allowedFolderArray Array being constructed with folders to display in a tree
  * @return allowedFolderArray for method chaining
  */
 function getFolderArrayRecursive($childrenArray, $class, $allowedFolderArray, $object = null)
 {
     // Get the session
     $session = new Session();
     // For each root folder, inspect it
     foreach ($childrenArray as $folder) {
         /* @var $folder Folder */
         // Has this folder allowed children?
         if ($folder->hasAllowedLeaf($class, Action::ADD_OBJECTS_ACTION())) {
             // echo "Evaluando folder: " . $folder->getTitle() . "<br/>";
             /* @var $folderClass FolderClass */
             // Can the user add objects to this folder ?
             $folderClass = $folder->getFolderClass($class);
             if (is_null($folderClass)) {
                 $folderClass = new FolderClass($class->getId(), $folder->getId());
                 $folderClass->setIsDefault(false);
             }
             // Must be displayed...
             $id = $folder->getId();
             $parentId = 0;
             $closed = "leaf.gif";
             $open = "leaf.gif";
             $mode = "";
             $checked = false;
             // If we are not rendering an update, we must check items that are marked as default
             if (is_null($object)) {
                 $checked = $folderClass->getIsDefault();
             }
             // Has him a parent ?
             if (is_null($folder->getParentId()) == false) {
                 $parentId = $folder->getParentId();
             }
             // If we are rendering an update, we must check items that are marked as it in the Persistence layer
             if ($object != null) {
                 $checked = $object->isObjectInFolder($folder->getId());
             }
             // Determine images
             if (count($folder->getChildren()) > 0) {
                 $closed = "folderClosed.gif";
                 $open = "folderOpen.gif";
             }
             // Create and add the new allowed item
             $arrayItem = array("id" => $id, "title" => $folder->getTitle(), "parentId" => $parentId, "closed" => $closed, "open" => $open, "mode" => $mode, "checked" => $checked);
             array_push($allowedFolderArray, $arrayItem);
         }
         // Display its children
         $allowedFolderArray = $this->getFolderArrayRecursive($folder->getChildren(), $class, $allowedFolderArray, $object);
     }
     return $allowedFolderArray;
 }
Exemplo n.º 4
0
 /**
  * Shows the folder view
  * @param $folder Folder - optional, if the folder is received, it is displayed. If not, the request parameter is used
  */
 function showView($folder = null)
 {
     if ($folder == null) {
         $folder = $this->getFolder();
     }
     // Set folder
     $this->tpl->assign("folder", $folder);
     $this->setFolderViewToolbar();
     // Create pathview
     $pathView = $folder->getTitle();
     $parentFolder = $folder->getParent();
     while ($parentFolder != null) {
         $pathView = "<a href='#' onclick='showFolder(" . $parentFolder->getId() . ")'>" . $parentFolder->getTitle() . "</a> &gt; " . $pathView;
         $parentFolder = $parentFolder->getParent();
     }
     $this->tpl->assign("pathView", $pathView);
     // Special objects that can be added to this folder
     $specialArray = array();
     // TODO: FOLDERS_ACTION: if ($folder->canDoAction(null, Action::ADD_FOLDERS_ACTION()))
     $specialArray["folder"] = $this->text["folder"];
     $this->tpl->assign("specialArray", $specialArray);
     // Classes to add
     $classesArray = array();
     foreach ($folder->getFolderClasses() as $folderClass) {
         if ($folderClass->canDoAction(null, Action::ADD_OBJECTS_ACTION()) == false) {
             continue;
         }
         $class = $folderClass->getClass();
         $classesArray[$class->getId()] = $class->getTitle();
     }
     $this->tpl->assign("classesArray", $classesArray);
     $this->displayView("folder.tpl.php");
 }