public function manageformAction()
 {
     $formForm = new Application_Form_Form();
     $formPageConversionMapper = Application_Model_Mappers_FormPageConversionMapper::getInstance();
     $pageMapper = Application_Model_Mappers_PageMapper::getInstance();
     if ($this->getRequest()->isPost()) {
         if ($formForm->isValid($this->getRequest()->getParams())) {
             $formPageConversionModel = new Application_Model_Models_FormPageConversion();
             $formData = $this->getRequest()->getParams();
             $form = new Application_Model_Models_Form($this->getRequest()->getParams());
             $contactEmail = $form->getContactEmail();
             $validEmail = $this->validateEmail($contactEmail);
             if (isset($validEmail['error'])) {
                 $this->_helper->response->fail(Tools_Content_Tools::proccessFormMessagesIntoHtml(array('contactEmail' => $validEmail['error']), get_class($formForm)));
             }
             if (isset($formData['thankyouTemplate']) && $formData['thankyouTemplate'] != 'select') {
                 $trackingPageUrl = $this->_createTrackingPage($formData['name'], $formData['thankyouTemplate']);
             }
             $this->_addConversionCode();
             $formPageConversionModel->setFormName($formData['name']);
             $formPageConversionModel->setPageId($formData['pageId']);
             $formPageConversionModel->setConversionCode($formData['trackingCode']);
             $formPageConversionMapper->save($formPageConversionModel);
             Application_Model_Mappers_FormMapper::getInstance()->save($form);
             $this->_helper->cache->clean('', '', array(Widgets_Form_Form::WFORM_CACHE_TAG));
             $this->_helper->response->success($this->_helper->language->translate('Form saved'));
         } else {
             $this->_helper->response->fail(Tools_Content_Tools::proccessFormMessagesIntoHtml($formForm->getMessages(), get_class($formForm)));
         }
     }
     $formName = filter_var($this->getRequest()->getParam('name'), FILTER_SANITIZE_STRING);
     $pageId = $this->getRequest()->getParam('pageId');
     $trackingPageName = 'form-' . $formName . '-thank-you';
     $trackingPageUrl = $this->_helper->page->filterUrl($trackingPageName);
     $trackingPageExist = $pageMapper->findByUrl($trackingPageUrl);
     if (!empty($trackingPageExist)) {
         $trackingPageResultUrl = $trackingPageUrl;
     }
     $form = Application_Model_Mappers_FormMapper::getInstance()->findByName($formName);
     $mailTemplates = Tools_Mail_Tools::getMailTemplatesHash();
     $regularPageTemplates = Application_Model_Mappers_TemplateMapper::getInstance()->findByType(Application_Model_Models_Template::TYPE_REGULAR);
     $conversionCode = $formPageConversionMapper->getConversionCode($formName, $pageId);
     if (!empty($conversionCode)) {
         $formForm->getElement('trackingCode')->setValue($conversionCode[0]->getConversionCode());
     }
     $formForm->getElement('name')->setValue($formName);
     $formForm->getElement('replyMailTemplate')->setMultioptions(array_merge(array(0 => 'select template'), $mailTemplates));
     if ($form !== null) {
         $formForm->populate($form->toArray());
     }
     $this->view->trackingPageUrl = $trackingPageResultUrl;
     $this->view->regularTemplates = $regularPageTemplates;
     $this->view->pageId = $pageId;
     $this->view->formForm = $formForm;
     $this->view->helpSection = 'editform';
 }
Beispiel #2
0
 public static function getMailTemplatesHash()
 {
     $hash = array();
     $mailTemplates = Application_Model_Mappers_TemplateMapper::getInstance()->findByType(Application_Model_Models_Template::TYPE_MAIL);
     if (!empty($mailTemplates)) {
         foreach ($mailTemplates as $temlate) {
             $hash[$temlate->getName()] = ucfirst($temlate->getName());
         }
     }
     return $hash;
 }
Beispiel #3
0
 public function init()
 {
     $this->setMethod(Zend_Form::METHOD_POST)->setAttrib('id', 'frm_template')->setDecorators(array('ViewScript'))->setElementDecorators(array('ViewHelper'));
     $this->addElement('text', 'name', array('id' => 'title', 'label' => 'Template name', 'value' => $this->_title, 'required' => true, 'filters' => array('StringTrim'), 'class' => array('templatename'), 'decorators' => array('ViewHelper', 'Label'), 'validators' => array(array('stringLength', false, array(3, 45)), new Zend_Validate_Regex(array('pattern' => '/^[\\s\\w-_]*$/u')))));
     $this->addElement('textarea', 'content', array('id' => 'template-content', 'label' => 'Paste your HTML code here:', 'cols' => '85', 'rows' => '33', 'value' => $this->_content, 'required' => true, 'filters' => array('StringTrim'), 'decorators' => array('ViewHelper', 'Label')));
     $this->addElement(new Zend_Form_Element_Select(array('name' => 'templateType', 'id' => 'template-type', 'label' => 'Used for', 'multiOptions' => Application_Model_Mappers_TemplateMapper::getInstance()->fetchAllTypes(), 'value' => $this->_type ? $this->_type : Application_Model_Models_Template::TYPE_REGULAR)));
     $this->addElement('hidden', 'id', array('value' => $this->_templateId, 'id' => 'template_id'));
     $this->addElement(new Zend_Form_Element_Hidden(array('id' => 'pageId', 'name' => 'pageId')));
     $this->addElement(new Zend_Form_Element_Button(array('name' => 'submit', 'type' => 'submit', 'label' => '<span class="icon-save"></span> Save changes', 'class' => array('formsubmit', 'mt15px'), 'ignore' => true, 'escape' => false)));
     $this->setElementDecorators(array('ViewHelper', 'Label'));
     $this->getElement('submit')->removeDecorator('Label');
     $this->removeDecorator('DtDdWrapper');
     $this->removeDecorator('DlWrapper');
 }
Beispiel #4
0
 protected function _load()
 {
     $website = Zend_Controller_Action_HelperBroker::getStaticHelper('website');
     $menuType = $this->_options[0];
     if (!empty($this->_options[1])) {
         $this->_menuTemplate = Application_Model_Mappers_TemplateMapper::getInstance()->find($this->_options[1]);
         if ($this->_menuTemplate instanceof Application_Model_Models_Template) {
             array_push($this->_cacheTags, $this->_menuTemplate->getName());
             $this->_menuTemplate = $this->_menuTemplate->getContent();
         }
     }
     $rendererName = '_render' . ucfirst($menuType) . 'Menu';
     $this->_view->websiteUrl = $website->getUrl();
     if (method_exists($this, $rendererName)) {
         return $this->{$rendererName}();
     }
     throw new Exceptions_SeotoasterException('Can not render <strong>' . $menuType . '</strong> menu.');
 }
 private function _removePluginOccurences()
 {
     $pattern = '~{\\$plugin:' . $this->_object->getName() . '[^{}]*}~usU';
     //removing plugin occurences from content
     $containerMapper = Application_Model_Mappers_ContainerMapper::getInstance();
     $containers = $containerMapper->fetchAll();
     if (!empty($containers)) {
         array_walk($containers, function ($container, $key, $data) {
             $container->setContent(preg_replace($data['pattern'], '', $container->getContent()));
             $data['mapper']->save($container);
         }, array('pattern' => $pattern, 'mapper' => $containerMapper));
     }
     unset($containers);
     //removing plugin occurences from the templates
     $templateMapper = Application_Model_Mappers_TemplateMapper::getInstance();
     $templates = $templateMapper->fetchAll();
     if (!empty($templates)) {
         array_walk($templates, function ($template, $key, $data) {
             $template->setContent(preg_replace($data['pattern'], '', $template->getContent()));
             $data['mapper']->save($template);
         }, array('pattern' => $pattern, 'mapper' => $templateMapper));
     }
     unset($templates);
 }
Beispiel #6
0
 /**
  * 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;
     }
 }
 protected function _prepareEmailBody()
 {
     $tmplMessage = $this->_options['message'];
     $mailTemplate = Application_Model_Mappers_TemplateMapper::getInstance()->find($this->_options['template']);
     if (!empty($mailTemplate)) {
         $this->_entityParser->setDictionary(array('emailmessage' => !empty($tmplMessage) ? $tmplMessage : ''));
         //pushing message template to email template and cleaning dictionary
         $mailTemplate = $this->_entityParser->parse($mailTemplate->getContent());
         $this->_entityParser->setDictionary(array());
         $mailTemplate = $this->_entityParser->parse($mailTemplate);
         $themeData = Zend_Registry::get('theme');
         $extConfig = Zend_Registry::get('extConfig');
         $parserOptions = array('websiteUrl' => $this->_websiteHelper->getUrl(), 'websitePath' => $this->_websiteHelper->getPath(), 'currentTheme' => $extConfig['currentTheme'], 'themePath' => $themeData['path']);
         $cDbTable = new Application_Model_DbTable_Container();
         $select = $cDbTable->getAdapter()->select()->from('container', array('uniqHash' => new Zend_Db_Expr("MD5(CONCAT_WS('-',`name`, COALESCE(`page_id`, 0), `container_type`))"), 'id', 'name', 'page_id', 'container_type', 'content', 'published', 'publishing_date'))->where('(container_type = 2 OR container_type = 4)')->where('page_id IS NULL');
         $stat = $cDbTable->getAdapter()->fetchAssoc($select);
         $parser = new Tools_Content_Parser($mailTemplate, array('containers' => $stat), $parserOptions);
         return Tools_Content_Tools::stripEditLinks($parser->parseSimple());
     }
     return false;
 }
 /**
  * Method which delete template (AJAX)
  */
 public function deletetemplateAction()
 {
     if ($this->getRequest()->isPost()) {
         $mapper = Application_Model_Mappers_TemplateMapper::getInstance();
         $templateId = $this->getRequest()->getPost('id');
         if ($templateId) {
             $template = $mapper->find($templateId);
             if ($template instanceof Application_Model_Models_Template && !in_array($template->getName(), $this->_protectedTemplates)) {
                 $result = $mapper->delete($template);
                 if ($result) {
                     $currentThemePath = realpath($this->_websiteConfig['path'] . $this->_themeConfig['path'] . $this->_helper->config->getConfig('currentTheme'));
                     $filename = $currentThemePath . DIRECTORY_SEPARATOR;
                     if ($template->getType() === Application_Model_Models_Template::TYPE_MOBILE && preg_match('~^mobile_~', $template->getName())) {
                         $filename .= preg_replace('~^mobile_~', 'mobile' . DIRECTORY_SEPARATOR, $template->getName());
                     } else {
                         $filename .= $template->getName();
                     }
                     $filename .= '.html';
                     Tools_Filesystem_Tools::deleteFile($filename);
                     $status = $this->_translator->translate('Template deleted.');
                 } else {
                     $status = $this->_translator->translate('Can\'t delete template or template doesn\'t exists.');
                 }
                 $this->_helper->response->response($status, false);
             }
         }
         $this->_helper->response->response($this->_translator->translate('Template doesn\'t exists'), false);
     }
 }
Beispiel #9
0
 public static function getTemplatesHash($type = 'all')
 {
     $mapper = Application_Model_Mappers_TemplateMapper::getInstance();
     $hash = array();
     $templates = array();
     if ($type == 'all') {
         $templates = $mapper->fetchAll();
     } else {
         $templates = $mapper->findByType($type);
     }
     if (!empty($templates)) {
         foreach ($templates as $template) {
             $hash[$template->getName()] = ucfirst($template->getName());
         }
     }
     return $hash;
 }
 public function indexAction()
 {
     $page = null;
     $pageContent = null;
     $currentUser = $this->_helper->session->getCurrentUser();
     // tracking referer
     if (!isset($this->_helper->session->refererUrl)) {
         $refererUrl = $this->getRequest()->getHeader('referer');
         $currentUser->setReferer($refererUrl);
         $this->_helper->session->setCurrentUser($currentUser);
         $this->_helper->session->refererUrl = $refererUrl;
     }
     // Getting requested url. If url is not specified - get index.html
     $pageUrl = filter_var($this->getRequest()->getParam('page', Helpers_Action_Website::DEFAULT_PAGE), FILTER_SANITIZE_STRING);
     // Trying to do canonical redirects
     $this->_helper->page->doCanonicalRedirect($pageUrl);
     //Check if 301 redirect is present for requested page then do it
     $this->_helper->page->do301Redirect($pageUrl);
     // Loading page data using url from request. First checking cache, if no cache
     // loading from the database and save result to the cache
     $pageCacheKey = md5($pageUrl);
     if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_CACHE_PAGE)) {
         $page = $this->_helper->cache->load($pageCacheKey, 'pagedata_');
     }
     // page is not in cache
     if ($page === null) {
         $page = Application_Model_Mappers_PageMapper::getInstance()->findByUrl($pageUrl);
     }
     // page found
     if ($page instanceof Application_Model_Models_Page) {
         $cacheTag = preg_replace('/[^\\w\\d_]/', '', $page->getTemplateId());
         $this->_helper->cache->save($pageCacheKey, $page, 'pagedata_', array($cacheTag, 'pageid_' . $page->getId()));
     }
     // If page doesn't exists in the system - show 404 page
     if ($page === null) {
         //show 404 page and exit
         $page = Application_Model_Mappers_PageMapper::getInstance()->find404Page();
         if (!$page instanceof Application_Model_Models_Page) {
             $this->view->websiteUrl = $this->_helper->website->getUrl();
             $this->view->adminPanel = $this->_helper->admin->renderAdminPanel($this->_helper->session->getCurrentUser()->getRoleId());
             $this->_helper->response->notFound($this->view->render('index/404page.phtml'));
             exit;
         }
         $this->getResponse()->setHeader('HTTP/1.1', '404 Not Found');
         $this->getResponse()->setHeader('Status', '404 File not found');
     }
     //if requested page is not allowed - redirect to the signup landing page
     if (!Tools_Security_Acl::isAllowed($page)) {
         $signupLanding = Tools_Page_Tools::getLandingPage(Application_Model_Models_Page::OPT_SIGNUPLAND);
         $this->_helper->redirector->gotoUrl($signupLanding instanceof Application_Model_Models_Page ? $this->_helper->website->getUrl() . $signupLanding->getUrl() : $this->_helper->website->getUrl());
     }
     // Mobile switch
     if ((bool) $this->_config->getConfig('enableMobileTemplates')) {
         if ($this->_request->isGet() && $this->_request->has('mobileSwitch')) {
             $showMobile = filter_var($this->_request->getParam('mobileSwitch'), FILTER_SANITIZE_NUMBER_INT);
             if (!is_null($showMobile)) {
                 $this->_helper->session->mobileSwitch = (bool) $showMobile;
             }
         }
         if (!isset($showMobile) && isset($this->_helper->session->mobileSwitch)) {
             $showMobile = $this->_helper->session->mobileSwitch;
         } else {
             $showMobile = $this->_helper->mobile->isMobile();
         }
         // Mobile detect
         if ($showMobile === true) {
             $mobileTemplate = Application_Model_Mappers_TemplateMapper::getInstance()->find('mobile_' . $page->getTemplateId());
             if (null !== $mobileTemplate) {
                 $page->setTemplateId($mobileTemplate->getName())->setContent($mobileTemplate->getContent());
             }
             unset($mobileTemplate);
         }
     }
     $pageData = $page->toArray();
     //Parsing page content and saving it to the cache
     if ($pageContent === null) {
         $themeData = Zend_Registry::get('theme');
         $parserOptions = array('websiteUrl' => $this->_helper->website->getUrl(), 'websitePath' => $this->_helper->website->getPath(), 'currentTheme' => $this->_config->getConfig('currentTheme'), 'themePath' => $themeData['path']);
         $parser = new Tools_Content_Parser($page->getContent(), $pageData, $parserOptions);
         $pageContent = $parser->parse();
         unset($parser);
         unset($themeData);
         //$this->_helper->cache->save($page->getUrl(), $pageContent, 'page_');
     }
     $pageContent = $this->_pageRunkSculptingDemand($page, $pageContent);
     // Finalize page generation routine
     $this->_complete($pageContent, $pageData, $parserOptions);
 }
Beispiel #11
0
 /**
  * Sets the name of the mail template to use
  *
  * If secont parameter set to true then instance of template object
  * Will be created and mailer body will be filled with template content.
  *
  * @param string $bodyTemplateName
  * @param boolean $initBody
  * @return Tools_Mail_Mailer
  */
 public function setMailTemplateName($bodyTemplateName, $initBody = false)
 {
     $this->_mailTemplateName = $bodyTemplateName;
     if ($initBody) {
         $entityParser = new Tools_Content_EntityParser();
         $entityParser->setDictionary($this->_dictonary);
         $bodyTemplate = Application_Model_Mappers_TemplateMapper::getInstance()->find($this->_mailTemplateName);
         $this->_body = $entityParser->parse($bodyTemplate->getContent());
     }
     return $this;
 }