00001 <?php
00002
00015
00016
00017 define('BLOCK_CONTEXT_LEFT_SIDEBAR', 0x00000001);
00018 define('BLOCK_CONTEXT_RIGHT_SIDEBAR', 0x00000002);
00019 define('BLOCK_CONTEXT_HOMEPAGE', 0x00000003);
00020
00021 class BlockPlugin extends Plugin {
00022 function BlockPlugin() {
00023 parent::Plugin();
00024 }
00025
00026 function register($category, $path) {
00027 $success = parent::register($category, $path);
00028 if ($success && $this->getEnabled()) {
00029 $contextMap =& $this->getContextMap();
00030 $blockContext = $this->getBlockContext();
00031 if (isset($contextMap[$blockContext])) {
00032 $hookName = $contextMap[$blockContext];
00033 HookRegistry::register($hookName, array(&$this, 'callback'));
00034 }
00035 }
00036 return $success;
00037 }
00038
00043 function getBlockContext() {
00044 $conference =& Request::getConference();
00045 $conferenceId = ($conference?$conference->getId():0);
00046 return $this->getSetting($conferenceId, 0, 'context');
00047 }
00048
00053 function setBlockContext($context) {
00054 $conference =& Request::getConference();
00055 $conferenceId = ($conference?$conference->getId():0);
00056 return $this->updateSetting($conferenceId, 0, 'context', $context, 'int');
00057 }
00058
00063 function getSupportedContexts() {
00064 fatalError('ABSTRACT METHOD');
00065 }
00066
00071 function getEnabled() {
00072 $conference =& Request::getConference();
00073 $conferenceId = ($conference?$conference->getId():0);
00074 return $this->getSetting($conferenceId, 0, 'enabled');
00075 }
00076
00081 function setEnabled($enabled) {
00082 $conference =& Request::getConference();
00083 $conferenceId = ($conference?$conference->getId():0);
00084 return $this->updateSetting($conferenceId, 0, 'enabled', $enabled, 'bool');
00085 }
00086
00092 function getSeq() {
00093 $conference =& Request::getConference();
00094 $conferenceId = ($conference?$conference->getId():0);
00095 return $this->getSetting($conferenceId, 0, 'seq');
00096 }
00097
00103 function setSeq($i) {
00104 $conference =& Request::getConference();
00105 $conferenceId = ($conference?$conference->getId():0);
00106 return $this->updateSetting($conferenceId, 0, 'seq', $i, 'int');
00107 }
00108
00113 function &getContextMap() {
00114 static $contextMap = array(
00115 BLOCK_CONTEXT_LEFT_SIDEBAR => 'Templates::Common::LeftSidebar',
00116 BLOCK_CONTEXT_RIGHT_SIDEBAR => 'Templates::Common::RightSidebar',
00117 BLOCK_CONTEXT_HOMEPAGE => 'Templates::Index::Conference'
00118 );
00119 HookRegistry::call('BlockPlugin::getContextMap', array(&$this, &$contextMap));
00120 return $contextMap;
00121 }
00122
00128 function getName() {
00129
00130 return 'BlockPlugin';
00131 }
00132
00137 function getDisplayName() {
00138
00139
00140 return 'Abstract Block Plugin';
00141 }
00142
00146 function getDescription() {
00147 return 'This is the BlockPlugin base class. Its functions can be overridden by subclasses to provide support for UI blocks.';
00148 }
00149
00157 function getBlockTemplateFilename() {
00158 return 'block.tpl';
00159 }
00160
00166 function getContents(&$templateMgr) {
00167 $blockTemplateFilename = $this->getBlockTemplateFilename();
00168 if ($blockTemplateFilename === null) return '';
00169 return $templateMgr->fetch($this->getTemplatePath() . $blockTemplateFilename);
00170 }
00171
00172 function callback($hookName, $args) {
00173 $params =& $args[0];
00174 $smarty =& $args[1];
00175 $output =& $args[2];
00176 $output .= $this->getContents($smarty);
00177 }
00178 }
00179
00180 ?>