예제 #1
0
 public static function getContainerByRequest($queryString = null)
 {
     $params = array();
     $resultFeatureId = null;
     if ($queryString != null) {
         parse_str($queryString, $params);
     }
     $features = MetatagsContainerFactory::getFeatures();
     foreach ($features as $featureId => $feature) {
         $success = true;
         if (isset($feature["params"])) {
             foreach ($feature["params"] as $paramsArray) {
                 $success = true;
                 foreach ($paramsArray as $key => $value) {
                     if ($queryString != null) {
                         if ($value !== null) {
                             $success = $success && (isset($params[$key]) && $params[$key] == $value);
                         } else {
                             $success = $success && isset($params[$key]);
                         }
                     } else {
                         if ($value !== null) {
                             $success = $success && JRequest::getCmd($key) == $value;
                         } else {
                             $success = $success && JRequest::getCmd($key, null) !== null;
                         }
                     }
                 }
                 if ($success) {
                     $resultFeatureId = $featureId;
                     break;
                 }
             }
         }
         if ($success) {
             $resultFeatureId = $featureId;
             break;
         }
     }
     return self::getContainerById($resultFeatureId);
 }
예제 #2
0
파일: controller.php 프로젝트: Rikisha/proj
 private function seoPages($task)
 {
     $mainframe =& JFactory::getApplication();
     $this->addSubmenu('pages_view');
     require_once "classes/MetatagsContainerFactory.php";
     $itemType = JRequest::getVar('type', null, '', 'string');
     if (!$itemType) {
         $itemType = key(MetatagsContainerFactory::getFeatures());
     }
     $metatagsContainer = MetatagsContainerFactory::getContainerById($itemType);
     if (!is_object($metatagsContainer)) {
         //TODO: throw error here.
     }
     switch ($task) {
         case "pages_save_text":
             $metatagsContainer->setMetadata($id = JRequest::getVar('id', '', '', 'int'), array("title" => JRequest::getVar('title', '', '', 'string'), "metatitle" => JRequest::getVar('metatitle', '', '', 'string'), "metakeywords" => JRequest::getVar('metakeywords', '', '', 'string'), "metadescription" => JRequest::getVar('metadescription', '', '', 'string')));
             echo "<script>window.parent.document.adminForm.submit();</script>";
             break;
         case "pages_edit_text":
             $id = JRequest::getVar('id', '', '', 'int');
             $data = $metatagsContainer->getMetadata($id);
             $data["id"] = $id;
             $view =& $this->getView('Pages');
             $view->assignRef('itemType', $itemType);
             $view->assignRef('data', $data);
             $view->display('edit');
             break;
         default:
             $limit = JRequest::getVar('limit', $mainframe->getCfg('list_limit'));
             $limitstart = JRequest::getVar('limitstart', 0);
             $db =& JFactory::getDBO();
             $pages = $metatagsContainer->getPages($limitstart, $limit);
             $db->setQuery('SELECT FOUND_ROWS();');
             //no reloading the query! Just asking for total without limit
             jimport('joomla.html.pagination');
             $pageNav = new JPagination($db->loadResult(), $limitstart, $limit);
             require_once "algorithm/KeywordsCounter.php";
             for ($i = 0; $i < count($pages); $i++) {
                 $stat_arr = array();
                 for ($j = 0; $j < count($pages[$i]->metakey); $j++) {
                     $stat_arr[] = getStat($pages[$i]->metakey[$j], $pages[$i]->content);
                 }
                 $pages[$i]->stat = $stat_arr;
             }
             $view =& $this->getView('Pages');
             $view->assignRef('itemType', $itemType);
             $view->assignRef('rows', $pages);
             $view->assignRef('page', $page);
             $view->assignRef('itemsOnPage', $itemsOnPage);
             $view->assignRef('filter', $metatagsContainer->getFilter());
             $view->assignRef('availableTypes', MetatagsContainerFactory::getFeatures());
             $view->assignRef('pageNav', $pageNav);
             $view->display();
     }
 }