Example #1
1
 /**
  *
  */
 public function checkSkinStyles($name, $values)
 {
     $config = Zend_Registry::get('config');
     $basePath = $config->design->pathToSkins;
     $xhtml = array();
     $this->view->name = $name;
     $this->view->selectedStyles = $values;
     //load the skin folders
     if (is_dir('./' . $basePath)) {
         $folders = Digitalus_Filesystem_Dir::getDirectories('./' . $basePath);
         if (count($folders) > 0) {
             foreach ($folders as $folder) {
                 $this->view->skin = $folder;
                 $styles = Digitalus_Filesystem_File::getFilesByType('./' . $basePath . '/' . $folder . '/styles', 'css');
                 if (is_array($styles)) {
                     foreach ($styles as $style) {
                         //add each style sheet to the hash
                         // key = path / value = filename
                         $hashStyles[$style] = $style;
                     }
                     $this->view->styles = $hashStyles;
                     $xhtml[] = $this->view->render($this->partialFile);
                     unset($hashStyles);
                 }
             }
         }
     } else {
         throw new Zend_Acl_Exception('Unable to locate skin folder');
     }
     return implode(null, $xhtml);
 }
 public function indexAction()
 {
     // STAGE 3: Choose, create, and optionally update models using business logic.
     $cities = parse_ini_file('cities.ini');
     // $cities contains our simple data model
     // STAGE 4: Apply business logic to create a presentation model for the view.
     ksort($_SERVER);
     $this->_view->SERVER = $_SERVER;
     $this->_view->date = date('Y-m-d H:i:s');
     $this->_view->cities = array();
     $this->_view->distances = array();
     if (isset($_REQUEST['distance'])) {
         $maxDistance = intval($_REQUEST['distance']);
     } else {
         $this->_redirect('/?distance=10000');
     }
     $this->_view->maxDistance = $maxDistance;
     foreach ($cities as $city => $distance) {
         // business logic specifies to filter the data model satisfying distance criteria
         if ($distance < $maxDistance) {
             $this->_view->cities[] = $city;
             $this->_view->distances[] = $distance;
             #echo "Distance from London, UK to $city is $distance km.<br>\n";
         }
     }
     // STAGE 5: Choose view and submit presentation model to view.
     $this->_response->appendBody($this->_view->render('indexIndex.phtml'));
 }
Example #3
0
 /**
  * @return string
  */
 public function menu()
 {
     $model = new Site_Model_Menu();
     $items = $model->fetchAll(null, 'orderid');
     $activeItem = $model->fetchRow(array('"' . addcslashes($this->view->url(), "'") . '" LIKE CONCAT("%",url,"%")'), 'LENGTH(url) desc');
     $this->view->items = $items;
     if ($activeItem) {
         $this->view->activeId = $activeItem->id;
     }
     return $this->view->render('menu.phtml');
 }
Example #4
0
 private function renderTemplate($templateName)
 {
     if (!strpos($templateName, '.phtml')) {
         $templateName .= '.phtml';
     }
     return $this->view->render($templateName);
 }
Example #5
0
 /**
  * Render a view script (optionally to a named response segment)
  *
  * Sets the noRender flag to true when called.
  *
  * @param  string $script
  * @param  string $name
  * @return void
  */
 public function renderScript($script, $name = null)
 {
     if (null === $name) {
         $name = $this->getResponseSegment();
     }
     $this->getResponse()->appendBody($this->view->render($script), $name);
     $this->setNoRender();
 }
    /**
     * Render a view script (optionally to a named response segment)
     *
     * Sets the noRender flag to true when called.
     *
     * @param  string $script
     * @param  string $name
     * @return void
     */
    public function renderScript($script, $name = null)
    {
        if (null === $name) {
            $name = $this->getResponseSegment();
        }

require_once 'Zend/Log.php';
require_once 'Zend/Log/Writer/Stream.php';
$log = new Zend_Log(new Zend_Log_Writer_Stream('/tmp/zf.log'));
$log->info(sprintf('Preparing to render script "%s"', $script));

        $this->getResponse()->appendBody(
            $this->view->render($script),
            $name
        );

        $this->setNoRender();
    }
Example #7
0
 private function renderBody($script)
 {
     return $this->_view->render($script);
 }
Example #8
0
 /**
  * Renders the module content with the module template.
  *
  * @return string
  */
 public function render($template, $vars = array(), $spec = null)
 {
     $template = $template . $this->_templateSuffix;
     if (null === $spec) {
         $this->view->assign($vars);
     } else {
         $this->view->assign($spec, $vars);
     }
     return $this->view->render($template);
 }