| 1 |
<?php |
<?php |
| 2 |
|
/** |
| 3 |
|
* @package Mambo Open Source |
| 4 |
|
* @copyright (C) 2005 - 2007 Mambo Foundation Inc. |
| 5 |
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 6 |
|
* |
| 7 |
|
* Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure |
| 8 |
|
* that Mambo remained free Open Source software owned and managed by the community. |
| 9 |
|
* Mambo is Free Software |
| 10 |
|
*/ |
| 11 |
|
|
| 12 |
/** |
/** |
| 13 |
* Category database table class |
* Category database table class |
|
* @package Mambo |
|
| 14 |
*/ |
*/ |
| 15 |
class mosCategory extends mosDBTable { |
class mosCategory extends mosDBTable { |
| 16 |
/** @var int Primary key */ |
/** @var int Primary key */ |
| 101 |
/** @var int */ |
/** @var int */ |
| 102 |
var $access=null; |
var $access=null; |
| 103 |
/** @var string */ |
/** @var string */ |
| 104 |
var $params=null; |
var $params=''; |
| 105 |
|
|
| 106 |
/** |
/** |
| 107 |
* @param database A database connector object |
* @param database A database connector object |
| 203 |
/** |
/** |
| 204 |
* @param database A database connector object |
* @param database A database connector object |
| 205 |
*/ |
*/ |
| 206 |
function mosContent( &$db ) { |
function mosContent() { |
| 207 |
|
$db =& mamboDatabase::getInstance(); |
| 208 |
$this->mosDBTable( '#__content', 'id', $db ); |
$this->mosDBTable( '#__content', 'id', $db ); |
| 209 |
} |
} |
| 210 |
|
|
| 257 |
} |
} |
| 258 |
} |
} |
| 259 |
|
|
| 260 |
class contentHandler { |
class mosExtendedContent extends mosContent { |
| 261 |
|
/** @var numeric */ |
| 262 |
|
var $rating = null; |
| 263 |
|
/** @var int */ |
| 264 |
|
var $rating_count = null; |
| 265 |
|
/** @var string */ |
| 266 |
|
var $author = null; |
| 267 |
|
/** @var string */ |
| 268 |
|
var $usertype = null; |
| 269 |
|
/** @var string */ |
| 270 |
|
var $section = null; |
| 271 |
|
/** @var string */ |
| 272 |
|
var $category = null; |
| 273 |
|
/** @var string */ |
| 274 |
|
var $groups = null; |
| 275 |
|
/** @var string */ |
| 276 |
|
var $text = null; |
| 277 |
|
|
| 278 |
|
function getText () { |
| 279 |
|
return $this->text; |
| 280 |
|
} |
| 281 |
|
|
| 282 |
|
function saveText ($text) { |
| 283 |
|
$this->text = $text; |
| 284 |
|
} |
| 285 |
|
|
| 286 |
|
function getImages () { |
| 287 |
|
return $this->images; |
| 288 |
|
} |
| 289 |
|
|
| 290 |
|
function saveImages ($images) { |
| 291 |
|
$this->images = $images; |
| 292 |
|
} |
| 293 |
|
|
| 294 |
|
function getId () { |
| 295 |
|
return $this->id; |
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
function getRating () { |
| 299 |
|
return $this->rating; |
| 300 |
|
} |
| 301 |
|
|
| 302 |
|
function getRatingCount () { |
| 303 |
|
return $this->rating_count; |
| 304 |
|
} |
| 305 |
|
|
| 306 |
|
} |
| 307 |
|
|
| 308 |
|
class contentHandler { |
| 309 |
|
var $_category_limit = 250; |
| 310 |
|
var $_category_status = 0; |
| 311 |
|
var $_category; |
| 312 |
|
var $_section_limit = 250; |
| 313 |
|
var $_section_status = 0; |
| 314 |
|
var $_sections; |
| 315 |
|
|
| 316 |
|
function &getInstance () { |
| 317 |
|
static $instance; |
| 318 |
|
if (!is_object($instance)) $instance = new contentHandler(); |
| 319 |
|
return $instance; |
| 320 |
|
} |
| 321 |
/** |
/** |
| 322 |
* @return number of Published Blog Sections |
* @return number of Published Blog Sections |
| 323 |
*/ |
*/ |
| 324 |
function getBlogSectionCount( ) { |
function getBlogSectionCount( ) { |
| 325 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 326 |
if (count($menuhandler->getMenusByType('content_blog_section'))) { |
if (count($menuhandler->getMenusByType('content_blog_section'))) { |
| 327 |
$query = "SELECT COUNT( m.id )" |
$query = "SELECT COUNT( m.id )" |
| 328 |
."\n FROM #__content AS i" |
."\n FROM #__content AS i" |
| 331 |
."\n WHERE m.type='content_blog_section'" |
."\n WHERE m.type='content_blog_section'" |
| 332 |
."\n AND m.published='1'" |
."\n AND m.published='1'" |
| 333 |
; |
; |
| 334 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 335 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 336 |
$count = $database->loadResult(); |
$count = $database->loadResult(); |
| 337 |
|
} else { |
| 338 |
|
$count = 0; |
| 339 |
} |
} |
|
else $count = 0; |
|
| 340 |
return $count; |
return $count; |
| 341 |
} |
} |
| 342 |
|
|
| 344 |
* @return number of Published Blog Categories |
* @return number of Published Blog Categories |
| 345 |
*/ |
*/ |
| 346 |
function getBlogCategoryCount( ) { |
function getBlogCategoryCount( ) { |
| 347 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 348 |
if (count($menuhandler->getMenusByType('content_blog_category'))) { |
if (count($menuhandler->getMenusByType('content_blog_category'))) { |
| 349 |
$query = "SELECT COUNT( m.id )" |
$query = "SELECT COUNT( m.id )" |
| 350 |
. "\n FROM #__content AS i" |
. "\n FROM #__content AS i" |
| 353 |
. "\n WHERE m.type='content_blog_category'" |
. "\n WHERE m.type='content_blog_category'" |
| 354 |
. "\n AND m.published='1'" |
. "\n AND m.published='1'" |
| 355 |
; |
; |
| 356 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 357 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 358 |
$count = $database->loadResult(); |
$count = $database->loadResult(); |
| 359 |
} |
} |
| 365 |
* @return number of Published Global Blog Sections |
* @return number of Published Global Blog Sections |
| 366 |
*/ |
*/ |
| 367 |
function getGlobalBlogSectionCount( ) { |
function getGlobalBlogSectionCount( ) { |
| 368 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 369 |
return $menuhandler->getGlobalBlogSectionCount(); |
return $menuhandler->getGlobalBlogSectionCount(); |
| 370 |
} |
} |
| 371 |
|
|
| 373 |
* @return number of Static Content |
* @return number of Static Content |
| 374 |
*/ |
*/ |
| 375 |
function getStaticContentCount( ) { |
function getStaticContentCount( ) { |
| 376 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 377 |
return $menuhandler->getMenuCount ('content_typed', 1); |
return $menuhandler->getMenuCount ('content_typed', 1); |
| 378 |
} |
} |
| 379 |
|
|
| 381 |
* @return number of Content Item Links |
* @return number of Content Item Links |
| 382 |
*/ |
*/ |
| 383 |
function getContentItemLinkCount( ) { |
function getContentItemLinkCount( ) { |
| 384 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 385 |
return $menuhandler->getMenuCount ('content_item_link', 1); |
return $menuhandler->getMenuCount ('content_item_link', 1); |
| 386 |
} |
} |
| 387 |
|
|
| 388 |
|
function getItemid ($id, $typed=1, $link=1, $bs=1, $bc=1, $gbs=1) { |
| 389 |
|
$_Itemid = null; |
| 390 |
|
$menuhandler =& mosMenuHandler::getInstance(); |
| 391 |
|
if ($typed) { |
| 392 |
|
// Search for typed link |
| 393 |
|
$_Itemid = $menuhandler->getIDByTypeLink('content_typed', "index.php?option=com_content&task=view&id=$id"); |
| 394 |
|
} |
| 395 |
|
|
| 396 |
|
if ($_Itemid == null AND $link) { |
| 397 |
|
// Search for item link |
| 398 |
|
$_Itemid = $menuhandler->getIDByTypeLink('content_item_link', "index.php?option=com_content&task=view&id=$id"); |
| 399 |
|
} |
| 400 |
|
$sectionid = $this->getSection($id); |
| 401 |
|
if ($_Itemid == null) { |
| 402 |
|
// Search in sections |
| 403 |
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_section', $sectionid); |
| 404 |
|
} |
| 405 |
|
if ($_Itemid == null) { |
| 406 |
|
// Search in sections |
| 407 |
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_blog_section', $sectionid); |
| 408 |
|
} |
| 409 |
|
if ($_Itemid == null) { |
| 410 |
|
// Search in sections |
| 411 |
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_blog_category', $sectionid); |
| 412 |
|
} |
| 413 |
|
if ($_Itemid == null AND $gbs) { |
| 414 |
|
// Search in global blog section |
| 415 |
|
$_Itemid = $menuhandler->getIDByTypeCid('content_blog_section', 0); |
| 416 |
|
} |
| 417 |
|
/* |
| 418 |
|
if ($_Itemid == '') { |
| 419 |
|
// Search in global blog category |
| 420 |
|
$this->_db->setQuery( "SELECT id " |
| 421 |
|
."\nFROM #__menu " |
| 422 |
|
."\nWHERE type='content_blog_category' AND published='1' AND componentid=0" ); |
| 423 |
|
$_Itemid = $this->_db->loadResult(); |
| 424 |
|
} |
| 425 |
|
*/ |
| 426 |
|
$catid = $this->getCategory($id); |
| 427 |
|
if ($_Itemid == null) { |
| 428 |
|
// Search in categories |
| 429 |
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_category', $catid); |
| 430 |
|
} |
| 431 |
|
if ($_Itemid == null) { |
| 432 |
|
// Search in main menu |
| 433 |
|
$menus = $menuhandler->getByParentOrder(0,'mainmenu'); |
| 434 |
|
$home = $menus[0]; |
| 435 |
|
$_Itemid = $home->id; |
| 436 |
|
} |
| 437 |
|
if ($_Itemid) return $_Itemid; |
| 438 |
|
else return mamboCore::get('Itemid'); |
| 439 |
|
} |
| 440 |
|
|
| 441 |
|
function getSection ($id) { |
| 442 |
|
$database =& mamboDatabase::getInstance(); |
| 443 |
|
$limit = $this->_section_limit; |
| 444 |
|
if (!$this->_section_status) { |
| 445 |
|
$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"); |
| 446 |
|
$sections = $database->loadObjectList(); |
| 447 |
|
if ($sections) { |
| 448 |
|
foreach ($sections as $section) $this->_sections[$section->id] = $section->sectionid; |
| 449 |
|
$this->_section_status = count($sections); |
| 450 |
|
} |
| 451 |
|
} |
| 452 |
|
if ($this->_section_status) { |
| 453 |
|
if (isset($this->_sections[$id])) return $this->_sections[$id]; |
| 454 |
|
if (count($this->_sections) < $limit) return 0; |
| 455 |
|
$database->setQuery("SELECT i.sectionid FROM #__content AS i, #__sections AS s WHERE i.sectionid=s.id AND i.id=$id"); |
| 456 |
|
return $database->loadResult(); |
| 457 |
|
} |
| 458 |
|
else return 0; |
| 459 |
|
} |
| 460 |
|
|
| 461 |
|
function getCategory ($id) { |
| 462 |
|
$database =& mamboDatabase::getInstance(); |
| 463 |
|
$limit = $this->_category_limit; |
| 464 |
|
if (!$this->_category_status) { |
| 465 |
|
$database->setQuery("SELECT i.id, i.catid FROM #__content AS i, #__categories AS s WHERE i.catid=s.id ORDER BY i.id DESC LIMIT $limit"); |
| 466 |
|
$categories = $database->loadObjectList(); |
| 467 |
|
if ($categories) { |
| 468 |
|
foreach ($categories as $category) $this->_categories[$category->id] = $category->catid; |
| 469 |
|
$this->_category_status = count($categories); |
| 470 |
|
} |
| 471 |
|
} |
| 472 |
|
if ($this->_category_status) { |
| 473 |
|
if (isset($this->_categories[$id])) return $this->_categories[$id]; |
| 474 |
|
if (count($this->_categories) < $limit) return 0; |
| 475 |
|
$database->setQuery("SELECT i.catid FROM #__content AS i, #__categories AS s WHERE i.catid=s.id AND i.id=$id"); |
| 476 |
|
return $database->loadResult(); |
| 477 |
|
} |
| 478 |
|
else return 0; |
| 479 |
|
} |
| 480 |
|
|
| 481 |
} |
} |
| 482 |
|
|