5 * Copyright (C) 2008 Vincent Tunru
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 * @license http://www.fsf.org/licensing/licenses/info/GPLv2.html GPL v.2
21 * @category PivipModulesDefault
22 * @package Module_Page
23 * @subpackage Controllers
24 * @copyright (C) 2008 Vincent Tunru
25 * @author Vincent Tunru <email@vincentt.org>
29 * Load a page's blocks
31 class IndexController
extends Pivip_Controller_Module_Abstract
34 * Disable rendering of the view for the Page module
36 public function init()
38 $this->_helper
->viewRenderer
->setNoRender();
42 * Load the blocks common to all pages
44 * Note: setting the 'bundle' request parameter will load a certain bundle,
45 * default bundle is 'default'.
47 public function commonAction()
49 $bundle = $this->_request
->getParam('bundle');
54 $query = new Doctrine_Query();
55 $query->from('Blocks b')
56 ->where('b.location=?', $bundle);
57 $rows = $query->execute();
58 foreach($rows as $row)
60 $nextRequest = new Zend_Controller_Request_Simple($row->action
,
63 $this->_helper
->actionStack($nextRequest);
68 * Adds stylesheets and loads the blocks of a certain page
70 * @throws Page_Exception
72 public function indexAction()
74 $pageConfig = new Zend_Config_Ini('./modules/page/config.ini');
77 $directories = new DirectoryIterator('public/styles');
78 } catch(Exception
$e) {
79 // Fail silently, no stylesheets found
81 foreach($directories as $directory)
83 if(!$directory->isDir() ||
$directory->isDot())
87 $files = new DirectoryIterator($directory->getPathname());
88 foreach($files as $file)
90 if($file->isDir() ||
$file->isDot())
94 if($pageConfig->styles
->default == $directory->getFilename())
96 $stylesheet = array('href' => $file->getPathname(),
98 'title' => $directory->getFilename(),
99 'rel' => 'stylesheet',
100 'media' => str_replace('.css', '',
101 $file->getFilename())
104 $stylesheet = array('href' => $file->getPathname(),
105 'type' => 'text/css',
106 'title' => $directory->getFilename(),
107 'rel' => 'alternate stylesheet');
109 $stylesheet['href'] = $this->_request
->getBaseUrl() . '/' .
111 $this->view
->headLink($stylesheet);
114 $this->commonAction();