| 93 |
/** @var int */ |
/** @var int */ |
| 94 |
var $access=null; |
var $access=null; |
| 95 |
/** @var string */ |
/** @var string */ |
| 96 |
var $params=null; |
var $params=''; |
| 97 |
|
|
| 98 |
/** |
/** |
| 99 |
* @param database A database connector object |
* @param database A database connector object |
| 249 |
} |
} |
| 250 |
|
|
| 251 |
class contentHandler { |
class contentHandler { |
| 252 |
|
var $_section_limit = 250; |
| 253 |
|
var $_section_status = 0; |
| 254 |
|
var $_sections; |
| 255 |
|
|
| 256 |
|
function &getInstance () { |
| 257 |
|
static $instance; |
| 258 |
|
if (!is_object($instance)) $instance = new contentHandler(); |
| 259 |
|
return $instance; |
| 260 |
|
} |
| 261 |
/** |
/** |
| 262 |
* @return number of Published Blog Sections |
* @return number of Published Blog Sections |
| 263 |
*/ |
*/ |
| 324 |
return $menuhandler->getMenuCount ('content_item_link', 1); |
return $menuhandler->getMenuCount ('content_item_link', 1); |
| 325 |
} |
} |
| 326 |
|
|
| 327 |
|
function getItemid ($id, $typed=1, $link=1, $bs=1, $bc=1, $gbs=1) { |
| 328 |
|
$_Itemid = null; |
| 329 |
|
$menuhandler = mosMenuHandler::getInstance(); |
| 330 |
|
if ($typed) { |
| 331 |
|
// Search for typed link |
| 332 |
|
$_Itemid = $menuhandler->getIDByTypeLink('content_typed', "index.php?option=com_content&task=view&id=$id"); |
| 333 |
|
} |
| 334 |
|
|
| 335 |
|
if ($_Itemid == null AND $link) { |
| 336 |
|
// Search for item link |
| 337 |
|
$_Itemid = $menuhandler->getIDByTypeLink('content_item_link', "index.php?option=com_content&task=view&id=$id"); |
| 338 |
|
} |
| 339 |
|
$sectionid = $this->getSection($id); |
| 340 |
|
if ($_Itemid == null) { |
| 341 |
|
// Search in sections |
| 342 |
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_section', $sectionid); |
| 343 |
|
} |
| 344 |
|
if ($_Itemid == null) { |
| 345 |
|
// Search in sections |
| 346 |
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_blog_section', $sectionid); |
| 347 |
|
} |
| 348 |
|
if ($_Itemid == null) { |
| 349 |
|
// Search in sections |
| 350 |
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_blog_category', $sectionid); |
| 351 |
|
} |
| 352 |
|
if ($_Itemid == null AND $gbs) { |
| 353 |
|
// Search in global blog section |
| 354 |
|
$_Itemid = $menuhandler->getIDByTypeCid('content_blog_section', 0); |
| 355 |
|
} |
| 356 |
|
/* |
| 357 |
|
if ($_Itemid == '') { |
| 358 |
|
// Search in global blog category |
| 359 |
|
$this->_db->setQuery( "SELECT id " |
| 360 |
|
."\nFROM #__menu " |
| 361 |
|
."\nWHERE type='content_blog_category' AND published='1' AND componentid=0" ); |
| 362 |
|
$_Itemid = $this->_db->loadResult(); |
| 363 |
|
} |
| 364 |
|
*/ |
| 365 |
|
if ($_Itemid) return $_Itemid; |
| 366 |
|
else return mamboCore::get('Itemid'); |
| 367 |
|
} |
| 368 |
|
|
| 369 |
|
function getSection ($id) { |
| 370 |
|
$database = mamboDatabase::getInstance(); |
| 371 |
|
$limit = $this->_section_limit; |
| 372 |
|
if (!$this->_section_status) { |
| 373 |
|
$database->setQuery("SELECT i.id, i.sectionid FROM #__content AS i, #__sections AS s WHERE i.sectionid=s.id ORDER BY i.id DESC LIMIT $limit"); |
| 374 |
|
$sections = $database->loadObjectList(); |
| 375 |
|
if ($sections) { |
| 376 |
|
foreach ($sections as $section) $this->_sections[$section->id] = $section->sectionid; |
| 377 |
|
$this->_section_status = count($sections); |
| 378 |
|
} |
| 379 |
|
} |
| 380 |
|
if ($this->_section_status) { |
| 381 |
|
if (isset($this->_sections[$id])) return $this->_sections[$id]; |
| 382 |
|
if (count($this->_sections) < $limit) return 0; |
| 383 |
|
$database->setQuery("SELECT i.sectionid FROM #__content AS i, #__sections AS s WHERE i.sectionid=s.id AND i.id=$id"); |
| 384 |
|
return $database->loadResult(); |
| 385 |
|
} |
| 386 |
|
else return 0; |
| 387 |
|
} |
| 388 |
|
|
| 389 |
} |
} |
| 390 |
|
|