function onDisplayFieldValue(&$field, $item, $values = null, $prop = 'display') { // execute the code only if the field type match the plugin type if ($field->field_type != 'quick2cart') { return; } jimport('joomla.filesystem.file'); if (JFile::exists(JPATH_SITE . '/components/com_quick2cart/quick2cart.php')) { $mainframe = JFactory::getApplication(); $lang = JFactory::getLanguage(); $lang->load('com_quick2cart'); $comquick2cartHelper = new comquick2cartHelper(); $output = $comquick2cartHelper->getBuynow($item->id, "com_flexicontent"); } $field->{$prop} = $output; }
function onK2AfterDisplayContent(&$item, &$params, $limitstart) { // Add Language file. $lang = JFactory::getLanguage(); $lang->load('com_quick2cart', JPATH_SITE); jimport('joomla.filesystem.file'); if (!JFile::exists(JPATH_SITE . '/components/com_quick2cart/quick2cart.php')) { return true; } $path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helper.php'; if (!class_exists('comquick2cartHelper')) { // require_once $path; JLoader::register('comquick2cartHelper', $path); JLoader::load('comquick2cartHelper'); } $mainframe = JFactory::getApplication(); $lang = JFactory::getLanguage(); $lang->load('com_quick2cart'); $comquick2cartHelper = new comquick2cartHelper(); $output = $comquick2cartHelper->getBuynow($item->id, 'com_k2'); return $output; }
/** * J1.7 * Plugin that loads module positions within content * * @param * string The context of the content being passed to the plugin. * @param * object The article object. Note $article->text is also * available * @param * object The article params * @param * int The 'page' number */ public function onContentPrepare($context, &$article, &$params, $page = 0) { $clientdetails = explode(".", $context); $client = $clientdetails[0]; if ($client != "com_content") { return; } $mainframe = JFactory::getApplication(); $lang = JFactory::getLanguage(); $lang->load('com_quick2cart'); $btn_pos_method = $this->params->get('btn_pos_method'); if ($btn_pos_method == 'data_tag') { jimport('joomla.filesystem.file'); if (!class_exists('JFolder')) { jimport('joomla.filesystem.folder'); } if (JFolder::exists(JPATH_ROOT . '/components/com_quick2cart')) { // Don't run this plugin when the content is being indexed if ($context == 'com_finder.indexer') { return true; } // simple performance check to determine whether bot should // process further if (strpos($article->text, 'loadquick2cart') === false) { return true; } // expression to search for (datatag) eg. {loadquick2cart id=3} // $regex = '/{loadquick2cart/i'; $regex = '/{loadquick2cart\\s+(.*?)}/i'; // Find all instances of plugin and put in $matches for // loadposition // $matches[0] is full pattern match, $matches[1] is the // position preg_match_all($regex, $article->text, $matches, PREG_SET_ORDER); // No matches, skip this if ($matches) { foreach ($matches as $match) { $vars = new stdClass(); $pcs = explode('=', $match[1]); $vars->product_id = $pcs[1]; $comquick2cartHelper = new comquick2cartHelper(); $output = $comquick2cartHelper->getBuynow($vars->product_id, "com_content"); // We should replace only first occurrence in order to // allow positions with the same name to regenerate // their content: $article->text = preg_replace("{" . $match[0] . "}", addcslashes($output, '\\$'), $article->text, 1); } } } } // End data_tag if return true; }