예제 #1
0
파일: Email.php 프로젝트: ud223/yj
 public function sendEmail($template, $to, $subject, $params = array())
 {
     try {
         $config = array('auth' => 'Login', 'port' => $this->_bootstrap_options['mail']['port'], 'ssl' => 'ssl', 'username' => $this->_bootstrap_options['mail']['username'], 'password' => $this->_bootstrap_options['mail']['password']);
         $tr = new Zend_Mail_Transport_Smtp($this->_bootstrap_options['mail']['server'], $config);
         Zend_Mail::setDefaultTransport($tr);
         $mail = new Zend_Mail('UTF-8');
         $layout = new Zend_Layout();
         $layout->setLayoutPath($this->_bootstrap_options['mail']['layout']);
         $layout->setLayout('email');
         $view = $layout->getView();
         $view->domain_url = $this->_bootstrap_options['site']['domainurl'];
         $view = new Zend_View();
         $view->params = $params;
         $view->setScriptPath($this->_bootstrap_options['mail']['view_script']);
         $layout->content = $view->render($template . '.phtml');
         $content = $layout->render();
         $mail->setBodyText(preg_replace('/<[^>]+>/', '', $content));
         $mail->setBodyHtml($content);
         $mail->setFrom($this->_bootstrap_options['mail']['from'], $this->_bootstrap_options['mail']['from_name']);
         $mail->addTo($to);
         $mail->setSubject($subject);
         $mail->send();
     } catch (Exception $e) {
         // 这里要完善
     }
     return true;
 }
예제 #2
0
파일: Email.php 프로젝트: hoaitn/base-zend
 /**
  * Tạo Object Layout cho Email
  */
 private function generateLayout()
 {
     $layout = new Zend_Layout();
     $layout->setLayoutPath(APPLICATION_PATH . 'modules/admin/views/scripts/email');
     $layout->setLayout('layout');
     return $layout;
 }
예제 #3
0
 private function __construct()
 {
     // setup file error logging
     $file_writer = new Logger_Errorlog();
     if (Config::get_optional("DEBUG_LOG") == false) {
         $file_writer->addFilter(Zend_Log::INFO);
     }
     $log = new Zend_Log();
     $log->addWriter($file_writer);
     // setup email error logging
     if (Config::get_optional("log_to_email") == true) {
         $mail = new Zend_Mail();
         $mail->setFrom(Config::get_mandatory('log_email_from'));
         $mail->addTo(Config::get_mandatory('log_email_to'));
         // setup email template
         $layout = new Zend_Layout();
         $layout->setLayoutPath(DOCUMENT_ROOT . Config::get_mandatory("log_email_template"));
         $layout->setLayout('error-logger');
         $layout_formatter = new Zend_Log_Formatter_Simple('<li>.' . Zend_Log_Formatter_Simple::DEFAULT_FORMAT . '</li>');
         // Use default HTML layout.
         $email_writer = new Zend_Log_Writer_Mail($mail, $layout);
         $email_writer->setLayoutFormatter($layout_formatter);
         $email_writer->setSubjectPrependText(Config::get_mandatory('log_email_subject_prepend'));
         $email_writer->addFilter(Zend_Log::ERR);
         $log->addWriter($email_writer);
     }
     self::$logger = $log;
 }
예제 #4
0
파일: Bootstrap.php 프로젝트: ei-grad/phorm
 /**
  * Инициализация объекта Layout
  * 
  * @return Phorm_Layout
  */
 protected function _initLayout()
 {
     $layout = new Zend_Layout();
     $layout->setLayoutPath(APPLICATION_PATH . '/templates');
     $layout->setViewSuffix('tpl');
     return $layout;
 }
예제 #5
0
 public function setLayout(Zend_Layout $layout)
 {
     if ($layout->getMvcEnabled()) {
         throw new InvalidArgumentException();
     }
     $this->_layout = $layout;
     return $this;
 }
예제 #6
0
파일: Mail.php 프로젝트: ao-lab/ao-zend
 /**
  * Retorna a instância única de Zend_Layout para auxiliar na construção dos emails.
  *
  * @return Zend_Layout
  */
 public function getLayout()
 {
     static $layout = null;
     if (is_null($layout)) {
         $layout = new Zend_Layout();
         $layout->setLayoutPath(APP_PATH . '/default/views/emails')->setLayout('layout');
     }
     return $layout;
 }
예제 #7
0
파일: Action.php 프로젝트: tudorfis/urfx
 public function ajaxResponse($message = "", $success = 1, $data = null, $type = 'json')
 {
     $this->layout->disableLayout();
     $this->viewRenderer->setNoRender(true);
     if (!$success) {
         $message = "A problem occurred.";
     }
     echo Zend_Json::encode(array('data' => $data, 'success' => $success, 'error' => !$success, 'message' => $message, 'type' => $type));
     exit;
 }
예제 #8
0
 public function init()
 {
     parent::init();
     $this->view->baseUrl = $this->_sBaseUrl;
     $this->_prepareLayout();
     $this->_oLayout->getView()->config = $this->_oConfig;
     $this->_oLayout->setViewScriptPath(APPLICATION_PATH . $this->_oConfig->views . '/layout');
     $this->view->setBasePath(APPLICATION_PATH . $this->_oConfig->views . '/modules/' . strtolower($this->getRequest()->getModuleName()));
     $this->view->addHelperPath(APPLICATION_PATH . $this->_oConfig->views . '/helpers');
     $this->view->addFilterPath(APPLICATION_PATH . $this->_oConfig->views . '/filters');
     $this->view->setLfiProtection(false);
     Zend_View_Helper_PaginationControl::setDefaultViewPartial('../../abstract/scripts/pagination_control.phtml');
 }
예제 #9
0
파일: Bootstrap.php 프로젝트: br00k/tnc-web
 /**
  * Initialize Logging
  *
  */
 protected function _initLogging()
 {
     $this->bootstrap('log');
     Zend_Registry::set('log', $log = $this->getResource('log'));
     $mail = new Zend_Mail();
     $config = Zend_Registry::get('config');
     $mail->addTo($config->core->debugMailTo);
     $layout = new Zend_Layout();
     $layout->setLayout('errormail');
     $writer = new Zend_Log_Writer_Mail($mail, $layout);
     $writer->setSubjectPrependText('CORE Error');
     $writer->addFilter(Zend_Log::CRIT);
     #$log->addWriter($writer);
 }
예제 #10
0
파일: Bootstrap.php 프로젝트: jtclark/phly
 protected function _initView()
 {
     $this->bootstrap('EventManager');
     $manager = $this->getResource('EventManager');
     $response = $manager->getResponse();
     $renderer = $response->getRenderer();
     $view = $renderer->getView();
     $view->addScriptPath(dirname(__FILE__) . '/views/scripts');
     $layout = new \Zend_Layout();
     $layout->setLayoutPath(dirname(__FILE__) . '/layouts/scripts');
     $view->getHelper('layout')->setLayout($layout);
     $renderer->setLayout($layout);
     return $view;
 }
예제 #11
0
파일: Model.php 프로젝트: hYOUstone/tsg
 public function setViewBody($script, $params = array())
 {
     $layout = new Zend_Layout(array('layoutPath' => $this->_getLayoutPath()));
     $layout->setLayout('email');
     $view = new Zend_View();
     $view->setScriptPath($this->_getViewPath() . '/email');
     foreach ($params as $k => $param) {
         $view->assign($k, $param);
     }
     $layout->content = $view->render($script . '.phtml');
     //$layout->content = $msg;
     $html = $layout->render();
     $this->setBodyHtml($html);
 }
예제 #12
0
파일: Mail.php 프로젝트: Remchi/ZF-Quani
 public function setBodyView($script, $params = array())
 {
     $layout = new Zend_Layout(array('layoutPath' => APPLICATION_PATH . '/views/layouts'));
     $layout->setLayout('email');
     $view = new Zend_View();
     $view->setScriptPath(APPLICATION_PATH . '/views/email');
     foreach ($params as $key => $value) {
         $view->assign($key, $value);
     }
     $layout->content = $view->render($script . '.phtml');
     $html = $layout->render();
     $this->setBodyHtml($html);
     return $this;
 }
예제 #13
0
파일: Mail.php 프로젝트: shevron/stoa
 /**
  * Set the e-mail's body from a template
  * 
  * @param  string $tempalte
  * @param  array  $params
  * @return Geves_Mail
  */
 public function fromTemplate($template, array $params)
 {
     $view = new Zend_View();
     $view->setScriptPath($this->_templateDir);
     $view->assign($params);
     if ($this->_layout) {
         $this->_layout->content = $view->render($template . '.phtml');
         $html = $this->_layout->render();
     } else {
         $html = $view->render($template . '.phtml');
     }
     $this->setBodyHtml($html);
     $this->setBodyText(strip_tags($html));
     return $this;
 }
예제 #14
0
 public function __invoke($message)
 {
     $layout = new Zend_Layout();
     // Установка пути к скриптам макета:
     $layout->setLayoutPath(APPLICATION_PATH . '/views/scripts/layouts');
     $layout->setLayout('inner');
     $view = new Zend_View();
     $view->setBasePath(APPLICATION_PATH . '/views/');
     $view->error_message = $message;
     // установка переменных:
     $layout->content = $view->render('/exeption/user.phtml');
     echo $layout->render();
     //echo $message;
     die;
 }
예제 #15
0
 public function postDispatch()
 {
     $layouts = array_reverse($this->_layouts);
     $mvcLayout = Zend_Layout::getMvcInstance();
     $mvcContentKey = $mvcLayout->getContentKey();
     $content = $this->getResponse()->getBody();
     $view = $this->_cloneView();
     $layout = new Zend_Layout(array('layoutPath' => $mvcLayout->getLayoutPath(), 'viewSuffix' => $mvcLayout->getViewSuffix()));
     $layout->setView($view);
     foreach ($layouts as $layoutName) {
         $layout->setLayout($layoutName);
         $layout->{$mvcContentKey} = $this->getResponse()->getBody();
         $this->getResponse()->setBody($layout->render());
     }
 }
예제 #16
0
 protected function renderMenu()
 {
     $container = new Zend_Navigation(VAR_menu);
     $this->view->assign('menu', $container);
     $this->view->assign('module', $this->_getParam('module'));
     Zend_Layout::getMvcInstance()->assign('navbar', $this->view->render('navbar.phtml'));
 }
예제 #17
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     Zend_Layout::getMvcInstance()->setLayout($request->getModuleName());
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/modules/" . $request->getModuleName() . "/layouts/scripts");
     $eh = Zend_Controller_Front::getInstance()->getPlugin("Zend_Controller_Plugin_ErrorHandler");
     $eh->setErrorHandlerModule($request->getModuleName());
 }
예제 #18
0
 /**
  * Retrieve layout object
  *
  * @return Zend_Layout
  */
 public function getLayout()
 {
     if (null === $this->_layout) {
         $this->_layout = Zend_Layout::startMvc($this->getOptions());
     }
     return $this->_layout;
 }
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if ($request->getParam('isAdmin')) {
         $layout = Zend_Layout::getMvcInstance();
         $layout->setLayout('admin');
     }
 }
예제 #20
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $auth = Zend_Auth::getInstance();
     $result = $auth->getStorage();
     $identity = $auth->getIdentity();
     $registry = Zend_Registry::getInstance();
     $config = Zend_Registry::get('config');
     $module = strtolower($this->_request->getModuleName());
     $controller = strtolower($this->_request->getControllerName());
     $action = strtolower($this->_request->getActionName());
     if ($identity && $identity != "") {
         $layout = Zend_Layout::getMvcInstance();
         $view = $layout->getView();
         $view->login = $identity;
         $siteInfoNamespace = new Zend_Session_Namespace('siteInfoNamespace');
         $id = $siteInfoNamespace->userId;
         $view->firstname = $siteInfoNamespace->Firstname;
         $username = $siteInfoNamespace->username;
         $password = $siteInfoNamespace->password;
         $db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => $config->resources->db->params->host, 'username' => $username, 'password' => $password, 'dbname' => $config->resources->db->params->dbname));
         Zend_Db_Table_Abstract::setDefaultAdapter($db);
         return;
     } else {
         $siteInfoNamespace = new Zend_Session_Namespace('siteInfoNamespace');
         $siteInfoNamespace->requestURL = $this->_request->getParams();
         $this->_request->setModuleName('default');
         $this->_request->setControllerName('Auth');
         $this->_request->setActionName('login');
     }
 }
예제 #21
0
 public function init()
 {
     $option = array("layout" => "layout", "layoutPath" => APPLICATION_PATH . "/layouts/scripts/");
     Zend_Layout::startMvc($option);
     $this->sessionGlobal = new Zend_Session_Namespace('username');
     $Sessioonlecturer_id = $this->sessionGlobal->lecturer_id;
 }
예제 #22
0
 public function postDispatch(Zend_Controller_Request_Abstract $request)
 {
     $layout = Zend_Layout::getMvcInstance();
     // the name "maintenanceMode" is also referred to in the Admin_MaintenanceController,
     // so if you change the filename, it needs to be changed there too
     $maintenanceModeFileName = 'maintenanceMode';
     $register = new Ot_Config_Register();
     $identity = Zend_Auth::getInstance()->getIdentity();
     $role = empty($identity->role) ? $register->defaultRole->getValue() : $identity->role;
     if (isset($identity->masquerading) && $identity->masquerading == true && isset($identity->realAccount) && !is_null($identity->realAccount) && isset($identity->realAccount->role)) {
         $role = $identity->realAccount->role;
     }
     $acl = Zend_Registry::get('acl');
     $view = $layout->getView();
     $viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer');
     if (is_file(APPLICATION_PATH . '/../overrides/' . $maintenanceModeFileName) && (!$request->isXmlHttpRequest() && !$viewRenderer->getNeverRender())) {
         if (!$acl->isAllowed($role, 'ot_maintenance', 'index')) {
             if (!($request->getModuleName() == 'ot' && $request->getControllerName() == 'login' && $request->getActionName() == 'index')) {
                 $response = $this->getResponse();
                 $layout->disableLayout();
                 $response->setBody($view->maintenanceMode()->publicLayout());
             }
         } else {
             $response = $this->getResponse();
             // there's no point in setting text here if it's a redirect
             if ($response->isRedirect()) {
                 $response->setBody('');
             } else {
                 $response->setBody($view->maintenanceMode()->header() . $response->getBody());
             }
         }
     }
 }
예제 #23
0
	function init()
	{
		@session_start();
		$this->setAccess();
		$_SESSION['home'] = 'home';
		$_SESSION['page'] = 'tintuc';
		$_SESSION['page'] = 'video';
		$this->view->headScript()->appendFile($this->view->baseUrl().'/application/templates/front/js/switch_news.js',"text/javascript");

		$layoutPath = APPLICATION_PATH  . '/templates/front';
		$option = array ('layout' => 'index', 
                   'layoutPath' => $layoutPath );
		Zend_Layout::startMvc ( $option );
		$this->mTimkiem=new Default_Model_Mtimkiem();
		$this->mDefault=new Default_Model_Mdf();
		$this->mTintuc=new Default_Model_Mtintuc();
		$this->mDiachi=new Default_Model_Mdiachi();
		$this->mVideo = new Default_Model_Mvideo();
		$this->mHinhanh = new Default_Model_Mhinhanh();
		$this->view->headScript()->appendFile($this->view->baseUrl().'/application/templates/front/js/switch_news.js',"text/javascript");
		
		$listThreadForum = $this->mDefault->getListThread();
				$this->listThreadTitle = array();
		//var_dump($listThreadForum);die();
		foreach($listThreadForum as $thread)
		{
			$content = file_get_contents('http://localhost/unc/forum/showthread.php?'.$thread['threadid']);
			$preg1 = preg_match_all('#<span class="threadtitle">.*</span>#',$content,$match);
			$this->listThreadTitle[] = $thread['threadid'].strip_tags($match[0][0]);
		}
	}
예제 #24
0
파일: Json.php 프로젝트: Cryde/sydney-core
 /**
  * Encode data as JSON, disable layouts, and set response header
  *
  * If $keepLayouts is true, does not disable layouts.
  * If $encodeJson is false, does not JSON-encode $data
  *
  * @param  mixed $data
  * @param  bool $keepLayouts
  * NOTE:   if boolean, establish $keepLayouts to true|false
  *         if array, admit params for Zend_Json::encode as enableJsonExprFinder=>true|false
  *         this array can contains a 'keepLayout'=>true|false and/or 'encodeData'=>true|false
  *         that will not be passed to Zend_Json::encode method but will be used here
  * @param  bool $encodeData
  * @return string|void
  */
 public function json($data, $keepLayouts = false, $encodeData = true)
 {
     $options = array();
     if (is_array($keepLayouts)) {
         $options = $keepLayouts;
         $keepLayouts = false;
         if (array_key_exists('keepLayouts', $options)) {
             $keepLayouts = $options['keepLayouts'];
             unset($options['keepLayouts']);
         }
         if (array_key_exists('encodeData', $options)) {
             $encodeData = $options['encodeData'];
             unset($options['encodeData']);
         }
     }
     if ($encodeData) {
         $data = Zend_Json::encode($data, null, $options);
     }
     if (!$keepLayouts) {
         require_once 'Zend/Layout.php';
         $layout = Zend_Layout::getMvcInstance();
         if ($layout instanceof Zend_Layout) {
             $layout->disableLayout();
         }
     }
     $response = Zend_Controller_Front::getInstance()->getResponse();
     $response->setHeader('Content-Type', 'application/json', true);
     return $data;
 }
예제 #25
0
 /**
  * get Zend_Layout instance
  * @param $name
  * 
  * @return Zend_Layout
  */
 public static function getLayout($name)
 {
     if (!is_null($name)) {
         self::$_layout->setLayout($name);
     }
     return self::$_layout;
 }
예제 #26
0
 function init()
 {
     $this->_redirector = $this->_helper->getHelper('Redirector');
     $this->_layout = $this->_helper->getHelper('Layout');
     $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger');
     //Get Controller,Action,Module Name
     $this->_moduleName = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
     $this->_controllerName = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
     $this->_actionName = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
     $this->_cleanUrl = $this->view->rootUrl() . '/' . $this->_moduleName . '/' . $this->_controllerName . '/' . $this->_actionName;
     //get user profile
     $this->setUserProfile();
     //Set layout
     $layout = Zend_Layout::getMvcInstance();
     $layout->setLayoutPath(APPLICATION_PATH . '/modules/admin/layouts');
     $layout->setLayout('admin');
     //set redirector helper
     $this->_redirector = $this->_helper->getHelper('Redirector');
     //set flash messenger
     $this->_flash = $this->_helper->FlashMessenger;
     //set Edit state
     if ($this->_actionName == 'edit') {
         $this->view->state_edit = TRUE;
     }
     //set paginator session
     $this->_paginator_sess = new Zend_Session_Namespace('paginator');
     $this->setPaginatorSession();
     //set default language (untuk sementara)
     Zend_Registry::set('language', 'en');
 }
예제 #27
0
파일: LayoutTest.php 프로젝트: lortnus/zf1
 public function testHelperMethodFetchesLayoutObject()
 {
     $layout = Zend_Layout::startMvc();
     $helper = new Zend_View_Helper_Layout();
     $received = $helper->layout();
     $this->assertSame($layout, $received);
 }
예제 #28
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $flash = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
     $mvc = Zend_Layout::getMvcInstance();
     $view = $mvc->getView();
     $view->flashMessages = $flash->getMessages();
 }
 public function initContext($format = null)
 {
     parent::initContext($format);
     // Hack to prevent duplicate content-type headers
     $pos = false;
     $response = $this->getResponse();
     $headers = $response->getHeaders();
     $response->clearHeaders();
     foreach ($headers as $header) {
         $name = $header['name'];
         $value = $header['value'];
         $replace = $header['replace'];
         if (strtolower($name) == 'content-type') {
             if ($pos === true) {
                 continue;
             }
             $pos = true;
         }
         $response->setHeader($name, $value, $replace);
     }
     if (null === $this->_currentContext || !$this->getAutoSwitchLayout()) {
         return;
     }
     $layoutName = $this->getLayout($this->_currentContext);
     if ($layoutName) {
         $layout = Zend_Layout::getMvcInstance();
         $layout->enableLayout()->setLayout($layoutName);
     }
 }
예제 #30
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if (!isset($_SERVER['HTTP_USER_AGENT']) || isset($_SERVER['HTTP_USER_AGENT']) && false === strpos($_SERVER['HTTP_USER_AGENT'], 'sanmax-crawler-bot')) {
         return;
     }
     $config = array('accept_schemes' => 'basic', 'realm' => 'crawler', 'digest_domains' => '/', 'nonce_timeout' => 3600);
     $adapter = new Zend_Auth_Adapter_Http($config);
     $basicResolver = new Zend_Auth_Adapter_Http_Resolver_File(APPLICATION_PATH . '/var/bot-basic');
     $adapter->setBasicResolver($basicResolver);
     $response = Zend_Controller_Front::getInstance()->getResponse();
     $adapter->setRequest($request);
     $adapter->setResponse($response);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($adapter);
     if (!$result->isValid()) {
         $response->sendHeaders();
         exit;
     }
     $user = new SxCms_User();
     $gMapper = new SxCms_Group_DataMapper();
     $groups = $gMapper->getAll();
     foreach ($groups as $group) {
         $user->addGroup($group);
     }
     $storage = $auth->getStorage();
     $storage->write($user);
     $front = Zend_Controller_Front::getInstance();
     $front->setParam('isBot', true);
     $mvc = Zend_Layout::getMvcInstance();
     $view = $mvc->getView();
     $view->isBot = true;
     return;
 }