| Current Path : /home/megadansyp/www/components/com_fwgallery/helpers/komento/ |
| Current File : /home/megadansyp/www/components/com_fwgallery/helpers/komento/com_fwgallery.php |
<?php
/**
* @package Komento
* @copyright Copyright (C) 2010 - 2018 Stack Ideas Sdn Bhd. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Komento is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Unauthorized Access');
require_once(__DIR__ . '/abstract.php');
class KomentoComFwGallery extends KomentoExtension
{
public $_item;
// map the keys here
public $_map = array(
'id' => 'id',
'title' => 'name',
'hits' => 'hits',
'created_by' => 'user_id',
'category_id' => 'category_id'
);
// constructor. add all required files here
public function __construct( $component )
{
// Load all required files by component
// $this->addFile( your component's files );
JFactory::getLanguage()->load('com_fwgallery');
parent::__construct( $component );
}
function getContentPermalink() {
$link = 'index.php?options=com_fwgallery&view=item&id=' . $this->_item->id;
$link = $this->prepareLink($link);
return $link;
}
// load all main properties here based on article id
public function load( $cid )
{
static $instances = array();
if( !isset( $instances[$cid] ) )
{
// populate $this->_item with:
// id
// name
// hits
// user_id
// category_id
// permalink_field
$db = KT::getDBO();
$query = 'SELECT `id`, `name`, `hits`, `user_id`, `category_id` FROM `#__fwsg_file` WHERE `id` = ' . $db->quote( $cid );
$db->setQuery( $query );
// return false or call the onLoadArticleError event if there are no objects to load
if( !$this->_item = $db->loadObject() )
{
return $this->onLoadArticleError( $cid );
}
// generate link for this article
$this->_item->permalink_field = 'index.php?options=com_fwgallery&view=item&id=' . $this->_item->id;
// call the prepareLink function and leave the rest to us
// unless you have custom SEF methods, then use "getContentPermalink" function to overwrite
$this->_item->permalink_field = $this->prepareLink( $this->_item->permalink_field );
$instances[$cid] = $this->_item;
}
$this->_item = $instances[$cid];
return $this;
}
public function getContentIds( $categories = '' )
{
$db = KT::getDBO();
$query = '';
if( empty( $categories ) )
{
$query = 'SELECT `id` FROM `#__fwsg_file` ORDER BY `id`';
}
else
{
if( is_array( $categories ) )
{
$categories = implode( ',', $categories );
}
$query = 'SELECT `id` FROM `#__fwsg_file` WHERE `category_id` IN (' . $categories . ') ORDER BY `id`';
}
$db->setQuery( $query );
return $db->loadResultArray();
}
public function getCategories()
{
$db = KT::getDBO();
$query = 'SELECT `id`, `name`, `parent` FROM `#__fwsg_category`';
$db->setQuery( $query );
$list = $children = array();
if ($citems = $db->loadObjectList()) {
foreach ($citems as $c) {
$pt = $c->parent;
$list = @ $children[$pt] ? $children[$pt] : array ();
array_push($list, $c);
$children[$pt] = $list;
}
JHTML::addIncludePath(FWMG_COMPONENT_ADMINISTRATOR.'/helpers');
$list = JHTML::_('fwsgCategory.treerecurse', 0, '', array(), $children, 9999, 0, 0);
}
return $list;
}
// to determine if is listing view
public function isListingView()
{
$views = array('fwgallery');
return in_array($this->input->get('view'), $views);
}
// to determine if is entry view
public function isEntryView()
{
return $this->input->get('view') == 'item';
}
public function onExecute( &$article, $html, $view, $options = array() )
{
// $html is the html content generated by komento (includes listing and form)
// $article->descr .= $html;
return $html;
}
}