/** * @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'; }
public function doCanonicalRedirect($pageUrl) { $this->_redirector->setCode(301); if (Tools_System_Tools::getUrlHost($_SERVER['HTTP_HOST']) != Tools_System_Tools::getUrlHost($this->_website->getUrl())) { $this->_redirector->gotoUrl($this->_website->getUrl() . $pageUrl); } if (in_array($pageUrl, $this->_canonicMap)) { $this->_redirector->gotoUrl($this->_website->getUrl()); } }
/** * Initialize search index to static property * @return Zend_Search_Lucene_Interface */ public static function initIndex() { if (self::$_index instanceof Zend_Search_Lucene_Interface) { return self::$_index; } $searchIndexPath = Zend_Controller_Action_HelperBroker::getStaticHelper('website')->getPath() . 'cache/' . Widgets_Search_Search::INDEX_FOLDER; if (!is_dir($searchIndexPath)) { if (!Tools_Filesystem_Tools::mkDir($searchIndexPath)) { Tools_System_Tools::debugMode() && error_log('Can\'t create search index folder in ' . $searchIndexPath); } } try { self::$_index = Zend_Search_Lucene::open($searchIndexPath); } catch (Exception $e) { self::$_index = Zend_Search_Lucene::create($searchIndexPath); } return self::$_index; }
protected function _load() { $pluginName = strtolower(array_shift($this->_options)); if (!$pluginName) { return $this->_translator->translate('Plugin name not specified.'); } $plugin = Application_Model_Mappers_PluginMapper::getInstance()->findByName($pluginName); if ($plugin !== null) { if ($plugin->getStatus() != Application_Model_Models_Plugin::ENABLED) { return $this->_translator->translate('You need install the ') . $plugin->getName() . $this->_translator->translate(' plug-in to view and use this great feature.') . ' <a href="http://www.seotoaster.com/website-plugins-marketplace.html" target="_blank">' . $this->_translator->translate('Download plug-ins here') . ' ' . '</a>' . $this->_translator->translate('and watch a short video to learn how to install plug-ins on your website') . ' <a href="http://www.seotoaster.com/how-to-add-a-plugin.html" target="_blank">' . $this->_translator->translate('here') . '</a>.'; } try { $toasterPlugin = Tools_Factory_PluginFactory::createPlugin($plugin->getName(), $this->_options, $this->_toasterOptions); return $toasterPlugin->run(); } catch (Exceptions_SeotoasterPluginException $spe) { if (Tools_System_Tools::debugMode()) { error_log($spe->getMessage() . "\n" . $spe->getTraceAsString()); } if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) { return $spe->getMessage(); } } catch (Exceptions_SeotoasterException $se) { if (Tools_System_Tools::debugMode()) { error_log($se->getMessage() . "\n" . $se->getTraceAsString()); } if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) { return $se->getMessage(); } } catch (Exception $e) { if (Tools_System_Tools::debugMode()) { error_log($e->getMessage() . "\n" . $e->getTraceAsString()); } //return $e->getMessage(); } } if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) { return $this->_translator->translate('You need the') . ' ' . $pluginName . ' ' . $this->_translator->translate('plug-in to view and use this great feature.') . ' <a href="http://www.seotoaster.com/website-plugins-marketplace.html" target="_blank">' . $this->_translator->translate('Download plug-ins here') . ' ' . '</a>' . $this->_translator->translate('and watch a short video to learn how to install plug-ins on your website') . ' <a href="http://www.seotoaster.com/how-to-add-a-plugin.html" target="_blank">' . $this->_translator->translate('here') . '</a>.'; } return ''; }
/** * Generates upload form * @param array $options * @param string $options['id'] Unique id for uploader form * @param string $options['type'] by default renders an upload button. Pass "dragdrop" option to allow drag'n'drop uploading. * @param boolean $options['caller'] Define context from which upload was called * @param boolean $options['disableResize'] Turn off client-side resizing (if supported in browser) * @param boolean $options['noMultiupload'] Turn off client-side multiple file selection for upload (will be applyed for all instances of upload on page) * @param array $options['filters'] Type of files allowed to be upload (for filtering in file select dialog): possible 'image', 'zip', 'video' * @return html generated form. */ public function toasterUploader($options = null) { if (isset($options['caller']) && !empty($options['caller'])) { $this->_uploadActionUrl['caller'] = $options['caller']; $this->view->caller = $options['caller']; } if (isset($options['disableResize']) && !empty($options['disableResize'])) { $this->view->disableResize = (bool) $options['disableResize']; } if (isset($options['noMultiupload']) && !empty($options['noMultiupload'])) { $this->view->noMultiupload = (bool) $options['noMultiupload']; } $dbConfigHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('config'); //assign all necessary JS and CSSs $websiteUrl = Zend_Controller_Action_HelperBroker::getExistingHelper('website')->getUrl(); $this->view->jQuery()->addJavascriptFile($websiteUrl . $this->_libraryPath . 'plupload.js'); $this->view->jQuery()->addJavascriptFile($websiteUrl . $this->_libraryPath . 'plupload.html5.js'); $this->view->jQuery()->addJavascriptFile($websiteUrl . $this->_libraryPath . 'plupload.html4.js'); $this->view->jQuery()->addJavascriptFile($websiteUrl . $this->_libraryPath . 'plupload.flash.js'); //assign all view variables $this->view->config = Zend_Registry::get('misc'); $this->view->teaserSize = $dbConfigHelper->getConfig('teaserSize'); $this->view->actionUrl = preg_replace('~/.*[/]*backend/~iu', $websiteUrl . 'backend/', $this->view->url($this->_uploadActionUrl, 'backend')); $this->view->formId = isset($options['id']) && !empty($options['id']) ? $options['id'] : 'toaster-uploader'; $this->view->formType = isset($options['type']) && !empty($options['type']) ? $options['type'] : 'button'; $this->view->buttonCaption = isset($options['caption']) && !empty($options['caption']) ? $options['caption'] : 'Upload files'; if (isset($options['filters']) && !empty($options['filters'])) { $this->view->filters = array_values(array_intersect_key($this->_fileTypes, array_flip($options['filters']))); } else { $this->view->filters = array(); } $this->view->caller = isset($this->_uploadActionUrl['caller']) ? $this->_uploadActionUrl['caller'] : false; // max upload file size and files count $this->view->allowedUploadData = Tools_System_Tools::getAllowedUploadData(); return $this->view->render('admin' . DIRECTORY_SEPARATOR . 'uploadForm.phtml'); }
/** * 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; }
private function _runMagicSpaces() { $this->_iteration++; preg_match_all('~{([\\w]+' . self::OPTIONS_SEPARATOR . '*[:\\w\\-\\s,&]*)}~uiUs', $this->_content, $spacesFound); $spacesFound = array_filter($spacesFound); if (!empty($spacesFound) && isset($spacesFound[1])) { foreach ($spacesFound[1] as $spaceName) { //if any parameters passed $parameters = explode(self::OPTIONS_SEPARATOR, $spaceName); if (is_array($parameters)) { $spaceName = array_shift($parameters); } try { $this->_content = Tools_Factory_MagicSpaceFactory::createMagicSpace($spaceName, $this->_content, array_merge($this->_pageData, $this->_options), $parameters)->run(); } catch (Exception $e) { Tools_System_Tools::debugMode() && error_log($e->getMessage()); continue; } } if ($this->_iteration <= self::PARSE_DEEP) { $this->_runMagicSpaces(); } } }
/** * Method exports zipped theme * @param string $themeName Theme name * @param bool $full Set true to dump data and media files */ protected function _exportTheme($themeName = '', $full = false, $noZip = false) { if (!$themeName) { $themeName = $this->_configHelper->getConfig('currentTheme'); } $themePath = $this->_websiteHelper->getPath() . $this->_themesConfig['path'] . $themeName . DIRECTORY_SEPARATOR; $websitePath = $this->_websiteHelper->getPath(); if ($full) { /** * @var $dbAdapter Zend_Db_Adapter_Abstract */ $dbAdapter = Zend_Registry::get('dbAdapter'); // exporting themes data for the full theme // init empty array for export data $data = array('page' => array()); // and for media files $mediaFiles = array(); // fetching index page and main menu pages $pagesSqlWhere = "SELECT * FROM `page` WHERE system = '0' AND draft = '0' AND (\n\t\t\turl = 'index.html' OR (parent_id = '0' AND show_in_menu = '1') OR (parent_id = '-1' AND show_in_menu = '2')\n\t\t OR (parent_id = '0' OR parent_id IN (SELECT DISTINCT `page`.`id` FROM `page` WHERE (parent_id = '0') AND (system = '0') AND (show_in_menu = '1')) )\n\t\t OR id IN ( SELECT DISTINCT `page_id` FROM `page_fa` )\n\t\t OR id IN ( SELECT DISTINCT `page_id` FROM `page_has_option` )\n\t\t ) ORDER BY `order` ASC"; $pages = $dbAdapter->fetchAll($pagesSqlWhere); if (is_array($pages) && !empty($pages)) { $data['page'] = $pages; unset($pages); } // combining list of queries for export others tables content $queryList = array(); $enabledPlugins = Tools_Plugins_Tools::getEnabledPlugins(true); foreach ($enabledPlugins as $plugin) { $pluginsData = Tools_Plugins_Tools::runStatic(self::PLUGIN_EXPORT_METHOD, $plugin); if (!$pluginsData) { continue; } if (isset($pluginsData['pages']) && is_array($pluginsData['pages']) && !empty($pluginsData['pages'])) { $data['page'] = array_merge($data['page'], $pluginsData['pages']); } if (isset($pluginsData['tables']) && is_array($pluginsData['tables']) && !empty($pluginsData['tables'])) { foreach ($pluginsData['tables'] as $table => $query) { if (array_key_exists($table, $this->_fullThemesSqlMap)) { continue; } $queryList[$table] = $query; unset($table, $query); } } if (isset($pluginsData['media']) && is_array($pluginsData['media']) && !empty($pluginsData['media'])) { $mediaFiles = array_unique(array_merge($mediaFiles, $pluginsData['media'])); } } unset($enabledPlugins); // getting list of pages ids for export $pagesIDs = array_map(function ($page) { return $page['id']; }, $data['page']); // building list of dump queries and executing it with page IDS substitution $queryList = array_merge($this->_fullThemesSqlMap, $queryList); foreach ($queryList as $table => $query) { $data[$table] = $dbAdapter->fetchAll($dbAdapter->quoteInto($query, $pagesIDs)); } unset($queryList, $pagesIDs); if (!empty($data)) { $exportData = new Zend_Config($data); $themeDataFile = new Zend_Config_Writer_Json(array('config' => $exportData, 'filename' => $themePath . self::THEME_DATA_FILE)); $themeDataFile->write(); } // exporting list of media files $totalFileSize = 0; // initializing files size counter $previewFolder = $this->_websiteHelper->getPreview(); $pagePreviews = array_filter(array_map(function ($page) use($previewFolder) { return !empty($page['preview_image']) ? $previewFolder . $page['preview_image'] : false; }, $data['page'])); $contentImages = array(); // list of images from containers if (!empty($data['container'])) { foreach ($data['container'] as $container) { preg_match_all('~media[^"\']*\\.(?:jpe?g|gif|png)~iu', $container['content'], $matches); if (!empty($matches[0])) { $contentImages = array_merge($contentImages, array_map(function ($file) { $file = explode(DIRECTORY_SEPARATOR, $file); if ($file[2] !== 'original') { $file[2] = 'original'; } return implode(DIRECTORY_SEPARATOR, $file); }, $matches[0])); } unset($matches, $container); } } $mediaFiles = array_merge($pagePreviews, $contentImages, $mediaFiles); $mediaFiles = array_unique(array_filter($mediaFiles)); if (!empty($mediaFiles)) { clearstatcache(); foreach ($mediaFiles as $key => $file) { if (!is_file($websitePath . $file)) { $mediaFiles[$key] = null; continue; } $totalFileSize += filesize($websitePath . $file); } } if ($totalFileSize > self::THEME_FULL_MAX_FILESIZE) { $this->_error('Too many images'); } else { $mediaFiles = array_filter($mediaFiles); } } // if requested name is current one we create system file with template types if ($themeName === $this->_configHelper->getConfig('currentTheme')) { // saving template types into theme.ini. @see Tools_Template_Tools::THEME_CONFIGURATION_FILE $themeIniConfig = new Zend_Config(array(), true); foreach (Application_Model_Mappers_TemplateMapper::getInstance()->fetchAll() as $template) { $themeIniConfig->{$template->getName()} = $template->getType(); } if (!empty($themeIniConfig)) { try { $iniWriter = new Zend_Config_Writer_Ini(array('config' => $themeIniConfig, 'filename' => $themePath . Tools_Template_Tools::THEME_CONFIGURATION_FILE)); $iniWriter->write(); } catch (Exception $e) { Tools_System_Tools::debugMode() && error_log($e->getMessage()); } } unset($themeIniConfig, $iniWriter); } //defining list files that needs to be excluded $excludeFiles = array(); if (!$full) { array_push($excludeFiles, self::THEME_DATA_FILE); } if ($noZip === true) { // backup media files to theme subfolder if (!empty($mediaFiles)) { if (!is_dir($themePath . 'previews')) { Tools_Filesystem_Tools::mkDir($themePath . 'previews'); } if (!is_dir($themePath . 'media')) { Tools_Filesystem_Tools::mkDir($themePath . 'media'); } foreach ($mediaFiles as $file) { if (!is_file($websitePath . $file)) { continue; } $path = explode(DIRECTORY_SEPARATOR, $file); if (!is_array($path) || empty($path)) { continue; } switch ($path[0]) { case 'previews': list($folder, $filename) = $path; break; case 'media': $folder = 'media' . DIRECTORY_SEPARATOR . $path[1]; if (!is_dir($themePath . $folder)) { Tools_Filesystem_Tools::mkDir($themePath . $folder); } $filename = end($path); break; default: continue; break; } $destination = $themePath . $folder . DIRECTORY_SEPARATOR . $filename; try { $r = Tools_Filesystem_Tools::copy($websitePath . $file, $destination); } catch (Exception $e) { Tools_System_Tools::debugMode() && error_log($e->getMessage()); } } } return true; } else { //create theme zip archive $themeArchive = Tools_Theme_Tools::zip($themeName, isset($mediaFiles) ? $mediaFiles : false, $excludeFiles); if ($themeArchive) { $body = file_get_contents($themeArchive); if (false !== $body) { Tools_Filesystem_Tools::deleteFile($themeArchive); } else { $this->_error('Unable to read website archive file'); } } else { $this->_error('Can\'t create website archive'); } //outputting theme zip $this->_response->clearAllHeaders()->clearBody(); $this->_response->setHeader('Content-Disposition', 'attachment; filename=' . $themeName . '.zip')->setHeader('Content-Type', 'application/zip', true)->setHeader('Content-Transfer-Encoding', 'binary', true)->setHeader('Expires', date(DATE_RFC1123), true)->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)->setHeader('Pragma', 'public', true)->setBody($body)->sendResponse(); exit; } }
public function exportAction() { if ($this->getRequest()->isPost()) { if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_USERS)) { $users = Application_Model_Mappers_UserMapper::getInstance()->fetchAll(); $dataToExport = array(); foreach ($users as $user) { $usrData = $user->toArray(); unset($usrData['password']); unset($usrData['id']); unset($usrData['attributes']); $dataToExport[] = $usrData; } $exportResult = Tools_System_Tools::arrayToCsv($dataToExport, array($this->_helper->language->translate('E-mail'), $this->_helper->language->translate('Role'), $this->_helper->language->translate('Full name'), $this->_helper->language->translate('Last login date'), $this->_helper->language->translate('Registration date'), $this->_helper->language->translate('IP address'))); if ($exportResult) { $usersArchive = Tools_System_Tools::zip($exportResult); $this->getResponse()->setHeader('Content-Disposition', 'attachment; filename=' . Tools_Filesystem_Tools::basename($usersArchive))->setHeader('Content-type', 'application/force-download'); readfile($usersArchive); $this->getResponse()->sendResponse(); } exit; } } }
/** * Checking the observer queue. If any, register those observers * */ protected function _readObserversQueue() { if (Zend_Registry::isRegistered('observers_queue')) { $observerQueue = Zend_Registry::get('observers_queue'); } else { $observerQueue = array(); } $modelClassName = get_called_class(); if (array_key_exists($modelClassName, $observerQueue) && !empty($observerQueue[$modelClassName])) { foreach ($observerQueue[$modelClassName] as $observer) { if (Zend_Loader_Autoloader::getInstance()->suppressNotFoundWarnings(true)->autoload($observer)) { $this->registerObserver(new $observer()); } else { if (Tools_System_Tools::debugMode()) { error_log('Unable to load an observer from the queue: ' . $observer); } } } } }
/** * Method build a list of css files for current theme * with subdirectories * @return <type> */ private function _buildCssFileList() { $currentThemeName = $this->_helper->config->getConfig('currentTheme'); $currentThemePath = Tools_System_Tools::normalizePath(realpath($this->_websiteConfig['path'] . $this->_themeConfig['path'] . $currentThemeName)); $cssFiles = Tools_Filesystem_Tools::findFilesByExtension($currentThemePath, 'css', true); $cssTree = array(); foreach ($cssFiles as $file) { // don't show concat css for editing if (preg_match('/' . MagicSpaces_Concatcss_Concatcss::FILE_NAME_PREFIX . '[a-zA-Z0-9]+\\.css/i', strtolower(basename($file)))) { continue; } preg_match_all('~^' . $currentThemePath . '/([a-zA-Z0-9-_\\s/.]+/)*([a-zA-Z0-9-_\\s.]+\\.css)$~i', Tools_System_Tools::normalizePath($file), $sequences); $subfolders = $currentThemeName . '/' . $sequences[1][0]; $files = array(); foreach ($sequences[2] as $key => $value) { $files[$subfolders . $value] = $value; } if (!array_key_exists($subfolders, $cssTree)) { $cssTree[$subfolders] = array(); } $cssTree[$subfolders] = array_merge($cssTree[$subfolders], $files); } return $cssTree; }
private function _updateDeeplinks() { $cacheHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Cache'); if (null === ($deeplinks = $cacheHelper->load(Helpers_Action_Cache::KEY_DEEPLINKS, Helpers_Action_Cache::PREFIX_DEEPLINKS))) { $deeplinks = Application_Model_Mappers_DeeplinkMapper::getInstance()->fetchAll(); $deeplinks = Tools_System_Tools::bobbleSortDeeplinks($deeplinks); $cacheHelper->save(Helpers_Action_Cache::KEY_DEEPLINKS, $deeplinks, Helpers_Action_Cache::PREFIX_DEEPLINKS, array(), Helpers_Action_Cache::CACHE_NORMAL); } if (!empty($deeplinks)) { $page = Application_Model_Mappers_PageMapper::getInstance()->find($this->_object->getPageId()); if (!$page instanceof Application_Model_Models_Page) { return; } foreach ($deeplinks as $deeplink) { Tools_Content_Tools::applyDeeplinkPerPage($deeplink, $page); } //Application_Model_Mappers_ContainerMapper::getInstance()->save($this->_object); } }
public function refreshcaptchaAction() { if ($this->getRequest()->isPost()) { $this->_helper->json(Tools_System_Tools::generateCaptcha()); } }
protected function _load() { if (!is_array($this->_options) || empty($this->_options) || !isset($this->_options[0]) || !$this->_options[0] || preg_match('~^\\s*$~', $this->_options[0])) { throw new Exceptions_SeotoasterException($this->_translator->translate('You should provide a form name.')); } if (strtolower($this->_options[0]) == 'conversioncode') { return $this->_conversionCode($this->_options); } $sessionHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Session'); $useCaptcha = isset($this->_options[1]) && $this->_options[1] == 'captcha' ? true : false; $useRecaptcha = isset($this->_options[1]) && $this->_options[1] == 'recaptcha' ? true : false; $uploadLimitSize = is_numeric(end($this->_options)) ? end($this->_options) : self::UPLOAD_LIMIT_SIZE; $formMapper = Application_Model_Mappers_FormMapper::getInstance(); $pageMapper = Application_Model_Mappers_PageMapper::getInstance(); $form = $formMapper->findByName($this->_options[0]); $pageHelper = new Helpers_Action_Page(); $pageHelper->init(); if ($useCaptcha || $useRecaptcha) { if ($form != null) { $form->setCaptcha(1); $formMapper->save($form); } if ($useRecaptcha) { $recaptchaTheme = 'red'; $recaptchaWidgetId = uniqid('recaptcha_widget_'); if (isset($this->_options[2])) { $recaptchaTheme = $this->_options[2]; if ($recaptchaTheme == 'custom') { $this->_view->customRecaptcha = true; } } $this->_view->recaptchaWidgetId = $recaptchaWidgetId; $this->_view->addScriptPath($this->_websiteHelper->getPath() . 'seotoaster_core/application/views/scripts/backend/form/'); $this->_view->recaptchaCode = Tools_System_Tools::generateRecaptcha($recaptchaTheme, $recaptchaWidgetId); } if ($useCaptcha) { $this->_view->captchaId = Tools_System_Tools::generateCaptcha(); } } if (isset($sessionHelper->toasterFormError)) { $this->_view->toasterFormError = $sessionHelper->toasterFormError; unset($sessionHelper->toasterFormError); } if (isset($sessionHelper->toasterFormSuccess)) { $this->_view->toasterFormSuccess = $sessionHelper->toasterFormSuccess; unset($sessionHelper->toasterFormSuccess); } $trackingConversionUrl = 'form-' . $this->_options[0] . '-thank-you'; $trackingConversionUrl = $pageHelper->filterUrl($trackingConversionUrl); $trackingPageExist = $pageMapper->findByUrl($trackingConversionUrl); if ($trackingPageExist instanceof Application_Model_Models_Page) { $this->_view->trackingConversionUrl = $trackingConversionUrl; } $this->_view->useRecaptcha = $useRecaptcha; $this->_view->useCaptcha = $useCaptcha; $this->_view->form = Application_Model_Mappers_FormMapper::getInstance()->findByName($this->_options[0]); $this->_view->allowMidification = Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL); $this->_view->formName = $this->_options[0]; $this->_view->uploadLimitSize = $uploadLimitSize; $filter = new Zend_Filter_Alnum(); $this->_view->formId = $filter->filter($this->_options[0]); $this->_view->pageId = $this->_toasterOptions['id']; $this->_view->websiteTmp = $this->_websiteHelper->getTmp(); $this->_view->formUrl = $this->_toasterOptions['url']; return $this->_view->render('form.phtml'); }
protected function _initTranslator() { $websiteHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('website'); $this->_translator = Zend_Registry::get('Zend_Translate'); $langsPath = $websiteHelper->getPath() . 'plugins/' . strtolower(get_called_class()) . '/' . $this->_languagesPath; if (is_dir($langsPath) && is_readable($langsPath)) { $locale = Zend_Registry::get('Zend_Locale'); if (!file_exists($langsPath . $locale->getLanguage() . '.lng')) { if (Tools_System_Tools::debugMode()) { error_log('Language file ' . $locale->getLanguage() . '.lng does not exist'); } return false; } try { $this->_translator->addTranslation(array('content' => $langsPath . $locale->getLanguage() . '.lng', 'locale' => $locale->getLanguage(), 'reload' => true)); Zend_Registry::set('Zend_Translate', $this->_translator); } catch (Exception $e) { if (Tools_System_Tools::debugMode()) { error_log("(plugin: " . strtolower(get_called_class()) . ") " . $e->getMessage() . "\n" . $e->getTraceAsString()); } } } }
public function actionmailsAction() { if ($this->getRequest()->isPost()) { $actions = $this->getRequest()->getParam('actions', false); if ($actions !== false) { $removeActions = array(); foreach ($actions as $action) { if (isset($action['delete']) && $action['delete'] === "true") { array_push($removeActions, $action['id']); continue; } //add trigger automatically if not exists //if(($exists = Application_Model_Mappers_EmailTriggersMapper::getInstance()->findByTriggerName($action['trigger'])->current()) === null) { // Application_Model_Mappers_EmailTriggersMapper::getInstance()->registerTrigger($action['trigger']); // } Application_Model_Mappers_EmailTriggersMapper::getInstance()->save($action); } if (!empty($removeActions)) { Application_Model_Mappers_EmailTriggersMapper::getInstance()->delete($removeActions); } $this->_helper->response->success($this->_helper->language->translate('Changes saved')); return true; } } $pluginsTriggers = Tools_Plugins_Tools::fetchPluginsTriggers(); $systemTriggers = Tools_System_Tools::fetchSystemtriggers(); $triggers = is_array($pluginsTriggers) ? array_merge($systemTriggers, $pluginsTriggers) : $systemTriggers; $recipients = Application_Model_Mappers_EmailTriggersMapper::getInstance()->getReceivers(true); $this->view->recipients = array_combine($recipients, $recipients); $this->view->mailTemplates = Tools_Mail_Tools::getMailTemplatesHash(); $this->view->triggers = $triggers; $this->view->actionsOptions = array_merge(array('0' => $this->_helper->language->translate('Select event area')), array_combine(array_keys($triggers), array_map(function ($trigger) { return str_replace('-', ' ', ucfirst($trigger)); }, array_keys($triggers)))); $this->view->actions = Application_Model_Mappers_EmailTriggersMapper::getInstance()->fetchArray(); }