function display($tpl = null) { $db = JFactory::getDBO(); if ($field = JRequest::getVar('field')) { if (strpos($field, 'plugin') !== false) { if (JVM_VERSION === 1) { $table = '#__plugins'; //$ext_id = 'id'; } else { $table = '#__extensions'; //$ext_id = 'extension_id'; } $field = substr($field, 6); $q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `element` = "' . $field . '"'; $db->setQuery($q); $this->plugin = $db->loadObject(); if (!class_exists('vmParameters')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'parameterparser.php'; } $parameters = new vmParameters($this->plugin, $this->plugin->element, 'plugin', 'vmuserfield'); $lang = JFactory::getLanguage(); $filename = 'plg_vmuserfield_' . $this->plugin->element; if (VmConfig::get('enableEnglish', 1)) { $lang->load($filename, JPATH_ADMINISTRATOR, 'en-GB', true); } $lang->load($filename, JPATH_ADMINISTRATOR, $lang->getDefault(), true); $lang->load($filename, JPATH_ADMINISTRATOR, null, true); echo $parameters->render(); //echo '<input type="hidden" value="'.$this->plugin->element.'" name="custom_value">'; jExit(); } } jExit(); }
function display($tpl = null) { $db = JFactory::getDBO(); if ($field = JRequest::getVar('field')) { if (strpos($field, 'plugin') !== false) { if (JVM_VERSION === 1) { $table = '#__plugins'; //$ext_id = 'id'; } else { $table = '#__extensions'; //$ext_id = 'extension_id'; } $field = substr($field, 6); $q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `element` = "' . $field . '"'; $db->setQuery($q); $this->plugin = $db->loadObject(); $this->loadHelper('parameterparser'); $parameters = new vmParameters($this->plugin, $this->plugin->element, 'plugin', 'vmuserfield'); $lang = JFactory::getLanguage(); $filename = 'plg_vmuserfield_' . $this->plugin->element; $lang->load($filename, JPATH_ADMINISTRATOR); echo $parameters->render(); //echo '<input type="hidden" value="'.$this->plugin->element.'" name="custom_value">'; jExit(); } } jExit(); }
function parseParams($ext) { $path = JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'ext' . DS . $ext; $params = null; if (file_exists($path . DS . 'extension.config.php')) { $txt = file_get_contents($path . DS . 'extension.config.php'); $params = vmParameters::parse($txt); } return $params; }
function display($tpl = null) { $db = JFactory::getDBO(); if ($virtuemart_media_id = JRequest::getInt('virtuemart_media_id')) { //$db = JFactory::getDBO(); $query = 'SELECT `file_url`,`file_title` FROM `#__virtuemart_medias` where `virtuemart_media_id`=' . $virtuemart_media_id; $db->setQuery($query); $json = $db->loadObject(); if (isset($json->file_url)) { $json->file_url = JURI::root() . $json->file_url; $json->msg = 'OK'; echo json_encode($json); } else { $json->msg = '<b>' . JText::_('COM_VIRTUEMART_NO_IMAGE_SET') . '</b>'; echo json_encode($json); } } elseif ($custom_jplugin_id = JRequest::getInt('custom_jplugin_id')) { if (JVM_VERSION === 1) { $table = '#__plugins'; $ext_id = 'id'; } else { $table = '#__extensions'; $ext_id = 'extension_id'; } $q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `' . $ext_id . '` = "' . $custom_jplugin_id . '"'; $db->setQuery($q); $this->plugin = $db->loadObject(); if (!class_exists('vmParameters')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'parameterparser.php'; } $parameters = new vmParameters($this->plugin->params, $this->plugin->element, 'plugin', 'vmcustom'); if (!class_exists('vmPlugin')) { require JPATH_VM_ADMINISTRATOR . DS . 'plugins' . DS . 'vmplugin.php'; } $filename = 'plg_vmcustom_' . $this->plugin->element; vmPlugin::loadJLang($filename, 'vmcustom', $this->plugin->element); echo $parameters->render(); echo '<input type="hidden" value="' . $this->plugin->element . '" name="custom_value">'; jExit(); } jExit(); }
/** * Main Function to display Product Snapshots * * @param mosContent $row * @param JParams $params * @param int $page * @param boolean $published * @return boolean */ function handleProductSnapShot(&$row, &$params, $page = 0, $published = true) { global $mosConfig_absolute_path, $mosConfig_live_site, $database; // load default parameters if (vmIsJoomla('1.5', '>=')) { $db = JFactory::getDBO(); $plugin =& JPluginHelper::getPlugin('content', 'vmproductsnapshots'); $parameters = $plugin->params; } else { $query = "SELECT id,params FROM #__mambots WHERE element = 'vmproductsnapshots' AND folder = 'content'"; $database->setQuery($query); $mambot = $database->loadResult(); $parameters = $mambot->params; } $bot_params = new vmParameters($parameters); $param_defaults = array('id' => '0', 'enabled' => '1', 'showname' => 'y', 'showimage' => 'y', 'showdesc' => 'n', 'showprice' => 'y', 'quantity' => '1', 'showaddtocart' => 'y', 'displaylist' => 'v', 'displayeach' => 'h', 'width' => '100', 'border' => '0', 'style' => '', 'align' => ''); // get settings from admin mambot parameters foreach ($param_defaults as $key => $value) { $param_defaults[$key] = $bot_params->get($key, $value); } $enabled = $param_defaults['enabled']; if (!$published || !$enabled) { $row->text = preg_replace("/{product_snapshot:.+?}/", '', $row->text); return true; } $vm_productsnap_entrytext = $row->text; $vm_productsnap_matches = array(); if (preg_match_all("/{product_snapshot:.+?}/", $vm_productsnap_entrytext, $vm_productsnap_matches, PREG_PATTERN_ORDER) > 0) { foreach ($vm_productsnap_matches[0] as $vm_productsnap_match) { $vm_productsnap_match = str_replace("{product_snapshot:", "", $vm_productsnap_match); $vm_productsnap_match = str_replace("}", "", $vm_productsnap_match); // Get Bot Parameters $vm_productsnap_params = get_prodsnap_params($vm_productsnap_match, $param_defaults); // Get the html $showsnapshot = return_snapshot($vm_productsnap_params); $vm_productsnap_entrytext = preg_replace("/{product_snapshot:.+?}/", $showsnapshot, $vm_productsnap_entrytext, 1); } $row->text = $vm_productsnap_entrytext; } return; }
function getPclasses() { $jlang = JFactory::getLanguage(); $jlang->load('plg_vmpayment_klarna', JPATH_ADMINISTRATOR, 'en-GB', true); $jlang->load('plg_vmpayment_klarna', JPATH_ADMINISTRATOR, $jlang->getDefault(), true); $jlang->load('plg_vmpayment_klarna', JPATH_ADMINISTRATOR, NULL, true); // call klarna server for pClasses //$methodid = jrequest::getInt('methodid'); if (!class_exists('VmModel')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmmodel.php'; } $model = VmModel::getModel('paymentmethod'); $payment = $model->getPayment(); if (!class_exists('vmParameters')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'parameterparser.php'; } $parameters = new vmParameters($payment, $payment->payment_element, 'plugin', 'vmpayment'); $data = $parameters->getParamByName('data'); // echo "<pre>";print_r($data); $json = KlarnaHandler::fetchPClasses($data); ob_start(); require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'pclasses_html.php'; $json['pclasses'] = ob_get_clean(); $document = JFactory::getDocument(); $document->setMimeEncoding('application/json'); //echo json_encode($json, true); echo json_encode($json); jexit(); // echo result with tmpl ? }
/** * @param string * @return string */ function vmParseParams($txt) { return vmParameters::parse($txt); }
function renderUserfieldPlugin($element, $params) { $db = JFactory::getDBO(); if (JVM_VERSION === 1) { $table = '#__plugins'; $jelement = 'element'; } else { $table = '#__extensions'; $jelement = 'element'; } $q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `' . $jelement . '` = "' . $element . '"'; $db->setQuery($q); $this->plugin = $db->loadObject(); $this->loadHelper('parameterparser'); $parameters = new vmParameters($params, $this->plugin->element, 'plugin', 'vmuserfield'); $lang = JFactory::getLanguage(); $filename = 'plg_vmuserfield_' . $this->plugin->element; $lang->load($filename, JPATH_ADMINISTRATOR); return $parameters->render(); }
defined('JPATH_BASE') or die; require 'define.php'; $jlang = JFactory::getLanguage(); $jlang->load('plg_vmpayment_klarna', JPATH_ADMINISTRATOR, 'en-GB', true); $jlang->load('plg_vmpayment_klarna', JPATH_ADMINISTRATOR, $jlang->getDefault(), true); $jlang->load('plg_vmpayment_klarna', JPATH_ADMINISTRATOR, null, true); $total = 0; if (!class_exists('VmModel')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmmodel.php'; } $model = VmModel::getModel('paymentmethod'); $payment = $model->getPayment(); if (!class_exists('vmParameters')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'parameterparser.php'; } $parameters = new vmParameters($payment, $payment->payment_element, 'plugin', 'vmpayment'); $data = $parameters->getParamByName('data'); //vmdebug('pclasses',$data); $eid_array = KlarnaHandler::getEidSecretArray($data); foreach ($eid_array as $country => $eid_data) { try { $klarna = new Klarna_virtuemart(); $klarna->config($eid_data['eid'], $eid_data['secret'], null, null, null, $data->klarna_mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $data->klarna_mode == 'klarna_live'); $klarna->setCountry($country); $pclasses = $klarna->getPClasses(); $total = $total + count($pclasses); if (!count($pclasses) == 0) { ?> <table class="klarna_pclasses"> <thead class="klarna_pclasses_header"> <td class="pclass_id"><?php
/** * @author Patrick Kohl * @param $type * @param $name * @param $render */ function plgVmOnSelfCallFE ($type, $name, &$render) { if ($name != $this->_name || $type != 'vmpayment') { return FALSE; } //Klarna Ajax require (JPATH_VMKLARNAPLUGIN . '/klarna/helpers/klarna_ajax.php'); if (!class_exists ('VmModel')) { require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmmodel.php'); } $model = VmModel::getModel ('paymentmethod'); $payment = $model->getPayment (); if (!class_exists ('vmParameters')) { require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'parameterparser.php'); } $parameters = new vmParameters($payment, $payment->payment_element, 'plugin', 'vmpayment'); $method = $parameters->getParamByName ('data'); $country = JRequest::getWord ('country'); $country = KlarnaHandler::convertToThreeLetterCode ($country); if (!class_exists ('klarna_virtuemart')) { require (JPATH_VMKLARNAPLUGIN . '/klarna/helpers/klarna_virtuemart.php'); } $settings = KlarnaHandler::getCountryData ($method, $country); $klarna = new Klarna_virtuemart(); $klarna->config ($settings['eid'], $settings['secret'], $settings['country'], $settings['language'], $settings['currency'], KlarnaHandler::getKlarnaMode ($method, $settings['country_code_3']), VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type (), TRUE); $SelfCall = new KlarnaAjax($klarna, (int)$settings['eid'], JPATH_VMKLARNAPLUGIN, Juri::base ()); $action = JRequest::getWord ('action'); $jlang = JFactory::getLanguage (); $currentLang = substr ($jlang->getDefault (), 0, 2); $newIso = JRequest::getWord ('newIso'); if ($currentLang != $newIso) { $iso = array( "sv" => "sv-SE", "da" => "da-DK", "en" => "en-GB", "de" => "de-DE", "nl" => "nl-NL", "nb" => "nb-NO", "fi" => "fi-FI"); if (array_key_exists ($newIso, $iso)) { $jlang->load ('plg_vmpayment_klarna', JPATH_ADMINISTRATOR, $iso[$newIso], TRUE); } } echo $SelfCall->$action(); jexit (); }
<?php /** * * Description * * @package VirtueMart * @subpackage Paymentmethod * @author Max Milbers * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: edit_config.php 6043 2012-05-21 21:40:56Z Milbo $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); if ($this->payment->payment_jplugin_id) { //$parameters = new vmParameters($this->paym->payment_params, JPATH_PLUGINS.DS.'vmpayment'.DS.basename($this->paym->payment_element).'.xml', 'plugin' ); $parameters = new vmParameters($this->payment, $this->payment->payment_element, 'plugin', 'vmpayment'); echo $rendered = $parameters->render(); } else { echo JText::_('COM_VIRTUEMART_SELECT_PAYMENT_METHOD'); }
/** * Function to add a new Shopper into the Shop and Joomla * * @param array $d * @return boolean */ function add(&$d) { global $my, $auth, $mainframe, $mosConfig_absolute_path, $sess, $VM_LANG, $vmLogger, $database, $mosConfig_useractivation; $ps_vendor_id = $_SESSION["ps_vendor_id"]; $hash_secret = "VirtueMartIsCool"; $db = new ps_DB(); $timestamp = time(); if (!$this->validate_add($d)) { return False; } if (empty($my->id)) { $_POST['name'] = vmGet($d, 'first_name', 'First Name') . " " . vmGet($d, 'last_name', 'Last Name'); if (VM_REGISTRATION_TYPE == 'SILENT_REGISTRATION' || VM_REGISTRATION_TYPE == 'NO_REGISTRATION' || VM_REGISTRATION_TYPE == 'OPTIONAL_REGISTRATION' && empty($d['register_account'])) { // Silent Registration, Optional Registration with no account wanted and No Registration // means we need to create a hidden user if (vmIsJoomla('1.5')) { $username_length = 100; } else { $username_length = 25; } $silent_username = substr(str_replace('-', '_', vmGet($d, 'email')), 0, $username_length); $db->query('SELECT username FROM `#__users` WHERE username=\'' . $silent_username . '\''); $i = 0; while ($db->next_record()) { $silent_username = substr_replace($silent_username, $i, strlen($silent_username) - 1); $db->query('SELECT username FROM `#__users` WHERE username=\'' . $silent_username . '\''); $i++; } $_POST['username'] = $d['username'] = $silent_username; $_POST['password'] = $d['password'] = vmGenRandomPassword(); $_POST['password2'] = $_POST['password']; } if (VM_REGISTRATION_TYPE == 'NO_REGISTRATION' || VM_REGISTRATION_TYPE == 'OPTIONAL_REGISTRATION' && empty($d['register_account'])) { // If no user shall be registered into the global user table, we just add the registration info into the vm_user_info table // Make sure that "dummy" entries for non-existing Joomla! users won't ever have the same user_id as a future Joomla! user $db->query("SELECT MIN(user_id)-1 as uid FROM `#__{vm}_user_info`"); $db->next_record(); // Don't allow a user id of zero $uid = $db->f('uid') == 0 ? -1 : $db->f('uid'); } else { // Process the CMS registration if (vmIsJoomla('1.5')) { if (!$this->register_save()) { return false; } } else { if (!$this->saveRegistration()) { return false; } } $db->query("SELECT id FROM #__users WHERE username='******'username'] . "'"); $db->next_record(); $uid = $db->f('id'); } } else { $uid = $my->id; $d['email'] = $_POST['email'] = $my->email; $d['username'] = $_POST['username'] = $my->username; } // Prevent empty USER ID if (empty($uid)) { $vmLogger->crit("Failed to retrieve a valid USER ID when attempting to add a new user"); return false; } if (!empty($auth['user_id'])) { $db->query('SELECT user_id FROM #__{vm}_user_info WHERE user_id=' . $auth['user_id']); $db->next_record(); if ($db->f('user_id')) { return $this->update($d); } } // Get all fields which where shown to the user $userFields = ps_userfield::getUserFields('registration', false, '', true); $skipFields = ps_userfield::getSkipFields(); // Insert billto; // The first 7 fields are FIX and not built dynamically $fields = array('user_info_id' => md5(uniqid($hash_secret)), 'user_id' => $uid, 'address_type' => 'BT', 'address_type_name' => '-default-', 'cdate' => $timestamp, 'mdate' => $timestamp, 'perms' => 'shopper'); foreach ($userFields as $userField) { if (!in_array($userField->name, $skipFields)) { $fields[$userField->name] = ps_userfield::prepareFieldDataSave($userField->type, $userField->name, vmGet($d, $userField->name, strtoupper($userField->name))); // Catch a newsletter registration! if (stristr($userField->params, 'newsletter')) { if (!empty($d[$userField->name])) { require_once CLASSPATH . 'parameters.class.php'; $subscribeTo = new vmParameters($userField->params); $vmLogger->debug('Adding the user to the Newsletter.'); } } } } $fields['user_email'] = $fields['email']; unset($fields['email']); $db->buildQuery('INSERT', '#__{vm}_user_info', $fields); // Run the query now! $db->query(); // Insert vendor relationship $q = "INSERT INTO #__{vm}_auth_user_vendor (user_id,vendor_id)"; $q .= " VALUES "; $q .= "('" . $uid . "','"; $q .= $ps_vendor_id . "') "; $db->query($q); $d['shopper_group_id'] = ''; // Get the ID of the shopper group for this customer if ($d['isValidVATID']) { if (trim($d['__euvatid_field']->params) != '') { $shopper_group = new vmParameters($d['__euvatid_field']->params); $d['shopper_group_id'] = $shopper_group->get('shopper_group_id'); } } if (empty($d['shopper_group_id'])) { $q = "SELECT shopper_group_id from #__{vm}_shopper_group WHERE "; $q .= "`default`='1' "; $db->query($q); if (!$db->num_rows()) { // take the first in the table $q = "SELECT shopper_group_id from #__{vm}_shopper_group"; $db->query($q); } $db->next_record(); $d['shopper_group_id'] = $db->f("shopper_group_id"); } $customer_nr = uniqid(rand()); // Insert Shopper -ShopperGroup - Relationship $q = "INSERT INTO #__{vm}_shopper_vendor_xref "; $q .= "(user_id,vendor_id,shopper_group_id,customer_number) "; $q .= "VALUES ('{$uid}', '{$ps_vendor_id}','" . $d['shopper_group_id'] . "', '{$customer_nr}')"; $db->query($q); // Process the Newsletter subscription if (!empty($subscribeTo) && strtolower(get_class($subscribeTo)) == 'vmparameters') { switch ($subscribeTo->get('newsletter', 'letterman')) { // TODO: case 'ccnewsletter': $db->query("INSERT INTO `#__ccnewsletter_subscribers` ( `name`, `email`, `plainText`, `enabled`, `sdate`) \r\n\t\t\t\t\t\t\tVALUES('" . $d['first_name'] . " " . $d['last_name'] . "','" . $d['email'] . "', '0', '1', NOW())"); // case 'anjel': // case 'anjel': case 'letterman': default: if (file_exists($mosConfig_absolute_path . '/components/com_letterman/letterman.php')) { $db->query("INSERT INTO `#__letterman_subscribers` (`user_id`, `subscriber_name`, `subscriber_email`, `confirmed`, `subscribe_date`)\r\n\t\t\t\t\t\t\t\t\t\tVALUES('{$uid}','" . $d['first_name'] . " " . $d['last_name'] . "','" . $d['email'] . "', '1', NOW())"); } } } if (VM_REGISTRATION_TYPE == 'NO_REGISTRATION' || VM_REGISTRATION_TYPE == 'OPTIONAL_REGISTRATION' && empty($d['register_account'])) { $auth['user_id'] = $uid; $auth['username'] = $d['email']; $_SESSION['auth'] = $auth; } elseif (!$my->id && $mosConfig_useractivation == '0') { // HANDLE LOGIN if (vmIsJoomla('1.5')) { // Username and password must be passed in an array $credentials = array('username' => vmGet($d, 'username'), 'password' => vmGet($d, 'password')); $mainframe->login($credentials); } elseif (class_exists('mambocore') || vmIsJoomla('1.0.13', '>=', false)) { // Login for Mambo 4.6.x and Joomla >= 1.0.13 $mainframe->login($d['username'], $d['password']); } else { // Login for Joomla < 1.0.13 (and Mambo 4.5.2.3) $mainframe->login($d['username'], md5($d['password'])); } // Redirect to the Checkout Page if the cart is not empty if (!empty($_SESSION['cart']['idx'])) { $redirect_to_page = 'checkout.index'; } else { $redirect_to_page = HOMEPAGE; } vmRedirect($sess->url('index.php?page=' . $redirect_to_page, false, false), $VM_LANG->_('REG_COMPLETE')); } if (!empty($my->id) || !empty($auth['user_id'])) { vmRedirect($sess->url('index.php?page=checkout.index', false, false)); } else { $GLOBALS['page'] = 'shop.cart'; $msg = strip_tags($VM_LANG->_('REG_COMPLETE_ACTIVATE', false)); $vmLogger->info($msg); } return true; }
$theme = vmGet($_REQUEST, 'theme', 'default'); $themepath = $mosConfig_absolute_path . '/components/com_virtuemart/themes/' . basename($theme); if (!file_exists($themepath)) { echo '<script type="text/javascript">alert(\'' . str_replace('{theme}', basename(shopMakeHtmlSafe($theme)), $VM_LANG->_('VM_ADMIN_THEME_NOT_EXISTS')) . '\');history.back();</script>'; exit; } if (!file_exists($themepath . '/theme.config.php')) { if (!fopen($themepath . '/theme.config.php', 'w')) { echo vmCommonHTML::getErrorField($VM_LANG->_('VM_ADMIN_THEME_CFG_NOT_EXISTS')); return; } } $current_config = file_get_contents($themepath . '/theme.config.php'); $parameter_xml_file = $themepath . '/theme.xml'; // get params definitions $params = new vmParameters($current_config, $parameter_xml_file, 'theme'); $title = ' <img src="' . VM_THEMEURL . 'images/administration/header/icon-48-config.png" align="middle" border="0" alt="' . $VM_LANG->_('VM_ADMIN_CFG_THEME_SETTINGS') . '" /> '; $title .= $VM_LANG->_('VM_ADMIN_CFG_THEME_SETTINGS'); //First create the object and let it print a form heading $formObj = new formFactory($title); //Then Start the form $formObj->startForm(); $ps_html->writableIndicator($themepath . '/theme.config.php', 'text-align:left;width:78%;'); vmCommonHTML::loadExtjs(); ?> <fieldset style="width: 80%"> <legend><?php echo $VM_LANG->_('VM_ADMIN_CFG_THEME_PARAMETERS'); ?> </legend>
/** * Search method * * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav */ function vmExtendedSearch($text, $phrase = '', $ordering = '') { $database = JFactory::getDBO(); $text = trim($text); if ($text == '') { return array(); } // Get mambot parameters // check if param query has previously been processed if (!isset($GLOBALS['_search_mambot_params']['vmxsearch'])) { // load mambot params info $query = "SELECT params FROM #__plugins WHERE element = 'vmxsearch.plugin' AND folder = 'search'"; $database->setQuery($query); $mambot = $database->loadObject(); // save query to class variable $GLOBALS['_search_mambot_params']['vmxsearch'] = $mambot; } // pull query data from class variable $mambot = $GLOBALS['_search_mambot_params']['vmxsearch']; $botParams = new vmParameters($mambot->params); $fields = array(); $thumbnail_flag = $botParams->def('thumbnail_flag', 1); $thumbnailx = $botParams->def('thumbnailx', 40); $thumbnaily = $botParams->def('thumbnaily', 40); if ($botParams->def('name_flag', 1) == 1) { $fields[] = 'p.product_name'; } if ($botParams->def('sku_flag', 1) == 1) { $fields[] = 'p.product_sku'; } if ($botParams->def('desc_flag', 1) == 1) { $fields[] = 'p.product_desc'; } if ($botParams->def('sdesc_flag', 1) == 1) { $fields[] = 'p.product_s_desc'; } if ($botParams->def('url_flag', 1) == 1) { $fields[] = 'p.product_url'; } if ($botParams->def('review_flag', 1) == 1) { $fields[] = 'r.comment'; } if ($botParams->def('manufacturer_flag', 1) == 1) { $fields[] = 'm.mf_name'; } if ($botParams->def('category_flag', 1) == 1) { $fields[] = 'c.category_name'; } $oos_where = PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != 1 ? 'and product_in_stock > 0' : ''; switch ($botParams->def('parent_filter', 'both')) { case 'parent': $parent_where = "AND (p.product_parent_id='' OR p.product_parent_id='0')"; break; case 'child': $parent_where = "AND (p.product_parent_id > '0')"; break; case 'both': $parent_where = ''; break; } // Build search logic $wheres = array(); switch ($phrase) { case 'exact': $wheres2 = array(); foreach ($fields as $field) { $wheres2[] = "{$field} LIKE '%" . $database->getEscaped($text) . "%'"; } $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $wheres2 = array(); foreach ($fields as $field) { $wheres2[] = "{$field} LIKE '%" . $database->getEscaped($word) . "%'"; } $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')'; break; } switch ($ordering) { case 'newest': default: $order = 'p.cdate DESC'; break; case 'oldest': $order = 'p.cdate ASC'; break; case 'popular': $order = 'p.product_name ASC'; break; case 'alpha': $order = 'p.product_name ASC'; break; case 'category': $order = 'p.category_name ASC'; break; } if ($botParams->def('density_flag', 1) == 1) { $whole_text = ", CONCAT_WS(' ',LOWER(" . implode('), LOWER(', $fields) . ')) AS whole_text '; } else { $whole_text = ''; } //Get Virtuemart module ID $database->setQuery(" SELECT id, name FROM `#__menu` WHERE link LIKE '%com_virtuemart%' AND published=1 AND access=0"); $Item = $database->loadObject(); $ItemName = !empty($Item->name) ? $Item->name : "Shop"; $Itemid = !empty($Item->id) ? $Item->id : "1"; $query = "SELECT DISTINCT p.product_id, p.product_name as title,\r\n\t\t\t\t\tFROM_UNIXTIME( p.cdate, '%Y-%m-%d %H:%i:%s' ) AS created,\r\n\t\t\t\t\tp.product_s_desc AS text,\r\n\t\t\t\t\tCONCAT('{$ItemName}/',c.category_name) as section,\r\n\t\t\t\t\tCONCAT('index.php?option=com_virtuemart&page=shop.product_details&flypage=',IFNULL(c.category_flypage,'" . FLYPAGE . "'),'&category_id=',IFNULL(c.category_id,''),'&product_id=',p.product_id,'&Itemid='," . $Itemid . ") as href,\r\n\t\t\t\t\t'2' as browsernav \r\n\t\t\t\t\t{$whole_text} \r\n\t\t\t\t\tFROM #__vm_product p\r\n\t\t\t\t\tLEFT JOIN #__vm_product_reviews r ON (r.product_id = p.product_id) \r\n\t\t\t\t\tLEFT JOIN #__vm_product_mf_xref mx ON (mx.product_id = p.product_id) \r\n\t\t\t\t\tLEFT JOIN #__vm_manufacturer m ON (m.manufacturer_id = mx.manufacturer_id),\r\n\t\t\t\t\t\t#__vm_product_category_xref cx, #__vm_category c\r\n\t\t\t\t\t\tWHERE ({$where})" . "\n AND cx.product_id = p.product_id\r\n\t\t\t\t\t\t\tAND cx.category_id = c.category_id {$parent_where}\r\n\t\t\t\t\t\t\tAND c.category_publish='Y'\r\n\t\t\t\t\t\t\tAND p.product_publish='Y'\r\n\t\t\t\t\t{$oos_where}\r\n\t\t\t\t\tORDER BY {$order}"; //echo "\n-QUERY:\n$query\n"; $database->setQuery($query); $row = $database->loadObjectList(); if (!empty($row) && $botParams->def('density_flag', 1) == 1) { $txt = strtolower($text); if ($phrase != 'exact') { $txt_array = explode(' ', $txt); } else { $txt_array[0] = $txt; } $i = 0; foreach ($row as $result) { $count = 0; foreach ($txt_array as $txt) { $count = substr_count($result->whole_text, $txt) + $count; } $row[$i]->count = $count; $i++; } pg_keydenseSort($row, 'count', 'DESC'); } return $row; }