예제 #1
0
 function display($tpl = null)
 {
     JHTML::_('behavior.modal');
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $view = $jinput->get('view');
     $document = JFactory::getDocument();
     $model = $this->getModel();
     $menus = $app->getMenu('site');
     $menu = $menus->getActive();
     $mOption = empty($menu->query['option']) ? null : $menu->query['option'];
     $mCatid = empty($menu->query['cid']) ? null : (int) $menu->query['cid'];
     $mProdid = empty($menu->query['pid']) ? null : (int) $menu->query['pid'];
     $params = Djcatalog2Helper::getParams();
     $filter_order = $jinput->get('order', $params->get('producers_default_order', 'i.ordering'), 'cmd');
     $filter_order_Dir = $jinput->get('dir', $params->get('producers_default_order_dir', 'asc'), 'word');
     $limitstart = $jinput->getInt('limitstart', 0);
     $limit_items_show = $params->get('producers_pagination_limit', 10);
     $jinput->set('limit', $limit_items_show);
     $dispatcher = JDispatcher::getInstance();
     $list = $model->getItems();
     $total = $model->getTotal();
     $pagination = $model->getPagination();
     $this->assignref('document', $document);
     $this->assignref('items', $list);
     $this->assignref('total', $total);
     $this->assignref('pagination', $pagination);
     $this->assignref('params', $params);
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #2
0
 function display($tpl = null)
 {
     JHTML::_('behavior.modal');
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $model = $this->getModel();
     $params = Djcatalog2Helper::getParams();
     $menus = $app->getMenu('site');
     $menu = $menus->getActive();
     $dispatcher = JDispatcher::getInstance();
     $categories = Djc2Categories::getInstance(array('state' => '1'));
     $item = $model->getData();
     /* If Item not published set 404 */
     if ($item->id == 0 || !$item->published) {
         throw new Exception(JText::_('COM_DJCATALOG2_PRODUCT_NOT_FOUND'), 404);
     }
     /* plugins */
     JPluginHelper::importPlugin('djcatalog2');
     $results = $dispatcher->trigger('onPrepareItemDescription', array(&$item, &$params, 0));
     $this->assignref('categories', $categories);
     $this->assignref('item', $item);
     $this->assignref('images', $images);
     $this->assignref('params', $params);
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #3
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     if (empty($this->item)) {
         return JError::raiseError(404, JText::_('COM_DJCATALOG2_ORDER_NOT_FOUND'));
         return;
     }
     if ($user->guest) {
         $return_url = base64_encode(DJCatalogHelperRoute::getOrderRoute($this->item->id));
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     if ($user->id != $this->item->user_id) {
         return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $this->items = $this->item->items;
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #4
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     /*
     		$price_auth = ($this->params->get('price_restrict', '0') == '1' && $user->guest) ? false : true;
     		
     		if (!$price_auth) {
     			$return_url = base64_encode(DJCatalogHelperRoute::getCartRoute());
     			$app->redirect(JRoute::_('index.php?option=com_users&view=login&return='.$return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
     			return true;
     		}*/
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     $this->total = $this->basket->getTotal();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #5
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     /*
     		$price_auth = ($this->params->get('price_restrict', '0') == '1' && $user->guest) ? false : true;
     		
     		if (!$price_auth) {
     			$return_url = base64_encode(DJCatalogHelperRoute::getCartRoute());
     			$app->redirect(JRoute::_('index.php?option=com_users&view=login&return='.$return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
     			return true;
     		}*/
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     $this->total = $this->basket->getTotal();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     if (count($this->items)) {
         JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models', 'DJCatalog2Model');
         $itemsModel = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
         $parents = array();
         foreach ($this->items as $item) {
             if ($item->parent_id > 0) {
                 $parents[] = $item->parent_id;
             }
         }
         if (count($parents) > 0) {
             $state = $itemsModel->getState();
             $itemsModel->setState('list.start', 0);
             $itemsModel->setState('list.limit', 0);
             $itemsModel->setState('filter.catalogue', false);
             $itemsModel->setState('list.ordering', 'i.name');
             $itemsModel->setState('list.direction', 'asc');
             $itemsModel->setState('filter.parent', '*');
             $itemsModel->setState('filter.state', '3');
             $itemsModel->setState('filter.item_ids', $parents);
             $parentItems = $itemsModel->getItems();
             foreach ($this->items as $id => $item) {
                 if ($item->parent_id > 0 && isset($parentItems[$item->parent_id])) {
                     $this->items[$id]->parent = $parentItems[$item->parent_id];
                 } else {
                     $this->items[$id]->parent = false;
                 }
             }
         }
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #6
0
파일: price.php 프로젝트: ForAEdesWeb/AEW3
 public static function getTaxRate($tax_rate_id, $user_id = null)
 {
     $user = Djcatalog2Helper::getUserProfile($user_id);
     $tax_rate = 0;
     if (isset($user->tax_rules)) {
         if (isset($user->tax_rules[$tax_rate_id])) {
             $tax_rate = $user->tax_rules[$tax_rate_id];
         }
     }
     return $tax_rate;
 }
예제 #7
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     if (JFactory::getUser()->guest) {
         $return_url = base64_encode(DJCatalogHelperRoute::getOrdersRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->params = Djcatalog2Helper::getParams();
     $this->pagination = $this->get('Pagination');
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #8
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     $this->params = Djcatalog2Helper::getParams();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $authorised = false;
     if (empty($this->item->id)) {
         $authorised = $user->authorise('core.create', 'com_djcatalog2');
     } else {
         if ($user->authorise('core.edit', 'com_djcatalog2')) {
             $authorised = true;
         } else {
             $ownerId = (int) $this->item->created_by;
             if (!$user->guest && $ownerId == $user->id && $user->authorise('core.edit.own', 'com_djcatalog2')) {
                 $authorised = true;
             }
         }
     }
     if ($authorised !== true) {
         if ((bool) $user->guest && empty($this->item->id)) {
             $return_url = base64_encode(DJCatalogHelperRoute::getMyItemsRoute());
             $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
             return true;
         } else {
             JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
             return false;
         }
     }
     $document = JFactory::getDocument();
     JHTML::_('behavior.framework');
     JHTML::_('behavior.calendar');
     $document->addScriptDeclaration('var djc_joomla_base_url = \'' . JUri::base() . '\'');
     $document->addScript(JURI::base() . "components/com_djcatalog2/views/itemform/itemform.js");
     $document->addScript(JURI::base() . "components/com_djcatalog2/assets/nicEdit/nicEdit.js");
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #9
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     $this->model = $this->getModel();
     if ($this->params->get('cart_query_enabled', '1') != '1') {
         throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $auth = $this->params->get('cart_query_registered', '1') == '1' && $user->guest ? false : true;
     if (!$auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getQueryRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     if (empty($this->items)) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return true;
     }
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->form = $this->get('Form');
     $data = JArrayHelper::fromObject($user_profile, false);
     $post_data = (array) $app->getUserState('com_djcatalog2.query.data', array());
     if (!empty($post_data)) {
         foreach ($post_data as $k => $v) {
             $data[$k] = $v;
         }
     }
     $this->user_valid = $this->model->validate($this->form, array('djcatalog2profile' => $data));
     $this->user_profile = $user_profile;
     $this->user = $user;
     $this->total = $this->basket->getTotal();
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #10
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     if ((bool) $user->guest) {
         $return_url = base64_encode(DJCatalogHelperRoute::getMyItemsRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models', 'DJCatalog2Model');
     $model = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
     $this->state = $model->getState();
     $this->params = Djcatalog2Helper::getParams();
     //$model->setState('list.start', $app->input->get('limitstart', 0));
     // TODO
     //$limitstart = $app->getUserStateFromRequest('com_djcatalog2.myitems.limitstart', 'limitstart', 0);
     $limitstart = $app->input->get('limitstart', 0);
     $model->setState('list.start', $limitstart);
     $model->setState('list.limit', 10);
     // state 0 means both published and unpublished
     $model->setState('filter.state', 0);
     $model->setState('filter.catalogue', false);
     if (!$user->authorise('core.edit', 'com_djcatalog2') || $this->params->get('fed_myitems_list', '0') == '0') {
         $model->setState('filter.owner', $user->id);
     }
     $ordering = $app->getUserStateFromRequest('com_djcatalog2.myitems.ordering', 'order', 'i.ordering');
     $model->setState('list.ordering', $ordering);
     $order_dir = $app->getUserStateFromRequest('com_djcatalog2.myitems.order_dir', 'dir', 'asc');
     $model->setState('list.direction', $order_dir);
     $search = urldecode($app->input->get('search', '', 'string'));
     $search = JString::strtolower($search);
     $model->setState('filter.search', $search);
     $this->items = $model->getItems();
     $this->pagination = $model->getPagination();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #11
0
 protected function populateState($ordering = null, $direction = null)
 {
     // List state information.
     parent::populateState('a.name', 'asc');
     // Initialise variables.
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $params = Djcatalog2Helper::getParams();
     $this->setState('params', $params);
     //$search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
     //$this->setState('filter.search', $search);
     //$published = $this->getUserStateFromRequest($this->context.'.filter.published', 'filter_published', '');
     //$this->setState('filter.published', $published);
     $order = $app->input->get('order', $params->get('producers_default_order', 'a.ordering'), 'cmd');
     $this->setState('list.ordering', $order);
     $order_dir = $app->input->get('dir', $params->get('producers_default_order_dir', 'asc'), 'word');
     $this->setState('list.direction', $order_dir);
     // Load the parameters.
     $params = JComponentHelper::getParams('com_djcatalog2');
     $this->setState('params', $params);
 }
예제 #12
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     $price_auth = $this->params->get('price_restrict', '0') == '1' && $user->guest ? false : true;
     if (!$price_auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getCartRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     if (empty($this->items)) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return true;
     }
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     if (empty($user_profile) || empty($user_profile->id)) {
         $return_url = base64_encode(DJCatalogHelperRoute::getCheckoutRoute());
         $app->setUserState('com_users.edit.profile.redirect', DJCatalogHelperRoute::getCheckoutRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=profile&layout=edit&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_FILLIN_BILLING_DETAILS'));
         return true;
     }
     $this->user_profile = $user_profile;
     $this->user = $user;
     $this->total = $this->basket->getTotal();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #13
0
파일: cart.php 프로젝트: ForAEdesWeb/AEW4
 protected function allowQuery()
 {
     $app = JFactory::getApplication();
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     $params = JComponentHelper::getParams('com_djcatalog2');
     if ($params->get('cart_query_enabled', '1') != '1') {
         throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $auth = $params->get('cart_query_registered', '1') == '1' && $user->guest ? false : true;
     if (!$auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getQueryRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return false;
     }
     $basket = Djcatalog2HelperCart::getInstance(true);
     $basket->recalculate();
     if (empty($basket) || !$basket->getItems()) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return false;
     }
     return true;
 }
예제 #14
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $model = $this->getModel();
     $config = JFactory::getConfig();
     $siteEmail = $config->get('mailfrom');
     $fromName = $config->get('fromname');
     $feedEmail = $config->get('feed_email', 'author');
     $document->editor = $fromName;
     if ($feedEmail != 'none') {
         $document->editorEmail = $siteEmail;
     }
     $menus = $app->getMenu('site');
     $menu = $menus->getActive();
     $mOption = empty($menu->query['option']) ? null : $menu->query['option'];
     $mCatid = empty($menu->query['cid']) ? null : (int) $menu->query['cid'];
     $mProdid = empty($menu->query['pid']) ? null : (int) $menu->query['pid'];
     $filter_catid = $app->input->get('cid', null, 'int');
     if ($filter_catid === null && $mOption == 'com_djcatalog2' && $mCatid) {
         $filter_catid = $mCatid;
         $app->input->set('cid', $filter_catid);
     }
     $filter_producerid = $app->input->get('pid', null, 'string');
     if ($filter_producerid === null && $mOption == 'com_djcatalog2' && $mProdid) {
         $filter_producerid = $mProdid;
         $app->input->set('pid', $filter_producerid);
     }
     $params = Djcatalog2Helper::getParams();
     $params->set('product_catalogue', false);
     $filter_order = $params->get('rss_items_default_order', 'i.date');
     $filter_order_Dir = $params->get('rss_items_default_order_dir', 'desc');
     $limitstart = $app->input->get('limitstart', 0, 'int');
     $limit_items_show = $params->get('rss_limit_items_show', $config->get('feed_limit', 10));
     $app->input->set('limit', $limit_items_show);
     $dispatcher = JDispatcher::getInstance();
     $categories = Djc2Categories::getInstance(array('state' => '1'));
     // current category
     $category = $categories->get((int) $app->input->get('cid', 0, 'default'));
     $subcategories = null;
     if (!empty($category)) {
         $subcategories = $category->getChildren();
     }
     /* If Cateogory not published set 404 */
     if ($category && $category->id > 0 && $category->published == 0 || empty($category)) {
         throw new Exception(JText::_('COM_DJCATALOG2_PRODUCT_NOT_FOUND'), 404);
     }
     $title = $params->get('page_title', '');
     if ($menu && ($menu->query['option'] != 'com_djcatalog2' || $menu->query['view'] != 'items' || $id != $category->id)) {
         if (!empty($category->metatitle)) {
             $title = $category->metatitle;
         } else {
             if ($category->name && $category->id > 0) {
                 $title = $category->name;
             }
         }
     }
     if (empty($title)) {
         $title = $config->get('sitename');
     }
     $document->setTitle($title);
     $rows = $model->getItems();
     $document->link = JRoute::_(DJCatalogHelperRoute::getCategoryRoute($category->catslug));
     foreach ($rows as $row) {
         // Strip html from feed item title
         $title = $this->escape($row->name);
         $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
         // Compute the article slug
         $row->slug = $row->alias ? $row->id . ':' . $row->alias : $row->id;
         // Url link to article
         $link = JRoute::_(DJCatalogHelperRoute::getItemRoute($row->slug, $category->id == 0 ? $row->catslug : $category->catslug));
         // Get description, author and date
         $date = $row->created;
         // Load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = $link;
         $item->date = $date;
         $item->author = $row->author;
         $item->category = $category->id == 0 ? $row->category : $category->name;
         //$item->authorEmail = $siteEmail;
         if ($feedEmail == 'site') {
             $item->authorEmail = $siteEmail;
         } else {
             if ($feedEmail === 'author') {
                 $item->authorEmail = $row->author_email;
             }
         }
         $description = '';
         if ($row->item_image && (int) $params->get('rss_image_link_item', '1')) {
             //$item->image = new JFeedImage();
             //$item->image->url = DJCatalog2ImageHelper::getImageUrl($row->item_image,'small');
             //$item->image->link = $item->link;
             //$item->image->title = $row->image_caption;
             $description .= '<img src="' . DJCatalog2ImageHelper::getImageUrl($row->image_fullpath, 'small') . '" alt="' . $row->image_caption . '"/>';
         }
         if ($params->get('rss_description_type', '1') != '0') {
             $description .= $params->get('rss_description_type', '1') == '1' && $row->intro_desc ? $row->intro_desc : $row->description;
             if ($params->get('rss_showreadmore_item', '1')) {
                 $description .= '<p class="feed-readmore"><a target="_blank" href ="' . $item->link . '">' . JText::_('COM_DJCATALOG2_READMORE') . '</a></p>';
             }
         }
         // Load item description and add div
         $item->description = '<div class="feed-description">' . $description . '</div>';
         // Loads item info into rss array
         $document->addItem($item);
     }
 }
예제 #15
0
 function display($tpl = null)
 {
     JHTML::_('behavior.modal');
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $model = $this->getModel();
     $menus = $app->getMenu('site');
     $menu = $menus->getActive();
     $dispatcher = JDispatcher::getInstance();
     $user = JFactory::getUser();
     $groups = $user->getAuthorisedViewLevels();
     $categories = Djc2Categories::getInstance(array('state' => '1', 'access' => $groups));
     $limitstart = $app->input->get('limitstart', 0, 'int');
     $state = $this->get('State');
     $item = $this->get('Item');
     $this->contactform = $this->get('Form');
     $this->showcontactform = $app->getUserState('com_djcatalog2.contact.data') ? 'false' : 'true';
     if (empty($item) || !$item->published) {
         throw new Exception(JText::_('COM_DJCATALOG2_PRODUCT_NOT_FOUND'), 404);
     }
     $catid = (int) $app->input->get('cid');
     $category = $categories->get($item->cat_id);
     $current_category = $catid == $item->cat_id ? $category : $categories->get($catid);
     if ($current_category && $current_category->id > 0 && $current_category->published == 0 || empty($category)) {
         if ($category && $category->id > 0 && $category->published == 0 || empty($category)) {
             throw new Exception(JText::_('COM_DJCATALOG2_PRODUCT_NOT_FOUND'), 404);
         }
     }
     if (!in_array($current_category->access, $groups)) {
         throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
     }
     if ($item->parent_id > 0) {
         $app->redirect(JRoute::_(DJCatalogHelperRoute::getItemRoute($item->parent_id . ':' . $item->alias, $item->cat_id . ':' . $item->category_alias)));
     }
     // if category id in the URL differs from product's category id
     // we add canonical link to document's header
     /*if (JString::strcmp(DJCatalogHelperRoute::getItemRoute($item->slug, (int)$item->cat_id), DJCatalogHelperRoute::getItemRoute($item->slug, (int)$catid)) != 0) {
     			$document->addHeadLink(JRoute::_(DJCatalogHelperRoute::getItemRoute($item->slug, $item->catslug)), 'canonical');
     			//$document->addCustomTag('<link rel="canonical" href="'.JRoute::_(DJCatalogHelperRoute::getItemRoute($item->slug, $item->catslug)).'"/>');
     		}*/
     foreach ($this->document->_links as $key => $headlink) {
         if ($headlink['relation'] == 'canonical') {
             unset($this->document->_links[$key]);
         }
     }
     $this->document->addHeadLink(JRoute::_(DJCatalogHelperRoute::getItemRoute($item->slug, $item->catslug)), 'canonical');
     $app->input->set('refcid', $app->input->getString('cid'));
     // if category id is not present in the URL or it equals 0
     // we set it to product's cat id
     if ($catid == 0) {
         $app->input->set('cid', $item->cat_id);
     }
     // params in this view should be generated only after we make sure
     // that product's cat id is in the request.
     $params = Djcatalog2Helper::getParams();
     if (!empty($item) && !empty($item->params)) {
         $item_params = new JRegistry($item->params);
         $params->merge($item_params);
     }
     if (!in_array($item->access, $groups)) {
         if ($params->get('items_show_restricted') && $user->guest) {
             $uri = JURI::getInstance();
             $return_url = base64_encode((string) $uri);
             $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
             return true;
         } else {
             throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
         }
     }
     /* plugins */
     JPluginHelper::importPlugin('djcatalog2');
     JPluginHelper::importPlugin('content');
     $results = $dispatcher->trigger('onPrepareItemDescription', array(&$item, &$params, $limitstart));
     $item->event = new stdClass();
     $item->event->afterDJCatalog2DisplayTitle = false;
     $item->event->beforeDJCatalog2DisplayContent = false;
     $item->event->afterDJCatalog2DisplayContent = false;
     if ($this->getLayout() != 'print') {
         $resultsAfterTitle = $dispatcher->trigger('onAfterDJCatalog2DisplayTitle', array(&$item, &$params, $limitstart));
         $item->event->afterDJCatalog2DisplayTitle = trim(implode("\n", $resultsAfterTitle));
         $resultsBeforeContent = $dispatcher->trigger('onBeforeDJCatalog2DisplayContent', array(&$item, &$params, $limitstart));
         $item->event->beforeDJCatalog2DisplayContent = trim(implode("\n", $resultsBeforeContent));
         $resultsAfterContent = $dispatcher->trigger('onAfterDJCatalog2DisplayContent', array(&$item, &$params, $limitstart));
         $item->event->afterDJCatalog2DisplayContent = trim(implode("\n", $resultsAfterContent));
     }
     $this->assignref('categories', $categories);
     $this->assignref('category', $category);
     $this->assignref('item', $item);
     $this->assignref('images', $images);
     $this->assignref('files', $files);
     $this->assignref('params', $params);
     $this->relateditems = $model->getRelatedItems();
     $this->attributes = $model->getAttributes();
     $this->navigation = $model->getNavigation($this->item->id, $this->item->cat_id, $params);
     $this->children = $model->getChildren($this->item->id);
     if (!empty($this->children)) {
         $childrenModel = $model->getChildrenModel();
         $this->childrenAttributes = $childrenModel->getAttributes();
         $this->childrenColumns = $childrenModel->getFieldGroups($childrenModel);
     }
     if ($app->input->get('pdf') == '1' && $app->input->get('tmpl') == 'component' && $this->getLayout() == 'print') {
         if (JFile::exists(JPath::clean(JPATH_ROOT . '/libraries/dompdf/dompdf_config.inc.php')) == false) {
             throw new Exception('DOMPDF Libary is missing!');
         }
         $this->_preparePDF();
         $app->close();
         return true;
     }
     $this->_prepareDocument();
     $model->hit();
     parent::display($tpl);
 }
예제 #16
0
파일: cart.php 프로젝트: ForAEdesWeb/AEW3
 public function recalculate()
 {
     $params = Djcatalog2Helper::getParams();
     $sub_totals = array();
     $total = array('net' => 0, 'tax' => 0, 'gross' => 0.0);
     foreach ($this->items as $k => &$item) {
         if (empty($item->id)) {
             unset($this->items[$k]);
             continue;
         }
         $item->_quantity = isset($this->quantities[$item->id]) ? $this->quantities[$item->id] : 1;
         $item->_prices = Djcatalog2HelperPrice::getCartPrices($item->final_price, $item->price, $item->tax_rate_id, false, $item->_quantity, $params);
         if (!$item->tax_rate_id) {
             $item->tax_rate_id = 0;
         }
         if (!isset($sub_totals[$item->tax_rate_id])) {
             $sub_totals[$item->tax_rate_id] = array('net' => 0, 'tax' => 0, 'gross' => 0.0);
         }
         $sub_totals[$item->tax_rate_id]['net'] += $item->_prices['total']['net'];
         $sub_totals[$item->tax_rate_id]['gross'] += $item->_prices['total']['gross'];
         $sub_totals[$item->tax_rate_id]['tax'] += $item->_prices['total']['tax'];
     }
     unset($item);
     $tax_already_incl = (bool) ($params->get('price_including_tax', 1) == 1);
     foreach ($sub_totals as $tax_rate_id => $sub_total) {
         if ($tax_already_incl) {
             $sub_totals[$tax_rate_id]['tax'] = Djcatalog2HelperPrice::calculate($sub_total['gross'], 'T', $tax_rate_id);
             $sub_totals[$tax_rate_id]['net'] = $sub_totals[$tax_rate_id]['gross'] - $sub_totals[$tax_rate_id]['tax'];
         } else {
             $sub_totals[$tax_rate_id]['tax'] = Djcatalog2HelperPrice::calculate($sub_total['net'], 'T', $tax_rate_id);
             $sub_totals[$tax_rate_id]['gross'] = $sub_totals[$tax_rate_id]['net'] + $sub_totals[$tax_rate_id]['tax'];
         }
         $total['net'] += $sub_totals[$tax_rate_id]['net'];
         $total['tax'] += $sub_totals[$tax_rate_id]['tax'];
         $total['gross'] += $sub_totals[$tax_rate_id]['gross'];
     }
     $this->sub_totals = $sub_totals;
     $this->total = $total;
     return true;
 }
예제 #17
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $user = JFactory::getUser();
     $categories = Djc2Categories::getInstance(array('state' => '1'));
     $menus = $app->getMenu('site');
     $menu = $menus->getActive();
     JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models', 'DJCatalog2Model');
     $model = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
     $mOption = empty($menu->query['option']) ? null : $menu->query['option'];
     $mCatid = empty($menu->query['cid']) ? null : (int) $menu->query['cid'];
     $mProdid = empty($menu->query['pid']) ? null : (int) $menu->query['pid'];
     $filter_catid = $jinput->getInt('cid', null);
     if ($filter_catid === null && $mOption == 'com_djcatalog2' && $mCatid) {
         $filter_catid = $mCatid;
         $jinput->set('cid', $filter_catid);
     }
     $category = $categories->get((int) $jinput->getInt('cid', 0));
     $filter_producerid = $jinput->get('pid', null, 'string');
     if ($filter_producerid === null && $mOption == 'com_djcatalog2' && $mProdid) {
         $filter_producerid = $mProdid;
         $jinput->set('pid', (int) $filter_producerid);
     }
     $search = urldecode($jinput->get('mapsearch', '', 'string'));
     $search = JString::strtolower($search);
     $this->state = $model->getState();
     $this->params = $params = Djcatalog2Helper::getParams();
     if ($filter_catid) {
         $model->setState('filter.category', (int) $filter_catid);
     }
     if ($filter_producerid) {
         $model->setState('filter.producer', (int) $filter_producerid);
     }
     if (JString::strlen($search) > 0) {
         $model->setState('filter.map.address', $search);
     } else {
         $search = '';
     }
     // state 0 means both published and unpublished
     $model->setState('filter.state', 1);
     $map_radius = $jinput->get('ms_radius', false, 'int');
     $model->setState('filter.map.radius', $map_radius);
     $map_unit = $jinput->get('ms_unit', false, 'string');
     $model->setState('filter.map.unit', $map_unit);
     $model->setState('filter.map', true);
     $model->setState('filter.catalogue', false);
     $ordering = 'i.ordering';
     // $app->getUserStateFromRequest('com_djcatalog2.myitems.ordering', 'order', 'i.ordering');
     $model->setState('list.ordering', $ordering);
     $order_dir = 'asc';
     //$app->getUserStateFromRequest('com_djcatalog2.myitems.order_dir', 'dir', 'asc');
     $model->setState('list.direction', $order_dir);
     $this->items = $model->getItems();
     //$this->pagination	= $model->getPagination();
     $lists = array();
     $lists['search'] = $search;
     // category filter
     $category_options = $categories->getOptionList('- ' . JText::_('COM_DJCATALOG2_SELECT_CATEGORY') . ' -');
     if ($filter_catid > 0 && !empty($category)) {
         $category_path = $category->getPath();
         if (count($category_path) > 0) {
             if ($mCatid == 0) {
                 $parent_category = $categories->get(0);
             } else {
                 $parent_category = $categories->get((int) end($category_path));
             }
             if ($parent_category) {
                 $childrenList = array($parent_category->id);
                 $parent_category->makeChildrenList($childrenList);
                 foreach ($category_options as $key => $option) {
                     if (!in_array($option->value, $childrenList)) {
                         unset($category_options[$key]);
                     }
                     if ($option->value == $parent_category->id) {
                         $category_options[$key]->text = '- ' . JText::_('COM_DJCATALOG2_SELECT_CATEGORY') . ' -';
                     }
                 }
             }
         }
     }
     $lists['categories'] = JHTML::_('select.genericlist', $category_options, 'cid', 'class="inputbox input"', 'value', 'text', $filter_catid);
     // producer filter
     $producers_first_option = new stdClass();
     $producers_first_option->id = '0';
     $producers_first_option->text = '- ' . JText::_('COM_DJCATALOG2_SELECT_PRODUCER') . ' -';
     $producers_first_option->disable = false;
     $prodList = $model->getProducers();
     $producers = count($prodList) ? array_merge(array($producers_first_option), $prodList) : array($producers_first_option);
     $lists['producers'] = JHTML::_('select.genericlist', $producers, 'pid', 'class="inputbox input"', 'id', 'text', (int) $filter_producerid);
     $this->assignref('lists', $lists);
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #18
0
파일: order.php 프로젝트: ForAEdesWeb/AEW3
 protected function loadFormData()
 {
     $data = Djcatalog2Helper::getUserProfile(JFactory::getUser()->id);
     $data = JArrayHelper::fromObject($data, false);
     $data = array('djcatalog2profile' => $data);
     $post_data = (array) JFactory::getApplication()->getUserState('com_djcatalog2.order.data', array());
     if (!empty($post_data)) {
         foreach ($post_data as $k => $v) {
             $data[$k] = $v;
         }
     }
     $this->preprocessData('com_djcatalog2.order', $data);
     return $data;
 }
예제 #19
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     $model = JModelLegacy::getInstance('Order', 'Djcatalog2Model', array());
     $this->setModel($model, true);
     $this->model = $this->getModel();
     if ($this->params->get('cart_enabled', '1') != '1') {
         throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
     }
     $auth = $this->params->get('cart_registered', '1') == '1' && $user->guest ? false : true;
     if (!$auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getCheckoutRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     foreach ($this->basket->items as $item) {
         if ($item->_prices['base']['display'] == 0.0 || !$item->onstock || floatval($item->stock) == 0.0) {
             $app->redirect(JRoute::_(DJCatalogHelperRoute::getCartRoute(), false), JText::sprintf('COM_DJCATALOG2_CHECKOUT_EMPTY_PRICES', JRoute::_('index.php?option=com_djcatalog2&task=cart.clearfree')));
             return true;
         }
     }
     $this->items = $this->basket->getItems();
     if (empty($this->items)) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return true;
     }
     if (count($this->items)) {
         JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models', 'DJCatalog2Model');
         $itemsModel = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
         $parents = array();
         foreach ($this->items as $item) {
             if ($item->parent_id > 0) {
                 $parents[] = $item->parent_id;
             }
         }
         if (count($parents) > 0) {
             $state = $itemsModel->getState();
             $itemsModel->setState('list.start', 0);
             $itemsModel->setState('list.limit', 0);
             $itemsModel->setState('filter.catalogue', false);
             $itemsModel->setState('list.ordering', 'i.name');
             $itemsModel->setState('list.direction', 'asc');
             $itemsModel->setState('filter.parent', '*');
             $itemsModel->setState('filter.state', '3');
             $itemsModel->setState('filter.item_ids', $parents);
             $parentItems = $itemsModel->getItems();
             foreach ($this->items as $id => $item) {
                 if ($item->parent_id > 0 && isset($parentItems[$item->parent_id])) {
                     $this->items[$id]->parent = $parentItems[$item->parent_id];
                 } else {
                     $this->items[$id]->parent = false;
                 }
             }
         }
     }
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->form = $this->get('Form');
     $data = JArrayHelper::fromObject($user_profile, false);
     $postOrder = (array) $app->getUserState('com_djcatalog2.order.data', array());
     if (!empty($postOrder)) {
         foreach ($postOrder as $k => $v) {
             $data[$k] = $v;
         }
     }
     $this->user_valid = $this->model->validate($this->form, array('djcatalog2profile' => $data), 'djcatalog2profile');
     $this->billing_valid = $this->model->validate($this->form, array('djcatalog2billing' => $data), 'djcatalog2billing');
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('djcatalog2payment');
     JPluginHelper::importPlugin('djcatalog2delivery');
     $deliveryMethods = $model->getDeliveryMethods();
     $paymentMethods = $model->getPaymentMethods('*');
     $deliveryRes = array();
     $paymentRes = array();
     foreach ($deliveryMethods as &$deliveryObject) {
         $params = new JRegistry();
         $params->loadString($deliveryObject->params, 'JSON');
         $deliveryObject->params = $params;
         $deliveryRes[$deliveryObject->id] = $dispatcher->trigger('onDJC2CheckoutDetailsDisplay', array('com_djcatalog2.checkout.delivery', $deliveryObject));
     }
     unset($deliveryObject);
     foreach ($paymentMethods as &$paymentObject) {
         $params = new JRegistry();
         $params->loadString($paymentObject->params, 'JSON');
         $paymentObject->params = $params;
         $paymentRes[$paymentObject->id] = $dispatcher->trigger('onDJC2CheckoutDetailsDisplay', array('com_djcatalog2.checkout.payment', $paymentObject));
     }
     unset($paymentObject);
     $this->delivery_info = $deliveryRes;
     $this->payment_info = $paymentRes;
     $this->user_profile = $user_profile;
     $this->user = $user;
     $this->total = $this->basket->getTotal();
     $this->product_total = $this->basket->getProductTotal();
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #20
0
 function display($tpl = null)
 {
     JHTML::_('behavior.modal');
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $view = $jinput->get('view');
     $document = JFactory::getDocument();
     $model = $this->getModel();
     $menus = $app->getMenu('site');
     $menu = $menus->getActive();
     $mOption = empty($menu->query['option']) ? null : $menu->query['option'];
     $mCatid = empty($menu->query['cid']) ? null : (int) $menu->query['cid'];
     $mProdid = empty($menu->query['pid']) ? null : (int) $menu->query['pid'];
     $filter_catid = $jinput->getInt('cid', null);
     if ($filter_catid === null && $mOption == 'com_djcatalog2' && $mCatid) {
         $filter_catid = $mCatid;
         $jinput->set('cid', $filter_catid);
     }
     $filter_producerid = $jinput->get('pid', null, 'string');
     if ($filter_producerid === null && $mOption == 'com_djcatalog2' && $mProdid) {
         $filter_producerid = $mProdid;
         $jinput->set('pid', (int) $filter_producerid);
     }
     $params = Djcatalog2Helper::getParams();
     $filter_order = $jinput->get('order', $params->get('items_default_order', 'i.ordering'), 'cmd');
     $filter_order_Dir = $jinput->get('dir', $params->get('items_default_order_dir', 'asc'), 'word');
     $search = urldecode($jinput->get('search', '', 'string'));
     $search = JString::strtolower($search);
     $limitstart = $jinput->get('limitstart', 0, 'int');
     $limit_items_show = $params->get('limit_items_show', 10);
     //$jinput->set('limit', $limit_items_show);
     if (JString::strlen($search) > 0 && JString::strlen($search) < 2 || JString::strlen($search) > 40) {
         JError::raiseNotice(E_USER_NOTICE, JText::_('COM_DJCATALOG2_SEARCH_RESTRICTION'));
     }
     if ($filter_order_Dir == '' || $filter_order_Dir == 'desc') {
         $lists['order_Dir'] = 'asc';
     } else {
         $lists['order_Dir'] = 'desc';
     }
     $lists['order'] = $filter_order;
     $layout = $jinput->get('layout', 'default', 'string');
     $dispatcher = JDispatcher::getInstance();
     $categories = Djc2Categories::getInstance(array('state' => '1'));
     // current category
     $category = $categories->get((int) $jinput->getInt('cid', 0));
     $subcategories = null;
     if (!empty($category)) {
         $subcategories = $category->getChildren();
         //$subcategories = $model->getSubCategories($category);
     }
     /* If Cateogory not published set 404 */
     if ($category && $category->id > 0 && $category->published == 0 || empty($category)) {
         throw new Exception(JText::_('COM_DJCATALOG2_PRODUCT_NOT_FOUND'), 404);
     }
     $list = $model->getItems();
     $total = count($list);
     //$model->getTotal();
     $pagination = $model->getPagination();
     // search filter
     $lists['search'] = $search;
     // category filter
     $category_options = $categories->getOptionList('- ' . JText::_('COM_DJCATALOG2_SELECT_CATEGORY') . ' -');
     if ($filter_catid > 0 && (int) $params->get('category_filter_type', '0') > 0) {
         $category_path = $category->getPath();
         if (count($category_path) > 0) {
             $parent_category = null;
             if ($params->get('category_filter_type', '1') == '1' || count($category_path) == 1) {
                 $parent_category = $categories->get((int) end($category_path));
             } else {
                 if ($params->get('category_filter_type', '1') == '3') {
                     $parent_category = $categories->get($category->id);
                 } else {
                     $parent_category = $categories->get((int) $category_path[1]);
                 }
             }
             if ($parent_category) {
                 $childrenList = array($parent_category->id);
                 $parent_category->makeChildrenList($childrenList);
                 foreach ($category_options as $key => $option) {
                     if (!in_array($option->value, $childrenList)) {
                         unset($category_options[$key]);
                     }
                 }
             }
         }
     }
     $lists['categories'] = JHTML::_('select.genericlist', $category_options, 'cid', 'class="inputbox input"', 'value', 'text', $filter_catid);
     // producer filter
     $producers_first_option = new stdClass();
     $producers_first_option->id = '0';
     $producers_first_option->text = '- ' . JText::_('COM_DJCATALOG2_SELECT_PRODUCER') . ' -';
     $producers_first_option->disable = false;
     $prodList = $model->getProducers();
     $producers = count($prodList) ? array_merge(array($producers_first_option), $prodList) : array($producers_first_option);
     $lists['producers'] = JHTML::_('select.genericlist', $producers, 'pid', 'class="inputbox input"', 'id', 'text', (int) $filter_producerid);
     $lists['index'] = $model->getIndexCount();
     /* plugins */
     if ($category && $category->id > 0) {
         JPluginHelper::importPlugin('djcatalog2');
         $results = $dispatcher->trigger('onPrepareItemDescription', array(&$category, &$params, $limitstart));
     }
     $this->assignref('document', $document);
     $this->assignref('item', $category);
     $this->assignref('categories', $categories);
     $this->assignref('subcategories', $subcategories);
     $this->assignref('lists', $lists);
     $this->assignref('items', $list);
     $this->assignref('lists', $lists);
     $this->assignref('total', $total);
     $this->assignref('pagination', $pagination);
     $this->assignref('params', $params);
     $this->assignref('model', $model);
     $this->attributes = $model->getAttributes();
     $this->column_attributes = $model->getFieldGroups();
     $this->sortables = $model->getSortables();
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #21
0
 function display($tpl = null)
 {
     die('not supported yet');
     $app = JFactory::getApplication();
     $moduleclass_sfx = JRequest::getVar('moduleclass_sfx', null, 'default', 'string');
     $mid = (int) JRequest::getVar('moduleId', null, 'default', 'int');
     $stitle = JRequest::getVar('stitle', '1', 'default', 'string');
     $ltitle = JRequest::getVar('ltitle', '1', 'default', 'string');
     $scattitle = JRequest::getVar('scattitle', null, 'default', 'string');
     $spag = JRequest::getVar('spag', null, 'default', 'int');
     $trunc = (int) JRequest::getVar('trunc', '0', 'default', 'int');
     $trunclimit = (int) JRequest::getVar('trunclimit', '0', 'default', 'int');
     $showreadmore = (int) JRequest::getVar('showreadmore', '1', 'default', 'int');
     $readmoretext = JRequest::getVar('readmoretext', '', 'post');
     $readmoretext = $readmoretext != '' ? urldecode($readmoretext) : JText::_('COM_DJCATALOG2_READMORE');
     $largewidth = JRequest::getVar('largewidth', '400', 'default', 'int');
     $largeheight = JRequest::getVar('largeheight', '240', 'default', 'int');
     $largecrop = JRequest::getVar('largecrop', 1, 'default', 'int') ? true : false;
     $smallwidth = JRequest::getVar('smallwidth', '90', 'default', 'int');
     $smallheight = JRequest::getVar('smallheight', '70', 'default', 'int');
     $smallcrop = JRequest::getVar('smallcrop', 1, 'default', 'int') ? true : false;
     JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models');
     $model = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
     $state = $model->getState();
     $params = Djcatalog2Helper::getParams();
     $model->setState('params', $params);
     $paginationStart = (int) JRequest::getVar('pagstart', null, 'default', 'int');
     $model->setState('list.start', $paginationStart);
     $cols = (int) JRequest::getVar('cols', null, 'default', 'int');
     $rows = (int) JRequest::getVar('rows', null, 'default', 'int');
     $itemsPerPage = $rows * $cols;
     $model->setState('list.limit', $itemsPerPage);
     $categories = JRequest::getVar('categories', null, 'default', 'string', 0);
     $catsw = JRequest::getVar('catsw', 0, 'default', 'int', 0);
     $categories = explode('|', $categories);
     if ($catsw && count($categories)) {
         $model->setState('filter.category', $categories);
         $model->setState('filter.catalogue', true);
     }
     $featured_only = JRequest::getVar('featured_only', 0, 'default', 'int', 0);
     if ($featured_only) {
         $model->setState('filter.featured', 1);
     }
     $featured_first = JRequest::getVar('featured_first', 0, 'default', 'int', 0);
     if ($featured_first) {
         $model->setState('list.ordering_featured', 1);
     }
     $filter_order = JRequest::getVar('order', null, 'default', 'cmd');
     if ($filter_order) {
         $orderby = null;
         switch ($filter_order) {
             case '0':
                 $orderby = 'i.ordering';
                 break;
             case '1':
                 $orderby = 'i.name';
                 break;
             case '2':
                 $orderby = 'c.ordering';
                 break;
             case '3':
                 $orderby = 'p.ordering';
                 break;
             case '4':
                 $orderby = 'i.price';
                 break;
             case '5':
                 $orderby = 'i.id';
                 break;
             case '6':
                 $orderby = 'i.created';
                 break;
             default:
                 $orderby = 'i.ordering';
                 break;
         }
         $model->setState('list.ordering', $orderby);
     }
     $filter_order_Dir = JRequest::getVar('dir', 0, 'asc', 'default', 'word');
     if ($filter_order_Dir) {
         $model->setState('list.direction', $filter_order_Dir);
     }
     $list = $model->getItems();
     $result = new stdClass();
     $result->current = $paginationStart;
     $result->total = $model->getTotal();
     $result->module_id = $mid;
     $result->items = array();
     foreach ($list as $item) {
         $element = new stdClass();
         $element->id = $item->id;
         $element->name = $item->name;
         $element->slug = $item->slug;
         $element->cat_id = $item->cat_id;
         $element->catslug = $item->catslug;
         $element->category = $item->category;
         $element->producer_id = $item->producer_id;
         $element->image = $item->item_image;
         $element->image_caption = $item->image_caption;
         $element->description = $item->intro_desc;
         $result->items[] = $element;
     }
     print_r($result);
     die;
     //parent::display($tpl);
 }
예제 #22
0
 public static function getThemeName()
 {
     if (!self::$themeName) {
         $app = JFactory::getApplication();
         $document = JFactory::getDocument();
         //$params = $app->getParams('com_djcatalog2');
         $params = Djcatalog2Helper::getParams();
         self::$themeName = $params->get('theme', 'bootstrapped');
     }
     return self::$themeName;
 }
예제 #23
0
파일: items.php 프로젝트: ForAEdesWeb/AEW3
 public function getSortables()
 {
     $params = Djcatalog2Helper::getParams();
     $db = JFactory::getDBO();
     $model = JModelLegacy::getInstance('Items', 'Djcatalog2Model');
     $state = $model->getState();
     $model->setState('params', $params);
     $model->setState('list.start', 0);
     $model->setState('list.limit', 0);
     $model->setState('list.select', 'i.id');
     $model->setState('filter.catalogue', true);
     $model->setState('list.ordering', 'i.id');
     $model->setState('list.direction', 'asc');
     $items_query = $model->buildQuery();
     $query = $db->getQuery(true);
     $query->select('f.*');
     $query->from('#__djc2_items_extra_fields as f');
     $query->join('inner', '#__djc2_items as i on i.group_id = f.group_id');
     $query->join('inner', '(' . $items_query . ') as iq on iq.id = i.id');
     $query->where('(f.visibility = 2 or f.visibility = 3) and f.published = 1 and f.sortable = 1 and (f.type = \'text\' || f.type = \'radio\' || f.type = \'select\' || f.type = \'calendar\')');
     $query->group('f.name, f.alias, f.id, f.group_id');
     $query->order('f.group_id asc, f.ordering asc');
     $db->setQuery($query);
     $sortables = $db->loadObjectList();
     return $sortables;
 }
예제 #24
0
 public function display($tpl = null)
 {
     JHTML::_('behavior.modal');
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $view = $jinput->get('view');
     $document = JFactory::getDocument();
     $menus = $app->getMenu('site');
     $menu = $menus->getActive();
     $mOption = empty($menu->query['option']) ? null : $menu->query['option'];
     $mCatid = empty($menu->query['cid']) ? null : (int) $menu->query['cid'];
     $mProdid = empty($menu->query['pid']) ? null : (int) $menu->query['pid'];
     $filter_catid = $jinput->getInt('cid', null);
     if ($filter_catid === null && $mOption == 'com_djcatalog2' && $mCatid) {
         $filter_catid = $mCatid;
         $jinput->set('cid', $filter_catid);
     }
     $filter_producerid = $jinput->get('pid', null, 'string');
     if ($filter_producerid === null && $mOption == 'com_djcatalog2' && $mProdid) {
         $filter_producerid = $mProdid;
         $jinput->set('pid', (int) $filter_producerid);
     }
     JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models', 'DJCatalog2Model');
     $model = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
     $this->state = $model->getState();
     $params = Djcatalog2Helper::getParams();
     $filter_order = $jinput->get('order', $params->get('items_default_order', 'i.ordering'), 'cmd');
     $filter_order_Dir = $jinput->get('dir', $params->get('items_default_order_dir', 'asc'), 'word');
     $search = urldecode($jinput->get('search', '', 'string'));
     $search = JString::strtolower($search);
     $limitstart = $jinput->get('limitstart', 0, 'int');
     $limit_items_show = $params->get('limit_items_show', 10);
     $lists = array();
     if ($filter_order_Dir == '' || $filter_order_Dir == 'desc') {
         $lists['order_Dir'] = 'asc';
     } else {
         $lists['order_Dir'] = 'desc';
     }
     $lists['order'] = $filter_order;
     $categories = Djc2Categories::getInstance(array('state' => '1'));
     // current category
     $category = $categories->get((int) $jinput->getInt('cid', 0));
     if ($category && $category->id > 0 && $category->published == 0 || empty($category)) {
         throw new Exception(JText::_('COM_DJCATALOG2_PRODUCT_NOT_FOUND'), 404);
     }
     //$model->setState('list.start', $app->input->get('limitstart', 0));
     $model->setState('list.start', $limitstart);
     $model->setState('list.limit', 10);
     // state 2 means archived
     $model->setState('filter.state', 2);
     $model->setState('filter.category', (int) $filter_catid);
     $model->setState('filter.producer', (int) $filter_producerid);
     $model->setState('filter.catalogue', false);
     $model->setState('list.ordering', $filter_order);
     $model->setState('list.direction', $filter_order_Dir);
     $this->items = $model->getItems();
     $this->pagination = $model->getPagination();
     $this->params = $params;
     $this->lists = $lists;
     $this->attributes = $model->getAttributes();
     $this->column_attributes = $model->getFieldGroups();
     $this->sortables = $model->getSortables();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #25
0
 private static function getCountersApprox($hash)
 {
     if (empty(self::$counters[$hash])) {
         self::$counters[$hash] = array();
         $db = JFactory::getDbo();
         $app = JFactory::getApplication();
         $cparams = Djcatalog2Helper::getParams();
         $params = new JRegistry();
         $params->merge($cparams);
         JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models');
         $model = JModelLegacy::getInstance('Items', 'Djcatalog2Model');
         $state = $model->getState();
         $params->set('product_catalogue', 0);
         $params->set('limit_items_show', 0);
         $model->setState('params', $params);
         $model->setState('filter.catalogue', false);
         //$model->setState('filter.customattribute', array());
         $model->setState('list.start', 0);
         $model->setState('list.limit', 0);
         $model->setState('list.select', 'i.id');
         $model->setState('list.ordering', 'i.id');
         $items_query = $model->buildQuery();
         $query = $db->getQuery(true);
         $query->select('ef.id as field_id, ef.name as field_name, opt.id as option_id, opt.value as option_value, count(fv.item_id) as item_count');
         $query->from('#__djc2_items_extra_fields_values_int as fv');
         $query->join('inner', '#__djc2_items_extra_fields as ef on ef.id=fv.field_id');
         $query->join('inner', '#__djc2_items_extra_fields_options as opt on opt.field_id=ef.id and opt.id=fv.value');
         $query->join('inner', '(' . $items_query . ') as item_ids on fv.item_id = item_ids.id');
         $query->group('ef.id, opt.value');
         $query->order('ef.name asc');
         $db->setQuery($query);
         $intCounters = $db->loadObjectList('option_id');
         $query = $db->getQuery(true);
         $query->select('ef.id as field_id, ef.name as field_name, "" as option_id, "" as option_value, count(fv.item_id) as item_count');
         $query->from('#__djc2_items_extra_fields_values_text as fv');
         $query->join('inner', '#__djc2_items_extra_fields as ef on ef.id=fv.field_id AND ef.filterable = 1');
         $query->join('inner', '(' . $items_query . ') as item_ids on fv.item_id = item_ids.id');
         $query->group('ef.id');
         $query->order('ef.name asc');
         $db->setQuery($query);
         $textCounters = $db->loadObjectList('field_id');
         foreach ($intCounters as $k => $v) {
             self::$counters[$hash][$k] = $v;
         }
         foreach ($textCounters as $k => $v) {
             self::$counters[$hash]['t_' . $k] = $v;
         }
         //self::$counters[$hash] = $db->loadObjectList('option_id');
     }
     return self::$counters[$hash];
 }
예제 #26
0
파일: helper.php 프로젝트: ForAEdesWeb/AEW3
 private static function getCounters($attributes)
 {
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $cparams = Djcatalog2Helper::getParams();
     $params = new JRegistry();
     $params->merge($cparams);
     JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models');
     $model = JModelLegacy::getInstance('Items', 'Djcatalog2Model');
     $state = $model->getState();
     $params->set('product_catalogue', 0);
     $params->set('limit_items_show', 0);
     $model->setState('params', $params);
     $model->setState('filter.catalogue', false);
     $model->setState('list.start', 0);
     $model->setState('list.limit', 0);
     $model->setState('list.select', 'i.id');
     $model->setState('list.ordering', 'i.id');
     /*
     $items = $model->getItems();
     if (empty($items)){
     	return false;
     }
     $itemIds = array_keys($items);
     */
     $items_query = $model->buildQuery();
     //echo str_replace('#_','jos',$items_query).'<br/>';die();
     $query = $db->getQuery(true);
     $query->select('concat(cast(ef.id as char), "_", cast(opt.id as char)) as row_index, ef.id as field_id, ef.name as field_name, opt.id as option_id, opt.value as option_value, count(fv.item_id) as item_count');
     $query->from('#__djc2_items_extra_fields_values_int as fv');
     $query->join('inner', '#__djc2_items_extra_fields as ef on ef.id=fv.field_id');
     $query->join('inner', '#__djc2_items_extra_fields_options as opt on opt.field_id=ef.id and opt.id=fv.value');
     //$query->where('fv.item_id in ('.implode(',', $itemIds).')');
     $query->join('inner', '(' . $items_query . ') as item_ids on fv.item_id = item_ids.id');
     $query->group('ef.id, opt.value');
     $query->order('ef.name asc');
     $db->setQuery($query);
     //echo str_replace('#_','jos',$query).'<br/>';die();
     return $db->loadObjectList('option_id');
 }
예제 #27
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $this->params = Djcatalog2Helper::getParams();
     $this->model = $this->getModel();
     if ($this->params->get('cart_query_enabled', '1') != '1') {
         throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $auth = $this->params->get('cart_query_registered', '1') == '1' && $user->guest ? false : true;
     if (!$auth) {
         $return_url = base64_encode(DJCatalogHelperRoute::getQueryRoute());
         $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return_url, false), JText::_('COM_DJCATALOG2_PLEASE_LOGIN'));
         return true;
     }
     $cart_items = $app->getUserState('com_djcatalog2.cart.items', array());
     $this->basket = Djcatalog2HelperCart::getInstance();
     $this->items = $this->basket->getItems();
     if (empty($this->items)) {
         $app->redirect(JUri::base(), JText::_('COM_DJCATALOG2_CART_IS_EMPTY'));
         return true;
     }
     if (count($this->items)) {
         JModelLegacy::addIncludePath(JPATH_BASE . DS . 'components' . DS . 'com_djcatalog2' . DS . 'models', 'DJCatalog2Model');
         $itemsModel = JModelLegacy::getInstance('Items', 'Djcatalog2Model', array('ignore_request' => true));
         $parents = array();
         foreach ($this->items as $item) {
             if ($item->parent_id > 0) {
                 $parents[] = $item->parent_id;
             }
         }
         if (count($parents) > 0) {
             $state = $itemsModel->getState();
             $itemsModel->setState('list.start', 0);
             $itemsModel->setState('list.limit', 0);
             $itemsModel->setState('filter.catalogue', false);
             $itemsModel->setState('list.ordering', 'i.name');
             $itemsModel->setState('list.direction', 'asc');
             $itemsModel->setState('filter.parent', '*');
             $itemsModel->setState('filter.state', '3');
             $itemsModel->setState('filter.item_ids', $parents);
             $parentItems = $itemsModel->getItems();
             foreach ($this->items as $id => $item) {
                 if ($item->parent_id > 0 && isset($parentItems[$item->parent_id])) {
                     $this->items[$id]->parent = $parentItems[$item->parent_id];
                 } else {
                     $this->items[$id]->parent = false;
                 }
             }
         }
     }
     $user_profile = Djcatalog2Helper::getUserProfile();
     $user = Djcatalog2Helper::getUser();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->form = $this->get('Form');
     $data = JArrayHelper::fromObject($user_profile, false);
     $post_data = (array) $app->getUserState('com_djcatalog2.query.data', array());
     if (!empty($post_data)) {
         foreach ($post_data as $k => $v) {
             $data[$k] = $v;
         }
     }
     $this->user_valid = $this->model->validate($this->form, array('djcatalog2profile' => $data), 'djcatalog2profile');
     $this->user_profile = $user_profile;
     $this->user = $user;
     $this->total = $this->basket->getTotal();
     $this->_prepareDocument();
     parent::display($tpl);
 }
예제 #28
0
 public static function getParams($reload = false)
 {
     if (!self::$params || $reload == true) {
         $app = JFactory::getApplication();
         // our params
         $params = new JRegistry();
         // component's global params
         $cparams = JComponentHelper::getParams('com_djcatalog2');
         // current params - all
         $aparams = $app->getParams();
         // curent params - djc2 only
         $mparams = $app->getParams('com_djcatalog2');
         // first let's use all current params
         $params->merge($aparams);
         // then override them with djc2 global settings - in case some other extension share's the same parameter name
         $params->merge($cparams);
         // finally, override settings with current params, but only related to djc2.
         $params->merge($mparams);
         // ...and then, override with category specific params
         $option = $app->input->get('option');
         $view = $app->input->get('view');
         if ($option = 'com_djcatalog2' && ($view = 'item' || ($view = 'items' || ($view = 'archived')))) {
             $user = JFactory::getUser();
             $groups = $user->getAuthorisedViewLevels();
             $categories = Djc2Categories::getInstance(array('state' => '1', 'access' => $groups));
             $category = $categories->get((int) $app->input->get('cid', 0, 'int'));
             if (!empty($category)) {
                 $catpath = array_reverse($category->getPath());
                 foreach ($catpath as $k => $v) {
                     $parentCat = $categories->get((int) $v);
                     if (!empty($parentCat) && !empty($category->params)) {
                         $catparams = new JRegistry($parentCat->params);
                         $params->merge($catparams);
                     }
                 }
             }
         }
         $listLayout = $app->input->get('l', $app->getUserState('com_djcatalog2.list_layout', null), 'cmd');
         if ($listLayout == 'items') {
             $app->setUserState('com_djcatalog2.list_layout', 'items');
             $params->set('list_layout', 'items');
         } else {
             if ($listLayout == 'table') {
                 $app->setUserState('com_djcatalog2.list_layout', 'table');
                 $params->set('list_layout', 'table');
             }
         }
         $catalogMode = $app->input->get('cm', null, 'int');
         $indexSearch = $app->input->get('ind', null, 'string');
         $globalSearch = urldecode($app->input->get('search', '', 'string'));
         $globalSearch = trim(JString::strtolower($globalSearch));
         if (substr($globalSearch, 0, 1) == '"' && substr($globalSearch, -1) == '"') {
             $globalSearch = substr($globalSearch, 1, -1);
         }
         if (strlen($globalSearch) > 0 && strlen($globalSearch) < 3 || strlen($globalSearch) > 20) {
             $globalSearch = null;
         }
         if ($catalogMode === 0 || $globalSearch || $indexSearch) {
             $params->set('product_catalogue', '0');
             // set 'filtering' variable in REQUEST
             // so we could hide for example sub-categories
             // when searching/filtering is performed
             $app->input->set('filtering', true);
         }
         self::$params = $params;
     }
     return self::$params;
 }
예제 #29
0
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_COMPONENT . '/helpers/djcatalog2.php';
     Djcatalog2Helper::addSubmenu(JFactory::getApplication()->input->getCmd('view', 'cpanel'));
     parent::display($cachable, $urlparams);
 }
예제 #30
0
 * along with DJ-Catalog2. If not, see <http://www.gnu.org/licenses/>.
 *
 */
defined('_JEXEC') or die('Restricted access');
$app = JFactory::getApplication();
$filter_modules = JModuleHelper::getModules('djc2_filters');
$this->filter_modules = '';
if (!empty($filter_modules)) {
    foreach ($filter_modules as $module) {
        $this->filter_modules .= JModuleHelper::renderModule($module);
    }
}
$author_id = $app->input->getInt('aid', 0);
$author_user = false;
if ($author_id > 0) {
    $author_user = Djcatalog2Helper::getUser($author_id);
}
if ($this->params->get('show_page_heading', 1)) {
    ?>
<h1 class="componentheading<?php 
    echo $this->params->get('pageclass_sfx');
    ?>
">
	<?php 
    echo $this->escape($this->params->get('page_heading'));
    ?>
</h1>
<?php 
}
?>