コード例 #1
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');
 }
コード例 #2
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;
 }
コード例 #3
0
 /**
  * Magic reuturn property - alias for __get in Zend_View
  * 
  * @param string $name
  * @return mixed|null 
  */
 public function __get($name)
 {
     if (isset($this->layout->getView()->{$name})) {
         return $this->layout->getView()->{$name};
     }
     return null;
 }
コード例 #4
0
ファイル: Widget.php プロジェクト: zendmaniacs/zly-templater
 /**
  * Switch viewRenderer responseSegment to
  * segment received from request
  */
 public function preDispatch()
 {
     /**
      * Custom action views placed in themes 
      */
     $viewRenderer = $this->getBroker()->load('viewRenderer');
     $module = $this->getRequest()->getModuleName();
     $options = $this->getOptions();
     $viewPath = realpath($this->_layout->getLayoutPath() . '/../' . $options['view']['directory'] . '/' . $module . '/scripts/');
     $existingPaths = array();
     foreach ($this->_layout->getView()->resolver()->getPaths() as $path) {
         $existingPaths[] = $path;
     }
     if ($viewPath && !in_array($viewPath, $existingPaths)) {
         $this->_layout->getView()->resolver()->addPath($viewPath);
     }
     /**
      * Set widget markers into the new form parameters
      */
     $widgetId = $this->getRequest()->getParam($this->_widgetIdName);
     if ($widgetId !== null) {
         $formHelper = $this->_layout->getView()->getBroker()->load('form');
         if ($formHelper instanceof \Zly\View\Helper\Form) {
             $formHelper->setMarker($this->_widgetPostMarker, $widgetId);
         }
     }
     /**
      * Check post parameters
      */
     $postFormMarker = $this->getRequest()->getParam($this->_widgetPostMarker);
     if ($this->getRequest()->isPost()) {
         if ($postFormMarker !== null && $widgetId === null) {
             //id not widget request and post marker found
             $_SERVER['REQUEST_METHOD'] = 'GET';
             $this->_POST = $_POST;
         } elseif ($widgetId !== $postFormMarker) {
             //if post marker NOT of current widget request
             $_SERVER['REQUEST_METHOD'] = 'GET';
             $this->_POST = $_POST;
         }
     }
     if ($postFormMarker !== null && $widgetId == $postFormMarker && !empty($this->_POST)) {
         $_SERVER['REQUEST_METHOD'] = 'POST';
         $_POST = $this->_POST;
         $this->_POST = null;
     }
     /**
      * Set view renderer segment of current widget
      */
     $slot = $this->getRequest()->getParam($this->_marker, null);
     $viewRenderer->setResponseSegment($slot);
 }
コード例 #5
0
ファイル: LayoutTest.php プロジェクト: hjr3/zf2
 /**
  * @return void
  */
 public function testViewAccessorsAllowSettingView()
 {
     $layout = new Zend_Layout();
     $view = new Zend_View();
     $layout->setView($view);
     $received = $layout->getView();
     $this->assertSame($view, $received);
 }