/** * @param array $app * @param array $config */ public function __construct($app, $config = array()) { parent::__construct($app, $config); $this->app->jbdoc->noindex(); $this->_jbmoney = $this->app->jbmoney; $this->_config = JBModelConfig::model()->getGroup('cart.config'); $this->cart = JBCart::getInstance(); $this->application = $this->app->zoo->getApplication(); // load template $tmplName = $this->_config->get('tmpl_name', 'uikit'); $templates = $this->application->getTemplates(); $this->template = $this->application->getTemplate(); if (isset($templates[$tmplName])) { $this->template = $templates[$tmplName]; } if (!$this->_config->get('enable', 1)) { $this->app->jbnotify->error('JBZOO_CART_DISABLED'); } if (!$this->cart->canAccess($this->app->user->get())) { $user = JFactory::getUser(); if (empty($user->id)) { $url = 'index.php?option=com_users&view=login&return=' . base64_encode($this->app->jbenv->getCurrentUrl()); $this->setRedirect($url, JText::_('JBZOO_CART_NEED_LOGIN')); } else { $this->app->jbnotify->error('JBZOO_CART_UNABLE_ACCESS'); } } }
/** * @param array $app * @param array $config * @throws AppException */ public function __construct($app, $config = array()) { parent::__construct($app, $config); $this->_jbrequest = $this->app->jbrequest; $task = $this->_jbrequest->getWord('task'); $ctrl = $this->_jbrequest->getCtrl(); if (!method_exists($this, $task)) { throw new AppException('Action method not found! ' . $ctrl . ' :: ' . $task . '()'); } // internal vars $this->application = $this->app->zoo->getApplication(); $this->_params = $this->application->getParams('frontpage'); $this->joomla = $this->app->system->application; $isSite = $this->app->jbenv->isSite(); if (!$isSite) { $this->app->document->addStylesheet("root:administrator/templates/system/css/system.css"); $this->app->jbassets->uikit(true, true); $this->_setToolbarTitle(); } else { $this->params = $this->joomla->getParams(); $this->pathway = $this->joomla->getPathway(); $this->app->jbassets->setAppCSS(); $this->app->jbassets->setAppJS(); } $this->_config = JBModelConfig::model(); }
/** * Class constructor * @param App $app * @param null $path */ public function __construct($app, $path = null) { parent::__construct($app, $path); $this->_position = $app->jbcartposition; $this->_element = $app->jbcartelement; $this->_config = JBModelConfig::model(); }
/** * Init JBTemplate * @param $event */ public function init($event) { $application = $event->getSubject(); $isSite = $this->app->jbenv->isSite(); $appGroup = $application->application_group; $template = $application->params->get('template'); $controller = $this->app->jbrequest->get('controller'); $task = $this->app->jbrequest->get('task'); $application->cartConfig = JBModelConfig::model()->getGroup('cart.config'); if ($controller == 'basket' && $task == 'index') { $application->basketTmpl = $template = $application->cartConfig->get('tmpl_name', 'uikit'); } if ($isSite && $appGroup == JBZOO_APP_GROUP) { $classPath = $this->_getClassPath(); $tmplClassPath = $this->_getTmplClassPath($template); require_once "{$classPath}"; $this->_initMethod($event, $this->_classPrefix, 'init'); $template = $this->camelize($template); if (file_exists($tmplClassPath)) { require_once "{$tmplClassPath}"; $this->_initMethod($event, $this->_getClassName($template)); } else { $this->_initMethod($event, $this->_classPrefix); } } if ($appGroup == JBZOO_APP_GROUP) { JFactory::getLanguage()->load('jbzoo_' . $template, $this->app->path->path('jbtmpl:' . $template)); } }
/** * @param Element $element * @param int $applicationId * @param string $itemType */ public function __construct(Element $element, $applicationId, $itemType) { parent::__construct($element, $applicationId, $itemType); $this->money = $this->app->jbmoney; $this->helper = $this->app->jbprice; $this->_currency = JBModelConfig::model()->getCurrency(); }
/** * Compatibility list of params were saved in config files * @param string|null $group * @return array|object */ public function getList($group = null) { $ymlConfig = $this->app->path->path('jbapp:config') . '/yml_config.php'; if (JFile::exists($ymlConfig)) { require_once $ymlConfig; } $config = $this->app->path->path('jbapp:config') . '/config.php'; if (JFile::exists($config)) { require_once $config; } $result = array(); foreach ($this->_oldVersionMap as $key => $value) { if (!defined($key)) { continue; } if (in_array($key, array('JBZOO_CONFIG_YML_TYPE', 'JBZOO_CONFIG_YML_APP_LIST'))) { $result[$value] = explode(':', constant($key)); } else { $result[$value] = constant($key); } } if (!empty($group)) { $result = JBModelConfig::model()->getGroup($group, $result); } return $this->app->data->create($result); }
/** * @return array */ public function toCSV() { $params = JBModelConfig::model()->getGroup('export.items'); if ((int) $params->merge_repeatable) { return implode(JBCSVItem::SEP_ROWS, $this->_item->getTags()); } else { return $this->_item->getTags(); } }
/** * @param App $app */ public function __construct($app) { parent::__construct($app); $this->_lessFull = JPath::clean($this->app->path->path('jbapp:assets/less')); $this->_lessRel = JUri::root() . $this->app->path->relative($this->_lessFull); $this->_minFull = JPath::clean($this->app->path->path('root:') . '/cache/jbzoo_assets'); $this->_minRel = $this->app->path->relative($this->_minFull); $this->_force = (int) JBModelConfig::model()->get('less_mode', '0', 'config.assets'); $this->_jbcache = $this->app->jbcache; }
/** * Class Constructor */ public function __construct() { // get app instance $this->app = App::getInstance('zoo'); $this->_config = JBModelConfig::model()->getGroup('cart'); // decorate data as object $this->params = $this->app->parameter->create(array(JBCart::CONFIG_MODIFIER_ORDER_PRICE => $this->_config->find(JBCart::ELEMENT_TYPE_MODIFIER_ORDER_PRICE . '.' . JBCart::DEFAULT_POSITION, array()), JBCart::CONFIG_MODIFIER_ITEM_PRICE => $this->_config->find(JBCart::ELEMENT_TYPE_MODIFIER_ITEM_PRICE . '.' . JBCart::DEFAULT_POSITION, array()))); // decorate data as object $this->_elements = $this->app->data->create(array()); $this->_items = $this->app->data->create($this->_items); }
/** * @param App $app */ public function __construct($app) { parent::__construct($app); $this->_config = JBModelConfig::model(); $this->_defaultCur = $this->_config->getCurrency(); $this->_currencyMode = $this->_config->get('undefined_currency', 'default', 'cart.config'); if (empty($this->_currencyMode)) { $this->_currencyMode = 'default'; } $this->_jbcache = $this->app->jbcache; }
/** * @param string $eventType * @param JBCartOrder $order * @return array */ public function getByEvent($eventType = null, $order) { $result = array(); $eventType = 'list'; // TODO add new evenet types $params = JBModelConfig::model()->get($eventType, array(), 'cart.validator'); if (!empty($params)) { $result = array(); foreach ($params as $elementParams) { $result[$elementParams['identifier']] = $order->getValidatorElement($elementParams['identifier']); } } return $result; }
/** * @param App $app */ public function __construct($app) { parent::__construct($app); $this->_cachePath = JPath::clean($this->app->path->path('root:') . '/cache/jbzoo_assets'); $this->_config = JBModelConfig::model()->getGroup('config.assets'); $this->_jbfile = $this->app->jbfile; $this->_jbcache = $this->app->jbcache; // for developers if ($this->_repoPath = realpath($this->app->path->path('jbapp:') . '/../../../')) { foreach ($this->_simlinks as $locPath => $repoPath) { $this->_simlinks[$locPath] = JPath::clean($this->_repoPath . '/' . $repoPath); } } else { $this->_simlinks = array(); } }
/** * On type deleted * @param AppEvent $event */ public static function deleted($event) { $app = self::app(); $type = $event->getSubject(); $config = JBModelConfig::model(); $elements = $app->jbprice->getTypePrices($type); $tableName = $app->jbtables->getIndexTable($type->id); $app->jbtables->dropTable($tableName); if (!empty($elements)) { foreach ($elements as $id => $element) { $config->removeGroup('cart.' . JBCart::ELEMENT_TYPE_PRICE . '.' . $id); $config->removeGroup('cart.' . JBCart::CONFIG_PRICE_TMPL . '.' . $id); $config->removeGroup('cart.' . JBCart::CONFIG_PRICE_TMPL_FILTER . '.' . $id); } } }
/** * @return string */ public function toCSV() { $settings = JBModelConfig::model()->getGroup('export.categories'); if ($settings->category_settings) { $arrayParams = array(); $params = $this->_category->getParams()->get('template.'); foreach ($params as $key => $value) { if (preg_match('/^category*/', $key) && $key !== 'lastmodified') { $arrayParams[$key] = $value; } } $result = $this->_packToLine($arrayParams); return $result; } else { return parent::toCSV(); } }
/** * @return string */ public function toCSV() { $settings = JBModelConfig::model()->getGroup('export.categories'); if ($settings->config_category_settings) { $arrayParams = array(); $params = $this->_category->getParams()->get('config.'); foreach ($params as $key => $value) { if ($key == 'show_feed_link') { $arrayParams[$key] = $value; } } $result = $this->_packToLine($arrayParams); return $result; } else { return parent::toCSV(); } }
/** * @return string */ public function toCSV() { $settings = JBModelConfig::model()->getGroup('export.categories'); if ($settings->config_items_order_settings) { $result = ''; $arrayParams = array(); $params = $this->_category->getParams()->get('config.'); foreach ($params as $key => $value) { if ($key == 'item_order') { $arrayParams = $value; } } $result = $this->_packToLine($arrayParams, true); return $result; } else { return parent::toCSV(); } }
/** * @return array */ protected function _getSliderParams() { $categoryId = $min = $max = null; $to = $this->_getCurrency(); $params = array('auto' => (int) $this->_params->get('jbzoo_filter_slider_auto', 0), 'min' => $this->_params->get('jbzoo_filter_slider_min', 0), 'max' => $this->_params->get('jbzoo_filter_slider_max', 10000), 'step' => $this->_params->get('jbzoo_filter_slider_step', 100)); if ($params['auto']) { $applicationId = (int) $this->_params->get('item_application_id', 0); $isCatDepend = (int) $this->_params->moduleParams->get('depend_category'); $itemType = $this->_params->get('item_type', null); if ($isCatDepend) { $categoryId = $this->app->jbrequest->getSystem('category'); } $rangesData = (array) JBModelValues::model()->getRangeByPrice($this->_jbprice->identifier, $itemType, $applicationId, $categoryId); $cur = JBModelConfig::model()->getCurrency(); $params['min'] = JBCart::val($rangesData['total_min'], $cur)->val($to); $params['max'] = JBCart::val($rangesData['total_max'], $cur)->val($to); } return $params; }
/** * @param JBCartOrder $order * @param bool|false $silentMode * @return int|mixed */ public function save(JBCartOrder $order, $silentMode = false) { $this->app->jbtables->checkOrder(); $currencies = $order->getCurrencyList(); $params = $order->getParams(); $params->set(JBCart::CONFIG_CURRENCIES, $currencies); $cartConfig = $order->params->find('config'); if (!$cartConfig) { $cartConfig = JBModelConfig::model()->getGroup('cart.config'); } $params->set('config', (array) $cartConfig); $total = $order->getTotalSum()->data(); $data = array('id' => $order->id, 'status' => $order->getStatus()->getCode(), 'status_payment' => $order->getPaymentStatus(), 'status_shipping' => $order->getShippingStatus(), 'created' => $order->created, 'created_by' => $order->created_by, 'total' => $total[0], 'items' => $order->getItems(false), 'fields' => $order->getFields(), 'shippingfields' => $order->getShippingFields(), 'modifiers' => $order->getModifiersData(), 'params' => $params, 'comment' => $order->comment); if ($shipping = $order->getShipping()) { $data['shipping'] = $shipping->data(); } if ($payment = $order->getPayment()) { $data['payment'] = $payment->data(); } if (!$silentMode) { $this->app->jbevent->fire($order, 'basket:beforeSave'); } if ($data['id'] <= 0) { unset($data['id']); $order->id = $this->_insert($data, ZOO_TABLE_JBZOO_ORDER); //TODO hardcoded $order->setItemsData((string) $data['items']); if (!$silentMode) { $this->app->jbevent->fire($order, 'basket:saved'); } } else { $data['modified'] = $this->app->jbdate->toMySql(); $this->_update($data, ZOO_TABLE_JBZOO_ORDER); if (!$silentMode) { $this->app->jbevent->fire($order, 'basket:updated'); } } if ($order->id && !$silentMode) { $this->app->jbevent->fire($order, 'basket:afterSave'); } return $order->id; }
/** * @return string */ public function toCSV() { $settings = JBModelConfig::model()->getGroup('export.categories'); if ($settings->config_others_settings) { $arrayParams = array(); $paramsConfig = $this->_category->getParams()->get('config.'); $paramsTemplate = $this->_category->getParams()->get('template.'); $params = array_merge($paramsConfig, $paramsTemplate); $others = array('alpha_index', 'alpha_chars', 'show_alpha_index'); foreach ($params as $key => $value) { if (in_array($key, $others)) { $arrayParams[$key] = $value; } } $result = $this->_packToLine($arrayParams); return $result; } else { return parent::toCSV(); } }
/** * @param App $app */ public function __construct($app) { parent::__construct($app); // get sef configs $this->_config = JBModelConfig::model()->getGroup('config.sef', array()); // helpers for alias $this->_aliasCat = $this->app->alias->category; $this->_aliasItem = $this->app->alias->item; $this->_aliasApp = $this->app->alias->application; // get other helpers $this->_string = $this->app->string; $this->_joomlaApp = $this->app->system->application; $this->_joomlaDoc = $this->app->system->document; $this->_jbrequest = $this->app->jbrequest; $this->_jbrouter = $this->app->jbrouter; $this->_jbdebug = $this->app->jbdebug; // get links to tables $this->_itemTable = $this->app->table->item; $this->_catTable = $this->app->table->category; $this->_appTable = $this->app->table->application; }
/** * Render HTML * @return string */ public function html() { $html = array(); $value = $this->_prepareValues(); $categoryId = $min = $max = null; $params = array('auto' => (int) $this->_params->get('jbzoo_filter_slider_auto', 0), 'min' => $this->_params->get('jbzoo_filter_slider_min', 0), 'max' => $this->_params->get('jbzoo_filter_slider_max', 10000), 'step' => $this->_params->get('jbzoo_filter_slider_step', 100)); $to = $this->_params->get('jbzoo_filter_currency_default', 'default_cur'); if ($params['auto']) { $applicationId = (int) $this->_params->get('item_application_id', 0); $isCatDepend = (int) $this->_params->moduleParams->get('depend_category'); $itemType = $this->_params->get('item_type', null); if ($isCatDepend) { $categoryId = $this->app->jbrequest->getSystem('category'); } $rangesData = (array) JBModelValues::model()->getRangeByPrice($this->_jbprice->identifier, $itemType, $applicationId, $categoryId); $cur = JBModelConfig::model()->getCurrency(); $params['min'] = JBCart::val($rangesData['total_min'] ? $rangesData['total_min'] . $cur : $params['min'])->val($to); $params['max'] = JBCart::val($rangesData['total_max'] ? $rangesData['total_max'] . $cur : $params['max'])->val($to); } $html[] = $this->_html->sliderInput($params, $value['range'], $this->_getName('range'), $this->app->jbstring->getId('jsSlider-'), $to); $html[] = $this->renderCurrency(); return implode(PHP_EOL, $html); }
/** * Get elements search data * @return mixed */ public function getSearchData() { $prices = $this->getPrices(); return $prices['total']->val(JBModelConfig::model()->getCurrency()); }
/** * @param string $key * @param mixed $default * @return mixed */ public function getFilters($key, $default = null) { $key = strtolower(trim($key)); if (!isset($this->filter[$key])) { $parameters = array(); $storage = (array) JBModelConfig::model()->getGroup('cart.' . $key, array()); $parts = explode('.', $key); foreach ($storage as $position => $elements) { $_index = 0; foreach ($elements as $index => $params) { // Backward Compatibility. Delete later. if (!is_numeric($index)) { $index = $_index++; } $params['_position'] = $position; $params['_index'] = $index; $params['_template'] = end($parts); $parameters[] = $params; } } $this->filter->set($key, $parameters); } return $this->filter->get($key, $default); }
/** * @param App $app * @param null $path */ public function __construct($app, $path = null) { parent::__construct($app, $path); $this->_jbconfig = JBModelConfig::model(); }
/** * Create form fields */ public function formFields() { $configModel = JBModelConfig::model(); $application = $this->_migrate->getCartApp(); $templatePath = null; $orderFields = null; if ($application) { $templatePath = $application->getTemplate()->getPath(); $orderFields = $this->_migrate->getOrderFields(); } if ($templatePath && $orderFields) { $posFile = $templatePath . '/renderer/item/positions.config'; $renderParams = array(); if (JFile::exists($posFile)) { $posFile = $this->app->data->create(json_decode(file_get_contents($posFile), true)); foreach ($posFile->get('jbuniversal.order.order', array()) as $position) { foreach ($position as $element) { $renderParams[$element['element']] = $element; } } } foreach ($renderParams as $elemId => $renderParam) { if (!isset($orderFields[$elemId])) { continue; } /** * @var AppData $config * @var AppData $renderParam */ $config = $this->app->data->create($orderFields[$elemId]); $renderParam = $this->app->data->create($renderParam); $elemType = isset($this->_elementMap[$config['type']]) ? $this->_elementMap[$config['type']] : 'text'; $orderElement = $this->_element->create($elemType, JBCart::ELEMENT_TYPE_ORDER, array('name' => $config->get('name'), 'description' => $config->get('description'), 'access' => $config->get('access'), 'default' => $config->get('default'), 'option' => $config->get('option'), 'multiple' => $config->get('multiple'))); $list = $configModel->getGroup('cart.field'); $list[JBCart::DEFAULT_POSITION][$orderElement->identifier] = (array) $orderElement->config; $configModel->setGroup('cart.field', $list); $renderElement = array('user_field' => '', 'showlabel' => '0', 'altlabel' => $renderParam->get('altlabel'), 'required' => $renderParam->get('required', 0), 'type' => $orderElement->getElementType(), 'group' => $orderElement->getElementGroup(), 'identifier' => $orderElement->identifier); $list = $configModel->getGroup('cart.field_tmpl.default'); $list[JBCart::DEFAULT_POSITION][] = $renderElement; $configModel->setGroup('cart.field_tmpl.default', $list); } } }
/** * Action Cet params Market * @return array */ protected function _getMarketParams() { $textCurrencyRate = array(); $siteUrl = $this->_appParams->get('site_url'); $siteName = $this->_appParams->get('site_name'); $companyName = $this->_appParams->get('company_name'); $supportCurrency = array('RUB', 'USD', 'BYR', 'KZT', 'EUR', 'UAH'); $currency = $this->_appParams->get('currency', 'RUB'); $currencyRate = $this->_appParams->get('currency_rate', 'default'); if (!empty($siteUrl)) { $site_url = $this->replaceSpecial($this->_appParams->get('site_url', '')); } else { $site_url = $this->replaceSpecial(JURI::root()); } if (!empty($siteName)) { $site_name = $this->replaceSpecial($this->_appParams->get('site_name', '')); } else { $site_name = $this->replaceSpecial(JFactory::getConfig()->get('sitename')); } if (!empty($companyName)) { $company_name = $this->replaceSpecial($this->_appParams->get('company_name', '')); } else { $company_name = $this->replaceSpecial(JFactory::getConfig()->get('sitename')); } foreach ($this->app->jbmoney->getCurrencyList() as $key => $value) { $key = strtoupper($key); if ($currencyRate == 'default') { if (in_array($key, $supportCurrency)) { $textCurrencyRate[$key] = str_replace(',', '.', $this->app->jbmoney->convert($key, $currency, 1)); } } else { if (in_array($key, $supportCurrency)) { $textCurrencyRate[$key] = $this->_appParams->get('currency_rate'); } } } if ($currencyRate != 'default') { $defaultCur = JBModelConfig::model()->getGroup('cart.config')->get('default_currency', 'RUB'); $defaultCur = strtoupper($defaultCur); $textCurrencyRate[$defaultCur] = 1; } if (isset($textCurrencyRate['RUB'])) { $textCurrencyRate['RUR'] = $textCurrencyRate['RUB']; unset($textCurrencyRate['RUB']); } $categories = $this->app->table->category->all(array('conditions' => array('application_id IN (' . implode(',', $this->_appParams->get('app_list')) . ')'))); return array('site_url' => $site_url, 'site_name' => $site_name, 'company_name' => $company_name, 'currency_rate' => $textCurrencyRate, 'categories' => $categories); }
/** * @return \JBModelConfig */ protected function _setupConfigure() { $configModel = \JBModelConfig::model(); $configModel->setGroup('config.yml', array('site_url' => rtrim(\JUri::root(), '/'), 'file_path' => $this->_getFilePath(), 'file_name' => $this->_getProfFileName(), 'site_name' => $this->_config->find('params.site_name', 'My site name'), 'company_name' => $this->_config->find('params.company_name', 'My company name'), 'currency_rate' => $this->_config->find('params.currency_rate', 'default'))); $configModel->set('app_list', $this->_config->find('params.app_list', array(1))); $configModel->set('type_list', $this->_config->find('params.type_list', array('product'))); return $configModel; }
/** * @param App $app */ public function __construct($app) { parent::__construct($app); $this->_config = JBModelConfig::model(); }
/** * Constructor * @param Element|String $element * @param Item $item * @param array $options */ function __construct($element, Item $item = null, $options = array()) { // get Zoo app $this->app = App::getInstance('zoo'); // set inner vars if (isset($options['elementId'])) { $this->_identifier = $options['elementId']; $this->_item = $item; $this->_element = $this->_item->getElement($this->_identifier); } else { if (is_object($element)) { $this->_element = $element; $this->_item = $element->getItem(); $this->_identifier = $element->identifier; } else { $this->_identifier = $element; } } // set repeatable flag if (is_object($this->_element) && is_subclass_of($this->_element, 'ElementRepeatable')) { $this->_isRepeatable = true; } // set Item object if (!$this->_item && $item) { $this->_item = $item; } // get current value for export) if ($this->_item && $this->_identifier && isset($this->_item->elements[$this->_identifier])) { $this->_value = $this->_item->elements[$this->_identifier]; } $this->_config = JBModelConfig::model(); $this->_exportParams = $this->_config->getGroup('export.items', array()); $this->_importParams = $this->_config->getGroup('import.items', array()); $this->_lastImportParams = $this->_config->getGroup('import.last.items', array()); }
/** * Class constructor * @param App $app * @param string $type * @param string $group */ public function __construct($app, $type, $group) { parent::__construct($app, $type, $group); $this->_jbmoney = $this->app->jbmoney; $this->_cartConfig = JBModelConfig::model()->getGroup('cart.config'); }