<?php
/**
* @version 1.0.0
* @category Anahita Social Engineâ¢
* @copyright Copyright (C) 2008 - 2010 rmdStudio Inc. and Peerglobe Technology Inc. All rights reserved.
* @license GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
* @link http://www.anahitapolis.com
*/
jimport('joomla.plugin.plugin');
class plgSystemSocialengine extends JPlugin
{
/**
*
* @return
* @param $subject Object
* @param $config Object[optional]
*/
public function __construct($subject, $config = array())
{
parent::__construct($subject,$config);
if (!defined('KOOWA')) {
JPluginHelper::importPlugin('system','koowa');
if ( !defined('KOOWA') ) {
return;
}
}
define('ANAHITA',true);
require_once 'socialengine'.DS.'FactoryAdapter.php';
require_once 'socialengine'.DS.'LoaderAdapter.php';
KLoader::addAdapter( new AnahitaLoaderAdapter() );
KFactory::addAdapter(new AnahitaFactoryAdapter());
global $mainframe;
KFactory::get('lib.joomla.language')->load('com_socialengine');
if ( $mainframe->isAdmin() ) return;
$doc =& JFactory::getDocument();
if ( class_exists('JDocumentHTML') && $doc instanceof JDocumentHTML) {
//require_once 'socialengine'.DS.'document'.DS.'html.php';
}
$format = KRequest::get('request.format', 'cmd', 'html');
if ($format == 'html' && class_exists('JDocumentHTML'))
{
$lang = KFactory::get('lib.joomla.language');
$options = array (
'charset' => 'utf-8',
'language' => $lang->getTag(),
'direction' => $lang->isRTL() ? 'rtl' : 'ltr'
);
$doc = KFactory::tmp('lib.anahita.util.document.html');
}
global $__blocks;
$__blocks = array();
function capture()
{
global $__blocks;
$args = func_get_args();
if ( count($args) > 0 ) {
$__blocks[] = $args;
}
ob_start();
}
function end_capture()
{
global $__blocks;
$body = ob_get_contents();
ob_end_clean();
if ( count($__blocks) ) {
$args = array_shift($__blocks);
$method = array_shift($args);
$args[] = $body;
return call_user_func_array($method, $args);
}
return $body;
}
}
/**
*
* @return
*/
public function _onAfterRoute()
{
global $mainframe;
return;
if ($mainframe->isAdmin() || !defined('KOOWA') || KInput::getMethod() == 'POST')
return;
$option = KInput::get('option','get','string');
$uri = KInput::get('REQUEST_URI','server','string');
$view = KInput::get('view','get','string');
if (($option && $option != 'com_socialengine') || $view) {
return;
}
$matches = array();
if (preg_match('/\/profile\/([a-zA-Z0-9-_]+)/',$uri,$matches)) {
global $option;
$option = 'com_socialengine';
KInput::set('option','com_socialengine','get');
KInput::set('view','profile','get');
$username = $matches[1];
// $username = str_replace('-',' ',$username);
// $username = str_replace('_','.',$username);
KInput::set('oid',$username,'get');
}
}
}