示例#1
0
文件: koowa.php 项目: Roma48/mayak
 public function __construct($subject, $config = array())
 {
     // Turn off E_STRICT errors for now
     error_reporting(error_reporting() & ~E_STRICT);
     // Check if database type is MySQLi
     if (JFactory::getApplication()->getCfg('dbtype') != 'mysqli') {
         if (JFactory::getApplication()->getName() === 'administrator') {
             $string = version_compare(JVERSION, '1.6', '<') ? 'mysqli' : 'MySQLi';
             $link = JRoute::_('index.php?option=com_config');
             $error = 'In order to use Joomlatools framework, your database type in Global Configuration should be set to <strong>%1$s</strong>. Please go to <a href="%2$s">Global Configuration</a> and in the \'Server\' tab change your Database Type to <strong>%1$s</strong>.';
             JError::raiseWarning(0, sprintf(JText::_($error), $string, $link));
         }
         return;
     }
     // Set pcre.backtrack_limit to a larger value
     // See: https://bugs.php.net/bug.php?id=40846
     if (version_compare(PHP_VERSION, '5.3.6', '<=') && @ini_get('pcre.backtrack_limit') < 1000000) {
         @ini_set('pcre.backtrack_limit', 1000000);
     }
     //Set constants
     define('KDEBUG', JDEBUG);
     //Set path definitions
     define('JPATH_FILES', JPATH_ROOT);
     define('JPATH_IMAGES', JPATH_ROOT . DIRECTORY_SEPARATOR . 'images');
     //Set exception handler
     set_exception_handler(array($this, 'exceptionHandler'));
     // Koowa : setup
     require_once JPATH_LIBRARIES . '/koowa/koowa.php';
     Koowa::getInstance(array('cache_prefix' => md5(JFactory::getApplication()->getCfg('secret')) . '-cache-koowa', 'cache_enabled' => false));
     KLoader::addAdapter(new KLoaderAdapterModule(array('basepath' => JPATH_BASE)));
     KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT)));
     KLoader::addAdapter(new KLoaderAdapterComponent(array('basepath' => JPATH_BASE)));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.module'));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin'));
     KServiceIdentifier::addLocator(KService::get('koowa:service.locator.component'));
     KServiceIdentifier::setApplication('site', JPATH_SITE);
     KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR);
     KService::setAlias('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli');
     KService::setAlias('translator', 'com:default.translator');
     //Setup the request
     if (JFactory::getApplication()->getName() !== 'site') {
         KRequest::root(str_replace('/' . JFactory::getApplication()->getName(), '', KRequest::base()));
     }
     //Load the koowa plugins
     JPluginHelper::importPlugin('koowa', null, true);
     //Bugfix : Set offset accoording to user's timezone
     if (!JFactory::getUser()->guest) {
         if ($offset = JFactory::getUser()->getParam('timezone')) {
             if (version_compare(JVERSION, '3.0', '>=')) {
                 JFactory::getConfig()->set('offset', $offset);
             } else {
                 JFactory::getConfig()->setValue('config.offset', $offset);
             }
         }
     }
     // Load language files for the framework
     KService::get('com:default.translator')->loadLanguageFiles();
     parent::__construct($subject, $config);
 }
示例#2
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param KConfig $config An optional KConfig object with configuration options.
  *
  * @return void
  */
 protected function _initialize(KConfig $config)
 {
     if (!$config->base_url) {
         $base = clone KRequest::base();
         foreach (array('host', 'scheme', 'port', 'user', 'pass') as $part) {
             $base->{$part} = KRequest::url()->{$part};
         }
         $config->base_url = $base;
     }
     $config->append(array('enable_rewrite' => false, 'url' => clone KService::get('koowa:http.url')));
     parent::_initialize($config);
 }
示例#3
0
 public function display()
 {
     $params = JFactory::getApplication()->getParams();
     // Build the image, if set
     if ($params->get('image') != -1) {
         if ($params->get('image_align') != "") {
             $attribs['align'] = $params->get('image_align');
         }
         $attribs['hspace'] = 6;
         $attribs['title'] = JText::_('Web Links');
         $image['src'] = KRequest::base() . '/images/stories/' . $params->get('image');
         $image['attribs'] = $attribs;
         $this->assign('image', $image);
     }
     $this->assign('params', $params);
     return parent::display();
 }
示例#4
0
 public function __toString()
 {
     if ($result = $this->getText()) {
         if ($this->isTranslatable()) {
             $result = $this->_translator->translate($result);
         }
         $result = '<span class="content">' . $result . '</span>';
         if (($link = $this->_link) && ($url = $link->url)) {
             $attribs = $link->attribs ? KHelperArray::toString(KConfig::unbox($link->attribs)) : '';
             if (strpos($url, 'mailto:') !== 0) {
                 if ($link->route) {
                     $url = JRoute::_($url);
                     if (version_compare(JVERSION, '1.6', '<') && JFactory::getApplication()->isAdmin()) {
                         // TODO Remove when J!1.5 support is dropped. J!1.5 backend router does not append the
                         // path relative to document root.
                         $url = KRequest::base() . '/' . $url;
                     }
                 } else {
                     // If routing is disabled, URLs are assumed as relative to site root.
                     $url = KRequest::root() . '/' . $url;
                 }
                 if ($link->absolute) {
                     $url = JURI::getInstance()->toString(array('scheme', 'host', 'port')) . $url;
                 }
             }
             if (!$link->route) {
                 $url = htmlspecialchars($url, ENT_QUOTES);
                 // Routed links are already escaped.
             }
             $result = '<a ' . $attribs . ' href="' . $url . '">' . $result . '</a>';
         }
         if ($attribs = $this->_attribs) {
             // TODO It seems that KHelperArray::toString is not properly working. Need to do the following
             // for having properly rendered attribs.
             foreach ($attribs as $attrib => $value) {
                 if (is_object($value)) {
                     $attribs->{$attrib} = implode(' ', KConfig::unbox($value));
                 }
             }
             $result = '<span ' . KHelperArray::toString($attribs) . '>' . $result . '</span>';
         }
     } else {
         $result = $this->getName(true);
     }
     return $result;
 }
示例#5
0
 /**
  * Display the view
  *
  * @return	string	The output of the view
  */
 public function display()
 {
     $category = $this->getService('com://site/weblinks.model.categories')->id($this->getModel()->getState()->category)->getItem();
     $categories = $this->getService('com://site/weblinks.model.categories')->getList();
     $params = JFactory::getApplication()->getParams();
     // Set up the category image
     if (isset($category->image) && $category->image != '') {
         $category->image = array('src' => KRequest::base() . '/' . str_replace(JPATH_ROOT . DS, '', JPATH_IMAGES . '/stories/' . $category->image), 'attribs' => array('align' => $category->image_position, 'hspace' => 6, 'title' => JText::_('Web Links')));
     }
     // Set up icon for table display
     if ($params->get('link_icons') != -1) {
         $image = array('src' => 'media://system/images/' . $params->get('weblink_icons', 'weblink.png'), 'title' => JText::_('Link'));
         $this->assign('image', $image);
     }
     $this->assign('params', $params);
     $this->assign('category', $category);
     $this->assign('categories', $categories);
     return parent::display();
 }
示例#6
0
 /**
  * Initializes the config for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   object  An optional KConfig object with configuration options
  * @return  void
  */
 protected function _initialize(KConfig $config)
 {
     $config->append(array('escape' => 'htmlspecialchars', 'layout_default' => 'default', 'template' => null, 'template_filters' => array('shorttag', 'alias', 'variable', 'script', 'style', 'link'), 'template_path' => null, 'auto_assign' => true, 'auto_filter' => false, 'base_url' => KRequest::base(), 'media_url' => KRequest::root() . '/media'))->append(array('layout' => $config->layout_default));
     parent::_initialize($config);
 }
示例#7
0
 /**
  * Prepares the CLI mode.
  * 
  * @param KCommandContext $context
  */
 protected function _actionPrepclienv(KCommandContext $context)
 {
     if (!empty($_SERVER['argv']) && count($_SERVER['argv']) > 1) {
         $args = array_slice($_SERVER['argv'], 1);
         if (is_readable(realpath($args[0]))) {
             $file = array_shift($args);
         }
         $args = explode('&-data&', implode($args, '&'));
         $args = array_filter($args, 'trim');
         foreach ($args as $i => $arg) {
             $arg = trim($arg);
             if ($i == 0) {
                 if (strpos($arg, '/') !== false) {
                     $arg = substr_replace($arg, '?', strpos($arg, '&'), 1);
                     $url = KService::get('koowa:http.url', array('url' => $arg));
                     KRequest::url()->path = KRequest::base() . $url->path;
                     $_GET = $url->query;
                 } else {
                     KRequest::url()->path = KRequest::base();
                     parse_str($arg, $_GET);
                 }
             } else {
                 parse_str($arg, $_POST);
             }
         }
     }
     $_GET['format'] = 'json';
     KRequest::url()->format = 'json';
     KRequest::url()->setQuery($_GET);
     jimport('joomla.plugin.helper');
     JPluginHelper::importPlugin('cli');
     $this->_application->triggerEvent('onCli');
     //if there's a file then just load the file and exit
     if (!empty($file)) {
         KService::get('koowa:loader')->loadFile($file);
         exit(0);
     }
 }
示例#8
0
 /**
  * Initializes the config for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   object  An optional KConfig object with configuration options
  * @return  void
  */
 protected function _initialize(KConfig $config)
 {
     //Clone the identifier
     $identifier = clone $this->_identifier;
     
     $config->append(array(
         'data'			   => array(),
         'escape'           => 'htmlspecialchars',
         'template'         => $this->getName(),
         'template_filters' => array('shorttag', 'alias', 'variable', 'script', 'style', 'link', 'template'),
         'auto_assign'      => true,
         'base_url'         => KRequest::base(),
         'media_url'        => KRequest::root().'/media',
     ));
     
     parent::_initialize($config);
 }
示例#9
0
 /**
  * Renders the output
  * 
  * @param KCommandContext $context Command chain context
  * 
  * @return boolean
  */
 protected function _actionRender(KCommandContext $context)
 {
     //old school of rendering for the backend for now
     $component = $this->getComponent()->getIdentifier()->package;
     $template = $this->_application->getTemplate();
     $file = $this->_request->get('tmpl', 'index');
     if ($component == 'login') {
         $file = 'login';
     }
     $config = array('template' => $template, 'file' => $file . '.php', 'directory' => JPATH_THEMES);
     $document =& JFactory::getDocument();
     $document->addScript(JURI::root(true) . '/administrator/includes/joomla.javascript.js');
     $document->setTitle(htmlspecialchars_decode($this->_application->getCfg('sitename')) . ' - ' . JText::_('Administration'));
     $document->setDescription($this->_application->getCfg('MetaDesc'));
     $document->setBuffer($context->response->getContent(), 'component');
     $content = $document->render(false, $config);
     //lets do some parsing. mission template and legacy stuff
     $content = preg_replace_callback('#(src|href)="templates\\/#', function ($matches) {
         return $matches[1] . '="' . KRequest::base() . '/templates/';
     }, $content);
     $content = preg_replace_callback('#(src|href)="/(media|administrator)/#', function ($matches) {
         return $matches[1] . '="' . KRequest::root() . '/' . $matches[2] . '/';
     }, $content);
     $content = preg_replace_callback('#action="index.php"#', function ($matches) {
         return 'action="index.php?"';
     }, $content);
     $context->response->setContent($content);
 }
示例#10
0
	/**
	* Class constructor.
	*
	* @param	integer	A client identifier.
	*/
    function __construct($config = array())
	{
		jimport('joomla.utilities.utility');

		//set the view name
		$this->_name		= $this->getName();
		$this->_clientId	= $config['clientId'];

		//Enable sessions by default
		if(!isset($config['session'])) {
			$config['session'] = true;
		}

		//Set the session default name
		if(!isset($config['session_name'])) {
			 $config['session_name'] = $this->_name;
		}

		//Set the default configuration file
		if(!isset($config['config_file'])) {
			$config['config_file'] = 'configuration.php';
		}

		//Setup the request
        KRequest::root(str_replace('/'.$this->getName(), '', KRequest::base()));

		//create the configuration object
		$this->_loadConfiguration(JPATH_CONFIGURATION.DS.$config['config_file']);

		//set defines
		define('JPATH_CACHE', $this->getCfg('cache_path', JPATH_ROOT.'/cache'));

		//Set the session autostart
		if(!isset($config['session_autostart'])) {
			 $config['session_autostart'] = !is_null($this->getCfg('session_autostart')) ? $this->getCfg('session_autostart') :  true;
		}

		//create the session if a session name is passed
		if($config['session'] !== false) {
			$this->_loadSession(JUtility::getHash($config['session_name']), false, $config['session_autostart']);
		}

		//create the site
		if(isset($config['multisite']) && $config['multisite'] == true)
		{
	        //Set the session default name
		    if(!isset($config['site'])) {
			    $config['site'] = 'default';
		    }

		    $this->_loadSite($config['site']);
		}

		$this->set( 'requestTime', gmdate('Y-m-d H:i') );
	}
 /**
  * Custom JError callback
  *
  * Push the exception call stack in the JException returned through the call back
  * adn then rener the custom error page
  *
  * @param object A JException object
  * @return void
  */
 public function errorHandler($error)
 {
     $error->setProperties(array('backtrace' => $this->_exception->getTrace(), 'file' => $this->_exception->getFile(), 'line' => $this->_exception->getLine()));
     if (JFactory::getConfig()->getValue('config.debug')) {
         $error->set('message', (string) $this->_exception);
     } else {
         $error->set('message', KHttpResponse::getMessage($error->get('code')));
     }
     if ($this->_exception->getCode() == KHttpResponse::UNAUTHORIZED) {
         header('WWW-Authenticate: Basic Realm="' . KRequest::base() . '"');
     }
     //Make sure the buffers are cleared
     while (@ob_get_clean()) {
     }
     JError::customErrorPage($error);
 }
示例#12
0
 public function display()
 {
     $user = KFactory::tmp('lib.joomla.user', array(KRequest::get('get.userid', 'int')));
     if ($user->username == KRequest::get('get.username', 'string')) {
         $targets = KFactory::tmp('site::com.stream.model.targets')->getList()->getData();
         $thing = reset($targets);
         $string = substr($thing['title'], 3);
         $option = strtolower(substr($string, 0, stripos($string, 'controller')));
         $view = strtolower(substr($string, stripos($string, 'controller') + 10));
         $model = KInflector::pluralize($view);
         $list = KFactory::tmp('site::com.' . $option . '.model.' . $model)->userid($user->id)->getList()->getData();
         $array = array();
         foreach ($list as $item) {
             $array[] = $item['id'];
         }
         //Get the list of posts
         $activities = KFactory::get($this->getModel())->set('parent_target_id', KRequest::get('get.parent_target_id', 'int'))->getList();
         $doc =& JFactory::getDocument();
         foreach ($activities as $activity) {
             if (!in_array($activity->parent_target_id, $array)) {
                 continue;
             }
             $date = new KDate();
             $date->setDate($activity->created_on);
             $currentDay == $date->format('%d %B');
             $user = KFactory::tmp('lib.joomla.user', array('id' => $activity->created_by));
             $string = substr($activity->controller, 3);
             $option = strtolower(substr($string, 0, stripos($string, 'controller')));
             $view = strtolower(substr($string, stripos($string, 'controller') + 10));
             $link = '';
             if ($activity->action != 'delete') {
                 $link = KRequest::base() . '/index.php?option=com_' . $option . '&view=' . $view . '&id=' . $activity->target_id . '&project_id=' . $activity->parent_target_id . '&Itemid=2';
             }
             $description = '<i>' . JText::_($activity->controller . '-' . $activity->action) . '</i>';
             $description .= ' ' . $activity->target_title;
             //add the parent name in the description, if I'm not in a specialized view
             if (!KRequest::get('get.parent_target_id', 'int')) {
                 $targets = KFactory::tmp('site::com.stream.model.targets')->getList()->getData();
                 $thing = reset($targets);
                 $string = substr($thing['title'], 3);
                 $option = strtolower(substr($string, 0, stripos($string, 'controller')));
                 $view = strtolower(substr($string, stripos($string, 'controller') + 10));
                 $model = KInflector::pluralize($view);
                 $data = KFactory::tmp('site::com.' . $option . '.model.' . $model)->id($activity->parent_target_id)->getItem();
                 $description .= '<strong>' . $data->title . '</strong>';
             }
             $date = new KDate();
             $date->setDate($activity->created_on);
             $item = new JFeedItem();
             $item->title = $activity->target_title;
             $item->link = $link . '&param=' . $activity->created_on;
             $item->description = $description;
             $item->date = $date->format('%d %B %Y, %R');
             $item->category = '';
             $item->authorEmail = '';
             $item->author = '';
             $user = KFactory::tmp('lib.joomla.user', array('id' => $activity->created_by));
             if ($user->id) {
                 $item->authorEmail = $user->email;
                 $item->author = $user->name;
             }
             // loads item info into rss array
             $doc->addItem($item);
         }
         $doc->link = $this->createRoute('format=html&view=activities');
     }
 }
示例#13
0
文件: error.php 项目: stonyyi/anahita
defined('_JEXEC') or die('Restricted access');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php 
echo $this->language;
?>
" lang="<?php 
echo $this->language;
?>
" dir="<?php 
echo $this->direction;
?>
" >
<head>
	<link rel="stylesheet" href="<?php 
print KRequest::base();
?>
/templates/system/css/error.css" type="text/css" />
</head>
<body>
	<table width="550" align="center" class="outline">
	<tr>
		<td align="center">
			<h1>
				<?php 
echo $this->error->getCode();
?>
 - <?php 
echo JText::_('An error has occurred');
?>
		</td>
示例#14
0
 protected function _getAsset($asset, $url, $extension = null)
 {
     if (!$extension) {
         $extension = KRequest::get('get.option', 'cmd');
     }
     $template = KFactory::get('lib.joomla.application')->getTemplate();
     $isMorph = $template == 'morph';
     $custom = '/images/' . $extension . $url;
     $framework = '/media/plg_koowa/' . $asset . $url;
     $fallback = '/media/com_ninja/' . $asset . $url;
     $default = '/media/' . $extension . '/' . $asset . $url;
     $overriden = '/templates/' . $template . '/' . $asset . '/' . $extension . $url;
     if ($isMorph) {
         $overriden = '/templates/' . $template . '/core/' . $asset . '/' . $extension . $url;
         if (class_exists('Morph')) {
             $themelet = '/morph_assets/themelets/' . Morph::getInstance()->themelet . '/' . $asset . '/' . $extension . $url;
         } else {
             $themelet = null;
         }
     }
     //Maybe support more types of assets for $custom in the future
     if ($asset == 'images' && file_exists(JPATH_ROOT . $custom)) {
         return KRequest::root() . $custom;
     } elseif ($isMorph && file_exists(JPATH_ROOT . $themelet)) {
         return KRequest::root() . $themelet;
     } elseif (file_exists(JPATH_BASE . $overriden)) {
         return KRequest::base() . $overriden;
     } elseif (file_exists(JPATH_ROOT . $default)) {
         return KRequest::root() . $default;
     } elseif (file_exists(JPATH_ROOT . $fallback)) {
         return KRequest::root() . $fallback;
     } elseif (file_exists(JPATH_ROOT . $framework)) {
         return KRequest::root() . $framework;
     }
     return false;
 }