/**
  * Create the snippets content
  *
  * This is a stub function either override getHtmlOutput() or override render()
  *
  * @param \Zend_View_Abstract $view Just in case it is needed here
  * @return \MUtil_Html_HtmlInterface Something that can be rendered
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     $url = $view->url(array('action' => 'export'));
     $container = \MUtil_Html::div(array('id' => 'export-container'));
     $button = $container->button(array($this->_('Export'), 'id' => 'modelExport'));
     return $container;
 }
 /**
  * Does the hard work for preg_replace_callback() in self::filter()
  * 
  * @param string $matches
  * @return string
  */
 protected function _replace($matches)
 {
     if ($this->_view instanceof Zend_View_Abstract) {
         $href = $this->_view->escape($matches[0]);
     } else {
         $href = htmlspecialchars($matches[0]);
     }
     return '<a' . ' href="' . $href . '"' . (null !== $this->_class ? ' class="' . $this->_class . '"' : '') . ' target="_blank" rel="nofollow"' . '>' . $matches[0] . '</a>';
 }
Ejemplo n.º 3
0
 /**
  * Construct the record iterator.
  * 
  * @uses Omeka_View_Helper_Singularize::singularize()
  * @param array $records
  * @param null|Zend_View_Abstract $view
  * @param null|string $currentRecordVar
  */
 public function __construct(array $records, $view = null, $currentRecordVar = null)
 {
     // Normalize the current record variable for the view.
     if ($view instanceof Zend_View_Abstract) {
         $currentRecordVar = $view->singularize($currentRecordVar);
     }
     $this->_records = $records;
     $this->_currentRecordVar = $currentRecordVar;
     $this->_view = $view;
 }
Ejemplo n.º 4
0
 function _compile_compiler_tag($tagCommand, $tagArgs, &$output)
 {
     //We first try to use Smarty's own functionality to parse the tag
     $found = parent::_compile_compiler_tag($tagCommand, $tagArgs, $output);
     if ($found === false) {
         try {
             //Check if helper exists and create output
             $this->zendView->getHelper($tagCommand);
             $helperArgs = array();
             if ($tagArgs !== null) {
                 //Start parsing our custom syntax
                 $params = explode(' ', $tagArgs);
                 foreach ($params as $p) {
                     //Split each key=value pair to vars
                     list($key, $value) = explode('=', $p, 2);
                     $section = '';
                     //If there's a dot in the key, it means we
                     //need to use associative arrays
                     if (strpos('.', $key) != -1) {
                         list($key, $section) = explode('.', $key);
                     }
                     //Use Smarty's own functions to parse the value
                     //so that if there's a variable, it gets changed to
                     //properly point at a template variable etc.
                     $value = $this->_parse_var_props($value);
                     //Put the value into the arg array
                     if ($section == '') {
                         if (array_key_exists($key, $helperArgs)) {
                             if (is_array($helperArgs[$key])) {
                                 $helperArgs[$key][] = $value;
                             } else {
                                 $helperArgs[$key] = array($helperArgs[$key], $value);
                             }
                         } else {
                             $helperArgs[$key] = $value;
                         }
                     } else {
                         if (!is_array($helperArgs[$key])) {
                             $helperArgs[$key] = array();
                         }
                         $helperArgs[$key][$section] = $value;
                     }
                 }
             }
             //Save the code to put to the template in the output
             $output = "<?php echo \$this->callViewHelper('{$tagCommand}',array(" . $this->_createParameterCode($helperArgs) . ")); ?>";
             $found = true;
         } catch (Exception $e) {
             //Exception means the helper was not found
             $found = false;
             fwrite(fopen('php://stderr', 'a'), $e->getMessage());
         }
     }
     return $found;
 }
Ejemplo n.º 5
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     if (isset($config['phptal'])) {
         System_Options::setOptions($this->getEngine(), (array) $config['phptal']);
     }
 }
Ejemplo n.º 6
0
 /**
  * Finds a view script from the available directories.
  *
  * @param $name string The base name of the script.
  * @return void
  */
 protected function _script($name)
 {
     if (strpos($name, ".") === false) {
         $name .= ".phtml";
     }
     return parent::_script(strtolower($name));
 }
Ejemplo n.º 7
0
 /**
  * Constructor
  *
  * Pass it a an array with the following configuration options:
  *
  * scriptPath: the directory where your templates reside
  * compileDir: the directory where you want your compiled templates (must be
  * writable by the webserver)
  * configDir: the directory where your configuration files reside
  *
  * both scriptPath and compileDir are mandatory options, as Smarty needs
  * them. You can't set a cacheDir, if you want caching use Zend_Cache
  * instead, adding caching to the view explicitly would alter behaviour
  * from Zend_View.
  *
  * @see Zend_View::__construct
  * @param array $config
  * @throws Exception
  */
 public function __construct($config = array())
 {
     $this->_smarty = new Smarty();
     //smarty object
     //compile dir must be set
     if (!array_key_exists('compileDir', $config)) {
         throw new Exception('compileDir must be set in $config for ' . get_class($this));
     } else {
         $this->_smarty->compile_dir = $config['compileDir'];
     }
     //configuration files directory
     if (array_key_exists('configDir', $config)) {
         $this->_smarty->config_dir = $config['configDir'];
     }
     if (array_key_exists('leftDelimiter', $config)) {
         $this->_smarty->left_delimiter = $config['leftDelimiter'];
     }
     if (array_key_exists('rightDelimiter', $config)) {
         $this->_smarty->right_delimiter = $config['rightDelimiter'];
     }
     if (array_key_exists('templateDir', $config)) {
         $this->_smarty->template_dir = array($config['templateDir']);
     }
     if (array_key_exists('pluginDir', $config)) {
         $this->_smarty->plugins_dir = $config['pluginDir'];
     }
     //call parent constructor
     parent::__construct($config);
 }
Ejemplo n.º 8
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $dirs = Zend_Registry::get('dirs');
     $template = Zend_Registry::get('theme');
     $config = Zend_Registry::get('config');
     $qool_module = Zend_Registry::get('Qool_Module');
     // Class Constructor.
     // These automatically get set with each new instance.
     $loader = new Twig_Loader_Filesystem(APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP);
     $twig = new Twig_Environment($loader, array('cache' => APPL_PATH . $dirs['structure']['cache'] . DIR_SEP . 'twig' . DIR_SEP));
     $lexer = new Twig_Lexer($twig, array('tag_comment' => array('<#', '#>}'), 'tag_block' => array('<%', '%>'), 'tag_variable' => array('<<', '>>')));
     $twig->setLexer($lexer);
     include_once APPL_PATH . $dirs['structure']['lib'] . DIR_SEP . 'Qool' . DIR_SEP . 'Template' . DIR_SEP . 'template.php';
     if (file_exists(APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP . 'functions.php')) {
         include_once APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP . 'functions.php';
     }
     $funcs = get_defined_functions();
     foreach ($funcs['user'] as $k => $v) {
         $twig->addFunction($v, new Twig_Function_Function($v));
     }
     $this->_twig = $twig;
     $this->assign('config', $config);
     Zend_Registry::set('tplExt', 'html');
 }
Ejemplo n.º 9
0
 function __construct(Am_Di $di = null)
 {
     parent::__construct();
     if (null === $di) {
         $this->di = Am_Di::getInstance();
     } else {
         $this->di = $di;
     }
     if ($this->di->hasService('theme')) {
         $this->theme = $this->di->theme;
     } else {
         $this->theme = new Am_Theme($this->di, 'default', array());
     }
     $this->setHelperPath('Am/View/Helper', 'Am_View_Helper_');
     $this->setEncoding('UTF-8');
     foreach ($this->di->viewPath as $dir) {
         $this->addScriptPath($dir);
     }
     if (!$this->getScriptPaths()) {
         $this->addScriptPath(dirname(__FILE__) . '/../../application/default/views');
     }
     $this->headScript()->prependScript("window.rootUrl = " . Am_Controller::getJson(REL_ROOT_URL) . ";\n");
     $this->headScript()->prependScript("window.CKEDITOR_BASEPATH = " . Am_Controller::getJson(REL_ROOT_URL . '/application/default/views/public/js/ckeditor/') . ";\n");
     $this->headScript()->prependScript("window.amLangCount = " . Am_Controller::getJson(count(Am_Di::getInstance()->config->get('lang.enabled'))) . ";\n");
 }
Ejemplo n.º 10
0
 /**
  * Render a panel region
  * @param array $region
  * @param array $blocks
  * @return string
  */
 function renderRegion($region, $blocks = array())
 {
     if ($blocks || $this->is_admin_page) {
         $rendered_blocks = array();
         if ($blocks) {
             foreach ($blocks as $block) {
                 $block->options['region'] = $region;
                 if (!$this->is_admin_page) {
                     $rendered_blocks[$block->id] = $block->render();
                 } else {
                     $rendered_blocks[$block->id] = $this->renderAdminBlock($block);
                 }
             }
         }
         $this->view->assign('region', $region);
         $this->view->assign('blocks', $rendered_blocks);
         if ($this->is_admin_page) {
             $template = "region_admin";
         } else {
             $template = "region_" . (isset($region['template']) && $region['template'] != "" ? $region['template'] : "standard");
         }
         return $this->view->render($template);
     }
     return "";
 }
Ejemplo n.º 11
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $dirs = Zend_Registry::get('dirs');
     $template = Zend_Registry::get('theme');
     $qool_module = Zend_Registry::get('Qool_Module');
     //set Qool directories
     $templates = APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP;
     $templates_c = APPL_PATH . $dirs['structure']['cache'] . DIR_SEP . 'smarty' . DIR_SEP . 'templates_c' . DIR_SEP;
     $configs = APPL_PATH . 'config' . DIR_SEP . 'smarty' . DIR_SEP;
     $cache = APPL_PATH . $dirs['structure']['cache'] . DIR_SEP . 'smarty' . DIR_SEP . 'cache' . DIR_SEP;
     // Class Constructor.
     // These automatically get set with each new instance.
     $this->_smarty = new Smarty();
     $this->_smarty->setTemplateDir($templates);
     $this->_smarty->setCompileDir($templates_c);
     $this->_smarty->setConfigDir($configs);
     $this->_smarty->setCacheDir($cache);
     $this->_smarty->caching = Smarty::CACHING_LIFETIME_CURRENT;
     $this->_smarty->caching = false;
     //get the template file and register all functions in it to smarty
     include_once APPL_PATH . $dirs['structure']['lib'] . DIR_SEP . 'Qool' . DIR_SEP . 'Template' . DIR_SEP . 'template.php';
     if (file_exists(APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP . 'functions.php')) {
         include_once APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP . 'functions.php';
     }
     // $this_smarty->register_function('date_now', 'print_current_date');
     Zend_Registry::set('tplExt', 'tpl');
 }
Ejemplo n.º 12
0
 public function __toString()
 {
     if (null === ($verb = $this->getParam('verb'))) {
         $this->_view->errors = array('badArgument' => 'Required verb is missing');
         return $this->_view->render('index/error.phtml');
     } else {
         try {
             try {
                 $this->checkParams($verb);
             } catch (OaiPmh_Exception $e) {
                 $this->_view->errors = array($e->getCodeAsString() => $e->getMessage());
                 return $this->_view->render('index/error.phtml');
             }
             try {
                 return $this->{$verb}();
             } catch (Exception $e) {
                 $this->_view->errors = array($e->getCodeAsString() => $e->getMessage());
                 return $this->_view->render('index/error.phtml');
             }
         } catch (OaiPmh_Exception $e) {
             $this->_view->errors = array($e->getCodeAsString() => $e->getMessage());
             return $this->_view->render('index/error.phtml');
         } catch (Exception $e) {
             $this->_view->errors = array('badArgument' => $e->getMessage());
             return $this->_view->render;
         }
     }
 }
Ejemplo n.º 13
0
 public function __construct($config = array())
 {
     if (APPLICATION_ENV == "testing") {
         $this->_testing = true;
         $this->_streamUrl = 'php://memory';
     }
     parent::__construct($config);
 }
Ejemplo n.º 14
0
 /**
  * Constructor
  *
  * Register Zend_View_Stream stream wrapper if short tags are disabled.
  *
  * @param  array $config
  * @return void
  */
 public function __construct($config = array())
 {
     if (array_key_exists('mail', $config)) {
         $this->setMail($config['mail']);
     }
     parent::__construct($config);
     $this->addHelperPath('App/Mail/View/Helper', 'App_Mail_View_Helper');
 }
Ejemplo n.º 15
0
 /**
  * Constructor
  * @access public
  */
 public function __construct($options = array(), $engine = null)
 {
     parent::__construct($options);
     if ($engine === null) {
         $engine = new PHPTAL();
     }
     $this->_engine = $engine;
     $this->_engine->set('this', $this);
 }
Ejemplo n.º 16
0
 /**
  * Send comment notification
  *
  * @param Newscoop\Entity\Comment $comment
  * @param Article $article
  * @param array $authors
  * @param Newscoop\Entity\User $user
  * @return void
  */
 public function sendCommentNotification(Comment $comment, \Article $article, array $authors, User $user = null)
 {
     $emails = array_unique(array_filter(array_map(function ($author) {
         return $author->getEmail();
     }, $authors)));
     if (empty($emails)) {
         return;
     }
     $this->view->placeholder(self::PLACEHOLDER_SUBJECT)->set('New Comment');
     $message = $this->view->action('comment-notify', 'email', 'default', array('comment' => $comment, 'article' => $article, 'user' => $user));
     $mail = new \Zend_Mail(self::CHARSET);
     $mail->setSubject($this->view->placeholder(self::PLACEHOLDER_SUBJECT));
     $mail->setBodyHtml($message);
     $mail->setFrom($user ? $user->getEmail() : $this->config['from']);
     foreach ($emails as $email) {
         $mail->addTo($email);
     }
     $mail->send();
 }
Ejemplo n.º 17
0
 /**
  * Class Constructor
  *
  * @param array [OPTIONAL] $data
  * @return ZendSmarty
  */
 public function __construct($webConfig)
 {
     parent::__construct(array());
     $configSmarty = $webConfig->smarty;
     $templateDir = $configSmarty->templateDirectory;
     $compileDir = $configSmarty->compileDirectory;
     $configDir = $configSmarty->configDirectory;
     $cacheDir = $configSmarty->cacheDirectory;
     $this->smarty = new ProjectSmarty($templateDir, $compileDir, $configDir, $cacheDir, false);
 }
Ejemplo n.º 18
0
    public function cultureWidget($limit, $show_thumbnails = false, $side_space = true)
    {
        $languageId = Zend_Registry::get('languageId');
        $cache = Zend_Registry::get('cache');
        if (($widget = $cache->load('widget_kebudayaan')) === false) {
            $title = $this->view->translate('popular_culture');
            $tbl_culture = new Model_DbTable_Destination();
            $cultures = $tbl_culture->getFeaturedCulture($languageId, $limit);
            $list = "<ul>";
            $thumbnails = '';
            foreach ($cultures as $culture) {
                $urlFormat = $this->view->makeUrlFormat($culture['name']);
                $link = $this->view->baseUrl("culture/{$culture['poi_id']}/{$urlFormat}");
                if ($show_thumbnails) {
                    $source = 'default.jpg';
                    $width = 50;
                    $height = 50;
                    $quality = 100;
                    $culture_image = 'upload/culture/' . $culture['image'];
                    if (!file_exists(IMAGE_FOLDER . $culture_image) || empty($culture['image'])) {
                        $culture_image = $source;
                    }
                    $timthumb = $this->view->imageUrl("timthumb.php?src={$culture_image}&w={$width}&h={$height}&q={$quality}");
                    $thumbnails = "<img class='thumbnail' src='{$timthumb}' alt='{$culture['name']}' />";
                }
                $list .= "<li>{$thumbnails}<a href='{$link}'><span class='desc'>{$culture['name']}</span></a></li>";
            }
            $list .= "</ul>";
            $list .= "<div class='clear'></div>";
            if ($side_space) {
                $side_space_class = 'side-space';
            }
            $widget = <<<HTML
    <div class="widget-half-list {$side_space_class}">         
        <h2>{$title}</h2>        
        {$list}        
      </div>
HTML;
            $cache->save($widget);
        }
        return $widget;
    }
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     $post = $this->request->getPost();
     $export = $this->loader->getExport();
     $exportTypes = $export->getExportClasses();
     if (isset($post['type'])) {
         $currentType = $post['type'];
     } else {
         reset($exportTypes);
         $currentType = key($exportTypes);
     }
     if (\MUtil_Bootstrap::enabled()) {
         $form = new \Gems_Form(array('id' => 'exportOptionsForm', 'class' => 'form-horizontal'));
     } else {
         $form = new \Gems_Form_TableForm();
     }
     $url = $view->url() . '/step/batch';
     $form->setAction($url);
     $elements = array();
     $elements['type'] = $form->createElement('select', 'type', array('label' => $this->_('Export to'), 'multiOptions' => $exportTypes, 'class' => 'autosubmit'));
     $form->addElements($elements);
     $exportClass = $export->getExport($currentType);
     $exportName = $exportClass->getName();
     $exportFormElements['firstCheck'] = $form->createElement('hidden', $currentType);
     $exportFormElements = $exportClass->getFormElements($form, $data);
     if ($exportFormElements) {
         $form->addElements($exportFormElements);
     }
     if (!isset($post[$currentType])) {
         $post[$exportName] = $exportClass->getDefaultFormValues();
     }
     $element = $form->createElement('submit', 'export_submit', array('label' => $this->_('Export')));
     $form->addElement($element);
     if ($post) {
         $form->populate($post);
     }
     $container = \MUtil_Html::div(array('id' => 'export-form'));
     $container->append($form);
     $form->setAttrib('id', 'autosubmit');
     $form->setAutoSubmit(\MUtil_Html::attrib('href', array('action' => $this->request->getActionName(), 'RouteReset' => true)), 'export-form', true);
     return $container;
 }
Ejemplo n.º 20
0
    public function eventWidget($limit, $show_thumbnails = false, $side_space = true)
    {
        $languageId = Zend_Registry::get('languageId');
        $cache = Zend_Registry::get('cache');
        if (($widget = $cache->load('widget_event')) === false) {
            $title = $this->view->translate('recent_events');
            $tbl_event = new Model_DbTable_Event();
            $events = $tbl_event->getEventLatestByIdLang($languageId, null, $limit);
            $list = "<ul>";
            $thumbnails = '';
            foreach ($events as $event) {
                $urlFormat = $this->view->makeUrlFormat($event['name']);
                $link = $this->view->baseUrl("event/detail/{$event['event_id']}/{$urlFormat}");
                if ($show_thumbnails) {
                    $source = 'default.jpg';
                    $image_dir = UPLOAD_FOLDER . 'event/';
                    $width = 50;
                    $height = 50;
                    $quality = 100;
                    if (file_exists($image_dir . $event['main_pics']) && !empty($event['main_pics'])) {
                        $source = "upload/event/{$event['main_pics']}";
                    }
                    $thumb = $this->view->imageUrl("timthumb.php?src={$source}&w={$width}&h={$height}&q={$quality}");
                    $thumbnails = "<img class='thumbnail' src='{$thumb}' alt='{$event['name']}' />";
                }
                $list .= "<li>{$thumbnails}<a href='{$link}'><span class='desc'>{$event['name']}</span></a></li>";
            }
            $list .= "</ul>";
            $list .= "<div class='clear'></div>";
            if ($side_space) {
                $side_space_class = 'side-space';
            }
            $widget = <<<HTML
        <div class="widget-half-list {$side_space_class}">         
          <h2>{$title}</h2>            
          {$list}      
        </div>
HTML;
            $cache->save($widget);
        }
        return $widget;
    }
Ejemplo n.º 21
0
 private function _generUrl($pageNo = null)
 {
     if ($pageNo && !$this->router) {
         $requestParams = $this->zendRequest->getParams();
         $requestParams[$this->pageNoKey] = $pageNo;
         return $this->zendView->url($requestParams, "default", true);
     } else {
         $requestParams = array();
         $requestParams[$this->pageNoKey] = $pageNo;
         return $this->zendView->url($requestParams, $this->router, true);
     }
 }
Ejemplo n.º 22
0
 /**
  * Constructor
  *
  * Register Zend_View_Stream stream wrapper if short tags are disabled.
  *
  * @param  array $config
  * @return void
  */
 public function __construct($config = array())
 {
     $this->_useViewStream = (bool) ini_get('short_open_tag') ? false : true;
     if ($this->_useViewStream) {
         if (!in_array('zend.view', stream_get_wrappers())) {
             stream_wrapper_register('zend.view', 'Zend_View_Stream');
         }
     }
     if (array_key_exists('useStreamWrapper', $config)) {
         $this->setUseStreamWrapper($config['useStreamWrapper']);
     }
     parent::__construct($config);
 }
 /**
  * Create the snippets content
  *
  * This is a stub function either override getHtmlOutput() or override render()
  *
  * @param \Zend_View_Abstract $view Just in case it is needed here
  * @return \MUtil_Html_HtmlInterface Something that can be rendered
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     $tabs = $this->getTabs();
     $tabCount = count($tabs);
     if ($tabs && ($this->displaySingleTab || $tabCount > 1)) {
         // Is there a better helper to include JS?
         $view->headScript()->appendFile($this->basepath->getBasePath() . '/gems/js/jquery.horizontalScrollMenu.js');
         $script = '(function($) {$(".' . $this->class . '").horizontalScrollMenu();}(jQuery));';
         $view->inlineScript()->appendScript($script);
         // Set the correct parameters
         $this->getCurrentTab();
         $scrollContainer = \MUtil_Html::create()->div();
         if ($tabCount > $this->scrollFromSize) {
             $scrollContainer->a('#', $this->prevLabel, array('class' => 'prev'));
         } else {
             $scrollContainer->span(array('class' => 'prev disabled'))->raw(str_repeat('&nbsp', strlen($this->prevLabel)));
         }
         $tabRow = $scrollContainer->div(array('class' => 'container'))->ul();
         foreach ($tabs as $tabId => $content) {
             $li = $tabRow->li(array('class' => $this->tabClass));
             if (strlen($content) > $this->tabLabelLength) {
                 $content = substr($content, 0, $this->tabLabelLength) . $this->tabLabelCutOffString;
             }
             $li->a($this->getParameterKeysFor($tabId) + $this->href, $content);
             if ($tabId == $this->currentTab) {
                 $li->appendAttrib('class', $this->tabActiveClass);
             }
         }
         if ($tabCount > $this->scrollFromSize) {
             $scrollContainer->a('#', $this->nextLabel, array('class' => 'next'));
         } else {
             $scrollContainer->span(array('class' => 'next disabled'))->raw(str_repeat('&nbsp', strlen($this->nextLabel)));
         }
         return $scrollContainer;
     } else {
         return null;
     }
 }
Ejemplo n.º 24
0
 public function __construct($options = array())
 {
     if (!isset($options["zf"])) {
         $options["zf"] = array();
     }
     if (!isset($options["twig"])) {
         $options["twig"] = array();
     }
     parent::__construct($options["zf"]);
     $this->_twig = new Twig_Environment(null, array_merge($this->_twigOptions, $options["twig"]));
     if (isset($options["twig"]["extensions"])) {
         $exts = (array) $options["twig"]["extensions"];
         $this->setExtensions($exts);
     }
 }
Ejemplo n.º 25
0
 /**
  * Constructor
  *
  * Register Zend_View_Stream stream wrapper if short tags are disabled.
  *
  * @param  array $config
  * @return void
  */
 public function __construct($config = array())
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/config.ini', 'default');
     $config = $config->resources->view->toArray();
     $this->_useViewStream = (bool) ini_get('short_open_tag') ? false : true;
     if ($this->_useViewStream) {
         if (!in_array('zend.view', stream_get_wrappers())) {
             require_once 'Zend/View/Stream.php';
             stream_wrapper_register('zend.view', 'Zend_View_Stream');
         }
     }
     if (array_key_exists('useStreamWrapper', $config)) {
         $this->setUseStreamWrapper($config['useStreamWrapper']);
     }
     parent::__construct($config);
 }
Ejemplo n.º 26
0
 /**
  * Constructor
  *
  * Pass it a an array with the following configuration options:
  *
  * scriptPath: the directory where your templates reside
  * compileDir: the directory where you want your compiled templates
  * (must be
  * writable by the webserver)
  * configDir: the directory where your configuration files reside
  *
  * both scriptPath and compileDir are mandatory options, as Smarty
  * needs
  * them. You can't set a cacheDir, if you want caching use
  * Zend_Cache
  * instead, adding caching to the view explicitly would alter
  * behaviour
  * from Zend_View.
  *
  * @see Zend_View::__construct
  * @param array $config
  * @throws Exception
  */
 public function __construct($config = array())
 {
     $this->_smarty = new Smarty();
     //smarty object
     if (!array_key_exists('compileDir', $config)) {
         throw new Exception('compileDir must be set in $config for ' . get_class($this));
     } else {
         $this->_smarty->compile_dir = $config['compileDir'];
     }
     //compile dir must be set
     if (array_key_exists('configDir', $config)) {
         $this->_smarty->config_dir = $config['configDir'];
     }
     //configuration files directory
     parent::__construct($config);
     //call parent constructor
 }
Ejemplo n.º 27
0
 /**
  * Render a hook's content
  *
  * @param string $name template to use
  * @param string $module module to fetch template from
  * @param string $controller controller to fetch template from, defaults to 'hooks'
  *
  * @return string Rendered content
  *
  */
 public function render($name, $module, $controller = "hooks")
 {
     $layout = Zend_Layout::getMvcInstance();
     // Reset view script paths
     $this->view->setScriptPath(null);
     // Build new ones for hooks
     $this->view->addBasePath(ZfApplication::$_base_path . "/app/{$module}/views", $module . "_View");
     //$this->view->addScriptPath(ZfApplication::$_base_path."/app/$module/Views/");
     $this->view->addScriptPath($layout->getLayoutPath() . "default/templates/{$module}");
     $this->view->addScriptPath($layout->getLayoutPath() . $layout->getLayout() . "/templates/{$module}");
     return $this->view->render($controller . "/" . $name);
 }
Ejemplo n.º 28
0
 /**
  * Wraper for parent's render method so preRender method
  * can be called (that will bind the plugin proxy to the
  * engine.
  *
  * @see Zend_View_Abstract::render
  * @return string The script output.
  */
 public function render($name)
 {
     $this->preRender();
     return parent::render($name);
 }
Ejemplo n.º 29
0
 /**
  * Processes a view script and returns the output.
  * Hack for Zend_Layout => force the view suffix
  * depending on template engine
  *
  * @param string $name The script name to process.
  * @return string The script output.
  */
 public function render($name)
 {
     // hack for Zend_Layout which has its own view suffix handling
     $filename = $name;
     $suffix = $this->getTemplateEngine()->getViewSuffix();
     $fileParts = pathinfo($name);
     $filename = str_replace('.' . $fileParts['extension'], '.' . $suffix, $name);
     return parent::render($filename);
 }
Ejemplo n.º 30
0
 public function __call($method, $args)
 {
     if (method_exists($this, $method)) {
         return call_user_func_array($callback, $args);
     }
     $callback = array(&$this->_smarty, $method);
     if (is_callable($callback)) {
         return call_user_func_array($callback, $args);
     } else {
         return parent::__call($method, $args);
     }
 }