コード例 #1
0
ファイル: Tools.php プロジェクト: PavloKovalov/seotoaster
 /**
  * @deprecated Use Tools_Page_Tools::getPreview() instead. Will be removed in 2.2
  */
 public static function getPreviewPath($pageId, $capIfNoPreview = false, $croped = false)
 {
     Tools_System_Tools::debugMode() && error_log('Called deprecated Tools_Page_Tools::getPreviewPath(). Use Tools_Page_Tools::getPreview() instead');
     $websiteHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('website');
     $configHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('config');
     $pageHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('page');
     $websiteUrl = $configHelper->getConfig('mediaServers') ? Tools_Content_Tools::applyMediaServers($websiteHelper->getUrl()) : $websiteHelper->getUrl();
     try {
         $previews = Tools_Filesystem_Tools::findFilesByExtension($websiteHelper->getPath() . ($croped ? $websiteHelper->getPreviewCrop() : $websiteHelper->getPreview()), 'jpg|png|jpeg|gif', true, true, false);
     } catch (Exceptions_SeotoasterException $se) {
         if (APPLICATION_ENV == 'development') {
             error_log("(Cant find preview thumbnail because: " . $se->getMessage() . "\n" . $se->getTraceAsString());
         }
         return $websiteUrl . 'system/images/noimage.png';
     }
     $page = Application_Model_Mappers_PageMapper::getInstance()->find($pageId);
     if ($page instanceof Application_Model_Models_Page) {
         $cleanUrl = $pageHelper->clean(preg_replace('~/+~', '-', $page->getUrl()));
         unset($page);
         $path = array_key_exists($cleanUrl, $previews) ? str_replace($websiteHelper->getPath(), $websiteUrl, $previews[$cleanUrl]) : '';
         if (!$path && $capIfNoPreview) {
             return $websiteUrl . 'system/images/noimage.png';
         }
         return str_replace(DIRECTORY_SEPARATOR, '/', $path);
     }
     return $websiteUrl . 'system/images/noimage.png';
 }
コード例 #2
0
ファイル: Page.php プロジェクト: PavloKovalov/seotoaster
 private function _generatePreviewOption()
 {
     $websiteHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Website');
     $pageHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Page');
     $files = Tools_Filesystem_Tools::findFilesByExtension($websiteHelper->getPath() . $websiteHelper->getPreview(), '(jpg|gif|png|jpeg)', false, false, false);
     $pagePreviews = array_values(preg_grep('~^' . $pageHelper->clean(preg_replace('~/+~', '-', $this->_toasterOptions['url'])) . '\\.(png|jpg|gif|jpeg)$~', $files));
     if (!empty($pagePreviews)) {
         $path = isset($this->_options) && end($this->_options) == 'crop' ? $websiteHelper->getPreviewCrop() : $websiteHelper->getPreview();
         return '<img class="page-teaser-image" src="' . $websiteHelper->getUrl() . $path . $pagePreviews[0] . '" alt="' . $pageHelper->clean($this->_toasterOptions['url']) . '" />';
     }
     return;
 }
コード例 #3
0
ファイル: Concatcss.php プロジェクト: PavloKovalov/seotoaster
 protected function _load()
 {
     if (!file_exists($this->_themeFullPath . '/' . self::FILENAME) || $this->_refresh) {
         $concatContent = '';
         $cssFiles = $this->_sortCss(Tools_Filesystem_Tools::findFilesByExtension($this->_themeFullPath, self::FILES_EXTENSION, true));
         foreach ($cssFiles as $key => $cssFile) {
             if (in_array(basename($cssFile), $this->_excludeFiles)) {
                 continue;
             }
             $concatContent .= $this->_addCss($cssFile);
         }
         try {
             Tools_Filesystem_Tools::saveFile($this->_themeFullPath . '/' . self::FILENAME, $concatContent);
         } catch (Exceptions_SeotoasterException $ste) {
             return $ste->getMessage();
         }
     }
     return '<link href="' . $this->_toasterOptions['websiteUrl'] . $this->_themeFullPath . '/' . self::FILENAME . '" rel="stylesheet" type="text/css" media="screen" />';
 }
コード例 #4
0
ファイル: Language.php プロジェクト: PavloKovalov/seotoaster
 /**
  * Returns a list of available translation languages
  * @param $detailed boolean Fetch additional info for translation
  * @return array List of translations
  */
 public function getLanguages($detailed = true)
 {
     $websiteConfigHelper = Zend_Controller_Action_HelperBroker::getExistingHelper('website');
     $languageIcons = Tools_Filesystem_Tools::findFilesByExtension($websiteConfigHelper->getPath() . $this->_langFlagsDir, 'png', false, true, false);
     $this->_languages = array();
     $loadedList = Zend_Registry::get('Zend_Translate')->getAdapter()->getList();
     foreach ($languageIcons as $country => $imgFile) {
         $locale = new Zend_Locale(Zend_Locale::getLocaleToTerritory($country));
         $lang = $locale->getLanguage();
         $langTitle = Zend_Locale::getTranslation($lang, 'language');
         if (!in_array($locale->getLanguage(), $loadedList)) {
             continue;
         }
         if ($detailed) {
             $this->_languages[$country] = array('locale' => $locale->toString(), 'language' => $langTitle, 'name' => $country, 'flag' => $this->_langFlagsDir . $imgFile);
         } else {
             $this->_languages[$country] = $langTitle;
         }
         unset($locale);
     }
     return $this->_languages;
 }
コード例 #5
0
 /**
  * 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;
 }
コード例 #6
0
 /**
  * Method returns list of templates or template content if id given in params (AJAX)
  * @return html || json
  */
 public function gettemplateAction()
 {
     if ($this->getRequest()->isPost()) {
         $mapper = Application_Model_Mappers_TemplateMapper::getInstance();
         $listtemplates = $this->getRequest()->getParam('listtemplates');
         $additional = $this->getRequest()->getParam('additional');
         $pageId = $this->getRequest()->getParam('pageId');
         if ($pageId) {
             $page = Application_Model_Mappers_PageMapper::getInstance()->find($pageId);
         }
         $currentTheme = $this->_helper->config->getConfig('currentTheme');
         //get template preview image
         $templatePreviewDir = $this->_websiteConfig['path'] . $this->_themeConfig['path'] . $currentTheme . DIRECTORY_SEPARATOR . $this->_themeConfig['templatePreview'];
         if ($templatePreviewDir && is_dir($templatePreviewDir)) {
             $tmplImages = Tools_Filesystem_Tools::findFilesByExtension($templatePreviewDir, '(jpg|gif|png)', false, true, false);
         } else {
             $tmplImages = array();
         }
         $types = $mapper->fetchAllTypes();
         if (array_key_exists($listtemplates, array_merge($types, array('all' => 'all')))) {
             $template = isset($page) && $page instanceof Application_Model_Models_Page ? $mapper->find($page->getTemplateId()) : $mapper->find($listtemplates);
             $this->view->templates = $this->_getTemplateListByType($listtemplates, $tmplImages, $currentTheme, $template instanceof Application_Model_Models_Template ? $template->getName() : '');
             if (empty($this->view->templates) || !$this->view->templates) {
                 $this->_helper->response->response($this->_translator->translate('Template not found'), true);
                 return true;
             }
             $this->view->protectedTemplates = $this->_protectedTemplates;
             $this->view->types = $this->_sortTemplates($types);
             echo $this->view->render($this->getViewScript('templateslist'));
         } else {
             $template = $mapper->find($listtemplates);
             if ($template instanceof Application_Model_Models_Template) {
                 $template = array('id' => $template->getId(), 'name' => $template->getName(), 'fullName' => $template->getName(), 'type' => $template->getType(), 'content' => $template->getContent(), 'preview' => isset($tmplImages[$template->getName()]) ? $this->_themeConfig['path'] . $currentTheme . '/' . $this->_themeConfig['templatePreview'] . $tmplImages[$template->getName()] : 'system/images/no_preview.png');
                 $this->_helper->response->response($template, true);
             } else {
                 //$response = array('done'=> false);
                 $this->_helper->response->response($this->_translator->translate('Template not found'), true);
             }
         }
         exit;
     }
 }
コード例 #7
0
 public function loadfilesAction()
 {
     if ($this->getRequest()->isPost()) {
         $folder = $this->getRequest()->getParam('folder');
         $filesPath = $this->_websiteData['path'] . $this->_websiteData['media'] . $folder;
         $this->view->files = is_dir($filesPath) ? Tools_Filesystem_Tools::findFilesByExtension($filesPath, '.*', false, false, false) : array();
         $this->view->html = $folder ? $this->view->render('backend/content/files.phtml') : '<h3 style="text-align: center;">' . $this->_helper->language->translate('Please, select a folder') . '</h3>';
     }
 }