static function getLayouts($dirs, $type = 0) { $result = array(); $emptyOption = JHtml::_('select.option', '0', vmText::_('COM_VIRTUEMART_ADMIN_CFG_NO_OVERRIDE')); $result[] = $emptyOption; $alreadyAddedFile = array(); foreach ($dirs as $dir) { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (!empty($file) and strpos($file, '.') !== 0 and $file != 'index.html' and !is_Dir($file)) { if (!empty($type) and strpos($file, $type) === 0 or empty($type) and strpos($file, '_') == 0) { //Handling directly for extension is much cleaner $path_info = pathinfo($file); if (empty($path_info['extension'])) { vmError('Attention file ' . $file . ' has no extension and directory ' . $dir); $path_info['extension'] = ''; } if ($path_info['extension'] == 'php' && !in_array($file, $alreadyAddedFile)) { $alreadyAddedFile[] = $file; $result[] = JHtml::_('select.option', $path_info['filename'], $path_info['filename']); } } } } } } return $result; }
/** * Retrieve a list of layouts from the default and chosen templates directory. * * @author Max Milbers * @param name of the view * @return object List of flypage objects */ static function getLayoutList($view) { $dirs[] = JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'views'.DS.$view.DS.'tmpl'; //This does not work, joomla takes only overrides of their standard template // $tplpath = VmConfig::get('vmtemplate',0); //So we look for template overrides in the joomla standard template //This method does not work, we get the Template of the backend //$app = JFactory::getApplication('site'); //$tplpath = $app->getTemplate();vmdebug('template',$tplpath); if (JVM_VERSION === 2) { $q = 'SELECT `template` FROM `#__template_styles` WHERE `client_id` ="0" AND `home`="1" '; } else { $q = 'SELECT `template` FROM `#__templates_menu` WHERE `client_id` ="0" '; } $db = JFactory::getDBO(); $db->setQuery($q); $tplnames = $db->loadResult(); if($tplnames){ if(is_dir(JPATH_ROOT.DS.'templates'.DS.$tplnames.DS.'html'.DS.'com_virtuemart'.DS.$view)){ $dirs[] = JPATH_ROOT.DS.'templates'.DS.$tplnames.DS.'html'.DS.'com_virtuemart'.DS.$view; } } $result = array(); $emptyOption = JHTML::_('select.option', '0', JText::_('COM_VIRTUEMART_ADMIN_CFG_NO_OVERRIDE')); $result[] = $emptyOption; $alreadyAddedFile = array(); foreach($dirs as $dir){ if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if(!empty($file) and strpos($file,'.')!==0 and strpos($file,'_')==0 and $file != 'index.html' and !is_Dir($file)){ //Handling directly for extension is much cleaner $path_info = pathinfo($file); if(empty($path_info['extension'])){ vmError('Attention file '.$file.' has no extension in view '.$view.' and directory '.$dir); $path_info['extension'] = ''; } if ($path_info['extension'] == 'php' && !in_array($file,$alreadyAddedFile)) { $alreadyAddedFile[] = $file; //There is nothing to translate here // $result[] = JHTML::_('select.option', $file, $path_info['filename']); $result[] = JHTML::_('select.option', $path_info['filename'], $path_info['filename']); } } } } } return $result; }
function display($tpl = null) { $this->loadHelper('image'); $this->loadHelper('html'); $model = VmModel::getModel(); $usermodel = VmModel::getModel('user'); JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48'); $this->addStandardEditViewCommands(); $config = VmConfig::loadConfig(); if (!empty($config->_params)) { unset($config->_params['pdf_invoice']); // parameter remove and replaced by inv_os } $this->config = $config; $this->userparams = JComponentHelper::getParams('com_users'); $this->jTemplateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT')); $this->vmLayoutList = $model->getLayoutList('virtuemart', VmConfig::get('vmlayout', 0), 'vmlayout'); $this->categoryLayoutList = $model->getLayoutList('category', VmConfig::get('categorylayout', 0), 'categorylayout'); $this->productLayoutList = $model->getLayoutList('productdetails', VmConfig::get('productlayout', 0), 'productlayout'); $this->noimagelist = $model->getNoImageList(); $this->orderStatusModel = VmModel::getModel('orderstatus'); $this->currConverterList = $model->getCurrencyConverterList(); $this->moduleList = $model->getModuleList(); $this->activeLanguages = $model->getActiveLanguages(VmConfig::get('active_languages')); $this->orderByFields = $model->getProductFilterFields('browse_orderby_fields'); $this->searchFields = $model->getProductFilterFields('browse_search_fields'); $this->aclGroups = $usermodel->getAclGroupIndentedTree(); if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) { $imagePath = VmConfig::get('vmtemplate') . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->imagePath = $imagePath; shopFunctions::checkSafePath(); $this->checkVmUserVendor(); parent::display($tpl); }
function search_records($path, $records, $file_to_search) { foreach ($records as $record) { $single_path = trim($record); if (is_dir($single_path)) { $single_path = trim($single_path); $is_folder = end(explode("/", $single_path)); if ($is_folder == $file_to_search) { $single_path = trim($single_path); $files = glob($single_path . '/{,.}*', GLOB_BRACE); foreach ($files as $filename) { $file_name = end(explode('/', $filename)); if (is_Dir($filename)) { echo '<div class="show_image" data-url=' . HTTP_PATH . '/views/window_action.php>'; echo '<img src=' . IMAGE_PATH . '/icons/folder.png height="32" width="32" data-file=' . $file_name . '>'; echo '<div>' . $file_name . '</div>'; echo '</div>'; } else { $ext = pathinfo($file_name, PATHINFO_EXTENSION); echo '<div class="show_image">'; switch ($ext) { case "txt": echo '<img src=' . IMAGE_PATH . '/icons/icon-doc-txt.png height="32" width="32">'; break; case "html": echo '<img src=' . IMAGE_PATH . '/icons/icon-doc-htm.png height="22" width="22">'; break; case "jpg": echo '<img src=' . IMAGE_PATH . '/icons/icon-doc-jpg.png height="22" width="22">'; break; case "avi": echo '<img src=' . IMAGE_PATH . '/icons/icon-doc-avi.png height="22" width="22">'; break; case "mov": echo '<img src=' . IMAGE_PATH . '/icons/icon-doc-mov.png height="22" width="22">'; break; case "doc": echo '<img src=' . IMAGE_PATH . '/icons/icon-doc-doc.png height="22" width="22">'; break; case "ppt": echo '<img src=' . IMAGE_PATH . '/icons/icon-doc-ppt.png height="22" width="22">'; break; case "pdf": echo '<img src=' . IMAGE_PATH . '/icons/icon-doc-pdf.png height="22" width="22">'; break; case "zip": echo '<img src=' . IMAGE_PATH . '/icons/icon-doc-zip.png height="22" width="22">'; break; case "mp3": echo '<img src=' . IMAGE_PATH . '/icons/icon-doc-mp3.png height="22" width="22">'; break; case "xls": echo '<img src=' . IMAGE_PATH . '/icons/icon-xls-txt.png height="22" width="22">'; break; case "php": echo '<img src=' . IMAGE_PATH . '/icons/php.ico height="32" width="32">'; break; case "js": echo '<img src=' . IMAGE_PATH . '/icons/js.png height="32" width="32">'; break; default: echo '<img src=' . IMAGE_PATH . '/icons/icon-doc-other.png height="22" width="22">'; break; } echo '<div class="content_name">' . $file_name . '</div>'; echo '</div>'; } } echo '<input type = "hidden" name = "path" id = "path" value=' . $single_path . '/>'; $record = 1; break; } } } if (!$record) { echo 1; } }
function fetchElement($name, $value, &$node, $control_name) { //Load languages $language = JFactory::getLanguage(); $language->load('plg_k2_k2mart', JPATH_ADMINISTRATOR); $language->load('com_virtuemart', JPATH_ADMINISTRATOR); //Get params $params = JComponentHelper::getParams('com_k2mart'); $mainframe = JFactory::getApplication(); $db = JFactory::getDBO(); //Add scripts and styles $document = JFactory::getDocument(); $document->addStyleSheet(JURI::root(true) . '/plugins/k2/k2mart/tmpl/admin/css/admin.style.css'); $document->addStyleSheet(JURI::root(true) . '/administrator/components/com_k2mart/css/chosen.css'); $document->addScript(JURI::root(true) . '/plugins/k2/k2mart/includes/js/admin.k2mart.js'); $document->addScript(JURI::root(true) . '/administrator/components/com_k2mart/js/chosen.jquery.min.js'); $document->addScript(JURI::root(true) . '/components/com_virtuemart/assets/js/fancybox/jquery.fancybox-1.3.4.js'); $document->addScript(JURI::root(true) . '/administrator/components/com_virtuemart/assets/js/vm2admin.js'); $document->addScript(JURI::root(true) . '/administrator/components/com_virtuemart/assets/js/jquery.coookie.js'); //Get K2 Item $itemID = JRequest::getInt('cid'); $productID = 0; if ($itemID) { $query = "SELECT referenceID FROM #__k2mart WHERE baseID = {$itemID}"; $db->setQuery($query); $productID = $db->loadResult(); } //Include Virtuemart classes require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; $config = VmConfig::loadConfig(); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'shopfunctions.php'; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'html.php'; JModel::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models'); //Get product $model = JModel::getInstance('Product', 'VirtuemartModel'); $product = $model->getProductSingle($productID, false); //Get product children $product->children = method_exists($model, 'getProductChilds') ? $model->getProductChilds($productID) : $model->getProductChildIds($productID); //Get product parent JModel::addIncludePath(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models'); $K2Model = JModel::getInstance('Itemlist', 'K2Model'); $tree = $K2Model->getCategoryTree($params->get('catalogRoot', 0)); $query = "SELECT id AS value, title AS text FROM #__k2_items WHERE catid IN(" . implode(',', $tree) . ")"; $db->setQuery($query); $items = $db->loadObjectList(); $option = new JObject(); $option->value = 0; $option->text = JText::_('K2MART_NONE'); array_unshift($items, $option); $parent = 0; if ($product->product_parent_id) { $query = "SELECT baseID FROM #__k2mart WHERE referenceID = {$product->product_parent_id}"; $db->setQuery($query); $parent = $db->loadResult(); } $lists['product_parent_id'] = JHTML::_('select.genericlist', $items, 'product_parent_id', 'class="inputbox"', 'value', 'text', $parent); //Get category tree if (isset($product->categories)) { $lists['categories'] = ShopFunctions::categoryListTree($product->categories); } else { $lists['categories'] = ShopFunctions::categoryListTree(); } //Get vendors if (Vmconfig::get('multix', 'none') !== 'none') { $lists['vendors'] = Shopfunctions::renderVendorList($product->virtuemart_vendor_id); } //Get images $model->addImages($product); if (is_array($product->images) && isset($product->images[0])) { $product->image = $product->images[0]; } else { $product->image = new JObject(); $product->image->virtuemart_media_id = 0; $product->image->file_title = ''; $product->image->file_description = ''; $product->image->file_meta = ''; $product->image->file_url = ''; $product->image->file_url_thumb = ''; $product->image->file_title = ''; } //Get manufacturers $model = JModel::getInstance('Manufacturer', 'VirtuemartModel'); $manufacturers = $model->getManufacturerDropdown($product->virtuemart_manufacturer_id); if (count($manufacturers) > 0) { $lists['manufacturers'] = JHTML::_('select.genericlist', $manufacturers, 'virtuemart_manufacturer_id', 'class="inputbox"', 'value', 'text', $product->virtuemart_manufacturer_id); } //Get shopper groups if (isset($product->shoppergroups)) { $lists['shopperGroups'] = ShopFunctions::renderShopperGroupList($product->shoppergroups, true); } //Get product price require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'calculationh.php'; $calculator = calculationHelper::getInstance(); $product->prices = $calculator->getProductPrices($product); // Get product price override options $options = array(0 => 'Disabled', 1 => 'Overwrite final', -1 => 'Overwrite price to tax'); $lists['price_override_options'] = VmHtml::radioList('override', $product->override, $options); // Get tax rules $dbTax = ''; foreach ($calculator->rules['DBTax'] as $rule) { $dbTax .= $rule['calc_name'] . '<br />'; } $dbTaxRules = $dbTax; $tax = JText::_('COM_VIRTUEMART_TAX_EFFECTING'); foreach ($calculator->rules['Tax'] as $rule) { $tax .= $rule['calc_name'] . '<br />'; } $taxRules = $tax; $daTax = ''; foreach ($calculator->rules['DATax'] as $rule) { $daTax .= $rule['calc_name'] . '<br />'; } $daTaxRules = $daTax; // Removed in VM 2.0.4 //$override = $calculator->override; //$product_override_price = $calculator->product_override_price; if (!isset($product->product_tax_id)) { $product->product_tax_id = 0; } $lists['taxrates'] = ShopFunctions::renderTaxList($product->product_tax_id, 'product_tax_id'); // Discounts if (!isset($product->product_discount_id)) { $product->product_discount_id = 0; } require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models' . DS . 'calc.php'; $discounts = VirtueMartModelCalc::getDiscounts(); $discountrates = array(); $discountrates[] = JHTML::_('select.option', '-1', JText::_('COM_VIRTUEMART_PRODUCT_DISCOUNT_NONE'), 'product_discount_id'); $discountrates[] = JHTML::_('select.option', '0', JText::_('COM_VIRTUEMART_PRODUCT_DISCOUNT_NO_SPECIAL'), 'product_discount_id'); foreach ($discounts as $discount) { $discountrates[] = JHTML::_('select.option', $discount->virtuemart_calc_id, $discount->calc_name, 'product_discount_id'); } $lists['discounts'] = JHTML::_('select.genericlist', $discountrates, 'product_discount_id', '', 'product_discount_id', 'text', $product->product_discount_id); //Define Virtuemart image path if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) { $imagePath = VmConfig::get('vmtemplate') . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } // Get currencies $model = JModel::getInstance('Currency', 'VirtuemartModel'); $vendorModel = JModel::getInstance('Vendor', 'VirtuemartModel'); $vendorModel->setId(1); $vendor = $vendorModel->getVendor(); if (empty($product->product_currency)) { $product->product_currency = $vendor->vendor_currency; } $lists['currencies'] = JHTML::_('select.genericlist', $model->getCurrencies(), 'product_currency', '', 'virtuemart_currency_id', 'currency_name', $product->product_currency); $currency = $model->getCurrency($product->product_currency); $productCurrency = $currency->currency_symbol; $currency = $model->getCurrency($vendor->vendor_currency); $vendorCurrency = $currency->currency_symbol; //Get dimensions $lists['product_weight_uom'] = ShopFunctions::renderWeightUnitList('product_weight_uom', !isset($product->product_weight_uom) ? $config->get('weight_unit_default') : $product->product_weight_uom); $lists['product_lwh_uom'] = ShopFunctions::renderLWHUnitList('product_lwh_uom', !isset($product->product_lwh_uom) ? $config->get('lwh_unit_default') : $product->product_lwh_uom); //Get custom fields $model = JModel::getInstance('CustomFields', 'VirtuemartModel'); $fieldTypes = $model->getField_types(); $customsList = JHTML::_('select.genericlist', $model->getCustomsList(), 'customlist'); if (!isset($product->customfields)) { $product->customfields = array(); } //Set some script variables $document->addScriptDeclaration('var k2martVmImagePath="' . JURI::root(true) . $imagePath . '"; var tip_image="' . JURI::root(true) . '/components/com_virtuemart/assets/js/images/vtip_arrow.png"; var k2martVmCustomFieldsNum = "' . count($product->customfields) . '";'); //Edit icon $application = JFactory::getApplication('admin'); $editIcon = JURI::root(true) . '/administrator/templates/' . $application->getTemplate() . '/images/menu/icon-16-edit.png'; //Output ob_start(); include JPATH_SITE . DS . 'plugins' . DS . 'k2' . DS . 'k2mart' . DS . 'tmpl' . DS . 'admin' . DS . 'form.php'; $contents = ob_get_clean(); return $contents; }
function display($tpl = null) { // Get the task $task = JRequest::getWord('task'); // Load helpers $this->loadHelper('currencydisplay'); $this->loadHelper('html'); $this->loadHelper('image'); //$category_model = VmModel::getModel('category'); $model = VmModel::getModel(); // Handle any publish/unpublish switch ($task) { case 'add': case 'edit': //this was in the controller for the edit tasks, I dont know if it is still needed, $this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'product' . DS . 'tmpl'); $virtuemart_product_id = JRequest::getVar('virtuemart_product_id', array()); if (is_array($virtuemart_product_id) && count($virtuemart_product_id) > 0) { $virtuemart_product_id = (int) $virtuemart_product_id[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_id; } $product = $model->getProductSingle($virtuemart_product_id, false); $product_parent = $model->getProductParent($product->product_parent_id); $mf_model = VmModel::getModel('manufacturer'); $manufacturers = $mf_model->getManufacturerDropdown($product->virtuemart_manufacturer_id); $this->assignRef('manufacturers', $manufacturers); // Get the category tree if (isset($product->categories)) { $category_tree = ShopFunctions::categoryListTree($product->categories); } else { $category_tree = ShopFunctions::categoryListTree(); } $this->assignRef('category_tree', $category_tree); //Get the shoppergoup list - Cleanshooter Custom Shopper Visibility if (isset($product->shoppergroups)) { $shoppergroupList = ShopFunctions::renderShopperGroupList($product->shoppergroups, true); } $this->assignRef('shoppergroupList', $shoppergroupList); // Load the product price if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } $calculator = calculationHelper::getInstance(); $product->prices = $calculator->getProductPrices($product); $product_childIds = $model->getProductChildIds($virtuemart_product_id); $product_childs = array(); foreach ($product_childIds as $id) { $product_childs[] = $model->getProductSingle($id, false); } $this->assignRef('product_childs', $product_childs); $DBTax = ''; //JText::_('COM_VIRTUEMART_RULES_EFFECTING') ; foreach ($calculator->rules['DBTax'] as $rule) { $DBTax .= $rule['calc_name'] . '<br />'; } $this->assignRef('DBTaxRules', $DBTax); $tax = ''; //JText::_('COM_VIRTUEMART_TAX_EFFECTING').'<br />'; foreach ($calculator->rules['Tax'] as $rule) { $tax .= $rule['calc_name'] . '<br />'; } foreach ($calculator->rules['VatTax'] as $rule) { $tax .= $rule['calc_name'] . '<br />'; } $this->assignRef('taxRules', $tax); $DATax = ''; //JText::_('COM_VIRTUEMART_RULES_EFFECTING'); foreach ($calculator->rules['DATax'] as $rule) { $DATax .= $rule['calc_name'] . '<br />'; } $this->assignRef('DATaxRules', $DATax); // $this->assignRef('override', $calculator->override); // $this->assignRef('product_override_price', $calculator->product_override_price); if (!isset($product->product_tax_id)) { $product->product_tax_id = 0; } $lists['taxrates'] = ShopFunctions::renderTaxList($product->product_tax_id, 'product_tax_id'); if (!isset($product->product_discount_id)) { $product->product_discount_id = 0; } $lists['discounts'] = $this->renderDiscountList($product->product_discount_id); if (!class_exists('VirtueMartModelConfig')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'config.php'; } $productLayouts = VirtueMartModelConfig::getLayoutList('productdetails'); $this->assignRef('productLayouts', $productLayouts); // Load Images $model->addImages($product); if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) { $imagePath = VmConfig::get('vmtemplate') . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->assignRef('imagePath', $imagePath); // Load the vendors $vendor_model = VmModel::getModel('vendor'); // $vendors = $vendor_model->getVendors(); // $lists['vendors'] = JHTML::_('select.genericlist', $vendors, 'virtuemart_vendor_id', '', 'virtuemart_vendor_id', 'vendor_name', $product->virtuemart_vendor_id); if (Vmconfig::get('multix', 'none') !== 'none') { $lists['vendors'] = Shopfunctions::renderVendorList($product->virtuemart_vendor_id); } // Load the currencies $currency_model = VmModel::getModel('currency'); $vendor_model->setId(1); $vendor = $vendor_model->getVendor(); if (empty($product->product_currency)) { $product->product_currency = $vendor->vendor_currency; } $currencies = JHTML::_('select.genericlist', $currency_model->getCurrencies(), 'product_currency', '', 'virtuemart_currency_id', 'currency_name', $product->product_currency); $currency = $currency_model->getCurrency($product->product_currency); $this->assignRef('product_currency', $currency->currency_symbol); $currency = $currency_model->getCurrency($vendor->vendor_currency); $this->assignRef('vendor_currency', $currency->currency_symbol); if (count($manufacturers) > 0) { $lists['manufacturers'] = JHTML::_('select.genericlist', $manufacturers, 'virtuemart_manufacturer_id', 'class="inputbox"', 'value', 'text', $product->virtuemart_manufacturer_id); } $lists['product_weight_uom'] = ShopFunctions::renderWeightUnitList('product_weight_uom', $task == 'add' ? VmConfig::get('weight_unit_default') : $product->product_weight_uom); $lists['product_lwh_uom'] = ShopFunctions::renderLWHUnitList('product_lwh_uom', $task == 'add' ? VmConfig::get('lwh_unit_default') : $product->product_lwh_uom); if (empty($product->product_available_date)) { $product->product_available_date = date("Y-m-d"); } $waitinglistmodel = VmModel::getModel('waitinglist'); /* Load waiting list */ if ($product->virtuemart_product_id) { //$waitinglist = $this->get('waitingusers', 'waitinglist'); $waitinglist = $waitinglistmodel->getWaitingusers($product->virtuemart_product_id); $this->assignRef('waitinglist', $waitinglist); } $bookedUsers = $waitinglistmodel->getProductShoppersByStatus($product->virtuemart_product_id, array('S')); $this->assignRef('customers', $bookedUsers); $orderstatusModel = VmModel::getModel('orderstatus'); $lists['OrderStatus'] = $orderstatusModel->renderOrderStatusList(true, array('S')); $field_model = VmModel::getModel('customfields'); $fieldTypes = $field_model->getField_types(); $this->assignRef('fieldTypes', $fieldTypes); /* Load product types lists */ $customsList = $field_model->getCustomsList(); $this->assignRef('customsList', JHTML::_('select.genericlist', $customsList, 'customlist')); $ChildCustomRelation = $field_model->getProductChildCustomRelation(); $this->assignRef('ChildCustomRelation', $ChildCustomRelation); /* Set up labels */ if ($product->product_parent_id > 0) { $info_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_INFO_LBL'); $status_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_STATUS_LBL'); $dim_weight_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL'); $images_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_IMAGES_LBL'); $delete_message = JText::_('COM_VIRTUEMART_PRODUCT_FORM_DELETE_ITEM_MSG'); } else { if ($task == 'add') { $action = JText::_('COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT_LBL'); } else { $action = JText::_('COM_VIRTUEMART_PRODUCT_FORM_UPDATE_ITEM_LBL'); } $info_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_INFO_LBL'); $status_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_STATUS_LBL'); $dim_weight_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL'); $images_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_IMAGES_LBL'); $delete_message = JText::_('COM_VIRTUEMART_PRODUCT_FORM_DELETE_PRODUCT_MSG'); } $config = JFactory::getConfig(); $tzoffset = $config->getValue('config.offset'); $this->assignRef('tzoffset', $tzoffset); // Assign the values $this->assignRef('pane', $pane); $this->assignRef('editor', $editor); $this->assignRef('product', $product); $this->assignRef('currencies', $currencies); //no need moved to top $this->assignRef('manufacturers', $manufacturers); $this->assignRef('related_products', $related_products); $this->assignRef('product_parent', $product_parent); /* Assign label values */ $this->assignRef('action', $action); $this->assignRef('info_label', $info_label); $this->assignRef('status_label', $status_label); $this->assignRef('dim_weight_label', $dim_weight_label); $this->assignRef('images_label', $images_label); $this->assignRef('delete_message', $delete_message); $this->assignRef('lists', $lists); // Toolbar $text = ""; if ($task == 'edit') { if ($product->product_sku) { $sku = ' (' . $product->product_sku . ')'; } else { $sku = ""; } if (!empty($product->virtuemart_product_id)) { $text = '<a href="' . juri::root() . 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '" target="_blank" >' . $product->product_name . $sku . '<span class="vm2-modallink"></span></a>'; } else { $text = $product->product_name . $sku; } } $this->SetViewTitle('PRODUCT', $text); //JToolBarHelper::custom('sentproductemailtocustomer', 'email_32', 'email_32', 'COM_VIRTUEMART_PRODUCT_EMAILTOSHOPPER' ,false); $this->addStandardEditViewCommands($product->virtuemart_product_id); break; default: if ($product_parent_id = JRequest::getInt('product_parent_id', false)) { $product_parent = $model->getProduct($product_parent_id); $title = 'PRODUCT_CHILDREN_LIST'; $link_to_parent = JHTML::_('link', JRoute::_('index.php?view=product&task=edit&virtuemart_product_id=' . $product_parent->virtuemart_product_id . '&option=com_virtuemart'), $product_parent->product_name, array('title' => JText::_('COM_VIRTUEMART_EDIT_PARENT') . ' ' . $product_parent->product_name)); $msg = JText::_('COM_VIRTUEMART_PRODUCT_OF') . " " . $link_to_parent; } else { $title = 'PRODUCT'; $msg = ""; } $this->db = JFactory::getDBO(); $this->SetViewTitle($title, $msg); $this->addStandardDefaultViewLists($model, 'created_on'); /* Get the list of products */ $productlist = $model->getProductListing(false, false, false, false, true); //The pagination must now always set AFTER the model load the listing $pagination = $model->getPagination(); $this->assignRef('pagination', $pagination); /* Get the category tree */ $categoryId = $model->virtuemart_category_id; //OSP switched to filter in model, was JRequest::getInt('virtuemart_category_id'); $category_tree = ShopFunctions::categoryListTree(array($categoryId)); $this->assignRef('category_tree', $category_tree); // Check for Media Items and Reviews, set the price $media = VmModel::getModel('media'); $productreviews = VmModel::getModel('ratings'); /* Load the product price */ if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } $vendor_model = VmModel::getModel('vendor'); foreach ($productlist as $virtuemart_product_id => $product) { $product->mediaitems = count($product->virtuemart_media_id); $product->reviews = $productreviews->countReviewsForProduct($product->virtuemart_product_id); $vendor_model->setId($product->virtuemart_vendor_id); $vendor = $vendor_model->getVendor(); $currencyDisplay = CurrencyDisplay::getInstance($vendor->vendor_currency, $vendor->virtuemart_vendor_id); if (!empty($product->product_price) && !empty($product->product_currency)) { $product->product_price_display = $currencyDisplay->priceDisplay($product->product_price, (int) $product->product_currency, 1, true); } /* Write the first 5 categories in the list */ $product->categoriesList = shopfunctions::renderGuiList('virtuemart_category_id', '#__virtuemart_product_categories', 'virtuemart_product_id', $product->virtuemart_product_id, 'category_name', '#__virtuemart_categories', 'virtuemart_category_id', 'category'); } $mf_model = VmModel::getModel('manufacturer'); $manufacturers = $mf_model->getManufacturerDropdown(); $this->assignRef('manufacturers', $manufacturers); /* add Search filter in lists*/ /* Search type */ $options = array('' => JText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION'), 'parent' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_PARENT_PRODUCT'), 'product' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRODUCT'), 'price' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRICE'), 'withoutprice' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_WITHOUTPRICE')); $this->lists['search_type'] = VmHTML::selectList('search_type', JRequest::getVar('search_type'), $options); /* Search order */ $options = array('bf' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_BEFORE'), 'af' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_AFTER')); $this->lists['search_order'] = VmHTML::selectList('search_order', JRequest::getVar('search_order'), $options); // Toolbar JToolBarHelper::save('sentproductemailtoshoppers', JText::_('COM_VIRTUEMART_PRODUCT_EMAILTOSHOPPERS')); JToolBarHelper::custom('createchild', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_CHILD'), true); JToolBarHelper::custom('cloneproduct', 'copy', 'copy', JText::_('COM_VIRTUEMART_PRODUCT_CLONE'), true); JToolBarHelper::custom('addrating', 'default', '', JText::_('COM_VIRTUEMART_ADD_RATING'), true); $this->addStandardDefaultViewCommands(); $this->assignRef('productlist', $productlist); $this->assignRef('virtuemart_category_id', $categoryId); $this->assignRef('model', $model); break; } parent::display($tpl); }
$fpLockFile = fopen($szLockFile, "a+"); clearstatcache(); if (!file_exists($szCacheFile) || $bForce) { flock($fpLockFile, LOCK_EX); fwrite($fpLockFile, "."); //check once more to see if the cache file was created while waiting for //the lock clearstatcache(); if (!file_exists($szCacheFile) || $bForce) { if (!extension_loaded('MapScript')) { dl($szPHPMapScriptModule); } if (!extension_loaded('gd')) { dl($szPHPGDModule); } if (!@is_Dir($szMetaDir)) { makeDirs($szMetaDir); } $oMap = ms_newMapObj($szMapFile); /* Metatile width/height include 2x the metaBuffer value */ $oMap->set('width', $tileWidth * $metaWidth + 2 * $metaBuffer); $oMap->set('height', $tileHeight * $metaHeight + 2 * $metaBuffer); /* Tell MapServer to not render labels inside the metaBuffer area * (new in 4.6) * TODO: Until MapServer bugs 1353/1355 are resolved, we need to * pass a negative value for "labelcache_map_edge_buffer" */ $oMap->setMetadata("labelcache_map_edge_buffer", -$metaBuffer); $inchesPerUnit = array(1, 12, 63360.0, 39.3701, 39370.1, 4374754); $geoWidth = $scale / ($oMap->resolution * $inchesPerUnit[$oMap->units]); $geoHeight = $scale / ($oMap->resolution * $inchesPerUnit[$oMap->units]);
/** * @return null * @param string $field_name - Имя поля формы и макроса для вывода элемента в шаблон * @param string $value - Список файлов * @desc Элемент формы для загрузки списка файлов */ public static function listFile($field_name, $value) { if (file_exists(MODUL_DIR . '/mpanel/template/list_file.tpl')) { include MODUL_DIR . '/mpanel/template/list_file.tpl'; /* if (system::fileExtIs($file_name, array('flv', 'png', 'jpg', 'jpeg', 'png'))) page::assign('link_type', 'href="#" onclick="$.prettyPhoto.open(\'%value%\');"'); else page::assign('link_type', 'href="%value%" target="_target"'); */ // if (!empty($value)) { $files = explode(";", $value); $items = ''; while (list($key, $file_name) = each($files)) { if (!empty($file_name) && file_exists(ROOT_DIR . $file_name) && !is_Dir(ROOT_DIR . $file_name)) { $info = stat(ROOT_DIR . $file_name); if (system::fileExtIs($file_name, array('png', 'gif', 'jpg', 'jpeg'))) { $size = getimagesize(ROOT_DIR . $file_name); $size_img = ', ' . $size[0] . 'x' . $size[1] . 'px'; } else { $size_img = ''; } page::assign('file.name', system::fileName($file_name)); page::assign('file.url', $file_name); page::assign('file.ext', system::fileExt($file_name)); page::assign('file.size', round($info[7] / 1024, 0) . ' Кбайт' . $size_img); $items .= page::parse($TEMPLATE['files']); } } page::assign('files', $items); return page::parse($TEMPLATE['frame_view']); } else { page::assign('value', $value); page::assign('sname', $field_name); return page::parse($TEMPLATE['frame_add']); } } }
function display($tpl = null) { // Get the task $task = JRequest::getWord('task', $this->getLayout()); vmdebug('VirtuemartViewProduct ' . $task); $this->task = $task; // Load helpers $this->loadHelper('currencydisplay'); $this->loadHelper('html'); $this->loadHelper('image'); $model = VmModel::getModel(); // Handle any publish/unpublish switch ($task) { case 'add': case 'edit': VmConfig::loadJLang('com_virtuemart_orders', TRUE); VmConfig::loadJLang('com_virtuemart_shoppers', TRUE); $this->jsonPath = JFactory::getApplication()->isSite() ? juri::root() : ''; $virtuemart_product_id = JRequest::getVar('virtuemart_product_id', array()); if (is_array($virtuemart_product_id) && count($virtuemart_product_id) > 0) { $virtuemart_product_id = (int) $virtuemart_product_id[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_id; } $product = $model->getProductSingle($virtuemart_product_id, false); $product_parent = $model->getProductParent($product->product_parent_id); $mf_model = VmModel::getModel('manufacturer'); $manufacturers = $mf_model->getManufacturerDropdown($product->virtuemart_manufacturer_id); $this->manufacturers = $manufacturers; // set category in front edit link if ($task == 'add') { if ($category_id = jRequest::getInt('virtuemart_category_id', 0)) { $product->categories = array($category_id); } } // Get the category tree if (isset($product->categories)) { $this->category_tree = ShopFunctions::categoryListTree($product->categories); } else { $this->category_tree = ShopFunctions::categoryListTree(); } //Get the shoppergoup list - Cleanshooter Custom Shopper Visibility if (isset($product->shoppergroups)) { $this->shoppergroupList = ShopFunctions::renderShopperGroupList($product->shoppergroups); } else { $this->shoppergroupList = ''; } // Load the product price $this->loadHelper('calculationh'); $product_childIds = $model->getProductChildIds($virtuemart_product_id); $product_childs = array(); foreach ($product_childIds as $id) { $product_childs[] = $model->getProductSingle($id, false); } $this->assignRef('product_childs', $product_childs); JLoader::register('VirtueMartModelConfig', JPATH_VM_ADMINISTRATOR . '/models/config.php'); $this->productLayouts = VirtueMartModelConfig::getLayoutList('productdetails', $product->layout); // Load Images $model->addImages($product); if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) { $imagePath = VmConfig::get('vmtemplate') . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->imagePath = $imagePath; // Load the vendors $vendor_model = VmModel::getModel('vendor'); if (Vmconfig::get('multix', 'none') !== 'none') { if ($task == 'add') { $vendor_id = $this->adminVendor; } else { $vendor_id = $product->virtuemart_vendor_id; } $lists['vendors'] = Shopfunctions::renderVendorList($vendor_id); } // Load the currencies $currency_model = VmModel::getModel('currency'); $this->loadHelper('permissions'); $vendor_model->setId(Permissions::getInstance()->isSuperVendor()); $vendor = $vendor_model->getVendor(); if (empty($product->product_currency)) { $product->product_currency = $vendor->vendor_currency; } //STUDIO42 fix for currency, old method set 2 time same currency symbol // TODO verify all others $currencyModel = VmModel::getModel('currency'); $currencyModel->setId($vendor->vendor_currency); $currency = $currencyModel->getData(); $this->vendor_currency = $currency->currency_symbol; $currencyModel->setId($product->product_currency); $currency = $currencyModel->getData(); $this->product_currency = $currency->currency_symbol; if (count($manufacturers) > 0) { $lists['manufacturers'] = JHTML::_('select.genericlist', $manufacturers, 'virtuemart_manufacturer_id', 'class="inputbox"', 'value', 'text', $product->virtuemart_manufacturer_id); } $lists['product_weight_uom'] = ShopFunctions::renderWeightUnitList('product_weight_uom', $task == 'add' ? VmConfig::get('weight_unit_default') : $product->product_weight_uom); $lists['product_iso_uom'] = ShopFunctions::renderUnitIsoList('product_unit', $task == 'add' ? VmConfig::get('weight_unit_default') : $product->product_unit); $lists['product_lwh_uom'] = ShopFunctions::renderLWHUnitList('product_lwh_uom', $task == 'add' ? VmConfig::get('lwh_unit_default') : $product->product_lwh_uom); if (empty($product->product_available_date)) { $product->product_available_date = date("Y-m-d"); } $waitinglistmodel = VmModel::getModel('waitinglist'); /* Load waiting list */ if ($product->virtuemart_product_id) { //$waitinglist = $this->get('waitingusers', 'waitinglist'); $waitinglist = $waitinglistmodel->getWaitingusers($product->virtuemart_product_id); $this->assignRef('waitinglist', $waitinglist); } $productShoppers = $model->getProductShoppersByStatus($product->virtuemart_product_id, array('S')); $this->assignRef('productShoppers', $productShoppers); $orderstatusModel = VmModel::getModel('orderstatus'); $lists['OrderStatus'] = $orderstatusModel->renderOSList(array(), 'order_status', TRUE); $field_model = VmModel::getModel('customfields'); $fieldTypes = $field_model->getField_types(); $this->assignRef('fieldTypes', $fieldTypes); /* Load product types lists */ if ($customsList = $field_model->getCustomsList()) { $emptyOption = JHTML::_('select.option', '', '- ' . JText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION') . ' :', 'value', 'text'); array_unshift($customsList, $emptyOption); $customlist = JHTML::_('select.genericlist', $customsList, 'customlist'); if ($task == "add") { if ($customfieldsDefault = $this->getBLankCustomfields()) { $product->customfields = $customfieldsDefault; // var_dump( $customfieldsDefault);jexit(); } } } $this->assignRef('customsList', $customlist); $ChildCustomRelation = $field_model->getProductChildCustomRelation(); $this->assignRef('ChildCustomRelation', $ChildCustomRelation); if ($product->product_parent_id > 0) { $parentRelation = $field_model->getProductParentRelation($product->virtuemart_product_id); $this->assignRef('parentRelation', $parentRelation); // Set up labels $info_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_INFO_LBL'); $status_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_STATUS_LBL'); $dim_weight_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL'); $images_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_IMAGES_LBL'); $delete_message = JText::_('COM_VIRTUEMART_PRODUCT_FORM_DELETE_ITEM_MSG'); } else { if ($task == 'add') { $action = JText::_('COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT_LBL'); } else { $action = JText::_('COM_VIRTUEMART_PRODUCT_FORM_UPDATE_ITEM_LBL'); } $info_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_INFO_LBL'); $status_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_STATUS_LBL'); $dim_weight_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL'); $images_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_IMAGES_LBL'); $delete_message = JText::_('COM_VIRTUEMART_PRODUCT_FORM_DELETE_PRODUCT_MSG'); } $this->assignRef('product', $product); $product_empty_price = array('virtuemart_product_price_id' => 0, 'virtuemart_product_id' => $virtuemart_product_id, 'virtuemart_shoppergroup_id' => NULL, 'product_price' => NULL, 'override' => NULL, 'product_override_price' => NULL, 'product_tax_id' => NULL, 'product_discount_id' => NULL, 'product_currency' => $vendor->vendor_currency, 'product_price_publish_up' => NULL, 'product_price_publish_down' => NULL, 'price_quantity_start' => NULL, 'price_quantity_end' => NULL); $this->assignRef('product_empty_price', $product_empty_price); $this->assignRef('product_parent', $product_parent); /* Assign label values */ $this->assignRef('action', $action); $this->assignRef('info_label', $info_label); $this->assignRef('status_label', $status_label); $this->assignRef('dim_weight_label', $dim_weight_label); $this->assignRef('images_label', $images_label); $this->assignRef('delete_message', $delete_message); $this->assignRef('lists', $lists); // Toolbar if ($product->product_sku) { $sku = ' (' . $product->product_sku . ')'; } else { $sku = ""; } if (!empty($product->canonCatLink)) { $canonLink = '&virtuemart_category_id=' . $product->canonCatLink; } else { $canonLink = ''; } if (!empty($product->virtuemart_product_id)) { $text = '<a href="' . juri::root() . 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . $canonLink . '" target="_blank" >' . $product->product_name . $sku . '<span class="vm2-modallink"></span></a>'; } else { $text = $product->product_name . $sku; } $this->SetViewTitle('PRODUCT', $text); //JToolBarHelper::custom('sentproductemailtocustomer', 'email_32', 'email_32', 'COM_VIRTUEMART_PRODUCT_EMAILTOSHOPPER' ,false); $this->addStandardEditViewCommands($product->virtuemart_product_id); break; case 'massxref_cats': case 'massxref_cats_exe': //TODO test if path is ok addpath is now in the constructor $this->addTemplatePath(JPATH_VM_ADMINISTRATOR . '/views' . DS . 'category' . DS . 'tmpl'); $this->SetViewTitle('PRODUCT_MASSXREF'); // $this->setLayout('massxref'); $this->loadHelper('permissions'); $this->perms = Permissions::getInstance(); $this->showVendors = $this->perms->check('admin'); $keyWord = ''; $catmodel = VmModel::getModel('category'); $this->catmodel = $catmodel; //$this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($catmodel, 'category_name'); $this->categories = $catmodel->getCategoryTree(0, 0, false, $this->lists['search']); $this->pagination = $catmodel->getPagination(); // restore icon is good but not the word JToolBarHelper::custom('display', 'restore', 'restore', JText::_('JTOOLBAR_BACK'), false); JToolBarHelper::custom('massxref_cats_exe', 'assign', 'assign', JText::_('COM_VIRTUEMART_MASS_REPLACE'), false); JToolBarHelper::custom('massxref_cats_add', 'new', 'new', JText::_('COM_VIRTUEMART_MASS_ADD'), true); break; case 'massxref_sgrps': case 'massxref_sgrps_exe': $this->SetViewTitle('PRODUCT_MASSXREF'); //TODO test if path is ok addpath is now in the constructor $this->addTemplatePath(JPATH_VM_ADMINISTRATOR . '/views' . DS . 'shoppergroup' . DS . 'tmpl'); $this->loadHelper('permissions'); $this->perms = Permissions::getInstance(); $this->showVendors = $this->perms->check('admin'); $sgrpmodel = VmModel::getModel('shoppergroup'); $this->addStandardDefaultViewLists($sgrpmodel); $this->shoppergroups = $sgrpmodel->getShopperGroups(false, true); $this->pagination = $sgrpmodel->getPagination(); JToolBarHelper::custom('massxref_sgrps_exe', 'groups-add', 'new', JText::_('COM_VIRTUEMART_PRODUCT_XREF_SGRPS_EXE'), false); break; default: if ($product_parent_id = JRequest::getInt('product_parent_id', false)) { $product_parent = $model->getProductSingle($product_parent_id, false); if ($product_parent) { $title = 'PRODUCT_CHILDREN_LIST'; $link_to_parent = JHTML::_('link', JRoute::_('index.php?view=product&task=edit&virtuemart_product_id=' . $product_parent->virtuemart_product_id . '&option=com_virtuemart'), $product_parent->product_name, array('class' => 'hasTooltip', 'title' => JText::_('COM_VIRTUEMART_EDIT_PARENT') . ' ' . $product_parent->product_name)); $msg = JText::_('COM_VIRTUEMART_PRODUCT_OF') . " " . $link_to_parent; } else { $title = 'PRODUCT_CHILDREN_LIST'; $msg = 'Parent with product_parent_id ' . $product_parent_id . ' not found'; } } else { $title = 'PRODUCT'; $msg = ""; } $this->db = JFactory::getDBO(); $this->loadHelper('permissions'); $this->SetViewTitle($title, $msg); $this->addStandardDefaultViewLists($model, 'created_on', 'DESC', 'filter_product'); $vendor_id = $this->adminVendor; if ($vendor_id == 1) { $vendor_id = null; } // fix ??? $catid = JRequest::getInt('uctlist = ', 0); /* Get the list of products */ $productlist = $model->getProductListing(false, false, false, false, true, true, $catid, $vendor_id); //The pagination must now always set AFTER the model load the listing $this->pagination = $model->getPagination(); /* Get the category tree */ $categoryId = $model->virtuemart_category_id; //OSP switched to filter in model, was JRequest::getInt('virtuemart_category_id'); $this->category_tree = ShopFunctions::categoryListTree(array($categoryId)); /* Load the product price */ $this->loadHelper('calculationh'); $vendor_model = VmModel::getModel('vendor'); $productreviews = VmModel::getModel('ratings'); foreach ($productlist as $virtuemart_product_id => $product) { if (isset($product->virtuemart_media_id)) { $product->mediaitems = count($product->virtuemart_media_id); } else { $product->mediaitems = 'none'; } $product->reviews = $productreviews->countReviewsForProduct($product->virtuemart_product_id); $vendor_model->setId($product->virtuemart_vendor_id); $vendor = $vendor_model->getVendor(); $currencyDisplay = CurrencyDisplay::getInstance($vendor->vendor_currency, $vendor->virtuemart_vendor_id); if (!empty($product->product_price) && !empty($product->product_currency)) { $product->product_price_display = $currencyDisplay->priceDisplay($product->product_price, (int) $product->product_currency, 1, true); } /* Write the first 5 categories in the list */ $product->categoriesList = shopfunctions::renderGuiList('virtuemart_category_id', '#__virtuemart_product_categories', 'virtuemart_product_id', $product->virtuemart_product_id, 'category_name', '#__virtuemart_categories', 'virtuemart_category_id', 'category'); } $mf_model = VmModel::getModel('manufacturer'); $this->manufacturers = $mf_model->getManufacturerDropdown(); /* add Search filter in lists*/ /* Search type */ $options = array('' => JText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION'), 'parent' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_PARENT_PRODUCT'), 'product' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRODUCT'), 'price' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRICE'), 'withoutprice' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_WITHOUTPRICE')); $this->lists['search_type'] = VmHTML::selectList('search_type', JRequest::getVar('search_type'), $options, 1, '', 'onchange="Joomla.ajaxSearch(this); return false;"', 'input-medium'); /* Search order */ $options = array('bf' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_BEFORE'), 'af' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_AFTER')); $this->lists['search_order'] = VmHTML::selectList('search_order', JRequest::getVar('search_order'), $options, 1, '', '', 'input-small'); // Toolbar //JToolBarHelper::save('sentproductemailtoshoppers', JText::_('COM_VIRTUEMART_PRODUCT_EMAILTOSHOPPERS')); JToolBarHelper::custom('massxref_cats', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_XREF_CAT'), true); JToolBarHelper::custom('massxref_sgrps', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_XREF_SGRPS'), true); JToolBarHelper::custom('createchild', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_CHILD'), true); JToolBarHelper::custom('cloneproduct', 'copy', 'copy', JText::_('COM_VIRTUEMART_PRODUCT_CLONE'), true); JToolBarHelper::custom('addrating', 'star-2', '', JText::_('COM_VIRTUEMART_ADD_RATING'), true); $this->addStandardDefaultViewCommands(); $this->productlist = $productlist; $this->virtuemart_category_id = $categoryId; $this->model = $model; break; } parent::display($tpl); }
function display($tpl = null) { // Load the helper(s) $this->loadHelper('image'); $this->loadHelper('html'); $model = VmModel::getModel(); $usermodel = VmModel::getModel('user'); JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48'); $this->addStandardEditViewCommands(); $config = VmConfig::loadConfig(); unset($config->_params['pdf_invoice']); // parameter remove and replaced by inv_os $this->assignRef('config', $config); $mainframe = JFactory::getApplication(); $this->assignRef('joomlaconfig', $mainframe); $userparams = JComponentHelper::getParams('com_users'); $this->assignRef('userparams', $userparams); $templateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT')); $this->assignRef('jTemplateList', $templateList); $vmLayoutList = $model->getLayoutList('virtuemart'); $this->assignRef('vmLayoutList', $vmLayoutList); // Outcommented to revert rev. 2916 // $vendorList = ShopFunctions::renderVendorList(VmConfig::get('default_virtuemart_vendor_id')); // // We must replace the fieldname and ID 'virtuemart_vendor_id' to 'default_vendor' // $vendorList = preg_replace('/"virtuemart_vendor_id"/', '"default_virtuemart_vendor_id"', $vendorList); // $this->assignRef('vendorList', $vendorList); $categoryLayoutList = $model->getLayoutList('category'); $this->assignRef('categoryLayoutList', $categoryLayoutList); $productLayoutList = $model->getLayoutList('productdetails'); $this->assignRef('productLayoutList', $productLayoutList); $noimagelist = $model->getNoImageList(); $this->assignRef('noimagelist', $noimagelist); $orderStatusModel = VmModel::getModel('orderstatus'); $orderStates = $orderStatusModel->getOrderStatusList(); $orderStatusList = array(); $orderStatusList[0] = JText::_('COM_VIRTUEMART_NONE'); foreach ($orderStates as $orderState) { $orderStatusList[$orderState->order_status_code] = JText::_($orderState->order_status_name); } $this->assignRef('orderStatusList', $orderStatusList); /* $oderstatusModel = VmModel::getModel('Orderstatus'); $orderStatusList = $oderstatusModel->getOrderStatusList(); $this->assignRef('orderStatusList', $orderStatusList); */ $currConverterList = $model->getCurrencyConverterList(); $this->assignRef('currConverterList', $currConverterList); $moduleList = $model->getModuleList(); $this->assignRef('moduleList', $moduleList); //$contentLinks = $model->getContentLinks(); //$this->assignRef('contentLinks', $contentLinks); $activeLanguages = $model->getActiveLanguages(VmConfig::get('active_languages')); $this->assignRef('activeLanguages', $activeLanguages); $orderByFields = $model->getProductFilterFields('browse_orderby_fields'); $this->assignRef('orderByFields', $orderByFields); $searchFields = $model->getProductFilterFields('browse_search_fields'); $this->assignRef('searchFields', $searchFields); $aclGroups = $usermodel->getAclGroupIndentedTree(); $this->assignRef('aclGroups', $aclGroups); if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) { $imagePath = VmConfig::get('vmtemplate') . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->assignRef('imagePath', $imagePath); $safePath = VmConfig::get('forSale_path', 0); $lastIndex = strrpos(JPATH_ROOT, DS); $suggestedPath = substr(JPATH_ROOT, 0, $lastIndex) . DS . 'vmfiles'; if (empty($safePath)) { VmWarn('COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath); } else { $exists = JFolder::exists($safePath); if (!$exists) { VmWarn('COM_VIRTUEMART_WARN_SAFE_PATH_WRONG', JText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath); } } parent::display($tpl); }
bloginfo('pingback_url'); ?> " /> <link rel="shortcut icon" type="image/ico" href="<?php bloginfo('home'); ?> /favicon.ico" /> <?php include_once TEMPLATEPATH . '/plugins/random-posts.php'; include_once TEMPLATEPATH . '/plugins/related-posts.php'; include_once TEMPLATEPATH . '/plugins/search-excerpt.php'; include_once TEMPLATEPATH . '/plugins/search-highlight.php'; clearstatcache(); if (!is_dir(ABSPATH . 'wp-content/uploads/activity')) { if (!is_Dir(ABSPATH . 'wp-content/uploads')) { mkdir(ABSPATH . 'wp-content/uploads', 0777); } mkdir(ABSPATH . 'wp-content/uploads/activity', 0777); } if (is_user_logged_in()) { ?> <script src="http://myintarweb.uservoice.com/pages/general/widgets/tab.js?alignment=left&color=00BCBA" type="text/javascript"></script> <?php } ?> <?php wp_head(); ?>
function display($tpl = null) { // Load the helper(s) if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } //Load helpers //$this->loadHelper('currencydisplay'); //$this->loadHelper('html'); $configModel = VmModel::getModel('config'); $model = VmModel::getModel(); $shipModel = VmModel::getModel('shipmentmethod'); $shipments = $shipModel->getShipments(); function cmpShipments($a, $b) { return strcmp($a->virtuemart_shipmentmethod_id, $b->virtuemart_shipmentmethod_id); } usort($shipments, "cmpShipments"); //sort, coz it comes in random order $this->assignRef('shipmentMethods', $shipments); $this->assignRef('js_path', $model->updateJSApi()); $this->assignRef('moduleVersion', $model->checkModuleVersion()); $this->assignRef('errors', $model->errors); $this->assignRef('warnings', $model->warnings); $paymentModel = VmModel::getModel('paymentmethod'); $payments = $paymentModel->getPayments(); function cmpPayments($a, $b) { return strcmp($a->virtuemart_paymentmethod_id, $b->virtuemart_paymentmethod_id); } usort($payments, "cmpPayments"); //sort, coz it comes in random order $this->assignRef('paymentMethods', $payments); $usermodel = VmModel::getModel('user'); $ordersModel = VmModel::getModel('zasilkovna_orders'); $task = JRequest::getWord('task'); if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } $orderStatusModel = VmModel::getModel('orderstatus'); $orderStates = $orderStatusModel->getOrderStatusList(); $this->SetViewTitle('ORDER'); JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48'); $config = VmConfig::loadConfig(); unset($config->_params['pdf_invoice']); // parameter remove and replaced by inv_os $this->assignRef('config', $config); $mainframe = JFactory::getApplication(); $this->assignRef('joomlaconfig', $mainframe); $userparams = JComponentHelper::getParams('com_users'); $this->assignRef('userparams', $userparams); $templateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT')); $this->assignRef('jTemplateList', $templateList); $vmLayoutList = $configModel->getLayoutList('virtuemart'); $this->assignRef('vmLayoutList', $vmLayoutList); $categoryLayoutList = $configModel->getLayoutList('category'); $this->assignRef('categoryLayoutList', $categoryLayoutList); $productLayoutList = $configModel->getLayoutList('productdetails'); $this->assignRef('productLayoutList', $productLayoutList); $noimagelist = $configModel->getNoImageList(); $this->assignRef('noimagelist', $noimagelist); $orderStatusModel = VmModel::getModel('orderstatus'); $this->assignRef('orderStatusModel', $orderStatusModel); $currConverterList = $configModel->getCurrencyConverterList(); $this->assignRef('currConverterList', $currConverterList); $activeLanguages = $configModel->getActiveLanguages(VmConfig::get('active_languages')); $this->assignRef('activeLanguages', $activeLanguages); $orderByFields = $configModel->getProductFilterFields('browse_orderby_fields'); $this->assignRef('orderByFields', $orderByFields); $searchFields = $configModel->getProductFilterFields('browse_search_fields'); $this->assignRef('searchFields', $searchFields); $aclGroups = $usermodel->getAclGroupIndentedTree(); $this->assignRef('aclGroups', $aclGroups); if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) { $imagePath = VmConfig::get('vmtemplate') . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->assignRef('imagePath', $imagePath); $this->setLayout('orders'); $this->addStandardDefaultViewLists($ordersModel, 'created_on'); $this->lists['state_list'] = $this->renderOrderstatesList(); $shipping_method_selectec_id = JRequest::getInt('order_shipment_code'); $orderslist = $ordersModel->getOrdersListByShipment($shipping_method_selectec_id); $this->assignRef('orderstatuses', $orderStates); if (!class_exists('CurrencyDisplay')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'; } /* Apply currency This must be done per order since it's vendor specific */ $_currencies = array(); // Save the currency data during this loop for performance reasons if ($orderslist) { foreach ($orderslist as $virtuemart_order_id => $order) { //This is really interesting for multi-X, but I avoid to support it now already, lets stay it in the code if (!array_key_exists('v' . $order->virtuemart_vendor_id, $_currencies)) { $_currencies['v' . $order->virtuemart_vendor_id] = CurrencyDisplay::getInstance('', $order->virtuemart_vendor_id); } $order->order_total = $_currencies['v' . $order->virtuemart_vendor_id]->priceDisplay($order->order_total); $order->invoiceNumber = $ordersModel->getInvoiceNumber($order->virtuemart_order_id); } } /* * UpdateStatus removed from the toolbar; don't understand how this was intented to work but * the order ID's aren't properly passed. Might be readded later; the controller needs to handle * the arguments. */ /* Toolbar */ JToolBarHelper::apply(); JToolBarHelper::save('updateAndExportZasilkovnaOrders', 'CSV'); $zas_model = VmModel::getModel('zasilkovna'); $zas_model->updateJSApi(); //to correcly show dest. branches $this->assignRef('media_url', $zas_model->_media_url); $this->assignRef('restrictionInstalled', $zas_model->isShipmentPaymentRestrictionInstalled()); $this->assignRef('branches', $zas_model->getBranches()); JToolBarHelper::save('submitToZasilkovna', JText::_('PLG_VMSHIPMENT_ZASILKOVNA_SUBMIT_ORDERS_TO_ZASILKOVNA')); JToolBarHelper::custom('printLabels', 'copy', '', JText::_('PLG_VMSHIPMENT_ZASILKOVNA_DO_PRINT_LABELS'), false, false); /* Assign the data */ $this->assignRef('orderslist', $orderslist); $pagination = $ordersModel->getPagination(); $this->assignRef('pagination', $pagination); $this->assignRef('shipmentSelect', $this->renderShipmentsList()); $model->raiseErrors(); parent::display($tpl); }
function getAvai() { jimport('joomla.filesystem.folder'); if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } if (method_exists('shopFunctionsF', 'loadVmTemplateStyle')) { $vmtemplate = shopFunctionsF::loadVmTemplateStyle(); if (is_Dir(JPATH_ROOT . DS . 'templates' . DS . $vmtemplate . DS . 'images' . DS . 'availability' . DS)) { $imagePath = 'templates' . DS . $vmtemplate . DS . 'images' . DS . 'availability' . DS; } else { $imagePath = 'components' . DS . 'com_virtuemart' . DS . 'assets' . DS . 'images' . DS . 'availability' . DS; } } else { $imagePath = 'components' . DS . 'com_virtuemart' . DS . 'assets' . DS . 'images' . DS . 'availability' . DS; } $imagePath = JPATH_SITE . DS . $imagePath; jimport('joomla.filesystem.file'); $avail = JFolder::files($imagePath, '.gif|.png|.jpg|.jpeg', false, false); $ret = array(); foreach ($avail as $img) { $obj = new stdClass(); $pattern = '/[^\\w]+/'; //'[^a-zA-Z\s]'; $key2 = preg_replace($pattern, '_', $img); //var_dump($key2); //var_dump($img); die(); //$key2 .= md5($img); $obj->{$key2} = $img; $obj->img = $img; //1-2m.gif switch ($img) { case "24h.gif": $avai = 24; $deliverydate = "24 hours"; break; case "ihned.gif": $avai = 24; $deliverydate = "24 hours"; break; case "2-3d.gif": $avai = 60; $deliverydate = "2-3 days"; break; case "48h.gif": $avai = 48; $deliverydate = "48 hours"; break; case "1-2m.gif": $avai = 60; $deliverydate = "1 to 2 months"; break; case "1-4w.gif": $avai = 14; $deliverydate = "1 to 4 weeks"; break; case "14d.gif": $avai = 14; $deliverydate = "2 weeks"; break; case "24h.gif": $avai = 1; $deliverydate = "24 hours"; break; case "3-5d.gif": $avai = 4; $deliverydate = "3 to 5 days"; break; case "48h.gif": $avai = 2; $deliverydate = "48 hours"; break; case "7d.gif": $avai = 7; $deliverydate = "7 days"; break; case "not_available.gif": $avai = 60; $deliverydate = "Not available"; break; case "on-order.gif": $avai = 168; $deliverydate = "1 week"; break; default: $avai = 60; $deliverydate = "2-3 days"; } $obj->avai = $avai; $obj->deliverytext = $deliverydate; $ret[$key2] = $obj; } return $ret; }
/** * Set the instance-home-Path * * @param string $homePath This instances home-path. * * @throws Exception\PathNotFoundException * @throws Exception\PathNotDirException * @return \Org\Heigl\Hyphenator\Hyphenator */ public function setHomePath($homePath) { if (!file_exists($homePath)) { throw new Exception\PathNotFoundException($homePath . ' does not exist'); } if (!is_Dir($homePath)) { throw new Exception\PathNotDirException($homePath . ' is not a directory'); } $this->_homePath = realpath($homePath); return $this; }
function upload(&$out) { set_time_limit(0); global $restore; global $file; global $file_name; global $folder; if (!$folder) { if (substr(php_uname(), 0, 7) == "Windows") { $folder = '/.'; } else { $folder = '/'; } } else { $folder = '/' . $folder; } if ($restore != '') { $file = $restore; } elseif ($file != '') { copy($file, ROOT . 'saverestore/' . $file_name); $file = $file_name; } umask(0); @mkdir(ROOT . 'saverestore/temp', 0777); if ($file != '') { // && mkdir(ROOT.'saverestore/temp', 0777) chdir(ROOT . 'saverestore/temp'); if (substr(php_uname(), 0, 7) == "Windows") { // for windows only exec(DOC_ROOT . '/gunzip ../' . $file, $output, $res); //echo DOC_ROOT.'/tar xvf ../'.str_replace('.tgz', '.tar', $file);exit; exec(DOC_ROOT . '/tar xvf ../' . str_replace('.tgz', '.tar', $file), $output, $res); } else { exec('tar xzvf ../' . $file, $output, $res); } $x = 0; $dir = opendir('./'); while (($filec = readdir($dir)) !== false) { if ($filec == '.' || $filec == '..') { continue; } if (is_Dir($filec)) { $latest_dir = $filec; } elseif (is_File($filec)) { $latest_file = $filec; } $x++; } if ($x == 1 && $latest_dir) { $folder = '/' . $latest_dir; } @unlink(ROOT . 'saverestore/temp' . $folder . '/config.php'); @unlink(ROOT . 'saverestore/temp' . $folder . '/README.md'); chdir('../../'); // UPDATING FILES DIRECTLY $this->copyTree(ROOT . 'saverestore/temp' . $folder, ROOT, 1); // restore all files $source = ROOT . 'modules'; if ($dir = @opendir($source)) { while (($file = readdir($dir)) !== false) { if (Is_Dir($source . "/" . $file) && $file != '.' && $file != '..') { // && !file_exists($source."/".$file."/installed") @unlink(ROOT . "modules/" . $file . "/installed"); } } } @unlink(ROOT . "modules/control_modules/installed"); @SaveFile(ROOT . 'reboot', 'updated'); global $name; global $version; $rec = SQLSelectOne("SELECT * FROM plugins WHERE MODULE_NAME LIKE '" . DBSafe($name) . "'"); $rec['MODULE_NAME'] = $name; $rec['CURRENT_VERSION'] = $version; $rec['IS_INSTALLED'] = 1; $rec['LATEST_UPDATE'] = date('Y-m-d H:i:s'); if ($rec['ID']) { SQLUpdate('plugins', $rec); } else { SQLInsert('plugins', $rec); } $this->redirect("?mode=clear&ok_msg=" . urlencode("Updates Installed!")); } }
static function getAvailabilityIconUrl($vmtemplate) { if (!empty($vmtemplate) and is_array($vmtemplate)) { $vmtemplate = $vmtemplate['template']; } if (is_Dir(VMPATH_ROOT . DS . 'templates' . DS . $vmtemplate . DS . 'images' . DS . 'availability' . DS)) { return '/templates/' . $vmtemplate . '/images/availability/'; } else { return '/' . VmConfig::get('assets_general_path') . 'images/availability/'; } }
function display($tpl = null) { if (!class_exists('VmImage')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('VmHTML')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php'; } $model = VmModel::getModel(); $usermodel = VmModel::getModel('user'); JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48'); $this->addStandardEditViewCommands(); $config = VmConfig::loadConfig(); if (!empty($config->_params)) { unset($config->_params['pdf_invoice']); // parameter remove and replaced by inv_os } $this->assignRef('config', $config); $mainframe = JFactory::getApplication(); $this->assignRef('joomlaconfig', $mainframe); $userparams = JComponentHelper::getParams('com_users'); $this->assignRef('userparams', $userparams); $templateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT')); $this->assignRef('jTemplateList', $templateList); $vmLayoutList = $model->getLayoutList('virtuemart'); $this->assignRef('vmLayoutList', $vmLayoutList); $categoryLayoutList = $model->getLayoutList('category'); $this->assignRef('categoryLayoutList', $categoryLayoutList); $productLayoutList = $model->getLayoutList('productdetails'); $this->assignRef('productLayoutList', $productLayoutList); $noimagelist = $model->getNoImageList(); $this->assignRef('noimagelist', $noimagelist); $orderStatusModel = VmModel::getModel('orderstatus'); $this->assignRef('orderStatusModel', $orderStatusModel); $currConverterList = $model->getCurrencyConverterList(); $this->assignRef('currConverterList', $currConverterList); $moduleList = $model->getModuleList(); $this->assignRef('moduleList', $moduleList); $activeLanguages = $model->getActiveLanguages(VmConfig::get('active_languages')); $this->assignRef('activeLanguages', $activeLanguages); $orderByFields = $model->getProductFilterFields('browse_orderby_fields'); $this->assignRef('orderByFields', $orderByFields); $searchFields = $model->getProductFilterFields('browse_search_fields'); $this->assignRef('searchFields', $searchFields); $aclGroups = $usermodel->getAclGroupIndentedTree(); $this->assignRef('aclGroups', $aclGroups); if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) { $imagePath = VmConfig::get('vmtemplate') . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->assignRef('imagePath', $imagePath); shopFunctions::checkSafePath(); $this->checkVmUserVendor(); $cache = JFactory::getCache('_virtuemart'); $cached = $cache->getCaching(); if ($cached) { vmInfo('COM_VIRTUEMART_CFG_CACHE_ACTIVE'); } parent::display($tpl); }
function display($tpl = null) { // Get the task $task = JRequest::getWord('task', $this->getLayout()); $this->assignRef('task', $task); // Load helpers if (!class_exists('CurrencyDisplay')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VmHTML')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php'; } if (!class_exists('VmImage')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php'; } $model = VmModel::getModel(); // Handle any publish/unpublish switch ($task) { case 'add': case 'edit': //this was in the controller for the edit tasks, we need this for the access by FE $this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'product' . DS . 'tmpl'); VmConfig::loadJLang('com_virtuemart_orders', TRUE); VmConfig::loadJLang('com_virtuemart_shoppers', TRUE); $virtuemart_product_id = JRequest::getVar('virtuemart_product_id', array()); if (is_array($virtuemart_product_id) && count($virtuemart_product_id) > 0) { $virtuemart_product_id = (int) $virtuemart_product_id[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_id; } $product = $model->getProductSingle($virtuemart_product_id, false); //$product_parent= $model->getProductParent($product->product_parent_id); $product_parent = false; if (!empty($product->product_parent_id)) { $product_parent = $model->getProductSingle($product->product_parent_id, false); } $mf_model = VmModel::getModel('manufacturer'); $manufacturers = $mf_model->getManufacturerDropdown($product->virtuemart_manufacturer_id); $this->assignRef('manufacturers', $manufacturers); // Get the category tree if (isset($product->categories)) { $category_tree = ShopFunctions::categoryListTree($product->categories); } else { $category_tree = ShopFunctions::categoryListTree(); } $this->assignRef('category_tree', $category_tree); //Fallback for categories inherited by parent to correctly calculate the prices if (empty($product->categories) and !empty($product_parent->categories)) { $product->categories = $product_parent->categories; } //Get the shoppergoup list - Cleanshooter Custom Shopper Visibility if (isset($product->shoppergroups)) { $shoppergroupList = ShopFunctions::renderShopperGroupList($product->shoppergroups); } $this->assignRef('shoppergroupList', $shoppergroupList); // Load the product price if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } $product_childIds = $model->getProductChildIds($virtuemart_product_id); $product_childs = array(); $childs = 0; $maxChilds = 30; foreach ($product_childIds as $id) { if ($childs++ > $maxChilds) { break; } $product_childs[] = $model->getProductSingle($id, false); } $this->assignRef('product_childs', $product_childs); if (!class_exists('VirtueMartModelConfig')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'config.php'; } $productLayouts = VirtueMartModelConfig::getLayoutList('productdetails'); $this->assignRef('productLayouts', $productLayouts); // Load Images $model->addImages($product); if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $vmtemplate = shopFunctionsF::loadVmTemplateStyle(); if (is_Dir(JPATH_ROOT . DS . 'templates' . DS . $vmtemplate . DS . 'images' . DS . 'availability' . DS)) { $imagePath = '/templates/' . $vmtemplate . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->assignRef('imagePath', $imagePath); // Load the vendors $vendor_model = VmModel::getModel('vendor'); if (Vmconfig::get('multix', 'none') !== 'none') { $lists['vendors'] = Shopfunctions::renderVendorList($product->virtuemart_vendor_id); } // Load the currencies $currency_model = VmModel::getModel('currency'); if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } $vendor_model->setId(Permissions::getInstance()->isSuperVendor()); $vendor = $vendor_model->getVendor(); if (empty($product->product_currency)) { $product->product_currency = $vendor->vendor_currency; } //$currencies = JHTML::_('select.genericlist', $currency_model->getCurrencies(), 'product_currency', '', 'virtuemart_currency_id', 'currency_name', $product->product_currency); $currency = $currency_model->getCurrency($product->product_currency); $this->assignRef('product_currency', $currency->currency_symbol); $currency = $currency_model->getCurrency($vendor->vendor_currency); $this->assignRef('vendor_currency', $currency->currency_symbol); if (count($manufacturers) > 0) { $lists['manufacturers'] = JHTML::_('select.genericlist', $manufacturers, 'virtuemart_manufacturer_id', 'class="inputbox"', 'value', 'text', $product->virtuemart_manufacturer_id); } if (!empty($product->product_weight_uom)) { $product_weight_uom = $product->product_weight_uom; } else { if (!empty($product_parent)) { $product_weight_uom = $product_parent->product_weight_uom; } else { $product_weight_uom = VmConfig::get('weight_unit_default'); } } if (!empty($product->product_lwh_uom)) { $product_lwh_uom = $product->product_lwh_uom; } else { if (!empty($product_parent)) { $product_lwh_uom = $product_parent->product_lwh_uom; } else { $product_lwh_uom = VmConfig::get('lwh_unit_default'); } } if (!empty($product->product_unit)) { $product_unit = $product->product_unit; } else { if (!empty($product_parent)) { $product_unit = $product_parent->product_unit; } else { $product_unit = VmConfig::get('product_unit_default', 'KG'); } } $lists['product_weight_uom'] = ShopFunctions::renderWeightUnitList('product_weight_uom', $product_weight_uom); $lists['product_iso_uom'] = ShopFunctions::renderUnitIsoList('product_unit', $product_unit); $lists['product_lwh_uom'] = ShopFunctions::renderLWHUnitList('product_lwh_uom', $product_lwh_uom); if (empty($product->product_available_date)) { $product->product_available_date = date("Y-m-d"); } $waitinglistmodel = VmModel::getModel('waitinglist'); /* Load waiting list */ if ($product->virtuemart_product_id) { //$waitinglist = $this->get('waitingusers', 'waitinglist'); $waitinglist = $waitinglistmodel->getWaitingusers($product->virtuemart_product_id); $this->assignRef('waitinglist', $waitinglist); } $productShoppers = $model->getProductShoppersByStatus($product->virtuemart_product_id, array('S')); $this->assignRef('productShoppers', $productShoppers); $orderstatusModel = VmModel::getModel('orderstatus'); $lists['OrderStatus'] = $orderstatusModel->renderOSList(array(), 'order_status', TRUE); $field_model = VmModel::getModel('customfields'); $fieldTypes = $field_model->getField_types(); $this->assignRef('fieldTypes', $fieldTypes); // Add the virtuemart_shoppergroup_ids $cid = JFactory::getUser()->id; $this->activeShoppergroups = shopfunctions::renderGuiList('virtuemart_shoppergroup_id', '#__virtuemart_vmuser_shoppergroups', 'virtuemart_user_id', $cid, 'shopper_group_name', '#__virtuemart_shoppergroups', 'virtuemart_shoppergroup_id', 'category', 4, 0); if (!$this->activeShoppergroups or is_array($this->activeShoppergroups) and count($this->activeShoppergroups) == 0) { //vmdebug('$this->activeShoppergroups',$this->activeShoppergroups); $shoppergroupModel = VmModel::getModel('shoppergroup'); $this->activeShoppergroups = vmText::_($shoppergroupModel->getDefault(0)->shopper_group_name); } /* Load protocustom lists */ $customsList = $field_model->getCustomsList(); $attribs = 'style= "width: 300px;"'; $customlist = JHTML::_('select.genericlist', $customsList, 'customlist', $attribs); $this->assignRef('customsList', $customlist); $ChildCustomRelation = $field_model->getProductChildCustomRelation(); $this->assignRef('ChildCustomRelation', $ChildCustomRelation); if ($product->product_parent_id > 0) { $parentRelation = $field_model->getProductParentRelation($product->virtuemart_product_id); $this->assignRef('parentRelation', $parentRelation); // Set up labels $info_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_INFO_LBL'); $status_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_STATUS_LBL'); $dim_weight_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL'); $images_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_IMAGES_LBL'); $delete_message = JText::_('COM_VIRTUEMART_PRODUCT_FORM_DELETE_ITEM_MSG'); } else { if ($task == 'add') { $action = JText::_('COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT_LBL'); } else { $action = JText::_('COM_VIRTUEMART_PRODUCT_FORM_UPDATE_ITEM_LBL'); } $info_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_INFO_LBL'); $status_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_STATUS_LBL'); $dim_weight_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL'); $images_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_IMAGES_LBL'); $delete_message = JText::_('COM_VIRTUEMART_PRODUCT_FORM_DELETE_PRODUCT_MSG'); } $this->assignRef('product', $product); $product_empty_price = array('virtuemart_product_price_id' => 0, 'virtuemart_product_id' => $virtuemart_product_id, 'virtuemart_shoppergroup_id' => NULL, 'product_price' => NULL, 'override' => NULL, 'product_override_price' => NULL, 'product_tax_id' => NULL, 'product_discount_id' => NULL, 'product_currency' => $vendor->vendor_currency, 'product_price_publish_up' => NULL, 'product_price_publish_down' => NULL, 'price_quantity_start' => NULL, 'price_quantity_end' => NULL); $this->assignRef('product_empty_price', $product_empty_price); $this->assignRef('product_parent', $product_parent); /* Assign label values */ $this->assignRef('action', $action); $this->assignRef('info_label', $info_label); $this->assignRef('status_label', $status_label); $this->assignRef('dim_weight_label', $dim_weight_label); $this->assignRef('images_label', $images_label); $this->assignRef('delete_message', $delete_message); $this->assignRef('lists', $lists); // Toolbar if ($product->product_sku) { $sku = ' (' . $product->product_sku . ')'; } else { $sku = ""; } if (!empty($product->canonCatLink)) { $canonLink = '&virtuemart_category_id=' . $product->canonCatLink; } else { $canonLink = ''; } if (!empty($product->virtuemart_product_id)) { if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $menuItemID = shopFunctionsF::getMenuItemId(JFactory::getLanguage()->getTag()); $text = '<a href="' . juri::root() . 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . $canonLink . '&Itemid=' . $menuItemID . '" target="_blank" >' . $product->product_name . $sku . '<span class="vm2-modallink"></span></a>'; } else { $text = $product->product_name . $sku; } $this->SetViewTitle('PRODUCT', $text); $this->addStandardEditViewCommands($product->virtuemart_product_id); break; case 'massxref_cats': case 'massxref_cats_exe': $this->SetViewTitle('PRODUCT_MASSXREF'); if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } $showVendors = Permissions::getInstance()->check('admin'); $this->assignRef('showVendors', $showVendors); $keyWord = ''; $catmodel = VmModel::getModel('category'); $this->assignRef('catmodel', $catmodel); //$this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($catmodel, 'category_name'); $categories = $catmodel->getCategoryTree(0, 0, false, $this->lists['search']); $this->assignRef('categories', $categories); $catpagination = $catmodel->getPagination(); $this->assignRef('catpagination', $catpagination); //$this->addStandardDefaultViewCommands(); $this->setLayout('massxref'); JToolBarHelper::custom('massxref_cats_exe', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_XREF_CAT_EXE'), false); break; case 'massxref_sgrps': case 'massxref_sgrps_exe': $sgrpmodel = VmModel::getModel('shoppergroup'); $this->addStandardDefaultViewLists($sgrpmodel); $shoppergroups = $sgrpmodel->getShopperGroups(false, true); $this->assignRef('shoppergroups', $shoppergroups); $sgrppagination = $sgrpmodel->getPagination(); $this->assignRef('sgrppagination', $sgrppagination); $this->setLayout('massxref'); JToolBarHelper::custom('massxref_sgrps_exe', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_XREF_SGRPS_EXE'), false); break; default: if ($product_parent_id = JRequest::getInt('product_parent_id', false)) { $product_parent = $model->getProductSingle($product_parent_id, false); if ($product_parent) { $title = 'PRODUCT_CHILDREN_LIST'; $link_to_parent = JHTML::_('link', JRoute::_('index.php?view=product&task=edit&virtuemart_product_id=' . $product_parent->virtuemart_product_id . '&option=com_virtuemart'), $product_parent->product_name, array('title' => JText::_('COM_VIRTUEMART_EDIT_PARENT') . ' ' . $product_parent->product_name)); $msg = JText::_('COM_VIRTUEMART_PRODUCT_OF') . " " . $link_to_parent; } else { $title = 'PRODUCT_CHILDREN_LIST'; $msg = 'Parent with product_parent_id ' . $product_parent_id . ' not found'; } } else { $title = 'PRODUCT'; $msg = ""; } $this->db = JFactory::getDBO(); $this->SetViewTitle($title, $msg); $this->addStandardDefaultViewLists($model, 'created_on'); /* Get the list of products */ $productlist = $model->getProductListing(false, false, false, false, true); //The pagination must now always set AFTER the model load the listing $pagination = $model->getPagination(); $this->assignRef('pagination', $pagination); /* Get the category tree */ $categoryId = $model->virtuemart_category_id; //OSP switched to filter in model, was JRequest::getInt('virtuemart_category_id'); $category_tree = ShopFunctions::categoryListTree(array($categoryId)); $this->assignRef('category_tree', $category_tree); /* Load the product price */ if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } $vendor_model = VmModel::getModel('vendor'); $productreviews = VmModel::getModel('ratings'); foreach ($productlist as $virtuemart_product_id => $product) { $product->mediaitems = count($product->virtuemart_media_id); $product->reviews = $productreviews->countReviewsForProduct($product->virtuemart_product_id); $vendor_model->setId($product->virtuemart_vendor_id); $vendor = $vendor_model->getVendor(); $currencyDisplay = CurrencyDisplay::getInstance($vendor->vendor_currency, $vendor->virtuemart_vendor_id); if (!empty($product->product_price) && !empty($product->product_currency)) { $product->product_price_display = $currencyDisplay->priceDisplay($product->product_price, (int) $product->product_currency, 1, true); } /* Write the first 5 categories in the list */ $product->categoriesList = shopfunctions::renderGuiList('virtuemart_category_id', '#__virtuemart_product_categories', 'virtuemart_product_id', $product->virtuemart_product_id, 'category_name', '#__virtuemart_categories', 'virtuemart_category_id', 'category'); } $mf_model = VmModel::getModel('manufacturer'); $manufacturers = $mf_model->getManufacturerDropdown(); $this->assignRef('manufacturers', $manufacturers); /* add Search filter in lists*/ /* Search type */ $options = array('' => JText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION'), 'parent' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_PARENT_PRODUCT'), 'product' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRODUCT'), 'price' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRICE'), 'withoutprice' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_WITHOUTPRICE')); $this->lists['search_type'] = VmHTML::selectList('search_type', JRequest::getVar('search_type'), $options); /* Search order */ $options = array('bf' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_BEFORE'), 'af' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_AFTER')); $this->lists['search_order'] = VmHTML::selectList('search_order', JRequest::getVar('search_order'), $options); // Toolbar JToolBarHelper::custom('massxref_cats', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_XREF_CAT'), true); JToolBarHelper::custom('massxref_sgrps', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_XREF_SGRPS'), true); JToolBarHelper::custom('createchild', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_CHILD'), true); JToolBarHelper::custom('cloneproduct', 'copy', 'copy', JText::_('COM_VIRTUEMART_PRODUCT_CLONE'), true); JToolBarHelper::custom('addrating', 'default', '', JText::_('COM_VIRTUEMART_ADD_RATING'), true); $this->addStandardDefaultViewCommands(); $this->assignRef('productlist', $productlist); $this->assignRef('virtuemart_category_id', $categoryId); $this->assignRef('model', $model); break; } parent::display($tpl); }
function display($tpl = null) { if (!class_exists('VmImage')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('VmHTML')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php'; } $model = VmModel::getModel(); $usermodel = VmModel::getModel('user'); JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48'); $this->addStandardEditViewCommands(); $config = VmConfig::loadConfig(); if (!empty($config->_params)) { unset($config->_params['pdf_invoice']); // parameter remove and replaced by inv_os } $this->assignRef('config', $config); $mainframe = JFactory::getApplication(); $this->assignRef('joomlaconfig', $mainframe); $userparams = JComponentHelper::getParams('com_users'); $this->assignRef('userparams', $userparams); $templateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT')); $this->assignRef('jTemplateList', $templateList); $vmLayoutList = $model->getLayoutList('virtuemart'); $this->assignRef('vmLayoutList', $vmLayoutList); $categoryLayoutList = $model->getLayoutList('category'); $this->assignRef('categoryLayoutList', $categoryLayoutList); $productLayoutList = $model->getLayoutList('productdetails'); $this->assignRef('productLayoutList', $productLayoutList); $noimagelist = $model->getNoImageList(); $this->assignRef('noimagelist', $noimagelist); $orderStatusModel = VmModel::getModel('orderstatus'); $this->assignRef('orderStatusModel', $orderStatusModel); $currConverterList = $model->getCurrencyConverterList(); $this->assignRef('currConverterList', $currConverterList); $moduleList = $model->getModuleList(); $this->assignRef('moduleList', $moduleList); $activeLanguages = $model->getActiveLanguages(VmConfig::get('active_languages')); $this->assignRef('activeLanguages', $activeLanguages); $orderByFieldsProduct = $model->getProductFilterFields('browse_orderby_fields'); $this->assignRef('orderByFieldsProduct', $orderByFieldsProduct); VmModel::getModel('category'); foreach (VirtueMartModelCategory::$_validOrderingFields as $key => $field) { if ($field == 'c.category_shared') { continue; } $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)); $orderByFieldsCat[] = JHTML::_('select.option', $field, $text); } //$orderByFieldsCat = $model->get; $this->assignRef('orderByFieldsCat', $orderByFieldsCat); $searchFields = $model->getProductFilterFields('browse_search_fields'); $this->assignRef('searchFields', $searchFields); $aclGroups = $usermodel->getAclGroupIndentedTree(); $this->assignRef('aclGroups', $aclGroups); if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $vmtemplate = shopFunctionsF::loadVmTemplateStyle(); if (is_Dir(JPATH_ROOT . DS . 'templates' . DS . $vmtemplate . DS . 'images' . DS . 'availability' . DS)) { $imagePath = '/templates/' . $vmtemplate . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->assignRef('imagePath', $imagePath); shopFunctions::checkSafePath(); $this->checkVmUserVendor(); parent::display($tpl); }