| 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 |
| 195 |
/** |
/** |
| 196 |
* @param database A database connector object |
* @param database A database connector object |
| 197 |
*/ |
*/ |
| 198 |
function mosContent( &$db ) { |
function mosContent() { |
| 199 |
|
$db =& mamboDatabase::getInstance(); |
| 200 |
$this->mosDBTable( '#__content', 'id', $db ); |
$this->mosDBTable( '#__content', 'id', $db ); |
| 201 |
} |
} |
| 202 |
|
|
| 249 |
} |
} |
| 250 |
} |
} |
| 251 |
|
|
| 252 |
class contentHandler { |
class mosExtendedContent extends mosContent { |
| 253 |
|
/** @var numeric */ |
| 254 |
|
var $rating = null; |
| 255 |
|
/** @var int */ |
| 256 |
|
var $rating_count = null; |
| 257 |
|
/** @var string */ |
| 258 |
|
var $author = null; |
| 259 |
|
/** @var string */ |
| 260 |
|
var $usertype = null; |
| 261 |
|
/** @var string */ |
| 262 |
|
var $section = null; |
| 263 |
|
/** @var string */ |
| 264 |
|
var $category = null; |
| 265 |
|
/** @var string */ |
| 266 |
|
var $groups = null; |
| 267 |
|
/** @var string */ |
| 268 |
|
var $text = null; |
| 269 |
|
|
| 270 |
|
function getText () { |
| 271 |
|
return $this->text; |
| 272 |
|
} |
| 273 |
|
|
| 274 |
|
function saveText ($text) { |
| 275 |
|
$this->text = $text; |
| 276 |
|
} |
| 277 |
|
|
| 278 |
|
function getImages () { |
| 279 |
|
return $this->images; |
| 280 |
|
} |
| 281 |
|
|
| 282 |
|
function saveImages ($images) { |
| 283 |
|
$this->images = $images; |
| 284 |
|
} |
| 285 |
|
|
| 286 |
|
function getId () { |
| 287 |
|
return $this->id; |
| 288 |
|
} |
| 289 |
|
|
| 290 |
|
function getRating () { |
| 291 |
|
return $this->rating; |
| 292 |
|
} |
| 293 |
|
|
| 294 |
|
function getRatingCount () { |
| 295 |
|
return $this->rating_count; |
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
} |
| 299 |
|
|
| 300 |
|
class contentHandler { |
| 301 |
|
var $_section_limit = 250; |
| 302 |
|
var $_section_status = 0; |
| 303 |
|
var $_sections; |
| 304 |
|
|
| 305 |
|
function &getInstance () { |
| 306 |
|
static $instance; |
| 307 |
|
if (!is_object($instance)) $instance = new contentHandler(); |
| 308 |
|
return $instance; |
| 309 |
|
} |
| 310 |
/** |
/** |
| 311 |
* @return number of Published Blog Sections |
* @return number of Published Blog Sections |
| 312 |
*/ |
*/ |
| 313 |
function getBlogSectionCount( ) { |
function getBlogSectionCount( ) { |
| 314 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 315 |
if (count($menuhandler->getMenusByType('content_blog_section'))) { |
if (count($menuhandler->getMenusByType('content_blog_section'))) { |
| 316 |
$query = "SELECT COUNT( m.id )" |
$query = "SELECT COUNT( m.id )" |
| 317 |
."\n FROM #__content AS i" |
."\n FROM #__content AS i" |
| 320 |
."\n WHERE m.type='content_blog_section'" |
."\n WHERE m.type='content_blog_section'" |
| 321 |
."\n AND m.published='1'" |
."\n AND m.published='1'" |
| 322 |
; |
; |
| 323 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 324 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 325 |
$count = $database->loadResult(); |
$count = $database->loadResult(); |
| 326 |
} |
} |
| 332 |
* @return number of Published Blog Categories |
* @return number of Published Blog Categories |
| 333 |
*/ |
*/ |
| 334 |
function getBlogCategoryCount( ) { |
function getBlogCategoryCount( ) { |
| 335 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 336 |
if (count($menuhandler->getMenusByType('content_blog_category'))) { |
if (count($menuhandler->getMenusByType('content_blog_category'))) { |
| 337 |
$query = "SELECT COUNT( m.id )" |
$query = "SELECT COUNT( m.id )" |
| 338 |
. "\n FROM #__content AS i" |
. "\n FROM #__content AS i" |
| 341 |
. "\n WHERE m.type='content_blog_category'" |
. "\n WHERE m.type='content_blog_category'" |
| 342 |
. "\n AND m.published='1'" |
. "\n AND m.published='1'" |
| 343 |
; |
; |
| 344 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 345 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 346 |
$count = $database->loadResult(); |
$count = $database->loadResult(); |
| 347 |
} |
} |
| 353 |
* @return number of Published Global Blog Sections |
* @return number of Published Global Blog Sections |
| 354 |
*/ |
*/ |
| 355 |
function getGlobalBlogSectionCount( ) { |
function getGlobalBlogSectionCount( ) { |
| 356 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 357 |
return $menuhandler->getGlobalBlogSectionCount(); |
return $menuhandler->getGlobalBlogSectionCount(); |
| 358 |
} |
} |
| 359 |
|
|
| 361 |
* @return number of Static Content |
* @return number of Static Content |
| 362 |
*/ |
*/ |
| 363 |
function getStaticContentCount( ) { |
function getStaticContentCount( ) { |
| 364 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 365 |
return $menuhandler->getMenuCount ('content_typed', 1); |
return $menuhandler->getMenuCount ('content_typed', 1); |
| 366 |
} |
} |
| 367 |
|
|
| 369 |
* @return number of Content Item Links |
* @return number of Content Item Links |
| 370 |
*/ |
*/ |
| 371 |
function getContentItemLinkCount( ) { |
function getContentItemLinkCount( ) { |
| 372 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 373 |
return $menuhandler->getMenuCount ('content_item_link', 1); |
return $menuhandler->getMenuCount ('content_item_link', 1); |
| 374 |
} |
} |
| 375 |
|
|
| 376 |
|
function getItemid ($id, $typed=1, $link=1, $bs=1, $bc=1, $gbs=1) { |
| 377 |
|
$_Itemid = null; |
| 378 |
|
$menuhandler =& mosMenuHandler::getInstance(); |
| 379 |
|
if ($typed) { |
| 380 |
|
// Search for typed link |
| 381 |
|
$_Itemid = $menuhandler->getIDByTypeLink('content_typed', "index.php?option=com_content&task=view&id=$id"); |
| 382 |
|
} |
| 383 |
|
|
| 384 |
|
if ($_Itemid == null AND $link) { |
| 385 |
|
// Search for item link |
| 386 |
|
$_Itemid = $menuhandler->getIDByTypeLink('content_item_link', "index.php?option=com_content&task=view&id=$id"); |
| 387 |
|
} |
| 388 |
|
$sectionid = $this->getSection($id); |
| 389 |
|
if ($_Itemid == null) { |
| 390 |
|
// Search in sections |
| 391 |
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_section', $sectionid); |
| 392 |
|
} |
| 393 |
|
if ($_Itemid == null) { |
| 394 |
|
// Search in sections |
| 395 |
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_blog_section', $sectionid); |
| 396 |
|
} |
| 397 |
|
if ($_Itemid == null) { |
| 398 |
|
// Search in sections |
| 399 |
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_blog_category', $sectionid); |
| 400 |
|
} |
| 401 |
|
if ($_Itemid == null AND $gbs) { |
| 402 |
|
// Search in global blog section |
| 403 |
|
$_Itemid = $menuhandler->getIDByTypeCid('content_blog_section', 0); |
| 404 |
|
} |
| 405 |
|
/* |
| 406 |
|
if ($_Itemid == '') { |
| 407 |
|
// Search in global blog category |
| 408 |
|
$this->_db->setQuery( "SELECT id " |
| 409 |
|
."\nFROM #__menu " |
| 410 |
|
."\nWHERE type='content_blog_category' AND published='1' AND componentid=0" ); |
| 411 |
|
$_Itemid = $this->_db->loadResult(); |
| 412 |
|
} |
| 413 |
|
*/ |
| 414 |
|
if ($_Itemid) return $_Itemid; |
| 415 |
|
else return mamboCore::get('Itemid'); |
| 416 |
|
} |
| 417 |
|
|
| 418 |
|
function getSection ($id) { |
| 419 |
|
$database =& mamboDatabase::getInstance(); |
| 420 |
|
$limit = $this->_section_limit; |
| 421 |
|
if (!$this->_section_status) { |
| 422 |
|
$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"); |
| 423 |
|
$sections = $database->loadObjectList(); |
| 424 |
|
if ($sections) { |
| 425 |
|
foreach ($sections as $section) $this->_sections[$section->id] = $section->sectionid; |
| 426 |
|
$this->_section_status = count($sections); |
| 427 |
|
} |
| 428 |
|
} |
| 429 |
|
if ($this->_section_status) { |
| 430 |
|
if (isset($this->_sections[$id])) return $this->_sections[$id]; |
| 431 |
|
if (count($this->_sections) < $limit) return 0; |
| 432 |
|
$database->setQuery("SELECT i.sectionid FROM #__content AS i, #__sections AS s WHERE i.sectionid=s.id AND i.id=$id"); |
| 433 |
|
return $database->loadResult(); |
| 434 |
|
} |
| 435 |
|
else return 0; |
| 436 |
|
} |
| 437 |
|
|
| 438 |
} |
} |
| 439 |
|
|