private static function makeList(&$html, &$root, $path, $expand, $cid, $level = 0, $show_count = false) { $children = $root->getChildren(); foreach ($children as $child) { $current = $child->id == $cid ? true : false; $parent = count($child->getChildren()) ? true : false; $active = $current || in_array($child->id, $path) ? true : false; $deeper = $parent && $expand ? true : false; $class = 'djc_catid-' . $child->id . ' level' . $level; $class .= $current ? ' current' : ''; $class .= $active ? ' active' : ''; $class .= $parent ? ' parent' : ''; $class .= $deeper ? ' deeper' : ''; $display_name = $child->name; if ($show_count) { if (($count = $child->getProductCount()) !== false) { $display_name = $child->name . ' <small class="djc_category_counter">[' . $count . ']</small>'; } } $html .= '<li class="' . $class . '"><a href="' . JRoute::_(DJCatalogHelperRoute::getCategoryRoute($child->id . ':' . $child->alias), true) . '">' . $display_name . '</a>'; if (($active || $expand) && count($child->getChildren())) { $html .= '<ul>'; $level++; self::makeList($html, $child, $path, $expand, $cid, $level, $show_count); $level--; $html .= '</ul>'; } $html .= '</li>'; } }
protected function _postSaveHook($model, $validData = array()) { $app = JFactory::getApplication(); $params = JComponentHelper::getParams('com_djcatalog2'); $user = JFactory::getUser(); if ((empty($validData['id']) || $validData['id'] == 0) && $user->guest) { $this->setRedirect(JRoute::_(DJCatalogHelperRoute::getCategoryRoute(0), false)); } if ((int) $params->get('fed_notify', 1) == 1 && (empty($validData['id']) || $validData['id'] == 0)) { $recordId = $model->getState($this->context . '.id'); $item = $model->getItem($recordId); $this->_sendEmail($item); } }
?> </div> <?php } ?> <?php if ($this->params->get('show_producers_items_item', 1)) { ?> <a <?php if (JFactory::getApplication()->input->get('tmpl') == 'component') { echo 'target="_blank"'; } ?> class="djc_producer_items_link btn btn-mini button" href="<?php echo JRoute::_(DJCatalogHelperRoute::getCategoryRoute(0) . '&cm=0&pid=' . $this->item->id); ?> "><span><?php echo JText::_('COM_DJCATALOG2_SHOW_PRODUCERS_ITEMS'); ?> </span></a> <?php } ?> <div class="djc_description"> <?php if (JString::strlen(trim($this->item->description)) > 0) { ?> <div class="djc_fulltext"> <?php echo JHTML::_('content.prepare', $this->item->description, $this->params, 'com_djcatalog2.producer.description');
} ?> <?php if ((int) $this->params->get('show_author_item', 0) > 0 && $this->item->author) { ?> <div class="djc_author"> <small> <?php echo JText::_('COM_DJCATALOG2_CREATED_BY') . ': '; ?> <?php if ((int) $this->params->get('show_author_item') == 1 && $this->item->created_by) { ?> <a href="<?php echo JRoute::_(DJCatalogHelperRoute::getCategoryRoute(0) . '&aid=' . $this->item->created_by . ':' . JApplication::stringURLSafe($this->item->author)); ?> "><span><?php echo $this->item->author; ?> </span></a> <?php } else { ?> <span><?php echo $this->item->author; ?> </span> <?php } ?>
protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $pathway = $app->getPathway(); $title = null; $heading = null; $document = JFactory::getDocument(); $menu = $menus->getActive(); $id = (int) @$menu->query['id']; $cid = (int) @$menu->query['cid']; if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } $title = $this->params->get('page_title', ''); $metakeys = null; $metadesc = null; if ($menu && ($menu->query['option'] != 'com_djcatalog2' || $menu->query['view'] == 'items' || $id != $this->item->id)) { if ($this->item->metatitle) { $title = $this->item->metatitle; } else { if ($this->item->name) { $title = $this->item->name; } } $category = $this->categories->get($this->item->cat_id); $path = array(array('title' => $this->item->name, 'link' => '')); while (($menu->query['option'] != 'com_djcatalog2' || $menu->query['view'] == 'items' && $cid != $category->id) && $category->id > 0) { $path[] = array('title' => $category->name, 'link' => DJCatalogHelperRoute::getCategoryRoute($category->catslug)); $category = $this->categories->get($category->parent_id); } $path = array_reverse($path); foreach ($path as $item) { $pathway->addItem($item['title'], $item['link']); } } else { if (!empty($menu)) { if ($this->params->get('menu-meta_description')) { $metadesc = $this->params->get('menu-meta_description'); } if ($this->params->get('menu-meta_keywords')) { $metakeys = $this->params->get('menu-meta_keywords'); } } } if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0)) { if ($app->getCfg('sitename_pagetitles', 0) == '2') { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } else { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } } $this->document->setTitle($title); if (!empty($this->item->metadesc)) { $this->document->setDescription($this->item->metadesc); } elseif (!empty($metadesc)) { $this->document->setDescription($metadesc); } if (!empty($this->item->metakey)) { $this->document->setMetadata('keywords', $this->item->metakey); } elseif (!empty($metakeys)) { $this->document->setMetadata('keywords', $metakeys); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } $this->document->addCustomTag('<meta property="og:title" content="' . trim($title) . '" />'); $this->document->addCustomTag('<meta property="twitter:title" content="' . trim($title) . '" />'); if ($metadesc) { $this->document->addCustomTag('<meta property="og:description" content="' . trim($metadesc) . '" />'); $this->document->addCustomTag('<meta property="twitter:description" content="' . trim($metadesc) . '" />'); } $this->document->addCustomTag('<meta property="og:url" content="' . JRoute::_(DJCatalogHelperRoute::getItemRoute($this->item->slug, $this->item->catslug), true, -1) . '" />'); if ($item_images = DJCatalog2ImageHelper::getImages('item', $this->item->id)) { if (isset($item_images[0])) { $this->document->addCustomTag('<meta property="og:image" content="' . $item_images[0]->large . '" />'); $this->document->addCustomTag('<meta property="twitter:image:src" content="' . $item_images[0]->large . '" />'); } } }
<?php if ($this->params->get('show_category_name') > 0 && $item->publish_category) { ?> <td class="djc_category" > <?php if ($this->params->get('show_category_name') == 2) { ?> <span><?php echo $item->category; ?> </span> <?php } else { ?> <a href="<?php echo JRoute::_(DJCatalogHelperRoute::getCategoryRoute($item->catslug)); ?> "><span class="djcat_category"><?php echo $item->category; ?> </span></a> <?php } ?> </td> <?php } ?> <?php if ($this->params->get('show_producer_name') > 0) { ?>
if ($app->input->get('cid', false, 'string') !== false) { $cid = $app->input->get('cid', false, 'string'); } else { if (isset($active->query['cid'])) { $cid = $active->query['cid']; } } } } } } JURI::reset(); $uri = null; $juri = JURI::getInstance(); if (!$catalogView) { $uri = JURI::getInstance(JRoute::_(DJCatalogHelperRoute::getCategoryRoute($cid) . '&cm=0')); } else { if ($active->id == $menu->getDefault()->id) { $uri = JURI::getInstance($juri->toString()); $temp_query = $uri->getQuery(true); $temp_query['cm'] = '0'; $temp_query['option'] = 'com_djcatalog2'; $temp_query['view'] = 'items'; $temp_query['cid'] = $cid; $temp_query['Itemid'] = $active->id; $uri->setQuery($temp_query); $uri = JURI::getInstance(JRoute::_('index.php?' . $uri->getQuery(false))); } else { $uri = JURI::getInstance($juri->toString()); } }
<?php } ?> <?php } ?> <?php } ?> <?php if ($this->params->get('showreadmore_subcategory')) { ?> <div class="clear"></div> <div class="djc_readon"> <a class="btn button readmore" href="<?php echo JRoute::_(DJCatalogHelperRoute::getCategoryRoute($subcategory->id . ':' . $subcategory->alias)); ?> " class="readmore"><?php echo JText::_('COM_DJCATALOG2_BROWSE'); ?> </a> </div> <?php } ?> </div> </div> </div> <?php if ($newrow_close) { ?>
?> <div class="djc_category_info"> <?php if ($this->params->get('show_category_name') == 2) { echo JText::_('COM_DJCATALOG2_CATEGORY') . ': '; ?> <span><?php echo $relateditem->category; ?> </span> <?php } else { echo JText::_('COM_DJCATALOG2_CATEGORY') . ': '; ?> <a href="<?php echo DJCatalogHelperRoute::getCategoryRoute($relateditem->catslug); ?> "> <span><?php echo $relateditem->category; ?> </span> </a> <?php } ?> </div> <?php } ?> <?php
protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $pathway = $app->getPathway(); $title = null; $heading = null; $menu = $menus->getActive(); $id = (int) @$menu->query['cid']; $pid = $app->input->get('pid', null, 'string'); $limitstart = $app->input->get('limitstart', 0, 'int'); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } $title = $this->params->get('page_title', ''); $metakeys = null; $metadesc = null; if ($menu && ($menu->query['option'] != 'com_djcatalog2' || $menu->query['view'] != 'items' || $id != $this->item->id)) { if (!empty($this->item->metatitle)) { $title = $this->item->metatitle; } else { if ($this->item->name && $this->item->id > 0) { $title = $this->item->name; } } $path = array(); if ($this->item->id == 0) { //$path = array(array('title' => $title, 'link' => '')); } else { $path = array(array('title' => $this->item->name, 'link' => '')); } $category = $this->categories->get($this->item->parent_id); if ($category) { while (($menu->query['option'] != 'com_djcatalog2' || $menu->query['view'] == 'item' || $id != $category->id) && $category->id > 0) { $path[] = array('title' => $category->name, 'link' => DJCatalogHelperRoute::getCategoryRoute($category->catslug)); $category = $this->categories->get($category->parent_id); } } $path = array_reverse($path); foreach ($path as $item) { $pathway->addItem($item['title'], $item['link']); } } else { if (!empty($menu)) { if ($this->params->get('menu-meta_description')) { $metadesc = $this->params->get('menu-meta_description'); } if ($this->params->get('menu-meta_keywords')) { $metakeys = $this->params->get('menu-meta_keywords'); } } } if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0)) { if ($app->getCfg('sitename_pagetitles', 0) == '2') { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } else { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } } $this->document->setTitle($title); $uri = JFactory::getURI(); $vars = $uri->getQuery(true); unset($vars['order']); unset($vars['dir']); unset($vars['l']); $canonical = DJCatalogHelperRoute::getCategoryRoute($this->item->catslug, $pid); /*if ($limitstart > 0) { $canonical .= '&limitstart='.$limitstart; }*/ if (!empty($vars)) { $canonical .= '&' . $uri->buildQuery($vars); } foreach ($this->document->_links as $key => $headlink) { if ($headlink['relation'] == 'canonical') { unset($this->document->_links[$key]); } } $this->document->addHeadLink(JRoute::_($canonical), 'canonical'); if (!empty($this->item->metadesc)) { $this->document->setDescription($this->item->metadesc); } elseif (!empty($metadesc)) { $this->document->setDescription($metadesc); } if (!empty($this->item->metakey)) { $this->document->setMetadata('keywords', $this->item->metakey); } elseif (!empty($metakeys)) { $this->document->setMetadata('keywords', $metakeys); } if ($app->input->get('filtering', false)) { $this->document->setMetadata('robots', 'noindex, follow'); } else { if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } } $this->document->addCustomTag('<meta property="og:title" content="' . trim($title) . '" />'); $this->document->addCustomTag('<meta property="og:url" content="' . JRoute::_(DJCatalogHelperRoute::getCategoryRoute($this->item->catslug)) . '" />'); if ($item_images = DJCatalog2ImageHelper::getImages('category', $this->item->id)) { if (isset($item_images[0])) { $this->document->addCustomTag('<meta property="og:image" content="' . $item_images[0]->large . '" />'); //$this->document->setMetadata('og:image', $item_images[0]->large); } } if ($this->params->get('rss_enabled', '1') == '1') { $this->feedlink = JRoute::_(DJCatalogHelperRoute::getCategoryRoute($this->item->catslug, $pid) . '&format=feed&type=rss&limitstart=0'); //$link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_(DJCatalogHelperRoute::getCategoryRoute($this->item->catslug, $pid) . '&format=feed&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_(DJCatalogHelperRoute::getCategoryRoute($this->item->catslug, $pid) . '&format=feed&type=atom'), 'alternate', 'rel', $attribs); } }
<?php if (count($producers) > 0) { $jinput = JFactory::getApplication()->input; $active = $jinput->get('pid', null, 'int') > 0 && $jinput->get('option', '', 'string') == 'com_djcatalog2' ? $jinput->get('pid', null, 'int') : 0; ?> <ul class="menu nav mod_djc2_producer_list"> <?php foreach ($producers as $producer) { $class = 'level0 djc_prodid-' . $producer['id']; if ($active > 0 && $active == (int) $producer['id']) { $class .= ' active current'; } $class = 'class="' . $class . '"'; if ($params->get('type', '0') == '0') { $url = DJCatalogHelperRoute::getCategoryRoute($cid, $producer['id'] . ':' . $producer['alias']) . '&cm=0'; } else { $url = DJCatalogHelperRoute::getProducerRoute($producer['id'] . ':' . $producer['alias']); } ?> <li <?php echo $class; ?> ><a href="<?php echo JRoute::_($url); ?> "><span><?php echo $producer['name']; ?> </span></a></li> <?php
function search() { $app = JFactory::getApplication(); //$post = JRequest::get('post'); $post = $app->input->getArray($_POST); $params = array(); foreach ($post as $key => $value) { if ($key != 'task' && $key != 'option' && $key != 'view' && $key != 'cid' && $key != 'pid' && $key != 'Itemid') { if ($key == 'search') { $params[] = $key . '=' . urlencode($value); } else { if (is_array($value)) { foreach ($value as $k => $v) { if (is_numeric($k)) { $params[] = $key . '[]=' . $v; } else { $params[] = $key . '[' . $k . ']=' . $v; } } } else { $params[] = $key . '=' . $value; } } } } if (!array_key_exists('cm', $post)) { $params[] = 'cm=0'; } $menu = JFactory::getApplication('site')->getMenu('site'); $uri = DJCatalogHelperRoute::getCategoryRoute($app->input->get('cid', '0', 'string'), $app->input->get('pid', null, 'string')); if (strpos($uri, '?') === false) { $get = count($params) ? '?' . implode('&', $params) : ''; } else { $get = count($params) ? '&' . implode('&', $params) : ''; } $app->redirect(JRoute::_($uri . $get, false) . '#tlb'); }
if (in_array('item', $this->params->get('social_code_views', array())) && $this->params->get('social_code_position', 'top') == 'bottom' && $this->params->get('social_code', '') != '') { ?> <div class="djc_clearfix djc_social_b"> <?php echo $this->params->get('social_code'); ?> </div> <?php } ?> <?php if (false) { ?> <?php $categoryUrl = JRoute::_(DJCatalogHelperRoute::getCategoryRoute(JFactory::getApplication()->input->getString('refcid', 0), $this->item->prodslug)); ?> <a class="button btn" href="<?php echo $categoryUrl; ?> "><?php echo JText::_('COM_DJCATALOG2_BACK_BUTTON'); ?> </a> <?php } ?> <?php if ($this->params->get('show_footer')) { echo DJCATFOOTER;
static function getDJCatalog2Category(&$xmap, &$parent, &$params, &$catid) { $database = JFactory::getDBO(); $djc2categories = Djc2Categories::getInstance(array('state' => '1')); $category = $djc2categories->get((int) $catid); if (!$category) { return false; } $categories = $category->getChildren(); $xmap->changeLevel(1); foreach ($categories as $row) { if (!$row->created) { $row->created = $xmap->now; } $node = new stdclass(); $node->name = $row->name; $node->link = DJCatalogHelperRoute::getCategoryRoute($row->id . ':' . $row->alias); $node->id = $parent->id; $node->uid = 'com_djcatalog2c' . $row->id; $node->browserNav = $parent->browserNav; $node->modified = $row->created; $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->expandible = true; $node->secure = $parent->secure; if ($xmap->printNode($node) !== FALSE) { self::getDJCatalog2Category($xmap, $parent, $params, $row->id); } } /* Returns URLs of all listings in the current category */ if ($params['include_products']) { $query = " SELECT a.name, a.alias, a.id, a.cat_id, c.alias as cat_alias, UNIX_TIMESTAMP(a.created) as `created` \n" . " FROM #__djc2_items AS a \n" . " INNER JOIN #__djc2_categories as c on c.id = a.cat_id" . " WHERE a.cat_id = " . (int) $catid . " AND a.published=1" . " ORDER BY a.ordering ASC, a.name ASC "; $database->setQuery($query); $rows = $database->loadObjectList(); foreach ($rows as $row) { $node = new stdclass(); $node->name = $row->name; $node->link = DJCatalogHelperRoute::getItemRoute($row->id . ':' . $row->alias, $row->cat_id . ':' . $row->cat_alias); $node->id = $parent->id; $node->uid = 'com_djcatalog2i' . $row->id; $node->browserNav = $parent->browserNav; $node->modified = $row->created; $node->priority = $params['link_priority']; $node->changefreq = $params['link_changefreq']; $node->expandible = false; $node->secure = $parent->secure; $xmap->printNode($node); } } $xmap->changeLevel(-1); return true; }
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); } }