예제 #1
0
 /**
  *
  * @param string $charset
  */
 public function __construct($charset = 'UTF-8')
 {
     parent::__construct($charset);
     $this->view = Axis::app()->getBootstrap()->getResource('layout')->getView();
     $this->view->addScriptPath(Axis::config('system/path') . '/app/design/mail');
     $this->view->site = Axis::getSite()->name;
     $this->view->company = Axis::single('core/site')->getCompanyInfo();
 }
예제 #2
0
 /**
  * Get view
  * 
  * @return Zend_View 
  */
 protected function getView()
 {
     if (!isset(self::$renderView)) {
         //init view
         self::$renderView = new Zend_View();
         self::$renderView->setScriptPath(APPLICATION_PATH . "/modules/teaser/views/scripts/templates/");
         self::$renderView->addHelperPath(APPLICATION_PATH . "/modules/teaser/views/helpers/", "Teaser_View_Helper");
         $mvcView = Zend_Layout::getMvcInstance()->getView();
         if (isset($mvcView->theme)) {
             self::$renderView->addScriptPath(APPLICATION_PATH . '/../themes/' . $mvcView->theme . '/views/teaser/templates/');
         }
     }
     return self::$renderView;
 }
예제 #3
0
 /**
  * load the template and send the message
  *
  * @param string $recipient
  * @param array $from
  * @param string $subject
  * @param string $template
  * @param array $data
  * @param string $cc
  * @return bool
  */
 public function send($recipient, $from = array(), $subject, $message, $cc = false)
 {
     $config = Zend_Registry::get('config');
     $this->_view->addScriptPath($config->filepath->emailTemplates);
     $this->_view->emailBody = $message;
     $this->_mail->setBodyHtml($this->_view->render('template.phtml'));
     $this->_mail->setFrom($from[0], $from[1]);
     $this->_mail->addTo($recipient);
     if ($cc) {
         $this->_mail->addCc($cc);
     }
     $this->_mail->setSubject($subject);
     return $this->_mail->send($this->_transport);
 }
예제 #4
0
 protected function _initView()
 {
     $path = APPLICATION_PATH . '/modules/' . MODULE_NAME . '/views';
     $view = new Zend_View();
     $view->setUseStreamWrapper(true);
     $view->setEncoding('UTF-8');
     $view->addScriptPath($path . '/partials');
     $view->addScriptPath($path . '/scripts');
     $view->addHelperPath(APPLICATION_PATH . '/../library/Bbx/View/Helper', 'Bbx_View_Helper');
     $view->addHelperPath($path . '/helpers', 'ViewHelper');
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
     $viewRenderer->setView($view);
     Zend_Registry::set('view', $view);
 }
예제 #5
0
 public function Show($parameters)
 {
     $output = "";
     $ns = new Zend_Session_Namespace();
     $languageID = Languages::get_language_id($ns->lang);
     $mainviewhelper = new Zend_View();
     $mainviewhelper->addBasePath(APPLICATION_PATH . '/modules/default/views/');
     $view = new Zend_View();
     $view->addScriptPath('../library/Shineisp/Custom/views');
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     if (!empty($parameters['code'])) {
         $code = $parameters['code'];
     } else {
         return "";
     }
     // Get the products
     $data = Products::GetProductsByGroupCode($code, $languageID);
     // Check the existence of the mandatories attributes
     if (!empty($data['attributes'][0])) {
         $view->attributes = $data['attributes'];
     }
     // Check if there are values set for the group of the product selected
     if (!empty($data['attributes_values'][0])) {
         $view->values = $data['attributes_values'];
     }
     // Get the products
     if (!empty($data['products'][0])) {
         $view->products = $data['products'];
     }
     $view->mainviewhelper = $mainviewhelper;
     // Path of the template
     return $view->render('productsattributes.phtml');
 }
예제 #6
0
 public function getView()
 {
     $view = new Zend_View();
     $view->addHelperPath(dirname(__FILE__) . '/../../../../library/Zend/View/Helper');
     $view->addScriptPath(dirname(__FILE__) . '/../_files/views/');
     return $view;
 }
예제 #7
0
 /**
  * Method constructure
  * @param string $name
  * @param Zend_View $view 
  */
 public function renderBlock($name, $view, $params = array())
 {
     $controllerName = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
     $actionName = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
     $view->addScriptPath(APPLICATION_PATH . '/views/scripts/' . $controllerName . '/block');
     $this->_setViewByParams($view, $params);
     //set view
     return $view->render($name . '.phtml');
     //render view
 }
예제 #8
0
 public function Show($parameters)
 {
     $view = new Zend_View();
     $view->addScriptPath('../library/Shineisp/Custom/views');
     $ns = new Zend_Session_Namespace();
     $languageID = Languages::get_language_id($ns->lang);
     // Generate the xml file in the public path /documents
     Reviews::getXMLDataMap($languageID);
     return $view->render('reviewsmap.phtml');
 }
예제 #9
0
파일: Mvc.php 프로젝트: JellyBellyDev/zle
 /**
  * Prepare view to be used
  *
  * @return void
  */
 private function _prepareView()
 {
     $defaultScriptPath = $this->getApplicationPath() . '/views/scripts/';
     if (!in_array($defaultScriptPath, $this->view->getScriptPaths())) {
         $this->view->addScriptPath($defaultScriptPath);
     }
     $defaultHelperPath = $this->getApplicationPath() . '/views/helpers/';
     if (!in_array($defaultHelperPath, $this->view->getHelperPaths())) {
         $this->view->addHelperPath($defaultHelperPath);
     }
 }
예제 #10
0
 /**
  * Show the domain checker form
  */
 public function Show($parameters)
 {
     $view = new Zend_View();
     $form = new Default_Form_DomainsinglecheckerForm(array('action' => '/domainschk/check', 'method' => 'post'));
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $title = !empty($parameters['title']) ? $parameters['title'] : "Choose your new domain name!";
     $form->getElement('name')->setAttrib('title', $translator->translate($title));
     // Set the path of the view templates
     $view->addScriptPath('../library/Shineisp/Custom/views');
     $view->form = $form;
     return $view->render('domainchecker.phtml');
 }
예제 #11
0
 public function init()
 {
     $view = new Zend_View($this->getOptions());
     $view->addScriptPath(APPLICATION_PATH . '/scripts');
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
     $viewRenderer->setView($view);
     $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')->appendHttpEquiv('X-UA-Compatible', 'IE=EmulateIE7')->appendName('viewport', 'width=device-width; initial-scale=1.0;')->appendName('viewport', 'user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0');
     $view->headLink(array('rel' => 'shortcut bookmark icon', 'type' => 'image/x-icon', 'href' => '/branding/images/shared/pathbuilder.ico', 'PREPEND'))->appendStylesheet('/resources/css/reset.css')->appendStylesheet('/resources/css/base.css')->appendStylesheet('/branding/css/global.css');
     $view->headScript()->appendFile('/lib/core/jquery.min.js')->appendFile('/lib/core/base.js')->appendFile('/lib/core/templates.js')->appendFile('/lib/i10n/en.js');
     require_once 'default/forms/SearchHeader.php';
     $view->searchform = new Default_Form_SearchHeader();
     return $view;
 }
예제 #12
0
 /**
  * Reset the view's script paths and set new ones
  * @todo: Move elsewhere - it shouldn't be in a service
  *
  * @param string $module
  * @param string $type
  */
 private function resetView($module, $type)
 {
     $module = ucfirst($module);
     $layout = Zend_Layout::getMvcInstance();
     // Reset view script paths
     $this->view->setScriptPath(null);
     // Build new ones for blocks
     $this->view->addBasePath(ZfApplication::$_base_path . "/app/" . ucfirst($module) . "/views", ucfirst($module) . "_View");
     $this->view->addScriptPath(ZfApplication::$_base_path . "/app/Content/views/scripts/{$type}");
     $this->view->addScriptPath(ZfApplication::$_base_path . "/app/" . ucfirst($module) . "/views/scripts/{$type}");
     $this->view->addScriptPath($layout->getLayoutPath() . "default/templates/" . ucfirst($module) . "/{$type}");
     $this->view->addScriptPath($layout->getLayoutPath() . $layout->getLayout() . "/templates/" . ucfirst($module) . "/{$type}");
 }
예제 #13
0
 public function send()
 {
     $config = Zend_Registry::get('config');
     $mail = new Zend_Mail('utf-8');
     $mail->setSubject('Bericht via de website van ' . $config->company->name)->setFrom($this->getEmail(), $this->getName() . ' ' . $this->getFirstName());
     $view = new Zend_View();
     $view->assign('contact', $this);
     $view->assign('config', $config);
     $view->addScriptPath(APPLICATION_PATH . '/modules/default/views/scripts');
     $body = $view->render('/contact/_mailMessage.phtml');
     $mail->setBodyHtml($body);
     $mail->addTo($config->contact->to);
     return $mail->send();
 }
예제 #14
0
 public function Show($parameters)
 {
     $view = new Zend_View();
     $view->addScriptPath('../library/Shineisp/Custom/views');
     $limit = 5;
     $ns = new Zend_Session_Namespace();
     $languageID = Languages::get_language_id($ns->lang);
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     if (!empty($parameters['limit']) && is_numeric($parameters['limit'])) {
         $limit = $parameters['limit'];
     }
     $view->data = Reviews::get_random($limit);
     return $view->render('reviewslist.phtml');
 }
예제 #15
0
 protected function _initDoctype()
 {
     ///$this->bootstrap('view');
     // $view = $this->getResource('view');
     //  $view->doctype('XHTML1_STRICT');
     //enable class autoloader start
     require_once 'Zend/Loader/Autoloader.php';
     $loader = Zend_Loader_Autoloader::getInstance();
     $loader->setFallbackAutoloader(true);
     //enable class autoloader end
     $frontCtrl = Zend_Controller_Front::getInstance();
     $frontCtrl->throwExceptions(true);
     $frontCtrl->addModuleDirectory(APPLICATION_PATH . '/modules');
     //set include path for modules
     set_include_path(get_include_path() . PATH_SEPARATOR . APPLICATION_PATH . '/modules/');
     $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/config.xml', 'production');
     //set database adaptor
     $db = Zend_Db::factory('PDO_MYSQL', $config->resources->db->params);
     Zend_Registry::set('db', $db);
     //cache setting start
     if ($config->configuration->cache) {
         $frontend = array('lifetime' => 200, 'cache_id_prefix' => 'site_', 'automatic_seralization' => true);
         $backend = array('cache_dir' => APPLICATION_PATH . '/../cache');
         $cache = Zend_Cache::factory('Page', 'File', $frontend, $backend);
         Zend_Registry::set('cache', $cache);
         $cache->start(md5($_SERVER['REQUEST_URI']));
     }
     $theme = 'default';
     if (isset($config->configuration->theme)) {
         $theme = $config->configuration->theme;
     }
     //theme layout path
     $layoutPath = APPLICATION_PATH . '/../public/themes/' . $theme . '/templates';
     //get module name
     $arrUrl = array_filter(explode("/", str_replace($config->configuration->base_path, '', $_SERVER['REQUEST_URI'])));
     $moduleName = current($arrUrl);
     $modules = array_keys($frontCtrl->getControllerDirectory());
     $moduleName = in_array($moduleName, $modules) ? $moduleName : 'default';
     $layout = Zend_Layout::startMvc()->setLayout('layout')->setLayoutPath($layoutPath)->setContentKey('content');
     //set view render
     $view = new Zend_View();
     $view->addBasePath($layoutPath . "/" . $moduleName);
     $view->addScriptPath($layoutPath . "/" . $moduleName);
     $view->doctype('XHTML1_STRICT');
     // Add it to the ViewRenderer
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
     $viewRenderer->setView($view);
 }
예제 #16
0
 public function Show($parameters)
 {
     $view = new Zend_View();
     $view->addScriptPath('../library/Shineisp/Custom/views');
     $ns = new Zend_Session_Namespace();
     $languageID = Languages::get_language_id($ns->lang);
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     if (!empty($parameters['category']) && is_numeric($parameters['category'])) {
         $id = $parameters['category'];
     } else {
         return "";
     }
     // Get the products
     $view->products = ProductsCategories::getProductListbyCatID($id, "p.product_id, p.uri as uri, pd.name as name, pd.shortdescription as description", $languageID);
     return $view->render('productlist.phtml');
 }
예제 #17
0
파일: Action.php 프로젝트: bersace/strass
 function initView()
 {
     $view = new Zend_View();
     $view->setEncoding('UTF-8');
     $fc = Zend_Controller_Front::getInstance();
     $cs = $fc->getControllerDirectory();
     $prefixes = array_keys($cs);
     foreach ($prefixes as $prefix) {
         $viewdir = dirname(dirname(__FILE__)) . '/Views/';
         $view->addScriptPath($viewdir . 'Scripts');
         $view->addHelperPath($viewdir . 'Helpers', $prefix . '_View_Helper_');
     }
     $page = new Strass_Page(new Wtk_Metas(array('DC.Title' => 'Installation', 'DC.Language' => 'fr', 'site' => 'Installation')));
     Zend_Registry::set('page', $page);
     return $view;
 }
예제 #18
0
 public function Show($parameters)
 {
     $view = new Zend_View();
     $view->addScriptPath('../library/Shineisp/Custom/views');
     $limit = 10;
     $id = null;
     $ns = new Zend_Session_Namespace();
     $languageID = Languages::get_language_id($ns->lang);
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     if (!empty($parameters['category']) && is_numeric($parameters['category'])) {
         $id = $parameters['category'];
     }
     if (!empty($parameters['limit']) && is_numeric($parameters['limit'])) {
         $limit = $parameters['limit'];
     }
     // Get the products
     $view->wiki = Wiki::get_items($limit, $id);
     return $view->render('wikilist.phtml');
 }
예제 #19
0
 protected function _initView()
 {
     // Create view
     $view = new Zend_View();
     // Set encoding (@todo maybe use configuration?)
     $view->setEncoding('utf-8');
     $view->addScriptPath(APPLICATION_PATH);
     // Setup and register viewRenderer
     // @todo we may not need to override zend's
     $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
     //$viewRenderer = new Engine_Controller_Action_Helper_ViewRenderer($view);
     $viewRenderer->setViewSuffix('phtml');
     Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-80, $viewRenderer);
     // Add default helper paths
     $view->addHelperPath('Khcn/View/Helper/', 'Khcn_View_Helper_');
     $this->initViewHelperPath();
     // Set doctype
     $doctypeHelper = new Zend_View_Helper_Doctype();
     $doctypeHelper->doctype('XHTML1_STRICT');
     // Add to local container and registry
     Zend_Registry::set('Zend_View', $view);
     return $view;
 }
예제 #20
0
 /**
  * preDispatch
  *
  * @param  Zend_Controller_Request_Abstract $oRequest
  * @return void
  */
 public function preDispatch(Zend_Controller_Request_Abstract $oRequest)
 {
     // Reset script path
     $this->_view->setScriptPath(null);
     // Loop theme basePath
     foreach ($this->_basePaths as $basePath) {
         foreach ($this->_themes as $theme) {
             // Mount basepath
             $path = $basePath . "/" . $theme . "/scripts";
             // Set module name
             $module = $oRequest->getModuleName();
             // Check if request is to module
             if ($module != "default") {
                 $scriptPath = $path . "/modules/" . $module . "/";
             } else {
                 $scriptPath = $path . "/controllers/";
             }
             // format scriptPath
             $scriptPath = preg_replace("/\\/\\//", "/", $scriptPath);
             // Add view scriptpath for module
             $this->_view->addScriptPath($scriptPath);
         }
     }
 }
예제 #21
0
 protected function sendNotificationEmail($message, $emailParams, $language, $template = 'notification.phtml')
 {
     $emailParams = array_merge($this->_application->get_email_settings(), $emailParams);
     //print_r($emailParams); die();
     $transport = HCMS_Email_TransportFactory::createFactory($emailParams);
     //init view
     $emailView = new Zend_View();
     $emailView->setScriptPath($this->getFrontController()->getModuleDirectory('admin') . '/views/scripts/email_templates/');
     $mvcView = clone Zend_Layout::getMvcInstance()->getView();
     if (isset($mvcView->theme)) {
         $emailView->addScriptPath(APPLICATION_PATH . '/../themes/' . $mvcView->theme . '/views/admin/email_templates/');
     }
     $emailView->assign(array('application' => $this->_application, 'message' => $message, 'lang' => $language, 'serverUrl' => $this->view->serverUrl(), 'imagesUrl' => isset($mvcView->theme) ? $this->view->serverUrl() . '/themes/' . $mvcView->theme . '/images/email/' : $this->view->serverUrl() . '/images/email/'));
     $body = $this->getEmailBody($emailView, $emailParams, $template, $language);
     $mail = new Zend_Mail('UTF-8');
     $mail->setBodyHtml($body);
     $mail->setFrom($emailParams['from_email'], $emailParams['from_name']);
     foreach ($emailParams['to_emails'] as $toEmail) {
         if (is_array($toEmail)) {
             $mail->addTo($toEmail['email'], $toEmail['name']);
         } else {
             $mail->addTo($toEmail);
         }
     }
     $mail->setSubject($this->translate($emailParams['subject']));
     $mail->send($transport);
 }
예제 #22
0
 /**
  * @return string
  */
 public function prepareBodyHtml($template, $arguments)
 {
     $config = $this->getConfig();
     $view = new \Zend_View();
     $view->addScriptPath($config['layoutPath']);
     foreach ($arguments as $alias => $argument) {
         $view->assign($alias, $argument);
     }
     $this->setBodyHtml(utf8_decode($view->render($template)))->_buildHtml();
     return $this;
 }
예제 #23
0
파일: ViewTest.php 프로젝트: jsnshrmn/Suma
 /**
  * @group ZF-9000
  * @group ZF-4622
  */
 public function testAddingStreamSchemeAsScriptPathShouldNotMangleThePath()
 {
     $view = new Zend_View();
     $path = rtrim('file://' . str_replace('\\', '/', realpath(dirname(__FILE__))), '/') . '/';
     $view->addScriptPath($path);
     $paths = $view->getScriptPaths();
     $this->assertContains($path, $paths, var_export($paths, 1));
 }
예제 #24
0
 /**
  * Handle errors gracefully, this will work as long as the views,
  * and the Zend classes are available
  *
  * @param Exception $e
  * @param string $email
  */
 protected function X__handleErrors(Exception $exp, $email)
 {
     header('HTTP/1.1 500 Internal Server Error');
     $view = new Zend_View();
     $view->addScriptPath(dirname(__FILE__) . '/../views/scripts');
     echo $view->render('fatalError.phtml');
     if ('' != $email) {
         $mail = new Zend_Mail();
         $mail->setSubject('Fatal error in application ' . SITE_NAME);
         $mail->addTo($email);
         $mail->setBodyText("\n" . $exp->getFile() . "\n" . $exp->getMessage() . "\n" . $exp->getTraceAsString());
         @$mail->send();
     }
 }
예제 #25
0
 /**
  * @group ZF-9000
  */
 public function testAddingStreamSchemeAsScriptPathShouldNotReverseSlashesOnWindows()
 {
     if (false === strstr(strtolower(PHP_OS), 'windows')) {
         $this->markTestSkipped('Windows-only test');
     }
     $view = new Zend_View();
     $path = rtrim('file://' . str_replace('\\', '/', realpath(dirname(__FILE__))), '/') . '/';
     $view->addScriptPath($path);
     $paths = $view->getScriptPaths();
     $this->assertContains($path, $paths, var_export($paths, 1));
 }
예제 #26
0
 /**
  * Cache the View Class.
  *
  * @param array $helperPaths Array with all the folders with helpers.
  *
  * @return Zend_View An instance of Zend_View.
  */
 private function _setView($helperPaths)
 {
     $viewNamespace = new Zend_Session_Namespace('Phprojekt-_setView');
     if (!isset($viewNamespace->view)) {
         $view = new Zend_View();
         $view->addScriptPath(PHPR_CORE_PATH . '/Default/Views/dojo/');
         foreach ($helperPaths as $helperPath) {
             if (is_dir($helperPath['directory'])) {
                 $view->addHelperPath($helperPath['directory'], $helperPath['module'] . '_' . 'Helpers');
             }
         }
         $viewNamespace->view = $view;
     } else {
         $view = $viewNamespace->view;
     }
     $this->_view = $view;
     return $view;
 }
예제 #27
0
 protected function _initView()
 {
     // Initialize view
     $view = new Zend_View();
     $view->addScriptPath(APPLICATION_PATH . '/views/scripts/');
     // Add it to the ViewRenderer
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
     $viewRenderer->setView($view);
     return $view;
 }
예제 #28
0
 public function setBody(array $arguments = array(), $assunto = 'MENSAGEM DE EMAIL')
 {
     //configuração servidor de envio
     $modelBanco = new Application_Model_ConfigSendMail();
     $dataBanco = $modelBanco->getConfig(1);
     if (count($dataBanco)) {
         $this->email_sender_sis = $dataBanco->snd_login;
         $this->pass_sender_sis = $dataBanco->snd_senha;
         $this->port_mailer = $dataBanco->snd_port;
         $this->ssl_protocol = $dataBanco->snd_ssl_protocolo;
         $this->smtp_account = $dataBanco->snd_smtp;
         $this->email_sender_client = $dataBanco->snd_email_envio;
         $this->name_sender_client = $dataBanco->snd_nome;
     } else {
         $this->email_sender_sis = EMAIL_SENDER_SIS;
         $this->pass_sender_sis = PASS_SENDER_SIS;
         $this->port_mailer = PORT_MAILER;
         $this->ssl_protocol = SSL_PROTOCOL;
         $this->smtp_account = SMTP_ACCOUNT;
         $this->email_sender_client = EMAIL_SENDER_CLIENT;
         $this->name_sender_client = NAME_SENDER_CLIENT;
     }
     $layout = $arguments['template'] ? $arguments['template'] : 'template_emkt.phtml';
     $email_send = $this->email_sender_client;
     $email_receive = $arguments['email_recebe'] ? $arguments['email_recebe'] : $this->email_sender_client;
     $name_receive = $arguments['nome_recebe'] ? $arguments['nome_recebe'] : 'Usuário';
     $text_receive = $arguments['dinamic_content'] ? $arguments['dinamic_content'] : '-';
     $envia = array('email' => $email_send, 'nome' => $this->name_sender_client);
     $recebe = array('email' => $email_receive, 'nome' => $name_receive);
     $this->assunto = $assunto;
     $front_controller = Zend_Controller_Front::getInstance();
     $request = new Zend_Controller_Request_Http();
     $this->_baseUrl = $request->getBaseUrl();
     $myView = new Zend_View();
     $myView->addScriptPath(APPLICATION_PATH . '/views/scripts/templates/');
     //$myView->addScriptPath($url.'/views/scripts/templates/'.$layout;);
     $html_body = $myView->render($layout);
     //substituí as tags pelo original
     $html_body = preg_replace('/{email}/', $email_receive, $html_body);
     $html_body = preg_replace('/{nome}/', $name_receive, $html_body);
     $html_body = preg_replace('/{texto_dinamico}/', $text_receive, $html_body);
     $html_body = preg_replace('/^<a(.*?)href=("|\')(.+)("|\')(.*?)>$/', '<a$1href=$2$3$2$5>', $html_body);
     preg_match_all('<a(.*?)href=("|\')([^"]+)("|\')(.*?)>', $html_body, $matches);
     if (count($matches)) {
         $arrayUrls = $matches[3];
         $urls = array_values(array_filter($arrayUrls));
     }
     if (count($urls)) {
         foreach ($urls as $k => $url) {
             $urlString = SITE_SUBFOLDER . '/index/click/k/' . str_replace('/', '::', base64_encode($email_receive)) . '/url/' . str_replace('/', '::', base64_encode(urlencode($url)));
             $urlString = $this->makeShortUrlBitly($urlString);
             $html_body = preg_replace('/<a(.*?)href=("|\')' . preg_quote($url, '/') . '("|\')(.*?)>/', '<a$1href=$2' . $urlString . '$2$5 mc:disable-tracking>', $html_body);
         }
     }
     //        if(count($urls) ) {
     //            foreach ($urls as $k => $url) {
     //
     //                $urlString = SITE_SUBFOLDER.'/index/click/k/'.str_replace('/','::',base64_encode($email_receive)).'/url/'.str_replace('/','::',base64_encode(utf8_encode($url)));
     //                $urlString = $this->makeShortUrlBitly($urlString);
     //               // $html_body = preg_replace('/<a(.*?)href=("|\')'.preg_quote($url, '/').'("|\')(.*?)>/', '<a$1href=$2'.$urlString.'$2$5 mc:disable-tracking>', $html_body);
     //
     //                $html_body = str_replace($url, $urlString, $html_body);
     //
     //            }
     //        }
     $html_body .= '<p>Se não deseja receber mais mensagens, <a href="' . $this->makeShortUrlBitly(SITE_SUBFOLDER . '/index/remover-email/k/' . str_replace('/', '::', base64_encode($email_receive))) . '" mc:disable-tracking>clique aqui</a>.</p>';
     $this->enviaEmail = $envia;
     $this->recebeEmail = $recebe;
     $this->retornoEmail = $recebe;
     $this->html_body = $html_body;
 }
예제 #29
0
 /**
  * Init the front for test it
  */
 public function __construct()
 {
     $this->request = new Zend_Controller_Request_Http();
     $this->response = new Zend_Controller_Response_Http();
     $this->config = Phprojekt::getInstance()->getConfig();
     $this->config->language = "en";
     $this->request->setModuleName('Default');
     $this->request->setActionName('index');
     // Languages Set
     Zend_Loader::loadClass('Phprojekt_Language', PHPR_LIBRARY_PATH);
     $cache = Phprojekt::getInstance()->getCache();
     if (!($translate = $cache->load('Phprojekt_getTranslate_en'))) {
         $translate = new Phprojekt_Language('en');
         $cache->save($translate, 'Phprojekt_getTranslate_en', array('Language'));
     }
     Zend_Registry::set('translate', $translate);
     $view = new Zend_View();
     $view->addScriptPath(PHPR_CORE_PATH . '/Default/Views/dojo/');
     $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
     $viewRenderer->setViewBasePathSpec(':moduleDir/Views');
     $viewRenderer->setViewScriptPathSpec(':action.:suffix');
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     /* Front controller stuff */
     $this->front = Zend_Controller_Front::getInstance();
     $this->front->setDispatcher(new Phprojekt_Dispatcher());
     $this->front->registerPlugin(new Zend_Controller_Plugin_ErrorHandler());
     $this->front->setDefaultModule('Default');
     $moduleDirectories = array();
     foreach (scandir(PHPR_CORE_PATH) as $module) {
         $dir = PHPR_CORE_PATH . DIRECTORY_SEPARATOR . $module;
         if (is_dir(!$dir)) {
             continue;
         }
         $helperPath = $dir . DIRECTORY_SEPARATOR . 'Helpers';
         if (is_dir($helperPath)) {
             $view->addHelperPath($helperPath, $module . '_' . 'Helpers');
             Zend_Controller_Action_HelperBroker::addPath($helperPath);
         }
         $dir = PHPR_CORE_PATH . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'SubModules';
         if (is_dir($dir)) {
             if ($module != 'Core') {
                 $moduleDirectories[] = $dir;
             } else {
                 $coreModules = scandir($dir);
                 foreach ($coreModules as $coreModule) {
                     $coreDir = $dir . DIRECTORY_SEPARATOR . $coreModule;
                     if ($coreModule != '.' && $coreModule != '..' && $coreModule != '.svn' && is_dir($coreDir)) {
                         $moduleDirectories[] = $coreDir;
                     }
                 }
             }
         }
     }
     Zend_Registry::set('view', $view);
     $view->webPath = $this->config->webpath;
     $this->front->setModuleControllerDirectoryName('Controllers');
     $this->front->addModuleDirectory(PHPR_CORE_PATH);
     foreach ($moduleDirectories as $moduleDirectory) {
         $this->front->addModuleDirectory($moduleDirectory);
     }
     $this->front->setParam('useDefaultControllerAlways', true);
     $this->front->throwExceptions(true);
 }
 /**
  * Send the agents renewal invitation letter, by email, to the agent
  *
  * @return void
  */
 public function sendRenewalDocumentAction()
 {
     $session = new Zend_Session_Namespace('connect_rg');
     $this->view->agentinvite = $session->agentinvite;
     // Agents invitation
     if ($session->agentinvite == 1) {
         // Send agent document by email
         $params = Zend_Registry::get('params');
         $referencingServer = $params->connect->baseUrl->referencing;
         $httpclient = curl_init();
         curl_setopt($httpclient, CURLOPT_URL, $referencingServer . '/cgi-bin/premrenewal.pl?refsend=email&policynumber=' . $session->policynumber);
         curl_setopt($httpclient, CURLOPT_HEADER, 0);
         curl_setopt($httpclient, CURLOPT_RETURNTRANSFER, 1);
         $httpresponse = curl_exec($httpclient);
         curl_close($httpclient);
     }
     // Landlords documents
     if (isset($session->documenttype) && $session->documenttype != '') {
         // Landlords document
         $templateview = new Zend_View();
         foreach ($this->view->getScriptPaths() as $scriptpath) {
             $templateview->addScriptPath($scriptpath);
         }
         // Add default template values
         $templateview->landlords_name = '[LandlordName]';
         $templateview->tenant_name = '[TenantName]';
         $templateview->agent_contact_number = '[ContactNumber]';
         $templateview->policy_premium = '[Premium]';
         $templateview->policy_term = '[Term]';
         $templateview->agent_name = $this->_agentrealname;
         $templateview->agent_job_title = '[JobTitle]';
         $templateview->documentaddress = $session->documentaddress;
         // Tenant name
         $rgmanager = new Manager_Insurance_Policy_Rentguarantee();
         $policydetails = $rgmanager->getPolicyDetails($session->policynumber);
         $templateview->enddate = new Zend_Date($policydetails->endDate, Zend_Date::YEAR . '-' . Zend_Date::MONTH . '-' . Zend_Date::DAY);
         $referencedetails = $rgmanager->getReference($session->policynumber);
         $templateview->tenant_name = $referencedetails->referenceSubject->name->title . ' ' . $referencedetails->referenceSubject->name->firstName . ' ' . $referencedetails->referenceSubject->name->lastName;
         // Apply data from session
         $templateview->landlords_name = $session->landlords_name;
         $templateview->policy_premium = $session->policy_premium;
         $templateview->policy_term = $session->policy_term;
         $templateview->agent_job_title = $session->agent_job_title;
         $templateview->agent_contact_number = $session->agent_contact_number;
         $viewname = $session->documenttype . '-' . $session->sendmethod . '.phtml';
         $content = $templateview->render('rentguarantee/letters/' . $viewname);
         // Emailing document
         if ($session->documenttype == 'landlordinvite') {
             $documenttype = "invitation";
             $this->view->documenttype = 'invitation';
         } else {
             if ($session->documenttype == 'landlordreminder') {
                 $documenttype = "reminder";
                 $this->view->documenttype = 'reminder';
             }
         }
         $this->view->sendmethod = $session->sendmethod;
         // Send document
         if ($session->sendmethod == 'post') {
             // Post document
             // Generate document using legacy fileserver interface
             $fileserver = new Application_Document_Legacy_Fileserver();
             $filename = $fileserver->makePDF($content, 'HL');
             if ($filename !== false) {
                 // Retrieve and store, and delete remote pdf
                 $pdfcontent = $fileserver->storePDF($filename);
                 $fileserver->deletePDF($filename);
                 // Strip slashes
                 $filename = preg_replace('/\\//', '', $filename);
                 $requesthash = preg_replace('/\\.pdf/', '', $filename);
                 $params = Zend_Registry::get('params');
                 $localcache_path = null;
                 if (@isset($params->dms->localcache->directory) && $params->dms->localcache->directory != '') {
                     $localcache_path = $params->dms->localcache->directory;
                 }
                 $full_filepath = realpath(APPLICATION_PATH . '/../' . $localcache_path) . '/' . $filename;
                 $fh = fopen($full_filepath, 'w+');
                 if (!is_resource($fh)) {
                     // Failed to open file
                     $this->render('send-renewal-document-failed');
                     return;
                 }
                 flock($fh, LOCK_EX);
                 fwrite($fh, $pdfcontent);
                 flock($fh, LOCK_UN);
                 fclose($fh);
                 // Check the homelet domain parameter is set
                 if (@isset($params->homelet->domain) && $params->homelet->domain != '') {
                     $homeletdomain = $params->homelet->domain;
                 }
                 $this->view->documentpath = $homeletdomain . '/document/?h=' . $requesthash . '&m=' . self::_generateAuthKey($requesthash);
                 $this->render('send-renewal-document');
                 return;
             } else {
                 $this->render('send-renewal-document-failed');
                 return;
             }
         } else {
             if ($session->sendmethod == 'email') {
                 // Send email and set status in to view
                 $landlordsemail = $session->landlords_email;
                 $this->view->landlordsemail = $session->landlords_email;
                 if ($this->_emailDocumentContent($content, $documenttype, $landlordsemail, $this->_agentrealname)) {
                     $this->render('send-renewal-document');
                     return;
                 } else {
                     $this->render('send-renewal-document-failed');
                 }
             }
         }
     }
 }