<?php
/**
* @version 1.0.0
* @category Anahita Social Engineâ¢
* @copyright Copyright (C) 2008 - 2009 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.filesystem.file');
abstract class AnUikitViewAbstract extends KViewHtml
{
/**
* Load a template file -- first look in the templates folder for an override
*
* This functions accepts both template local template file names or identifiers
* - application::com.component.view.[.path].name
*
* @param string The name of the template source file automatically searches
* the template paths and compiles as needed.
* @throws KViewException
* @return string The output of the the template script.
*/
public function loadTemplate( $identifier = null)
{
$identifier = isset($identifier) ? $identifier : $this->_layout;
if ( !strpos($identifier, '.') ) {
$this->prepareLayout( $identifier );
}
return parent::loadTemplate($identifier);
}
/**
*
* @return
* @param $layout Object
*/
public function prepareLayout( $layout )
{
$layoutMethod = 'prepare'.KInflector::camelize($layout).'Layout';
if ( method_exists( $this, $layoutMethod) )
$this->$layoutMethod();
}
/**
*
* @return
* @param $identifier Object
* @param $options Object[optional]
*/
public function kfactory($identifier, $options=array())
{
return KFactory::get($identifier,$options);
}
/**
* Method to render a template
*/
public function display()
{
print $this->loadTemplate();
}
/**
* Method to include a css file
* @param string filename
* @param string path to the file
* @return null
*/
public function css($path, $options=array())
{
$component = 'com_'.$this->getIdentifier()->package;
if ( !isset($options['overwrite_path']) ) {
$options['overwrite_path'] = 'css/'.$component;
}
if ( !preg_match('/media\/com_\w+/', $path) ) {
$path = 'media/'.$component.'/css/'.$path;
}
AnUikitTemplate::stylesheet($path, $options);
}
/**
* Method to include a javascript file
* @param string filename
* @param string path to the file
* @return null
*/
public function js($path, $options=array())
{
if ( $this->getIdentifier()->package == 'anahita' && basename($path) == $path) {
$path = 'media/plg_socialengine/uikit/'.basename($path);
} else {
$component = isset($options['component']) ? $options['component'] : 'com_'.$this->getIdentifier()->package;
if ( !isset($options['overwrite_path']) ) {
$options['overwrite_path'] = 'js/'.$component;
}
if ( !preg_match('/media\/com_\w+/', $path) ) {
$path = 'media/'.$component.'/js/'.$path;
}
}
AnUikitTemplate::script($path, $options);
}
/**
*
* @return
* @param $actor Object
*/
public function uikit_actor_avatar($actor)
{
$kit = KFactory::get('lib.anahita.uikit.actor.avatar');
$kit->setActor($actor);
return $kit;
}
/**
*
* @return
* @param $actor Object
*/
public function uikit_actor_name($actor)
{
$kit = KFactory::get('lib.anahita.uikit.actor.name');
$kit->setActor($actor);
return $kit;
}
public function uikit_actor_json($actor)
{
return KFactory::get('lib.anahita.uikit.actor')->toJson($actor);
}
/**
*
* @return
* @param $date Object
* @param $options Object[optional]
*/
public function uikit_date($date, $options = array())
{
return KFactory::get('lib.anahita.util.date.helper')->toString($date, $options);
}
/**
*
* @return
* @param $error Object
*/
public function uikit_error($error)
{
return KFactory::get('lib.anahita.uikit.prompt.error')->setBody($error);
}
/**
*
* @return
* @param $message Object
*/
public function uikit_message($message)
{
return KFactory::get('lib.anahita.uikit.prompt.message')->setBody($message);
}
/**
*
* @return
* @param $applications Object
*/
public function uikit_application_gadgets($applications)
{
$kit = KFactory::get('lib.anahita.uikit.gadget');
}
/**
*
* @return
* @param $collection Object
*/
public function uikit_pagination($collection)
{
return KFactory::get('lib.anahita.uikit.page.pagination')->setCollection($collection);
}
/**
*
* @return
* @param $collection Object
* @param $options Object[optional]
*/
public function uikit_next_page($collection, $options = array())
{
return KFactory::get('lib.anahita.uikit.page.next')->setCollection($collection, $options);
}
/**
*
* @return
* @param $uikit_path Object
*/
public function uikit($uikit_path)
{
return KFactory::get('lib.anahita.uikit.'.$uikit_path);
}
/**
*
* @return
* @param $name Object
* @param $options Object[optional]
*/
public function uikitjs($name, $options=array())
{
AnUikitTemplate::uikitjs($name, $options);
}
/**
*
* @return
* @param $name Object
* @param $options Object[optional]
*/
public function uikitcss($name, $options=array())
{
AnUikitTemplate::uikitcss($name, $options);
}
public function __toString()
{
try {
return parent::__toString();
} catch(Exception $e) {
print "Exception thrown <br />";
print $e->getMessage()."<br />";
print_r($e);
}
return "";
}
}