コード例 #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
ファイル: Logger.php プロジェクト: ThibautLeger/123-mini
 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
ファイル: Mailer.php プロジェクト: sgdoc/sgdoce-codigo
 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
ファイル: LayoutView.php プロジェクト: Webowiec/zendnote
 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
ファイル: NestedLayouts.php プロジェクト: rdallasgray/bbx
 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
ファイル: Layout.php プロジェクト: test3metizsoft/test
 /**
  * Retrieve layout object
  *
  * @return Zend_Layout
  */
 public function getLayout()
 {
     if (null === $this->_layout) {
         $this->_layout = Zend_Layout::startMvc($this->getOptions());
     }
     return $this->_layout;
 }
コード例 #19
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if ($request->getParam('isAdmin')) {
         $layout = Zend_Layout::getMvcInstance();
         $layout->setLayout('admin');
     }
 }
コード例 #20
0
ファイル: AuthPlugin.php プロジェクト: papoteur-mga/phpip
 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
ファイル: TimkiemController.php プロジェクト: hungnv0789/vhtm
	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
ファイル: Messenger.php プロジェクト: sonvq/2015_freelance6
 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();
 }
コード例 #29
0
 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
ファイル: HTTPCrawler.php プロジェクト: sonvq/2015_freelance6
 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;
 }