Пример #1
0
 public static function getMainListPanel($documentId, $moduleName, $page = 1)
 {
     $moduleName = strtolower($moduleName);
     try {
         if ($moduleName == "tag") {
             $moduleName = "admin";
         }
         $mainList = XMLParser::getXMLdataValues(sfConfig::get('sf_root_dir') . "/apps/panel/modules/" . $moduleName . "/config/mainList.xml");
         $displayedObjects = array();
         foreach ($mainList as $obj) {
             if ($obj['tag'] == 'OBJECT' && $obj['type'] == 'complete') {
                 $displayedObjects[] = $obj['value'];
             }
         }
         $children = array();
         $res = array('children', 'paging');
         $c = new Criteria();
         if (!$documentId) {
             $document = Rootfolder::getRootfolderByModule($moduleName);
             if ($document) {
                 $documentId = $document->getId();
             }
         }
         if ($documentId) {
             $pager = new sfPropelPager("Relation", 20);
             $c->add(RelationPeer::ID1, $documentId);
             $c->add(RelationPeer::DOCUMENT_MODEL2, $displayedObjects, Criteria::IN);
             if ($moduleName == 'houses' || $moduleName == 'jobs') {
                 $c->addDescendingOrderByColumn(RelationPeer::ID2);
             } else {
                 $c->addAscendingOrderByColumn(RelationPeer::SORT_ORDER);
             }
             $pager->setCriteria($c);
             $pager->setPage($page);
             $pager->init();
             foreach ($pager->getResults() as $relation) {
                 $id = $relation->getId2();
                 $res['children'][] = Document::getDocumentInstance($id);
             }
         }
         $res['paging'] = $pager->paging(true);
         return $res;
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #2
0
 public static function getMainList(&$documentId, $moduleName, $page = 1)
 {
     $moduleName = strtolower($moduleName);
     try {
         if ($moduleName == "settings") {
             $settingsArr = array();
             if (is_readable(sfConfig::get('sf_root_dir') . "/config/settings.xml")) {
                 $objects = XMLParser::getXMLdataValues(sfConfig::get('sf_root_dir') . "/config/settings.xml");
             }
             foreach ($objects as $obj) {
                 if ($obj['tag'] == 'ELEMENT' && $obj['type'] == 'open') {
                     $objName = $obj['attributes']['LABEL'];
                     $objDescription = $obj['attributes']['DESCRIPTION'];
                 }
                 if ($obj['tag'] == 'ITEM' && $obj['type'] == 'complete') {
                     //$val = $obj['attributes']['VALUE'];
                     $settingName = $objName;
                     //$settingName = strtolower($objName);
                     $settingsArr[$settingName] = $objDescription;
                 }
             }
             $pager = new sfPropelPager("Relation", 20);
             $pager->setResults($settingsArr);
             $pager->setPage($page);
             $pager->init();
             foreach ($pager->getResults() as $name => $label) {
                 $res['children'][$name] = $label;
             }
             $res['paging'] = $pager->paging(true);
             return $res;
         }
         if ($moduleName == "labels") {
             $localesArr = array();
             if (is_readable(sfConfig::get('sf_root_dir') . "/config/locales.xml")) {
                 $objects = XMLParser::getXMLdataValues(sfConfig::get('sf_root_dir') . "/config/locales.xml");
                 foreach ($objects as $obj) {
                     if ($obj['tag'] == 'LOCALE' && $obj['type'] == 'open') {
                         $objName = $obj['attributes']['LABEL'];
                         if ($obj['attributes']['DESCRIPTION']) {
                             $objDescription = $obj['attributes']['DESCRIPTION'];
                         } else {
                             $objDescription = '[' . $obj['attributes']['LABEL'] . ']';
                         }
                     }
                     if ($obj['tag'] == 'ITEM' && $obj['type'] == 'complete') {
                         //$val = $obj['attributes']['VALUE'];
                         $localeName = $objName;
                         //$localeName = strtolower($objName);
                         $localesArr[$localeName] = $objDescription;
                     }
                 }
             }
             $pager = new sfPropelPager("Relation", 20);
             $pager->setResults($localesArr);
             $pager->setPage($page);
             $pager->init();
             foreach ($pager->getResults() as $name => $label) {
                 $res['children'][$name] = $label;
             }
             $res['paging'] = $pager->paging(true);
             return $res;
         }
         $mainList = XMLParser::getXMLdataValues(sfConfig::get('sf_root_dir') . "/apps/panel/modules/" . $moduleName . "/config/mainList.xml");
         $displayedObjects = array();
         $rootId = null;
         foreach ($mainList as $obj) {
             if ($obj['tag'] == 'OBJECT' && $obj['type'] == 'complete') {
                 $displayedObjects[] = $obj['value'];
             }
             // check overwrite RootID
             if ($obj['tag'] == 'OBJECTS' && $obj['type'] == 'open') {
                 if (array_key_exists("attributes", $obj) && array_key_exists("PARENT", $obj['attributes'])) {
                     $rootName = $obj['attributes']['PARENT'];
                     $rootDocument = Rootfolder::getRootfolderByModule($rootName);
                     if ($rootDocument) {
                         $rootId = $rootDocument->getId();
                     }
                 }
                 if (array_key_exists("attributes", $obj) && array_key_exists("TAG", $obj['attributes'])) {
                     $tag = $obj['attributes']['TAG'];
                     $rootDocument = Document::getDocumentByExclusiveTag($tag);
                     if ($rootDocument) {
                         $rootId = $rootDocument->getId();
                     }
                 }
             }
         }
         $children = array();
         $res = array('children' => array(), 'paging' => '');
         $c = new Criteria();
         if (!$documentId) {
             if ($rootId) {
                 $documentId = $rootId;
             } else {
                 $document = Rootfolder::getRootfolderByModule($moduleName);
                 if ($document) {
                     $documentId = $document->getId();
                 }
             }
         }
         //echo "rootId = $rootId; moduleName = $moduleName;";
         if ($documentId) {
             $pager = new sfPropelPager("Relation", 20);
             $c->add(RelationPeer::ID1, $documentId);
             $c->add(RelationPeer::DOCUMENT_MODEL2, $displayedObjects, Criteria::IN);
             $c->addAscendingOrderByColumn(RelationPeer::SORT_ORDER);
             $pager->setCriteria($c);
             $pager->setPage($page);
             $pager->init();
             foreach ($pager->getResults() as $relation) {
                 $id = $relation->getId2();
                 $res['children'][] = Document::getDocumentInstance($id);
             }
         }
         $res['paging'] = $pager->paging(true);
         return $res;
     } catch (Exception $e) {
         throw $e;
     }
 }