Annotation of /mambo/branches/4.6/includes/cmtclasses.php
Parent Directory
|
Revision Log
Revision 458 - (view) (download)
| 1 : | counterpoi | 126 | t <?php |
| 2 : | counterpoi | 417 | t /** |
| 3 : | t * Component handler class | ||
| 4 : | t * @package Mambo | ||
| 5 : | t */ | ||
| 6 : | counterpoi | 126 | t class mosComponentHandler { |
| 7 : | t var $_buffer = ''; | ||
| 8 : | t | ||
| 9 : | t function &getInstance () { | ||
| 10 : | t static $instance; | ||
| 11 : | t if (!is_object($instance)) $instance = new mosComponentHandler(); | ||
| 12 : | t return $instance; | ||
| 13 : | t } | ||
| 14 : | t | ||
| 15 : | t function &getParamsByName ($name) { | ||
| 16 : | t $params = null; | ||
| 17 : | counterpoi | 392 | t $row = new mosComponent(); |
| 18 : | counterpoi | 126 | t $query = "SELECT a.params, a.option" |
| 19 : | t . "\n FROM #__components AS a" | ||
| 20 : | t . "\n WHERE a.name = '$name'" | ||
| 21 : | t ; | ||
| 22 : | counterpoi | 238 | t $database =& mamboDatabase::getInstance(); |
| 23 : | counterpoi | 126 | t $database->setQuery( $query ); |
| 24 : | t // load the row from the db table | ||
| 25 : | t if ($database->loadObject($row)) { | ||
| 26 : | t // get params definitions | ||
| 27 : | counterpoi | 238 | t $mainframe =& mosMainFrame::getInstance(); |
| 28 : | csouza | 138 | $params =& new mosParameters( $row->params); |
| 29 : | counterpoi | 126 | t } |
| 30 : | t return $params; | ||
| 31 : | t } | ||
| 32 : | t | ||
| 33 : | t function mosMainBody() { | ||
| 34 : | t // message passed via the url | ||
| 35 : | t $mosmsg = mosGetParam($_REQUEST, 'mosmsg', ''); | ||
| 36 : | t if ($mosmsg) { | ||
| 37 : | t if (!get_magic_quotes_gpc()) $mosmsg = addslashes( $mosmsg ); | ||
| 38 : | t echo "\n<div class=\"message\">$mosmsg</div>"; | ||
| 39 : | t } | ||
| 40 : | t echo $this->_buffer; | ||
| 41 : | t // Alternative if "popmessages" - apparently never implemented | ||
| 42 : | t // echo "\n<script language=\"javascript\">alert('$mosmsg');</script>"; | ||
| 43 : | t } | ||
| 44 : | t | ||
| 45 : | t function startBuffer () { | ||
| 46 : | t $this->_buffer = ''; | ||
| 47 : | t ob_start(); | ||
| 48 : | t } | ||
| 49 : | t | ||
| 50 : | t function endBuffer () { | ||
| 51 : | t $this->_buffer = ob_get_contents(); | ||
| 52 : | t ob_end_clean(); | ||
| 53 : | t } | ||
| 54 : | t | ||
| 55 : | t } | ||
| 56 : | t /** | ||
| 57 : | t * Component database table class | ||
| 58 : | t * @package Mambo | ||
| 59 : | t */ | ||
| 60 : | t class mosComponent extends mosDBTable { | ||
| 61 : | t /** @var int Primary key */ | ||
| 62 : | t var $id=null; | ||
| 63 : | t /** @var string */ | ||
| 64 : | t var $name=null; | ||
| 65 : | t /** @var string */ | ||
| 66 : | t var $link=null; | ||
| 67 : | t /** @var int */ | ||
| 68 : | t var $menuid=null; | ||
| 69 : | t /** @var int */ | ||
| 70 : | t var $parent=null; | ||
| 71 : | t /** @var string */ | ||
| 72 : | t var $admin_menu_link=null; | ||
| 73 : | t /** @var string */ | ||
| 74 : | t var $admin_menu_alt=null; | ||
| 75 : | t /** @var string */ | ||
| 76 : | t var $option=null; | ||
| 77 : | t /** @var string */ | ||
| 78 : | t var $ordering=null; | ||
| 79 : | t /** @var string */ | ||
| 80 : | t var $admin_menu_img=null; | ||
| 81 : | t /** @var int */ | ||
| 82 : | t var $iscore=null; | ||
| 83 : | t /** @var string */ | ||
| 84 : | t var $params=null; | ||
| 85 : | t | ||
| 86 : | t /** | ||
| 87 : | t * @param database A database connector object | ||
| 88 : | t */ | ||
| 89 : | counterpoi | 392 | t function mosComponent() { |
| 90 : | t $db = mamboDatabase::getInstance(); | ||
| 91 : | counterpoi | 126 | t $this->mosDBTable( '#__components', 'id', $db ); |
| 92 : | t } | ||
| 93 : | t } | ||
| 94 : | counterpoi | 417 | t /** |
| 95 : | t * Component common base class for both user and admin sides | ||
| 96 : | t * @package Mambo | ||
| 97 : | t */ | ||
| 98 : | t class mosComponentManager { | ||
| 99 : | t var $plugin_name = ''; | ||
| 100 : | counterpoi | 392 | t var $magic_quotes_value = 0; |
| 101 : | counterpoi | 458 | t var $plugin_version = ''; |
| 102 : | t var $option = ''; | ||
| 103 : | t | ||
| 104 : | t function mosComponentManager ($component_name, $version) { | ||
| 105 : | t $this->text_name = $component_name; | ||
| 106 : | t $this->plugin_name = strtolower(str_replace(' ', '', $component_name)); | ||
| 107 : | t $this->plugin_version = $version; | ||
| 108 : | t $this->option = mamboCore::get('option'); | ||
| 109 : | t $this->noMagicQuotes(); | ||
| 110 : | t $cname = 'com_'.$this->plugin_name; | ||
| 111 : | t $mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); | ||
| 112 : | t if(file_exists($mosConfig_absolute_path."/components/$cname/language/".mamboCore::get('mosConfig_lang').'.php')) require_once($mosConfig_absolute_path."/components/$cname/language/".mamboCore::get('mosConfig_lang').'.php'); | ||
| 113 : | t else if (file_exists($mosConfig_absolute_path."/components/$cname/language/english.php")) require_once($mosConfig_absolute_path."/components/$cname/language/english.php"); | ||
| 114 : | counterpoi | 126 | t |
| 115 : | counterpoi | 458 | t } |
| 116 : | t | ||
| 117 : | counterpoi | 417 | t function noMagicQuotes () { |
| 118 : | counterpoi | 392 | t // Is magic quotes on? |
| 119 : | t if (get_magic_quotes_gpc()) { | ||
| 120 : | counterpoi | 417 | t // Yes? Strip the added slashes |
| 121 : | t $_REQUEST =& $this->remove_magic_quotes($_REQUEST); | ||
| 122 : | t $_GET =& $this->remove_magic_quotes($_GET); | ||
| 123 : | t $_POST =& $this->remove_magic_quotes($_POST); | ||
| 124 : | counterpoi | 392 | t } |
| 125 : | counterpoi | 417 | t $this->magic_quotes_value = set_magic_quotes_runtime(0); |
| 126 : | t } | ||
| 127 : | t | ||
| 128 : | t function &remove_magic_quotes ($array) { | ||
| 129 : | t foreach ($array as $k => $v) { | ||
| 130 : | t if (is_array($v)) $array[$k] = $this->remove_magic_quotes($v); | ||
| 131 : | t else $array[$k] = stripslashes($v); | ||
| 132 : | t } | ||
| 133 : | t return $array; | ||
| 134 : | t } | ||
| 135 : | t | ||
| 136 : | t function restore_magic_quotes () { | ||
| 137 : | t set_magic_quotes_runtime($this->magic_quotes_value); | ||
| 138 : | t } | ||
| 139 : | t | ||
| 140 : | t function checkCallable (&$object, $method) { | ||
| 141 : | t if (is_callable(array(&$object, $method))) return true; | ||
| 142 : | t $name = get_class($object); | ||
| 143 : | t trigger_error (sprintf(T_('Component %s error: attempt to use non-existent class %s in %s'), $this->plugin_name, $method, $name)); | ||
| 144 : | t return false; | ||
| 145 : | t } | ||
| 146 : | t | ||
| 147 : | t } | ||
| 148 : | t /** | ||
| 149 : | t * Component base logic for user side | ||
| 150 : | t * @package Mambo | ||
| 151 : | t */ | ||
| 152 : | t class mosComponentUserManager extends mosComponentManager { | ||
| 153 : | t | ||
| 154 : | counterpoi | 458 | t function mosComponentUserManager ($component_name, $control_name, $alternatives, $default, $title, $version) { |
| 155 : | t mosComponentManager::mosComponentManager($component_name, $version); | ||
| 156 : | counterpoi | 392 | t $mainframe =& mosMainFrame::getInstance(); |
| 157 : | t $mainframe->SetPageTitle($title); | ||
| 158 : | t $func = mosGetParam ($_REQUEST, $control_name, $default); | ||
| 159 : | t if (isset($alternatives[$func])) $method = $alternatives[$func]; | ||
| 160 : | t else $method = $func; | ||
| 161 : | counterpoi | 446 | t $classname = $this->plugin_name.'_'.$method.'_Controller'; |
| 162 : | counterpoi | 392 | t if (class_exists($classname)) { |
| 163 : | t $controller =& new $classname($this); | ||
| 164 : | t if (is_callable(array(&$controller,$method))) $controller->$method($func); | ||
| 165 : | counterpoi | 446 | t else trigger_error (sprintf(T_('Component %s error: attempt to use non-existent method %s in %s'), $this->plugin_name, $method, $controller)); |
| 166 : | counterpoi | 392 | t } |
| 167 : | counterpoi | 446 | t else trigger_error(sprintf(T_('Component %s error: attempt to use non-existent class %s'), $this->plugin_name, $classname)); |
| 168 : | counterpoi | 392 | t $this->restore_magic_quotes(); |
| 169 : | t } | ||
| 170 : | t | ||
| 171 : | counterpoi | 417 | t function newHTMLClassCheck ($name, &$controller, $total_items, $clist) { |
| 172 : | t if (class_exists($name)) return new $name ($controller, $this->limit, $clist); | ||
| 173 : | counterpoi | 446 | t trigger_error(sprintf(T_('Component %s error: attempt to use non-existent class %s'), $this->plugin_name, $name)); |
| 174 : | counterpoi | 417 | t return false; |
| 175 : | t } | ||
| 176 : | t | ||
| 177 : | t } | ||
| 178 : | t /** | ||
| 179 : | t * Component base logic for admin side | ||
| 180 : | t * @package Mambo | ||
| 181 : | t */ | ||
| 182 : | t class mosComponentAdminManager extends mosComponentManager { | ||
| 183 : | t var $act = ''; | ||
| 184 : | t var $task = ''; | ||
| 185 : | t var $limitstart = 0; | ||
| 186 : | t var $limit = 0; | ||
| 187 : | t var $cfid = 0; | ||
| 188 : | t var $order = 0; | ||
| 189 : | t var $currid = 0; | ||
| 190 : | t | ||
| 191 : | counterpoi | 458 | t function mosComponentAdminManager ($component_name, $version) { |
| 192 : | t mosComponentManager::mosComponentManager($component_name, $version); | ||
| 193 : | t $this->act = mosGetParam ($_REQUEST, 'act', $this->plugin_name); | ||
| 194 : | t $this->task = mosGetParam($_REQUEST, 'task', 'list'); | ||
| 195 : | counterpoi | 417 | t $mainframe = mosMainFrame::getInstance(); |
| 196 : | t $default_limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', 20 ); | ||
| 197 : | t $this->limit = intval( mosGetParam( $_REQUEST, 'limit', $default_limit ) ); | ||
| 198 : | t $this->limitstart = mosGetParam($_REQUEST, 'limitstart', 0 ); | ||
| 199 : | t $this->cfid = mosGetParam($_REQUEST, 'cfid', array(0)); | ||
| 200 : | t if (is_array($this->cfid)) foreach ($this->cfid as $i=>$id) $this->cfid[$i] = intval($id); | ||
| 201 : | t $this->order= mosGetParam($_REQUEST, 'order', array()); | ||
| 202 : | t if (is_array( $this->cfid )) $this->currid=intval($this->cfid[0]); | ||
| 203 : | t else $this->currid=intval($this->cfid); | ||
| 204 : | t $name = $this->getAction(); | ||
| 205 : | t if (class_exists($name)) { | ||
| 206 : | t $controller =& new $name($this); | ||
| 207 : | t $task = $this->task.'Task'; | ||
| 208 : | t if (is_callable(array(&$controller, 'getRequestData'))) $controller->getRequestData(); | ||
| 209 : | t if (is_callable(array(&$controller,$task))) $controller->$task(); | ||
| 210 : | t else trigger_error(sprintf(T_('MOS error in %s: method %s not found in class %s'), $this->plugin_name, $task, $name)); | ||
| 211 : | counterpoi | 392 | t } |
| 212 : | counterpoi | 417 | t else trigger_error(sprintf(T_('MOS error in %s: class not found %s'), $this->plugin_name, $name)); |
| 213 : | t $this->restore_magic_quotes(); | ||
| 214 : | counterpoi | 392 | t } |
| 215 : | t | ||
| 216 : | counterpoi | 417 | t function check_selection ($text) { |
| 217 : | t if (!is_array($this->cfid) OR count( $this->cfid ) < 1) { | ||
| 218 : | t echo "<script> alert('".$text."'); window.history.go(-1);</script>\n"; | ||
| 219 : | t exit; | ||
| 220 : | t } | ||
| 221 : | counterpoi | 392 | t } |
| 222 : | t | ||
| 223 : | counterpoi | 417 | t function getAction () { |
| 224 : | t $actname = strtoupper(substr($this->act,0,1)).strtolower(substr($this->act,1)); | ||
| 225 : | t return strtolower($this->plugin_name).'Admin'.$actname; | ||
| 226 : | t } | ||
| 227 : | t | ||
| 228 : | counterpoi | 392 | t function newHTMLClassCheck ($name, &$controller, $total_items, $clist) { |
| 229 : | counterpoi | 417 | t $controller->makePageNav($this, $total_items); |
| 230 : | counterpoi | 392 | t if (class_exists($name)) return new $name ($controller, $this->limit, $clist); |
| 231 : | counterpoi | 417 | t trigger_error(sprintf(T_('Component %s error: attempt to use non-existent class %s'), $this->plugin_name, $name)); |
| 232 : | counterpoi | 392 | t return false; |
| 233 : | t } | ||
| 234 : | t | ||
| 235 : | counterpoi | 417 | t } |
| 236 : | t /** | ||
| 237 : | t * Component base class for admin side component controller logic | ||
| 238 : | t * @package Mambo | ||
| 239 : | t */ | ||
| 240 : | t class mosComponentAdminControllers { | ||
| 241 : | t var $admin = ''; | ||
| 242 : | t var $user = ''; | ||
| 243 : | t var $pageNav = ''; | ||
| 244 : | counterpoi | 458 | t var $rootPath = ''; |
| 245 : | t var $language = ''; | ||
| 246 : | counterpoi | 417 | t |
| 247 : | t function mosComponentAdminControllers ($admin) { | ||
| 248 : | t $this->admin = $admin; | ||
| 249 : | t $this->user = mamboCore::get('currentUser'); | ||
| 250 : | counterpoi | 458 | t $this->rootPath = mamboCore::get('mosConfig_absolute_path'); |
| 251 : | t $this->language = mamboCore::get('mosConfig_lang'); | ||
| 252 : | counterpoi | 392 | t } |
| 253 : | t | ||
| 254 : | counterpoi | 417 | t function makePageNav (&$admin, $total) { |
| 255 : | t require_once(mamboCore::get('mosConfig_absolute_path').'/administrator/includes/pageNavigation.php'); | ||
| 256 : | t $this->pageNav =& new mosPageNav( $total, $admin->limitstart, $admin->limit ); | ||
| 257 : | t } | ||
| 258 : | t | ||
| 259 : | counterpoi | 392 | t } |
| 260 : | t | ||
| 261 : | counterpoi | 126 | t /** |
| 262 : | t * Template Table Class | ||
| 263 : | t * | ||
| 264 : | t * Provides access to the mos_templates table | ||
| 265 : | t * @package Mambo | ||
| 266 : | t */ | ||
| 267 : | t class mosTemplate extends mosDBTable { | ||
| 268 : | t /** @var int */ | ||
| 269 : | t var $id=null; | ||
| 270 : | t /** @var string */ | ||
| 271 : | t var $cur_template=null; | ||
| 272 : | t /** @var int */ | ||
| 273 : | t var $col_main=null; | ||
| 274 : | t | ||
| 275 : | t /** | ||
| 276 : | t * @param database A database connector object | ||
| 277 : | t */ | ||
| 278 : | t function mosTemplate( &$database ) { | ||
| 279 : | t $this->mosDBTable( '#__templates', 'id', $database ); | ||
| 280 : | t } | ||
| 281 : | t } | ||
| 282 : | t | ||
| 283 : | t /** | ||
| 284 : | t * Class mosMambot | ||
| 285 : | t * @package Mambo | ||
| 286 : | t */ | ||
| 287 : | t class mosMambot extends mosDBTable { | ||
| 288 : | t /** @var int */ | ||
| 289 : | t var $id=null; | ||
| 290 : | t /** @var varchar */ | ||
| 291 : | t var $name=null; | ||
| 292 : | t /** @var varchar */ | ||
| 293 : | t var $element=null; | ||
| 294 : | t /** @var varchar */ | ||
| 295 : | t var $folder=null; | ||
| 296 : | t /** @var tinyint unsigned */ | ||
| 297 : | t var $access=null; | ||
| 298 : | t /** @var int */ | ||
| 299 : | t var $ordering=null; | ||
| 300 : | t /** @var tinyint */ | ||
| 301 : | t var $published=null; | ||
| 302 : | t /** @var tinyint */ | ||
| 303 : | t var $iscore=null; | ||
| 304 : | t /** @var tinyint */ | ||
| 305 : | t var $client_id=null; | ||
| 306 : | t /** @var int unsigned */ | ||
| 307 : | t var $checked_out=null; | ||
| 308 : | t /** @var datetime */ | ||
| 309 : | t var $checked_out_time=null; | ||
| 310 : | t /** @var text */ | ||
| 311 : | t var $params=null; | ||
| 312 : | t | ||
| 313 : | t function mosMambot( &$db ) { | ||
| 314 : | t $this->mosDBTable( '#__mambots', 'id', $db ); | ||
| 315 : | t } | ||
| 316 : | t } | ||
| 317 : | t | ||
| 318 : | t class mosModuleHandler { | ||
| 319 : | t var $_db = null; | ||
| 320 : | t var $_modules = null; | ||
| 321 : | counterpoi | 458 | t var $_unpublished = null; |
| 322 : | t var $_isAdmin = null; | ||
| 323 : | counterpoi | 126 | t |
| 324 : | t function mosModuleHandler () { | ||
| 325 : | counterpoi | 238 | t $this->_db =& mamboDatabase::getInstance(); |
| 326 : | counterpoi | 126 | t } |
| 327 : | t | ||
| 328 : | t function &getInstance () { | ||
| 329 : | t static $instance; | ||
| 330 : | t if (!is_object($instance)) $instance = new mosModuleHandler(); | ||
| 331 : | t return $instance; | ||
| 332 : | t } | ||
| 333 : | t | ||
| 334 : | t /** | ||
| 335 : | t * Cache some modules information | ||
| 336 : | t * @return array | ||
| 337 : | t */ | ||
| 338 : | t function initModules($isAdmin=false) { | ||
| 339 : | counterpoi | 458 | t if (!isset($this->_modules) OR $isAdmin != $this->_isAdmin) { |
| 340 : | t $this->_isAdmin = $isAdmin; | ||
| 341 : | counterpoi | 126 | t if ($isAdmin) { |
| 342 : | counterpoi | 458 | t $query = "SELECT id, title, module, position, content, showtitle, params, published" |
| 343 : | counterpoi | 126 | t . "\n FROM #__modules AS m" |
| 344 : | t . "\n WHERE m.published = '1'" | ||
| 345 : | t . "\n AND (m.client_id = 1)" | ||
| 346 : | t . "\n ORDER BY m.ordering"; | ||
| 347 : | t } | ||
| 348 : | t else { | ||
| 349 : | t $my = mamboCore::get('currentUser'); | ||
| 350 : | t $Itemid = mamboCore::get('Itemid'); | ||
| 351 : | counterpoi | 458 | t $query = "SELECT id, title, module, position, content, showtitle, params, published" |
| 352 : | counterpoi | 126 | t ."\nFROM #__modules AS m, #__modules_menu AS mm" |
| 353 : | counterpoi | 458 | t . "\nWHERE m.access <= '$my->gid' AND m.client_id='0'" |
| 354 : | counterpoi | 126 | t . "\nAND mm.moduleid=m.id" |
| 355 : | t . "\nAND (mm.menuid = '$Itemid' OR mm.menuid = '0')" | ||
| 356 : | t . "\nORDER BY ordering"; | ||
| 357 : | t } | ||
| 358 : | t $this->_db->setQuery( $query ); | ||
| 359 : | t $modules = $this->_db->loadObjectList(); | ||
| 360 : | t foreach ($modules as $module) { | ||
| 361 : | counterpoi | 458 | t if ($module->published == 1) $this->_modules[$module->position][] = $module; |
| 362 : | t else $this->_unpublished[] = $module; | ||
| 363 : | counterpoi | 126 | t } |
| 364 : | t } | ||
| 365 : | t } | ||
| 366 : | t /** | ||
| 367 : | t * @param string THe template position | ||
| 368 : | t */ | ||
| 369 : | t function mosCountModules( $position='left', $isAdmin=false ) { | ||
| 370 : | t $this->initModules($isAdmin); | ||
| 371 : | t return isset($this->_modules[$position]) ? count($this->_modules[$position]) : 0; | ||
| 372 : | t } | ||
| 373 : | t | ||
| 374 : | t /** | ||
| 375 : | counterpoi | 392 | t * @param string Name of module required |
| 376 : | t */ | ||
| 377 : | counterpoi | 458 | t function &getByName( $name, $isAdmin=false, $unpublished=false ) { |
| 378 : | counterpoi | 392 | t $this->initModules($isAdmin); |
| 379 : | counterpoi | 417 | t $modules = array(); |
| 380 : | counterpoi | 392 | t foreach ($this->_modules as $position) { |
| 381 : | counterpoi | 417 | t foreach ($position as $module) if ($module->module == $name) $modules[] = $module; |
| 382 : | counterpoi | 392 | t } |
| 383 : | counterpoi | 458 | t if ($unpublished AND $this->_unpublished) foreach ($this->_unpublished as $module) if ($module->module == $name) $modules[] = $module; |
| 384 : | counterpoi | 417 | t return $modules; |
| 385 : | counterpoi | 392 | t } |
| 386 : | t | ||
| 387 : | t /** | ||
| 388 : | counterpoi | 126 | t * @param string The position |
| 389 : | t * @param int The style. 0=normal, 1=horiz, -1=no wrapper | ||
| 390 : | t */ | ||
| 391 : | t function mosLoadModules( $position='left', $style=0, $isAdmin=false ) { | ||
| 392 : | t $Itemid = mamboCore::get('Itemid'); | ||
| 393 : | t $tp = mosGetParam( $_GET, 'tp', 0 ); | ||
| 394 : | t if ($tp) { | ||
| 395 : | t echo '<div style="height:50px;background-color:#eee;margin:2px;padding:10px;border:1px solid #f00;color:#700;">'; | ||
| 396 : | t echo $position; | ||
| 397 : | t echo '</div>'; | ||
| 398 : | t return; | ||
| 399 : | t } | ||
| 400 : | t $style = intval($style); | ||
| 401 : | t $cache =& mosCache::getCache('com_content'); | ||
| 402 : | t require_once( mamboCore::get('mosConfig_absolute_path').'/includes/frontend.html.php'); | ||
| 403 : | t $this->initModules($isAdmin); | ||
| 404 : | t if (isset($this->_modules[$position] )) $modules = $this->_modules[$position]; | ||
| 405 : | t else { | ||
| 406 : | t $modules = array(); | ||
| 407 : | t $style = 0; | ||
| 408 : | t } | ||
| 409 : | t if ($style == 1) { | ||
| 410 : | t echo "<table cellspacing=\"1\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n"; | ||
| 411 : | t echo "<tr>\n"; | ||
| 412 : | t } | ||
| 413 : | t $prepend = ($style == 1) ? "<td valign=\"top\">\n" : ''; | ||
| 414 : | t $postpend = ($style == 1) ? "</td>\n" : ''; | ||
| 415 : | t $count = 1; | ||
| 416 : | t foreach ($modules as $module) { | ||
| 417 : | t $params =& new mosParameters($module->params); | ||
| 418 : | t echo $prepend; | ||
| 419 : | t if ((substr("$module->module",0,4))=="mod_") $modfunc = 'module2'; | ||
| 420 : | t else $modfunc = 'module'; | ||
| 421 : | t if ($params->get('cache') == 1 AND mamboCore::get('mosConfig_caching') == 1) { | ||
| 422 : | t $cache->call("modules_html::$modfunc", $module, $params, $Itemid, $style ); | ||
| 423 : | t } | ||
| 424 : | t else modules_html::$modfunc($module, $params, $Itemid, $style, $count); | ||
| 425 : | t echo $postpend; | ||
| 426 : | t $count++; | ||
| 427 : | t } | ||
| 428 : | t if ($style == 1) echo "</tr>\n</table>\n"; | ||
| 429 : | t } | ||
| 430 : | t | ||
| 431 : | t /** | ||
| 432 : | t * Loads admin modules via module position | ||
| 433 : | t * @param string The position | ||
| 434 : | t * @param int 0 = no style, 1 = tabbed | ||
| 435 : | t */ | ||
| 436 : | t function mosLoadAdminModules( $position='left', $style=0 ) { | ||
| 437 : | t global $my, $acl; | ||
| 438 : | t $this->initModules(true); | ||
| 439 : | t $cache =& mosCache::getCache( 'com_content' ); | ||
| 440 : | t if (isset($this->_modules[$position] )) $modules = $this->_modules[$position]; | ||
| 441 : | t else $modules = array(); | ||
| 442 : | t | ||
| 443 : | t switch ($style) { | ||
| 444 : | t case 0: | ||
| 445 : | t default: | ||
| 446 : | t foreach ($modules as $module) { | ||
| 447 : | t $params =& new mosParameters( $module->params ); | ||
| 448 : | t if ( $module->module == '' ) mosLoadCustomModule( $module, $params ); | ||
| 449 : | t else mosLoadAdminModule( substr( $module->module, 4 ), $params ); | ||
| 450 : | t } | ||
| 451 : | t break; | ||
| 452 : | t case 1: | ||
| 453 : | t // Tabs | ||
| 454 : | t $tabs = new mosTabs(1); | ||
| 455 : | t $tabs->startPane( 'modules-' . $position ); | ||
| 456 : | t foreach ($modules as $module) { | ||
| 457 : | t $params =& new mosParameters( $module->params ); | ||
| 458 : | t $editAllComponents = $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' ); | ||
| 459 : | t // $authoriser = new mosAuthoriser($database); | ||
| 460 : | t // $editAllComponents = $authoriser->checkPermission('mosUser', $my->id, 'edit', 'editAllComponents', 0); | ||
| 461 : | t // special handling for components module | ||
| 462 : | t if ( $module->module != 'mod_components' || ( $module->module == 'mod_components' && $editAllComponents ) ) { | ||
| 463 : | csouza | 266 | $tabs->startTab( T_($module->title), 'module' . $module->id ); |
| 464 : | counterpoi | 126 | t if ( $module->module == '' ) mosLoadCustomModule( $module, $params ); |
| 465 : | t else mosLoadAdminModule( substr( $module->module, 4 ), $params ); | ||
| 466 : | t $tabs->endTab(); | ||
| 467 : | t } | ||
| 468 : | t } | ||
| 469 : | t $tabs->endPane(); | ||
| 470 : | t break; | ||
| 471 : | t case 2: | ||
| 472 : | t // Div'd | ||
| 473 : | t foreach ($modules as $module) { | ||
| 474 : | t $params =& new mosParameters( $module->params ); | ||
| 475 : | t echo '<div>'; | ||
| 476 : | t if ( $module->module == '' ) mosLoadCustomModule( $module, $params ); | ||
| 477 : | t else mosLoadAdminModule( substr( $module->module, 4 ), $params ); | ||
| 478 : | t echo '</div>'; | ||
| 479 : | t } | ||
| 480 : | t break; | ||
| 481 : | t } | ||
| 482 : | t } | ||
| 483 : | t | ||
| 484 : | t | ||
| 485 : | t } | ||
| 486 : | t | ||
| 487 : | t /** | ||
| 488 : | t * Module database table class | ||
| 489 : | t * @package Mambo | ||
| 490 : | t */ | ||
| 491 : | t class mosModule extends mosDBTable { | ||
| 492 : | t /** @var int Primary key */ | ||
| 493 : | t var $id=null; | ||
| 494 : | t /** @var string */ | ||
| 495 : | t var $title=null; | ||
| 496 : | t /** @var string */ | ||
| 497 : | t var $showtitle=null; | ||
| 498 : | t /** @var int */ | ||
| 499 : | t var $content=null; | ||
| 500 : | t /** @var int */ | ||
| 501 : | t var $ordering=null; | ||
| 502 : | t /** @var string */ | ||
| 503 : | t var $position=null; | ||
| 504 : | t /** @var boolean */ | ||
| 505 : | t var $checked_out=null; | ||
| 506 : | t /** @var time */ | ||
| 507 : | t var $checked_out_time=null; | ||
| 508 : | t /** @var boolean */ | ||
| 509 : | t var $published=null; | ||
| 510 : | t /** @var string */ | ||
| 511 : | t var $module=null; | ||
| 512 : | t /** @var int */ | ||
| 513 : | t var $numnews=null; | ||
| 514 : | t /** @var int */ | ||
| 515 : | t var $access=null; | ||
| 516 : | t /** @var string */ | ||
| 517 : | t var $params=null; | ||
| 518 : | t /** @var string */ | ||
| 519 : | t var $iscore=null; | ||
| 520 : | t /** @var string */ | ||
| 521 : | t var $client_id=null; | ||
| 522 : | t | ||
| 523 : | t /** | ||
| 524 : | t * @param database A database connector object | ||
| 525 : | t */ | ||
| 526 : | t function mosModule( &$db ) { | ||
| 527 : | t $this->mosDBTable( '#__modules', 'id', $db ); | ||
| 528 : | t } | ||
| 529 : | t // overloaded check function | ||
| 530 : | t function check() { | ||
| 531 : | t // check for valid name | ||
| 532 : | t if (trim( $this->title ) == '') { | ||
| 533 : | csouza | 149 | $this->_error = T_('Your Module must contain a title.'); |
| 534 : | counterpoi | 126 | t return false; |
| 535 : | t } | ||
| 536 : | t | ||
| 537 : | t // limitation has been removed | ||
| 538 : | t // check for existing title | ||
| 539 : | t //$this->_db->setQuery( "SELECT id FROM #__modules" | ||
| 540 : | t //. "\nWHERE title='$this->title'" | ||
| 541 : | t //); | ||
| 542 : | t // check for module of same name | ||
| 543 : | t //$xid = intval( $this->_db->loadResult() ); | ||
| 544 : | t //if ($xid && $xid != intval( $this->id )) { | ||
| 545 : | t // $this->_error = "There is a module already with that name, please try again."; | ||
| 546 : | t // return false; | ||
| 547 : | t //} | ||
| 548 : | t return true; | ||
| 549 : | t } | ||
| 550 : | t } | ||
| 551 : | t | ||
| 552 : | t ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

