Ejemplo n.º 1
0
 /**
  *
  * @param \RokSprocket_ItemCollection $items
  *
  * @return string the html to be rendered
  */
 public function render(RokSprocket_ItemCollection $items)
 {
     // get the layout
     $layout_name = $this->params->get('layout');
     $layout_service = $this->container[sprintf('roksprocket.layouts.%s.service', $layout_name)];
     // add the layout classpath
     $layout_lib_path = $this->container[sprintf('roksprocket.layouts.%s.library.paths', $layout_name)];
     foreach ($layout_lib_path as $lib_path) {
         RokCommon_ClassLoader::addPath($lib_path);
     }
     /** @var $i18n RokCommon_I18N */
     $i18n = $this->container->i18n;
     $layout_lang_paths = $this->container[sprintf('roksprocket.layouts.%s.paths', $layout_name)];
     foreach ($layout_lang_paths as $lang_path) {
         @$i18n->loadLanguageFiles('roksprocket_layout_' . $layout_name, $lang_path);
     }
     /** @var $layout RokSprocket_Layout */
     $layout = $this->container->{$layout_service};
     $layout->initialize($items, $this->params);
     $this->renderGlobalHeaders();
     $layout->renderLayoutHeaders();
     $layout->renderInstanceHeaders();
     ob_start();
     echo $layout->renderBody();
     return ob_get_clean();
 }
Ejemplo n.º 2
0
 /**
  * @param $model
  * @param $action
  * @param $params
  *
  * @return string
  */
 public static function run($model, $action, $params)
 {
     // Set up an independent AJAX error handler
     set_error_handler(array('RokCommon_Ajax', 'error_handler'));
     set_exception_handler(array('RokCommon_Ajax', 'exception_handler'));
     while (@ob_end_clean()) {
     }
     // clean any pending output buffers
     ob_start();
     // start a fresh one
     $result = null;
     try {
         /** @var RokCommon_Ajax_ModelLoader $ajaxModelLoader  */
         $ajaxModelLoader = RokCommon_ClassLoader::getLoader('AjaxModels');
         // get a model class instance
         $modelInstance = $ajaxModelLoader->getModel($model);
         $decoded_params = json_decode($params);
         if (null == $decoded_params && strlen($params) > 0) {
             throw new RokCommon_Ajax_Exception('Invalid JSON for params');
         }
         // set the result to the run
         $result = $modelInstance->run($action, $decoded_params);
     } catch (Exception $ae) {
         $result = new RokCommon_Ajax_Result();
         $result->setAsError();
         $result->setMessage($ae->getMessage());
     }
     $encoded_result = json_encode($result);
     // restore normal error handling;
     restore_error_handler();
     restore_exception_handler();
     return $encoded_result;
 }
Ejemplo n.º 3
0
 /**
  * @static
  * @return RokCommon_ClassLoader
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new RokCommon_ClassLoader();
         self::_setupDefaultLoader();
     }
     return self::$_instance;
 }
Ejemplo n.º 4
0
 /**
  * @param $params
  *  {
  *  "page":1,
  *  "moduleid": 86
  *  }
  *
  * @return RokCommon_Ajax_Result
  */
 public function getPage($params)
 {
     $result = new RokCommon_Ajax_Result();
     try {
         $html = '';
         $container = RokCommon_Service::getContainer();
         /** @var $platformHelper RokSprocket_PlatformHelper */
         $platformHelper = $container->roksprocket_platformhelper;
         $module_params = $platformHelper->getModuleParameters($params->moduleid);
         // add the layout classpath
         $layout_lib_path = $container['roksprocket.layouts.grids.library.paths'];
         foreach ($layout_lib_path as $lib_path) {
             RokCommon_ClassLoader::addPath($lib_path);
         }
         $container = RokCommon_Service::getContainer();
         /** @var $platformHelper RokSprocket_PlatformHelper */
         $platformHelper = $container->roksprocket_platformhelper;
         $items = $platformHelper->getFromCache(array('RokSprocket', 'getItemsWithParams'), array($params->moduleid, $module_params, true), $module_params, $params->moduleid);
         /** @var $layout RokSprocket_Layout_Grids */
         $layout = $container->getService('roksprocket.layout.grids');
         $layout->initialize($items, $module_params);
         $items = $layout->getItems();
         $provider_type = $module_params->get('provider', 'joomla');
         $sort_type = $module_params->get($provider_type . '_sort', 'automatic');
         if ($sort_type == RokSprocket_ItemCollection::SORT_METHOD_RANDOM) {
             $items->sort($sort_type);
         }
         $limit = $module_params->get('display_limit', '∞');
         if ($limit != '∞' && (int) $limit > 0) {
             $items = $items->trim($limit);
         }
         $offset = ($params->page - 1) * $module_params->get('grids_items_per_page', 1);
         $items = $items->slice($offset, $module_params->get('grids_items_per_page', 1));
         $items = $platformHelper->processItemsForEvents($items, $module_params);
         $themecontext = $layout->getThemeContent();
         ob_start();
         $index = 0;
         foreach ($items as $item) {
             echo $themecontext->load('item.php', array('item' => $item, 'parameters' => $module_params, 'index' => $index));
             $index++;
         }
         $html .= ob_get_clean();
         $html = $platformHelper->processOutputForEvents($html, $module_params);
         $result->setPayload(array('html' => $html, 'page' => $params->page));
     } catch (Exception $e) {
         throw $e;
     }
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * @param \RokCommon_XMLElement $xml_node
  *
  * @throws \RokCommon_Config_Exception
  */
 protected function initialize(RokCommon_XMLElement $xml_node)
 {
     $this->xml_node = $xml_node;
     // get the name of the entry
     if (!isset($this->xml_node['name'])) {
         throw new RokCommon_Config_Exception(rc__('Meta Config entry in %s does not have a name', $this->parent_identifier));
     }
     $this->name = (string) $this->xml_node['name'];
     // set the identifier name
     $id_parts = explode(self::ENTRY_SEPERATOR, $this->parent_identifier);
     $id_parts[] = $this->name;
     $this->identifier = implode(self::ENTRY_SEPERATOR, $id_parts);
     // get the filename of the entry
     if (!isset($this->xml_node['filename'])) {
         throw new RokCommon_Config_Exception(rc__('Meta Config entry %s does not have a filename', $this->identifier));
     }
     $this->filename = (string) $this->xml_node['filename'];
     // get the mode
     if (isset($this->xml_node['mode'])) {
         $this->mode = (string) $this->xml_node['mode'];
     }
     // get the jointype
     if (isset($this->xml_node['jointype'])) {
         $this->jointype = (string) $this->xml_node['jointype'];
     }
     // see if there is a library and add it to the lib path
     $library_paths = $xml_node->xpath('libraries/library');
     if ($library_paths) {
         foreach ($library_paths as $library_path) {
             $resolved_lib_path = RokCommon_Config::replaceTokens((string) $library_path, dirname($this->root_file));
             if (is_dir($resolved_lib_path)) {
                 RokCommon_ClassLoader::addPath($resolved_lib_path);
             }
         }
     }
     // get the paths for the config
     $paths = $xml_node->xpath('paths/path');
     if (!$paths) {
         throw new RokCommon_Config_Exception(rc__('Meta Config entry %s must have at least one path.', $this->identifier));
     }
     foreach ($paths as $path_entry) {
         $priority = RokCommon_Composite::DEFAULT_PRIORITY;
         if (isset($path_entry['priority'])) {
             $priority = (string) $path_entry['priority'];
         }
         $path = RokCommon_Config::replaceTokens((string) $path_entry, dirname($this->root_file));
         if (is_dir($path)) {
             // see if there is a testservice entry
             if (isset($path_entry['testservice'])) {
                 // see if the testservice extists
                 $testservice_name = (string) $path_entry['testservice'];
                 $container = RokCommon_Service::getContainer();
                 /** @var $testservice RokCommon_Config_PathTest */
                 $testservice = $container->{$testservice_name};
                 if (!$container->hasService($testservice_name)) {
                     throw new RokCommon_Config_Exception(rc__('Path test service %s does not exist', $testservice_name));
                 }
                 // see if we can add the
                 if ($testservice->isPathAvailable()) {
                     $this->addPath($path, $priority);
                 }
             } else {
                 // add the path if there is no testclass
                 $this->addPath($path, $priority);
             }
         } else {
             // TODO log unable to find path
         }
     }
     // add any subconfigs
     $subconfigs = $xml_node->xpath('subconfigs/subconfig');
     if ($subconfigs) {
         foreach ($subconfigs as $subconfig_entry) {
             $subconfig = new self($this->identifier, $this->root_file, $subconfig_entry);
             $this->subentries[$subconfig->getName()] = $subconfig;
         }
     }
     $this->context = RokCommon_Composite::get($this->identifier);
 }
Ejemplo n.º 6
0
    if (!defined('ROKCOMMON_LIB_PATH')) {
        define('ROKCOMMON_LIB_PATH', rokcommon_cleanPath(dirname(__FILE__)));
    }
    if (!defined('DS')) {
        define('DS', DIRECTORY_SEPARATOR);
    }
    // Check to see if there is a requiments file and run it.
    // Catch any exceptions and log them as errors.
    $requirements_file = rokcommon_cleanPath(ROKCOMMON_LIB_PATH . '/requirements.php');
    if (file_exists($requirements_file)) {
        try {
            require_once $requirements_file;
        } catch (Exception $e) {
            return;
        }
    }
    define('ROKCOMMON', '3.1.11');
    define('ROKCOMMON_CORE_DEBUG', true);
    // Bootstrap the base classloader and overrides
    require_once rokcommon_cleanPath(ROKCOMMON_LIB_PATH . '/RokCommon/ClassLoader.php');
    RokCommon_ClassLoader::getInstance();
    $container = RokCommon_Service::getContainer();
    $container->classloader;
    // load up the supporting functions
    $functions_path = rokcommon_cleanPath(ROKCOMMON_LIB_PATH . '/functions.php');
    if (file_exists($functions_path)) {
        require_once $functions_path;
    }
    RokCommon_Composite::addPackagePath('rc_context_path', ROKCOMMON_LIB_PATH);
}
return "ROKCOMMON_LIB_INCLUDED";
Ejemplo n.º 7
0
 /**
  * @static
  *
  * @param  $path
  *
  * @return void
  */
 public static function addModelPath($path)
 {
     $self = self::getInstance();
     RokCommon_ClassLoader::addPath($path);
     Doctrine_Core::loadModels($path);
 }
Ejemplo n.º 8
0
/**
 * @version   $Id: mod_roksprocket.php 19251 2014-02-27 21:49:01Z btowles $
 * @author    RocketTheme http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - 2015 RocketTheme, LLC
 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */
// no direct access
defined('_JEXEC') or die;
try {
    if (defined('ROKSPROCKET')) {
        $lang = JFactory::getLanguage();
        $lang->load('com_roksprocket', JPATH_BASE, $lang->getDefault(), false, false);
        $lang->load('com_roksprocket', JPATH_BASE, null, false, false);
        $lang->load('com_roksprocket', JPATH_SITE . '/components/com_roksprocket', $lang->getDefault(), false, false);
        $lang->load('com_roksprocket', JPATH_SITE . '/components/com_roksprocket', null, false, false);
        RokCommon_ClassLoader::addPath(dirname(__FILE__) . '/lib');
        $container = RokCommon_Service::getContainer();
        foreach ($container['roksprocket.layouts'] as $type => $layoutinfo) {
            foreach ($layoutinfo->paths as $layoutpath) {
                if (is_dir($layoutpath . '/language')) {
                    $lang->load('roksprocket_layout_' . $type, $layoutpath, $lang->getDefault(), true, false);
                    $lang->load('roksprocket_layout_' . $type, $layoutpath, null, true, false);
                }
            }
        }
        /** @var $logger logger */
        $logger = $container->logger;
        $module_parameters = RokCommon_Registry_Converter::convert($params);
        $module_parameters->set('module_id', $module->id);
        $roksprocket = new ModRokSprocket($module_parameters);
        $items = $roksprocket->getData();
Ejemplo n.º 9
0
 /**
  * @param $params
  *  {
  *  "page":1,
  *  "moduleid": 86
  *  }
  *
  * @return RokCommon_Ajax_Result
  */
 public function getPage($params)
 {
     $result = new RokCommon_Ajax_Result();
     try {
         $html = '';
         $container = RokCommon_Service::getContainer();
         /** @var $platformHelper RokSprocket_PlatformHelper */
         $platformHelper = $container->roksprocket_platformhelper;
         $module_params = $platformHelper->getModuleParameters($params->moduleid);
         // add the layout classpath
         $layout_lib_path = $container['roksprocket.layouts.mosaic.library.paths'];
         foreach ($layout_lib_path as $lib_path) {
             RokCommon_ClassLoader::addPath($lib_path);
         }
         $container = RokCommon_Service::getContainer();
         /** @var $platformHelper RokSprocket_PlatformHelper */
         $platformHelper = $container->roksprocket_platformhelper;
         $items = $platformHelper->getFromCache(array('RokSprocket', 'getItemsWithParams'), array($params->moduleid, $module_params, true, false, $params->displayed), $module_params, $params->moduleid);
         /** @var $layout RokSprocket_Layout_Mosaic */
         $layout = $container->getService('roksprocket.layout.mosaic');
         $layout->initialize($items, $module_params);
         $items = $layout->getItems();
         if (isset($params->filter) && $params->filter && $params->filter != 'all') {
             $filtered = new RokSprocket_ItemCollection();
             foreach ($items as $item) {
                 if ($this->in_arrayi($params->filter, $item->getTags())) {
                     $filtered->addItem($item);
                 }
             }
             $items = $filtered;
         }
         $total_items = count($items);
         $limit = $module_params->get('display_limit', '∞');
         $per_page = $module_params->get('mosaic_items_per_page', 1);
         $displayed_items = isset($params->displayed) ? count($params->displayed) : 0;
         $new_limit = (int) $limit > (int) $displayed_items ? (int) $limit - (int) $displayed_items : 0;
         $original_total = $displayed_items + $total_items;
         //trim to allowed limit
         if ($limit != '∞' && (int) $new_limit > 0 && $total_items > $new_limit) {
             $items = $items->trim($new_limit);
         }
         //trim if showing only next page
         if (!isset($params->all) && count($items) > $per_page) {
             $items = $items->trim($per_page);
         }
         $items = $platformHelper->processItemsForEvents($items, $module_params);
         $more = true;
         if (isset($params->all) && $params->all) {
             //showing all
             $more = false;
         }
         if ($limit != '∞' && $displayed_items + count($items) >= $limit) {
             //limit is met
             $more = false;
         }
         if ($displayed_items + count($items) >= $original_total) {
             //all have been shown
             $more = false;
         }
         $provider_type = $module_params->get('provider', 'joomla');
         $sort_type = $module_params->get($provider_type . '_sort', 'automatic');
         if ($sort_type == RokSprocket_ItemCollection::SORT_METHOD_RANDOM) {
             $items->sort($sort_type);
         }
         $themecontext = $layout->getThemeContent();
         ob_start();
         $index = 0;
         $displayed = $params->displayed;
         foreach ($items as $item_id => &$item) {
             echo $themecontext->load('item.php', array('item' => $item, 'parameters' => $module_params, 'index' => $index));
             array_push($displayed, (int) $item->getId());
             $index++;
         }
         $html .= ob_get_clean();
         $html = $platformHelper->processOutputForEvents($html, $module_params);
         $result->setPayload(array('page' => $params->page, 'more' => $more, 'behavior' => $params->behavior, 'displayed' => $displayed, 'html' => $html));
     } catch (Exception $e) {
         throw $e;
     }
     return $result;
 }
Ejemplo n.º 10
0
 /**
  * @static
  * @return RokCommon_Loader
  */
 public static function getInstance()
 {
     return RokCommon_ClassLoader::getLoader(self::NAME);
 }
Ejemplo n.º 11
0
 /**
  * @static
  * @return RokCommon_ClassLoader
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new RokCommon_ClassLoader();
         self::$_instance->setupBootstrap();
     }
     return self::$_instance;
 }
Ejemplo n.º 12
0
	/**
	 * @param $config_entries
	 */
	protected function registerLibraries($config_entries)
	{
		foreach ($config_entries as $config_entry) {
			if ($config_entry->type === self::ROKCOMMON_CONFIG_TYPE_LIBRARY) {
				$filepath = JPATH_SITE . $config_entry->file;
				if (is_dir($filepath)) {
					$this->logger->debug(rc__('Registering library path %s for %s', $filepath, $config_entry->extension));
					RokCommon_ClassLoader::addPath($filepath);
				} else {
					$this->logger->notice(rc__('Directory %s does not exist.  Unable to add to Class Loader ', $filepath));
				}
			}
		}
	}
Ejemplo n.º 13
0
 /**
  * @param $params
  * {
  *  "page":1,
  *  "moduleid": 86
  * }
  *
  * @return RokCommon_Ajax_Result
  */
 public function getPage($params)
 {
     $result = new RokCommon_Ajax_Result();
     try {
         $html = '';
         $container = RokCommon_Service::getContainer();
         /** @var $platformHelper RokSprocket_PlatformHelper */
         $platformHelper = $container->roksprocket_platformhelper;
         $module_params = $platformHelper->getModuleParameters($params->moduleid);
         // add the layout classpath
         $layout_lib_path = $container['roksprocket.layouts.mosaic.library.paths'];
         foreach ($layout_lib_path as $lib_path) {
             RokCommon_ClassLoader::addPath($lib_path);
         }
         $container = RokCommon_Service::getContainer();
         /** @var $platformHelper RokSprocket_PlatformHelper */
         $platformHelper = $container->roksprocket_platformhelper;
         $items = $platformHelper->getFromCache(array('RokSprocket', 'getItemsWithParams'), array($params->moduleid, $module_params, true), $module_params, $params->moduleid);
         /** @var $layout RokSprocket_Layout_Mosaic */
         $layout = $container->getService('roksprocket.layout.mosaic');
         $layout->initialize($items, $module_params);
         $items = $layout->getItems();
         if (isset($params->filter) && $params->filter && $params->filter != 'all') {
             $filtered = new RokSprocket_ItemCollection();
             foreach ($items as $item) {
                 $tags = $item->getParam('mosaic_item_tags', '');
                 $tags = explode(",", $tags);
                 foreach ($tags as $i => $tag) {
                     $cleanName = trim($tag);
                     $tags[$i] = str_replace(' ', '-', str_replace(array("'", '"'), '', $cleanName));
                 }
                 if (in_array($params->filter, $tags)) {
                     $filtered->addItem($item);
                 }
             }
             $items = $filtered;
         }
         $total_items = count($items);
         $provider_type = $module_params->get('provider', 'joomla');
         $sort_type = $module_params->get($provider_type . '_sort', 'automatic');
         if ($sort_type == RokSprocket_ItemCollection::SORT_METHOD_RANDOM) {
             $items->sort($sort_type);
         }
         $limit = $module_params->get('display_limit', '∞');
         if ($limit != '∞' && (int) $limit > 0) {
             $items = $items->trim($limit);
         }
         $per_page = $module_params->get('mosaic_items_per_page', 1);
         $offset = ($params->page - 1) * $per_page;
         if (isset($params->all) && $params->all) {
             $items = $items->slice($offset, $total_items);
         } else {
             $items = $items->slice($offset, $per_page);
         }
         $items = $platformHelper->processItemsForEvents($items, $module_params);
         $more = isset($params->all) && $params->all ? false : $params->page < ceil($total_items / $per_page);
         $themecontext = $layout->getThemeContent();
         ob_start();
         $index = 0;
         foreach ($items as $item) {
             echo $themecontext->load('item.php', array('item' => $item, 'parameters' => $module_params, 'index' => $index));
             $index++;
         }
         $html .= ob_get_clean();
         $result->setPayload(array('page' => $params->page, 'more' => $more, 'behavior' => $params->behavior, 'html' => $html));
     } catch (Exception $e) {
         throw $e;
     }
     return $result;
 }
Ejemplo n.º 14
0
<?php

/**
 * @version   $Id: include.php 48519 2012-02-03 23:18:52Z btowles $
 * @author    RocketTheme http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - ${copyright_year} RocketTheme, LLC
 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */
if (!defined('ROKCOMMON')) {
    define('ROKCOMMON_ROOT_PATH', dirname(__FILE__));
    if (!defined('DS')) {
        define('DS', DIRECTORY_SEPARATOR);
    }
    if (($loaderrors = (require_once ROKCOMMON_ROOT_PATH . '/requirements.php')) !== true) {
        return $loaderrors;
    }
    define('ROKCOMMON', '2.6.5');
    // Bootstrap the base classloader and overrides
    require_once ROKCOMMON_ROOT_PATH . '/RokCommon/ClassLoader.php';
    RokCommon_ClassLoader::addPath(ROKCOMMON_ROOT_PATH . '/Overrides');
    // load up the supporting functions
    require_once ROKCOMMON_ROOT_PATH . '/functions.php';
}
return "ROKCOMMON_LIB_INCLUDED";