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_Html
23 * @copyright (C) 2008 Vincent Tunru
24 * @author Vincent Tunru <email@vincentt.org>
28 * Manage the Html module
30 * @see /library/Pivip/Module/Abstract.php
32 class Html_Module
extends Pivip_Module_Abstract
35 * Checks whether this module is already installed
37 * In the case of the Html module, "installed" means that the database table
40 * @return boolean Whether Html is already installed.
42 public static function isInstalled()
44 if(!file_exists(CODE_PATH
. 'application/models/generated/BaseHtml.php'))
50 $htmlTable = Doctrine
::getTable('Html');
51 } catch(Exception
$e) {
58 * Communicate that Html does not need any configuration
60 * @return boolean False, since Html does not need to be configured.
62 public static function needsConfiguring()
68 * Creates the table in the database
70 * @throws Pivip_Install_Exception
71 * @return boolean Whether the installation succeeded
73 public function install()
78 * Remove the table from the database
80 * @throws Pivip_Install_Exception
81 * @return boolean Whether uninstallation succeeded
83 public function uninstall()
88 * Load the generic cache for use by this module
92 public static function loadCache()
94 $frontendOptions = array('cache_id_prefix' => 'html_');
95 $cacheConfig = Zend_Registry
::get('cacheConfig');
96 $cache = Zend_Cache
::factory('Core',
97 $cacheConfig->cache
->backend
,
99 $cacheConfig->backendOptions
->toArray());
104 * @return array A list of the blocks this module provides for normal pages,
106 * array('section' => array('Link to add this block'
109 public static function getPageBlocks($location)
111 if(!self
::isInstalled())
115 $translate = Zend_Registry
::get('Zend_Translate');
116 $route = Zend_Controller_Front
::getInstance()->getRouter()
117 ->getRoute('Html_AddHtml');
119 $sections = array('main');
120 foreach($sections as $section)
122 $blocks[$section] = array($route->assemble(array('section' => $section,
125 => $translate->_('Plain HTML block'));
133 public function bootstrap()
135 // Define the Access Control List
136 $acl = Zend_Registry
::get('acl');
137 $acl->add(new Zend_Acl_Resource('html'))
138 ->allow('admin', 'html', 'write');
139 Zend_Registry
::set('acl', $acl);
141 $router = Zend_Controller_Front
::getInstance()->getRouter();
142 $options = array('module' => 'html', 'controller' => 'index',
143 'action' => 'add', 'location' => '');
144 $route = new Zend_Controller_Router_Route('html/add/:section/:location',
146 $router->addRoute('Html_AddHtml', $route);
147 $options = array('module' => 'html', 'controller' => 'index',
149 $route = new Zend_Controller_Router_Route('html/edit/:html_id',
151 $router->addRoute('Html_EditHtml', $route);
152 $options = array('module' => 'html', 'controller' => 'index',
153 'action' => 'delete');
154 $route = new Zend_Controller_Router_Route('html/delete/:html_id',
156 $router->addRoute('Html_DeleteHtml', $route);