示例#1
0
 /**
  * Method to store the data to cache
  * 
  * @param mixed $data
  * @return bool
  */
 public function store($data)
 {
     $data = MageBridgeModelBridgeBlock::getInstance()->decode($data);
     $data = MageBridgeModelBridgeBlock::getInstance()->filterHtml($data);
     return parent::store($data);
 }
 public function getBlock($block_name, $arguments = null)
 {
     return MageBridgeModelBridgeBlock::getInstance()->getBlock($block_name, $arguments);
 }
示例#3
0
 public function getBlock($block_name, $arguments = null)
 {
     // Make sure the bridge is built
     MageBridgeModelBridge::getInstance()->build();
     // Get the response-data
     $segment = $this->getResponse('block', $block_name, $arguments);
     if (!isset($segment['data'])) {
         return null;
     }
     // Parse the response-data
     $block_data = $segment['data'];
     if (!empty($block_data)) {
         if (!isset($segment['cache'])) {
             $block_data = self::decode($block_data);
             $block_data = self::filterHtml($block_data);
         }
     }
     // Replace Joomla! jdoc:include tags
     if (MagebridgeModelConfig::load('enable_jdoc_tags') == 1) {
         $block_data = MageBridgeBlockHelper::parseBlock($block_data);
     }
     // Run Content Plugins on this block-html
     if (MagebridgeModelConfig::load('enable_content_plugins') == 1) {
         // Prepare a simple item (like an article) for use with Content Plugins
         $item = (object) null;
         $item->text = $block_data;
         // Get a list of all Content Plugins except MageBridge plugins
         $plugins = MageBridgeModelBridgeBlock::getContentPlugins();
         if (!empty($plugins)) {
             foreach ($plugins as $plugin) {
                 JPluginHelper::importPlugin('content', $plugin);
             }
         }
         // Once the plugins are imported, trigger the content-event
         $dispatcher = JDispatcher::getInstance();
         if (MageBridgeHelper::isJoomla15()) {
             $item->params = new JParameter(null);
             $result = $dispatcher->trigger('onPrepareContent', array(&$item, &$item->params, 0));
         } else {
             jimport('joomla.html.parameter');
             $item->params = new JParameter(null);
             $result = $dispatcher->trigger('onContentPrepare', array('com_magebridge.block', &$item, &$item->params, 0));
         }
         // Move the modified contents into $block_data
         $block_data = $item->text;
         unset($item);
     }
     // Filter the block throw the "magebridge" plugin group
     if (MagebridgeModelConfig::load('enable_block_rendering') == 1) {
         JPluginHelper::importPlugin('magebridge');
         JFactory::getApplication()->triggerEvent('onBeforeDisplayBlock', array(&$block_name, $arguments, &$block_data));
     }
     return $block_data;
 }
示例#4
0
 public function store($data)
 {
     $data = MageBridgeModelBridgeBlock::decode($data);
     $data = MageBridgeModelBridgeBlock::filterHtml($data);
     return parent::store($data);
 }
 /**
  * Handle the event that is generated when an user tries to login
  * 
  * @access public
  * @param string $context
  * @param object $row
  * @param string $params
  * @param mixed $page
  * @return null
  */
 public function onContentPrepare($context, $row, $params, $page)
 {
     // Do not continue if not enabled
     if ($this->isEnabled() == false) {
         return false;
     }
     // Get system variables
     $bridge = MageBridgeModelBridge::getInstance();
     // Load plugin paramaters
     jimport('joomla.html.parameter');
     $plugin = JPluginHelper::getPlugin('content', 'magebridgetags');
     $pluginParams = new JParameter($plugin->params);
     $max = $pluginParams->get('max_products', 10);
     // Find related data
     $tags = $this->getTags($row);
     // If there are no tags, don't do anything
     if (empty($tags)) {
         return false;
     }
     // Build the bridge
     $segment_id = $bridge->register('api', 'magebridge_tag.list', $tags);
     $bridge->build();
     $products = $bridge->getSegmentData($segment_id);
     // Do not continue if the result is empty
     if (empty($products)) {
         return false;
     }
     // Do not continue if the result is not an array
     if (!is_array($products)) {
         MageBridgeModelDebug::getInstance()->error("Fetching tags resulted in non-array: " . var_export($products, true));
         return false;
     }
     // Only show the needed amount of tags
     $products = array_slice($products, 0, $max);
     // Load the template script (and allow for overrides)
     jimport('joomla.filesystem.path');
     $template_dir = JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate();
     // Determine the right folder
     if (is_dir(dirname(__FILE__) . '/tmpl')) {
         $tmplDir = 'tmpl';
     } else {
         $tmplDir = 'magebridgetags';
     }
     // Load the layout file
     $layout = $template_dir . '/html/plg_magebridgetags/default.php';
     if (!is_file($layout) || !is_readable($layout)) {
         $layout = dirname(__FILE__) . '/' . $tmplDir . '/default.php';
     }
     // Prepare the variables
     $tagstring = implode(', ', $tags);
     // Read the template
     ob_start();
     include $layout;
     $output = ob_get_contents();
     ob_end_clean();
     // Append the result to the content
     $row->text .= MageBridgeModelBridgeBlock::filterHtml($output);
     return true;
 }
 public static function getBlockData($block_name)
 {
     return MageBridgeModelBridgeBlock::getInstance()->getBlock($block_name);
 }