public function deleteAction()
 {
     if ($this->getRequest()->isPost()) {
         $plugin = Tools_Plugins_Tools::findPluginByName($this->getRequest()->getParam('id'));
         $plugin->registerObserver(new Tools_Plugins_GarbageCollector(array('action' => Tools_System_GarbageCollector::CLEAN_ONDELETE)));
         $miscData = Zend_Registry::get('misc');
         $sqlFilePath = $this->_helper->website->getPath() . $miscData['pluginsPath'] . $plugin->getName() . '/system/' . Application_Model_Models_Plugin::UNINSTALL_FILE_NAME;
         if (file_exists($sqlFilePath)) {
             $sqlFileContent = Tools_Filesystem_Tools::getFile($sqlFilePath);
             if (strlen($sqlFileContent)) {
                 $queries = Tools_System_SqlSplitter::split($sqlFileContent);
             }
         }
         $delete = Tools_Filesystem_Tools::deleteDir($this->_helper->website->getPath() . 'plugins/' . $plugin->getName());
         if (!$delete) {
             $this->_helper->response->fail('Can\'t remove plugin\'s directory (not enough permissions). Plugin was uninstalled.');
             exit;
         }
         if (is_array($queries) && !empty($queries)) {
             $dbAdapter = Zend_Registry::get('dbAdapter');
             try {
                 array_walk($queries, function ($query, $key, $adapter) {
                     if (strlen(trim($query))) {
                         $adapter->query($query);
                     }
                 }, $dbAdapter);
                 Application_Model_Mappers_PluginMapper::getInstance()->delete($plugin);
             } catch (Exception $e) {
                 error_log($e->getMessage());
                 $this->_helper->response->fail($e->getMessage());
             }
         }
         $this->_helper->cache->clean(null, null, array('plugins'));
         $this->_helper->cache->clean('admin_addmenu', $this->_helper->session->getCurrentUser()->getRoleId());
         $this->_helper->response->success('Removed');
     }
 }
 /**
  * Serve sitemaps
  *
  */
 public function sitemapAction()
 {
     //disable renderer
     $this->_helper->viewRenderer->setNoRender(true);
     //get sitemap type from the params
     if (($sitemapType = $this->getRequest()->getParam('type', '')) == Tools_Content_Feed::SMFEED_TYPE_REGULAR) {
         //regular sitemap.xml requested
         if (null === ($this->view->pages = $this->_helper->cache->load('sitemappages', 'sitemaps_'))) {
             if (in_array('newslog', Tools_Plugins_Tools::getEnabledPlugins(true))) {
                 $this->view->newsPageUrlPath = Newslog_Models_Mapper_ConfigurationMapper::getInstance()->fetchConfigParam('folder');
             }
             $pages = Application_Model_Mappers_PageMapper::getInstance()->fetchAll();
             if (is_array($pages) && !empty($pages)) {
                 $quoteInstalled = Tools_Plugins_Tools::findPluginByName('quote')->getStatus() == Application_Model_Models_Plugin::ENABLED;
                 $pages = array_filter($pages, function ($page) use($quoteInstalled) {
                     if ($page->getExtraOption(Application_Model_Models_Page::OPT_PROTECTED) || $page->getDraft() || $page->getIs404page() || $quoteInstalled && intval($page->getParentId()) === Quote::QUOTE_CATEGORY_ID) {
                         return false;
                     }
                     return true;
                 });
             } else {
                 $pages = array();
             }
             $this->view->pages = $pages;
             $this->_helper->cache->save('sitemappages', $this->view->pages, 'sitemaps_', array('sitemaps'));
         }
     } else {
         if ($sitemapType == Tools_Content_Feed::SMFEED_TYPE_INDEX) {
             //default sitemaps
             $sitemaps = array('sitemap' => array('extension' => 'xml', 'lastmod' => date(DATE_ATOM)), 'sitemapnews' => array('extension' => 'xml', 'lastmod' => date(DATE_ATOM)));
             //real sitemaps (in the toaster root)
             $sitemapFiles = Tools_Filesystem_Tools::findFilesByExtension($this->_helper->website->getPath(), 'xml', false, false, false);
             if (is_array($sitemapFiles) && !empty($sitemapFiles)) {
                 foreach ($sitemapFiles as $sitemapFile) {
                     if (preg_match('~sitemap.*\\.xml.*~', $sitemapFile)) {
                         $fileInfo = pathinfo($this->_helper->website->getPath() . $sitemapFile);
                         if (is_array($fileInfo)) {
                             $sitemaps[$fileInfo['filename']] = array('extension' => $fileInfo['extension'], 'lastmod' => date(DATE_ATOM, fileatime($this->_helper->website->getPath() . $sitemapFile)));
                         }
                     }
                 }
             }
             $this->view->sitemaps = $sitemaps;
         }
     }
     $template = 'sitemap' . $sitemapType . '.xml.phtml';
     if (null === ($sitemapContent = $this->_helper->cache->load($sitemapType, Helpers_Action_Cache::PREFIX_SITEMAPS))) {
         try {
             $sitemapContent = $this->view->render('backend/seo/' . $template);
         } catch (Zend_View_Exception $zve) {
             // Try to find plugin's sitemap
             try {
                 $sitemapContent = Tools_Plugins_Tools::runStatic('getSitemap', $sitemapType);
                 if (!$sitemapContent) {
                     $sitemapContent = Tools_Plugins_Tools::runStatic('getSitemap' . ucfirst($sitemapType));
                 }
             } catch (Exception $e) {
                 Tools_System_Tools::debugMode() && error_log($e->getMessage());
                 $sitemapContent = false;
             }
             if ($sitemapContent === false) {
                 $this->getResponse()->setHeader('Content-Type', 'text/html', true);
                 return $this->forward('index', 'index', null, array('page' => 'sitemap' . $sitemapType . '.xml'));
             }
         }
         $this->_helper->cache->save($sitemapType, $sitemapContent, Helpers_Action_Cache::PREFIX_SITEMAPS, array('sitemaps'), Helpers_Action_Cache::CACHE_WEEK);
     }
     echo $sitemapContent;
 }
Example #3
0
 /**
  * @todo Should me moved to the shopping plugin
  * @static
  * @return null
  */
 public static function getProductCategoryPage()
 {
     // We need to know product category page url
     // This url specified in the bundle plugin "Shopping"
     // But this plugin may not be present in the system (not recommended)
     $shopping = Tools_Plugins_Tools::findPluginByName('shopping');
     $pageUrl = $shopping->getStatus() == Application_Model_Models_Plugin::ENABLED ? Shopping::PRODUCT_CATEGORY_URL : null;
     if ($pageUrl === null) {
         return null;
     }
     return Application_Model_Mappers_PageMapper::getInstance()->findByUrl($pageUrl);
 }