Esempio n. 1
0
 public static function buildCategorySelectBox($catlistid, $cat_link_itemids, $root_itemid, $show_empty_categories, $orderby_pri)
 {
     global $jlistConfig;
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $preload = array();
     $selected = array();
     $root_url = '';
     $url = array();
     $data = array();
     $catx_itemid = '';
     $preload[] = JHtml::_('select.option', 0, JText::_('COM_JDOWNLOADS_FE_SELECT_OVERVIEW'));
     if ($jlistConfig['show.header.catlist.uncategorised']) {
         $preload[] = JHtml::_('select.option', 1, JText::_('COM_JDOWNLOADS_FE_SELECT_UNCATEGORISED'));
     }
     if ($jlistConfig['show.header.catlist.all']) {
         $preload[] = JHtml::_('select.option', -1, JText::_('COM_JDOWNLOADS_FE_SELECT_ALL_DOWNLOADS'));
     }
     if ($jlistConfig['show.header.catlist.newfiles']) {
         $preload[] = JHtml::_('select.option', -2, JText::_('COM_JDOWNLOADS_SELECT_NEWEST_DOWNLOADS'));
     }
     if ($jlistConfig['show.header.catlist.topfiles']) {
         $preload[] = JHtml::_('select.option', -3, JText::_('COM_JDOWNLOADS_SELECT_HOTTEST_DOWNLOADS'));
     }
     $selected[] = JHtml::_('select.option', $catlistid);
     // get the categories data
     $categories_list = self::getCategoriesList($show_empty_categories, $orderby_pri);
     $categories = @array_merge($preload, $categories_list);
     foreach ($categories as $key => $value) {
         if (isset($value->value)) {
             $options[] = JHtml::_('select.option', $value->value, JText::_($value->text));
         } else {
             $options[] = JHtml::_('select.option', $value->id, JText::_($value->title));
         }
     }
     // get
     $query = $db->getQuery(true);
     $query->select('a.id, a.parent_id as parent, a.title');
     $query->from('#__jdownloads_categories AS a');
     $query->where('a.parent_id > 0');
     $query->where('a.published = 1');
     $query->where('a.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
     $query->order('a.id');
     $db->setQuery($query);
     $src_for_url_list = $db->loadObjectList();
     if ($src_for_url_list) {
         $max_cat_id = $src_for_url_list[count($src_for_url_list) - 1]->id;
     } else {
         $max_cat_id = 0;
     }
     $x = 0;
     // create array with all sef url's for listbox
     for ($i = 0; $i < $max_cat_id; $i++) {
         if ($src_for_url_list[$x]->id == $i + 1) {
             // exists a single category menu link for it?
             if ($cat_link_itemids) {
                 $catx_itemid = '';
                 for ($i2 = 0; $i2 < count($cat_link_itemids); $i2++) {
                     if ($cat_link_itemids[$i2]['catid'] == $src_for_url_list[$x]->id) {
                         $catx_itemid = $cat_link_itemids[$i2]['id'];
                     }
                 }
             }
             if (!$catx_itemid) {
                 // use global itemid when no single link exists
                 $catx_itemid = $root_itemid;
             }
             $url[$src_for_url_list[$x]->id] = jRoute::_("index.php?option=com_jdownloads&view=category&catid=" . $src_for_url_list[$x]->id . '&Itemid=' . $catx_itemid);
             $x++;
         } else {
             $url[$i + 1] = 'null';
         }
     }
     $data['url'] = implode(',', $url);
     $data['options'] = $options;
     $data['selected'] = $selected;
     return $data;
 }
					<ul class="nav pull-right">
						<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><?php 
echo $user->name;
?>
<b class="caret"></b></a>
							<ul class="dropdown-menu">
								<li class=""><a href="<?php 
echo jRoute::_('index.php?option=com_virtuemart&view=user');
?>
"><i class="icon icon-user"></i> <?php 
echo jText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
?>
</a></li>
								<li class="divider"></li>
								<li class=""><a href="<?php 
echo jRoute::_('index.php?option=com_users&task=user.logout&' . jSession::getFormToken() . '=1&return=' . base64_encode('index.php?option=com_virtuemart'));
?>
"><i class="icon icon-exit"></i> <?php 
echo jText::_('COM_VIRTUEMART_BUTTON_LOGOUT');
?>
</a></li>
							</ul>
						</li>
					</ul>
				</div>
			</div>
		</div>
	</nav>
	<?php 
if (count($messages)) {
    foreach ($messages as $message) {
 /**
  * Set a URL for browser redirection.
  * Use type 'error' if the message is an error message
  * @param   string  $url   URL to redirect to.
  * @param   string  $msg   Message to display on redirect. Optional, defaults to value set internally by controller, if any.
  * @param   string  $type  Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage.
  *
  * @return  JController  This object to support chaining.
  *
  * @since   11.1
  */
 public function setRedirect($url = null, $msg = null, $type = null)
 {
     if ($url === null) {
         $url = $this->redirectPath;
     }
     $format = JRequest::getWord('format');
     if ($format !== 'json') {
         // add menu item id in front
         if (JFactory::getApplication()->isSite()) {
             $url = jRoute::_($url, false);
         }
         return parent::setRedirect($url, $msg, $type);
     }
     if ($msg !== null) {
         // Controller may have set this directly
         $this->json->message = $msg;
     }
     // Ensure the type is not overwritten by a previous call to setMessage.
     if (empty($type)) {
         if (empty($this->messageType)) {
             $this->messageType = 'message';
         }
     } else {
         $this->messageType = $type;
     }
     if ($this->messageType == 'message') {
         $this->json->type = 'alert-info';
     } else {
         if ($this->messageType == 'error') {
             $this->json->type = 'alert-error';
         } else {
             $this->json->type = 'alert-' . $this->messageType;
         }
     }
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Cache-Control: no-cache, must-revalidate");
     header("Pragma: no-cache");
     header("Content-type: application/json;; charset=utf-8");
     echo json_encode($this->json);
     jexit();
 }