Пример #1
0
 /**
  * Filter action
  * @throws AppException
  * @return void
  */
 function compare()
 {
     // init
     $this->app->jbdebug->mark('compare::init');
     $this->app->jbdoc->noindex();
     $type = $this->_jbrequest->get('type');
     $appId = $this->_jbrequest->get('app_id');
     $itemId = $this->_jbrequest->get('Itemid');
     $layout = $this->_jbrequest->get('layout', 'v');
     if (!$type || !$appId) {
         throw new AppException('Type or AppId is no set');
     }
     // get items
     $searchModel = JBModelFilter::model();
     $itemIds = $this->app->jbcompare->getItemsByType($type);
     $items = $searchModel->getZooItemsByIds($itemIds);
     $this->items = $items;
     $this->params = $this->_params;
     $this->itemType = $type;
     $this->appId = $appId;
     $this->layoutType = $layout;
     $this->itemId = $itemId;
     if (!($this->template = $this->application->getTemplate())) {
         $this->app->jbnotify->error(JText::_('No template selected'));
         return;
     }
     // set renderer
     $this->renderer = $this->app->renderer->create('compare')->addPath(array($this->app->path->path('component.site:'), $this->template->getPath()));
     $this->app->jbdebug->mark('compare::renderInit');
     // display view
     $this->getView('compare')->addTemplatePath($this->template->getPath())->setLayout('compare')->display();
     $this->app->jbdebug->mark('compare::display');
 }
Пример #2
0
 public static function getFilterMarkers($params, $renderer)
 {
     $app = App::getInstance('zoo');
     $type = $app->jbrequest->get('type');
     $logic = strtoupper($app->jbrequest->getWord('logic', 'and'));
     $exact = (int) $app->jbrequest->get('exact', 0);
     $elements = $app->jbrequest->getElements();
     $appId = $app->jbrequest->get('app_id');
     // search!
     $searchModel = JBModelFilter::model();
     $items = $searchModel->search($elements, $logic, $type, $appId, $exact, 0, 999);
     $markers = array();
     foreach ($items as $item) {
         $elements = $item->getElements();
         foreach ($elements as $element) {
             if ($element->getElementType() == 'yamap' && $element->hasValue()) {
                 foreach ($element->data() as $value) {
                     $coordinatesArr = explode(',', $value["coordinates"]);
                     $lng = trim($coordinatesArr[1]);
                     $lat = trim($coordinatesArr[0]);
                     $name = htmlspecialchars($item->name, ENT_QUOTES);
                     $markers[] = array(array($lat, $lng), $name, $item->id, JFactory::getApplication()->getMenu()->getActive()->id);
                 }
             }
         }
     }
     return $markers;
 }
Пример #3
0
 /**
  * Favorite list of curret user
  * @throws AppException
  */
 function favorite()
 {
     // init
     $this->app->jbdebug->mark('favorite::init');
     $this->app->jbdoc->noindex();
     $type = $this->_jbrequest->get('type');
     $appId = $this->_jbrequest->get('app_id');
     $itemId = $this->_jbrequest->get('Itemid');
     if (!$appId) {
         throw new AppException('Type or AppId is no set');
     }
     if (!JFactory::getUser()->id) {
         $this->app->jbnotify->notice(JText::_('JBZOO_FAVORITE_NOTAUTH_NOTICE'));
     }
     // get items
     $searchModel = JBModelFilter::model();
     $items = $this->app->jbfavorite->getAllItems();
     $items = $searchModel->getZooItemsByIds(array_keys($items));
     $this->items = $items;
     $this->params = $this->_params;
     $this->appId = $appId;
     $this->itemId = $itemId;
     if (!($this->template = $this->application->getTemplate())) {
         throw new AppException('No template selected');
     }
     // set renderer
     $this->renderer = $this->app->renderer->create('item')->addPath(array($this->app->path->path('component.site:'), $this->template->getPath()));
     $this->app->jbdebug->mark('favorite::renderInit');
     // display view
     $this->getView('favorite')->addTemplatePath($this->template->getPath())->setLayout('favorite')->display();
     $this->app->jbdebug->mark('favorite::display');
 }
Пример #4
0
 /**
  * Show basket items in admin panel
  * @return mixed
  */
 public function edit()
 {
     $basketItems = $this->getOrderItems();
     $basketItemsId = $this->getOrderItemsId();
     JFactory::getSession()->set('items-' . $this->getItem()->id . '-' . $this->identifier, $this->data(), __CLASS__);
     if (!empty($basketItems)) {
         $items = JBModelFilter::model()->getZooItemsByIds($basketItemsId);
         if (!empty($items) && ($layout = $this->getLayout('jbbasketitems.php'))) {
             return self::renderLayout($layout, array('items' => $items, 'basketItems' => $basketItems, 'params' => isset($this->params) ? $this->params : null, 'renderMode' => $this->renderMode));
         }
     }
     return '<p>' . JText::_('JBZOO_CART_ITEMS_NOT_FOUND') . '</p>';
 }
Пример #5
0
 /**
  * Filter action
  */
 function filter()
 {
     $this->app->jbdebug->mark('filter::init');
     $this->app->jbdoc->noindex();
     $type = $this->_jbrequest->get('type');
     $page = ($page = $this->_jbrequest->get('page', 1)) ? $page : 1;
     $logic = strtoupper($this->_jbrequest->getWord('logic', 'and'));
     $order = $this->_jbrequest->get('order', 'none');
     $exact = (int) $this->_jbrequest->get('exact', 0);
     $limit = $this->_jbrequest->get('limit', $this->_params->get('config.items_per_page', 2));
     $offset = $limit * ($page - 1);
     $elements = $this->_jbrequest->getElements();
     $appId = $this->_jbrequest->get('app_id');
     // search!
     $searchModel = JBModelFilter::model();
     $items = $searchModel->search($elements, $logic, $type, $appId, $exact, $offset, $limit, $order);
     $itemsCount = $searchModel->searchCount($elements, $logic, $type, $appId, $exact);
     // create pagination
     if ($this->_jbrequest->isPost()) {
         $_POST['option'] = 'com_zoo';
         unset($_POST['page']);
         unset($_POST['view']);
         unset($_POST['layout']);
         $this->pagination_link = 'index.php?' . $this->app->jbrouter->query($_POST);
     } else {
         $_GET['option'] = 'com_zoo';
         unset($_GET['page']);
         unset($_GET['view']);
         unset($_GET['layout']);
         $this->pagination_link = 'index.php?' . $this->app->jbrouter->query($_GET);
     }
     $this->pagination = $this->app->pagination->create($itemsCount, $page, $limit, 'page', 'app');
     $this->pagination->setShowAll($limit == 0);
     $this->app->jbdebug->mark('filter::pagination');
     // set template and params
     if (!($this->template = $this->application->getTemplate())) {
         $this->app->jbnotify->error(JText::_('No template selected'));
         return;
     }
     // assign variables
     $this->items = $items;
     $this->params = $this->_params;
     $this->itemsCount = $itemsCount;
     // set renderer
     $this->renderer = $this->app->renderer->create('item')->addPath(array($this->app->path->path('component.site:'), $this->template->getPath()));
     $this->app->jbdebug->mark('filter::renderInit');
     // display view
     $this->getView('filter')->addTemplatePath($this->template->getPath())->setLayout('filter')->display();
     $this->app->jbdebug->mark('filter::display');
 }
Пример #6
0
 /**
  * @return array
  */
 public function getItems()
 {
     $this->init();
     $searchElements = array();
     $this->_app_id = $this->_params->get('condition_app', '0');
     $this->_type = $this->_params->get('condition_type', 'product');
     $conditions = (array) $this->_params->get('conditions', array());
     $logic = $this->_params->get('logic', 'AND');
     $order = (array) $this->_params->get('order_default');
     $exact = $this->_params->get('type_search', 0);
     $limit = $this->_params->get('pages', 20);
     $elements = $this->_getValue($conditions);
     if (!empty($elements)) {
         foreach ($elements as $fieldKey => $value) {
             if (empty($value)) {
                 continue;
             }
             if (strpos($fieldKey, '_') === false) {
                 $table = $this->app->jbtables;
                 $tableIndex = $table->getIndexTable($this->_type);
                 $fields = $table->getFields($tableIndex);
                 $myFiled = $table->getFieldName($fieldKey);
                 $elements = $this->_elements;
                 $element = $elements[$fieldKey];
                 unset($elements);
                 if (in_array($myFiled, $fields) || $element['type'] == 'textarea') {
                     $searchElements[$fieldKey] = $value;
                 }
             } else {
                 $searchElements[$fieldKey] = $value;
             }
         }
     }
     $items = JBModelFilter::model()->search($searchElements, strtoupper($logic), $this->_type, $this->_app_id, $exact, 0, $limit, $order);
     return $items;
 }