예제 #1
0
 /**
  * constructs a VmModel
  * setMainTable defines the maintable of the model
  *
  * @author Max Milbers
  */
 function __construct()
 {
     parent::__construct('virtuemart_product_id');
     $this->setMainTable('products');
     $this->starttime = microtime(TRUE);
     $this->maxScriptTime = VmConfig::getExecutionTime() * 0.95 - 1;
     $this->memory_limit = VmConfig::getMemoryLimit() - 4;
     // 	$this->addvalidOrderingFieldName(array('m.mf_name','pp.product_price'));
     $app = JFactory::getApplication();
     if ($app->isSite()) {
         $this->_validOrderingFieldName = array();
         $browseOrderByFields = VmConfig::get('browse_orderby_fields', array('product_sku', 'category_name', 'mf_name', 'product_name'));
     } else {
         if (!class_exists('shopFunctions')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
         }
         $browseOrderByFields = ShopFunctions::getValidProductFilterArray();
         $this->addvalidOrderingFieldName(array('product_price', 'product_sales'));
         //$this->addvalidOrderingFieldName (array('product_price'));
         // 	vmdebug('$browseOrderByFields',$browseOrderByFields);
     }
     $this->addvalidOrderingFieldName((array) $browseOrderByFields);
     $this->removevalidOrderingFieldName('virtuemart_product_id');
     //$this->removevalidOrderingFieldName ('product_sales');
     //unset($this->_validOrderingFieldName[0]);//virtuemart_product_id
     array_unshift($this->_validOrderingFieldName, 'p.virtuemart_product_id');
     $this->_selectedOrdering = VmConfig::get('browse_orderby_field', '`p`.virtuemart_product_id');
     $this->setToggleName('product_special');
     $this->initialiseRequests();
     //This is just done now for the moment for developing, the idea is of course todo this only when needed.
     $this->updateRequests();
 }
 /**
  * constructs a VmModel
  * setMainTable defines the maintable of the model
  *
  * @author Max Milbers
  */
 function __construct()
 {
     parent::__construct('virtuemart_product_id');
     $this->setMainTable('products');
     $this->starttime = microtime(TRUE);
     $this->maxScriptTime = ini_get('max_execution_time') * 0.95 - 1;
     // 	$this->addvalidOrderingFieldName(array('m.mf_name','pp.product_price'));
     $view = JRequest::getVar('view');
     $isSite = JFactory::getApplication()->isSite() && $view !== 'product' && $view !== 'inventory';
     if ($isSite) {
         $browseOrderByFields = VmConfig::get('browse_orderby_fields', array('product_sku', 'category_name', 'mf_name', 'product_name'));
     } else {
         JLoader::register('shopFunctions', JPATH_VM_ADMINISTRATOR . 'helpers/shopfunctions.php');
         $browseOrderByFields = ShopFunctions::getValidProductFilterArray();
         $this->addvalidOrderingFieldName(array('product_price', 'p.`product_sales`'));
         //$this->addvalidOrderingFieldName (array('product_price'));
         // 	vmdebug('$browseOrderByFields',$browseOrderByFields);
     }
     $this->addvalidOrderingFieldName((array) $browseOrderByFields);
     $this->removevalidOrderingFieldName('virtuemart_product_id');
     $this->removevalidOrderingFieldName('product_sales');
     //unset($this->_validOrderingFieldName[0]);//virtuemart_product_id
     array_unshift($this->_validOrderingFieldName, 'p.virtuemart_product_id');
     $this->_selectedOrdering = VmConfig::get('browse_orderby_field', '`p`.virtuemart_product_id');
     $this->setToggleName('product_special');
     $this->initialiseRequests();
     //This is just done now for the moment for developing, the idea is of course todo this only when needed.
     $this->updateRequests();
 }
예제 #3
0
 /**
  * Retrieve a list of preselected and existing search or order By Fields
  * $type = 'browse_search_fields' or 'browse_orderby_fields'
  * @author Kohl Patrick
  * @return array of order list
  */
 function getProductFilterFields($type)
 {
     $searchChecked = VmConfig::get($type);
     if (!is_array($searchChecked)) {
         $searchChecked = (array) $searchChecked;
     }
     $searchFieldsArray = ShopFunctions::getValidProductFilterArray();
     // 		if ($type !== 'browse_orderby_fields' ) array_shift($searchFieldsArray);
     $searchFields = new stdClass();
     $searchFields->checkbox = '<div class="threecols"><ul>';
     foreach ($searchFieldsArray as $key => $field) {
         if (in_array($field, $searchChecked)) {
             $checked = 'checked="checked"';
         } else {
             $checked = '';
         }
         $fieldWithoutPrefix = $field;
         $dotps = strrpos($fieldWithoutPrefix, '.');
         if ($dotps !== false) {
             $prefix = substr($field, 0, $dotps + 1);
             $fieldWithoutPrefix = substr($field, $dotps + 1);
         }
         $text = JText::_('COM_VIRTUEMART_' . strtoupper($fieldWithoutPrefix));
         if ($type == 'browse_orderby_fields') {
             $searchFields->select[] = JHTML::_('select.option', $field, $text);
         }
         $searchFields->checkbox .= '<li><input type="checkbox" id="' . $type . $fieldWithoutPrefix . $key . '" name="' . $type . '[]" value="' . $field . '" ' . $checked . ' /><label for="' . $type . $fieldWithoutPrefix . $key . '">' . $text . '</label></li>';
     }
     $searchFields->checkbox .= '</ul></div>';
     return $searchFields;
 }
예제 #4
0
 /**
  * Retrieve a list of preselected and existing search or order By Fields
  * $type = 'browse_search_fields' or 'browse_orderby_fields'
  * @author Kohl Patrick
  * @return array of order list
  */
 function getProductFilterFields($type)
 {
     $searchChecked = VmConfig::get($type);
     if (!is_array($searchChecked)) {
         $searchChecked = (array) $searchChecked;
     }
     if ($type != 'browse_cat_orderby_field') {
         $searchFieldsArray = ShopFunctions::getValidProductFilterArray();
         if ($type == 'browse_search_fields') {
             if ($key = array_search('pc.ordering', $searchFieldsArray)) {
                 unset($searchFieldsArray[$key]);
             }
         } else {
             if ($type == 'browse_orderby_fields') {
                 array_unshift($searchFieldsArray, 'pc.ordering,product_name');
             }
         }
     } else {
         $searchFieldsArray = array('category_name', 'category_description', 'cx.ordering', 'c.published');
     }
     $searchFields = new stdClass();
     $searchFields->checkbox = '<div class="threecols"><ul>';
     foreach ($searchFieldsArray as $key => $field) {
         if (in_array($field, $searchChecked)) {
             $checked = 'checked="checked"';
         } else {
             $checked = '';
         }
         $fieldWithoutPrefix = $field;
         $dotps = strrpos($fieldWithoutPrefix, '.');
         if ($dotps !== false) {
             $prefix = substr($field, 0, $dotps + 1);
             $fieldWithoutPrefix = substr($field, $dotps + 1);
         }
         $text = vmText::_('COM_VIRTUEMART_' . strtoupper(str_replace(array(',', ' '), array('_', ''), $fieldWithoutPrefix)));
         if ($type == 'browse_orderby_fields' or $type == 'browse_cat_orderby_field') {
             $searchFields->select[] = JHtml::_('select.option', $field, $text);
         }
         $searchFields->checkbox .= '<li><input type="checkbox" id="' . $type . $fieldWithoutPrefix . $key . '" name="' . $type . '[]" value="' . $field . '" ' . $checked . ' /><label for="' . $type . $fieldWithoutPrefix . $key . '">' . $text . '</label></li>';
     }
     $searchFields->checkbox .= '</ul></div>';
     return $searchFields;
 }