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_Imagestream
23 * @copyright (C) 2008 Vincent Tunru
24 * @author Vincent Tunru <email@vincentt.org>
28 * Manage the Imagestream module
30 * @see /library/Pivip/Module/Abstract.php
32 class Imagestream_Module
extends Pivip_Module_Abstract
35 * Check whether the Imagestream table exists
37 * @return boolean Whether the Imagestream module is installed
39 public static function isInstalled()
41 if(!file_exists(CODE_PATH
42 . 'application/models/generated/BaseImagestream.php'))
48 $imagestreamTable = Doctrine
::getTable('Imagestream');
49 } catch(Exception
$e) {
56 * @return boolean False
58 public static function needsConfiguring()
64 * Install the Imagestream module
66 public function install()
68 $nextRequest = new Zend_Controller_Request_Simple('index',
71 $this->_pushStack($nextRequest);
75 * Load the generic cache for use by this module
79 public static function loadCache()
81 $frontendOptions = array('cache_id_prefix' => 'imagestream_',
82 'automatic_serialization' => true);
83 $cacheConfig = Zend_Registry
::get('cacheConfig');
84 $cache = Zend_Cache
::factory('Core',
85 $cacheConfig->cache
->backend
,
87 $cacheConfig->backendOptions
->toArray());
92 * @return array A list of the blocks this module provides for normal pages,
94 * array('section' => array('Link to add this block'
97 public static function getPageBlocks($location)
99 if(!self
::isInstalled())
103 $translate = Zend_Registry
::get('Zend_Translate');
104 $route = Zend_Controller_Front
::getInstance()->getRouter()
105 ->getRoute('Imagestream_AddStream');
107 $sections = array('main');
108 foreach($sections as $section)
110 $blocks[$section] = array($route->assemble(array('section' => $section,
113 => $translate->_('Image stream'));
121 public function bootstrap()
123 // Define the Access Control List
124 $acl = Zend_Registry
::get('acl');
125 $acl->add(new Zend_Acl_Resource('imagestream'))
126 ->allow('admin', 'imagestream', 'write');
127 Zend_Registry
::set('acl', $acl);
129 $router = Zend_Controller_Front
::getInstance()->getRouter();
130 $options = array('module' => 'imagestream', 'controller' => 'stream',
131 'action' => 'add', 'location' => '');
132 $route = new Zend_Controller_Router_Route(
133 'imagestream/add/:section/:location', $options);
134 $router->addRoute('Imagestream_AddStream', $route);
135 $options = array('module' => 'imagestream', 'controller' => 'stream',
137 $route = new Zend_Controller_Router_Route('imagestream/edit/:stream_id',
139 $router->addRoute('Imagestream_EditStream', $route);
140 $options = array('module' => 'imagestream', 'controller' => 'stream',
141 'action' => 'delete');
142 $route = new Zend_Controller_Router_Route('imagestream/delete/:stream_id',
144 $router->addRoute('Imagestream_DeleteStream', $route);