Beispiel #1
0
 public static function runPageRankSculpting($siloId, $pageContent)
 {
     self::$_websiteHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('website');
     $silo = Application_Model_Mappers_SiloMapper::getInstance()->find($siloId);
     $sculptingReplacement = array();
     $links = Tools_Content_Tools::findLinksInContent($pageContent);
     if (empty($links) || !isset($links[1])) {
         return $pageContent;
     }
     $hrefs = array_combine($links[0], $links[1]);
     $siloedPagesUrls = array_merge(array(self::$_websiteHelper->getUrl() . 'index.html', self::$_websiteHelper->getUrl() . 'index.htm'), array_map(array('self', '_callbackUrls'), $silo->getRelatedPages()));
     foreach ($hrefs as $key => $href) {
         if (in_array($href, $siloedPagesUrls)) {
             unset($hrefs[$key]);
             continue;
         }
         $page = Application_Model_Mappers_PageMapper::getInstance()->findByUrl(str_replace(self::$_websiteHelper->getUrl(), '', $href));
         if ($page === null) {
             continue;
         }
         $pageContent = str_replace($key, '<span class="' . md5($key) . '">' . $page->getNavName() . '</span>', $pageContent);
         $sculptingReplacement[] = array('id' => md5($key), 'repl' => $key);
         unset($page);
     }
     Zend_Registry::set('sculptingReplacement', json_encode($sculptingReplacement));
     return $pageContent;
 }
 public function managesilosAction()
 {
     if (!$this->getRequest()->isPost()) {
         $this->view->siloForm = new Application_Form_Silo();
     } else {
         $action = $this->getRequest()->getParam('act', null);
         if ($action === null) {
             $this->_helper->response->fail($this->_helper->language->translate('Action is not defined'));
         }
         switch ($action) {
             case 'loadlist':
                 $this->view->silos = Application_Model_Mappers_SiloMapper::getInstance()->fetchAll(null, array('name'));
                 $this->_helper->response->success($this->view->render('backend/seo/siloslist.phtml'));
                 break;
             case 'remove':
                 $ids = (array) $this->getRequest()->getParam('id');
                 if (empty($ids)) {
                     $this->_helper->response->fail($this->_helper->language->translate('Silo id is not specified'));
                 }
                 $siloMapper = Application_Model_Mappers_SiloMapper::getInstance();
                 foreach ($ids as $siloId) {
                     $silo = $siloMapper->find($siloId, true);
                     if (!$silo instanceof Application_Model_Models_Silo) {
                         $this->_helper->response->fail($this->_helper->language->translate('Cannot find silo to remove.'));
                     }
                     $silo->registerObserver(new Tools_Seo_GarbageCollector(array('action' => Tools_Seo_GarbageCollector::CLEAN_ONDELETE)));
                     $siloMapper->delete($silo);
                 }
                 $this->_helper->response->success($this->_helper->language->translate('Silo(s) removed.'));
                 break;
         }
     }
 }