function getFirstLevelItem($mitem)
 {
     global $Itemid, $mosConfig_live_site, $mainframe, $sess;
     $txt = '';
     switch ($mitem->type) {
         case 'separator':
         case 'component_item_link':
             break;
         case 'content_item_link':
             $temp = split("&task=view&id=", $mitem->link);
             $mitem->link .= '&Itemid=' . $mainframe->getItemid($temp[1]);
             break;
         case 'url':
             if (eregi('index.php\\?', $mitem->link)) {
                 if (!eregi('Itemid=', $mitem->link)) {
                     $mitem->link .= '&Itemid=' . $mitem->id;
                 }
             }
             break;
         case 'content_typed':
         default:
             $mitem->link .= '&Itemid=' . $sess->getShopItemid();
             break;
     }
     $id = 'id="menu' . $mitem->id . '"';
     $mitem->link = vmAmpReplace($mitem->link);
     if (strcasecmp(substr($mitem->link, 0, 4), 'http')) {
         $mitem->link = sefRelToAbs($mitem->link);
     }
     $menuclass = 'mainlevel' . $this->parent->_params->get('class_sfx');
     // Active Menu highlighting
     $current_itemid = trim(vmRequest::getInt('Itemid'));
     if (in_array($mitem->id, $this->parent->open)) {
         $menuclass = 'mainlevel_active' . $this->parent->_params->get('class_sfx');
     }
     switch ($mitem->browserNav) {
         // cases are slightly different
         case 1:
             // open in a new window
             $txt = '<a href="' . $mitem->link . '" target="_blank" class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</a>';
             break;
         case 2:
             // open in a popup window
             $txt = "<a href=\"#\" onclick=\"javascript: window.open('" . $mitem->link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\" class=\"{$menuclass}\" " . $id . ">" . $mitem->name . "</a>\n";
             break;
         case 3:
             // don't link it
             $txt = '<span class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</span>';
             break;
         default:
             // formerly case 2
             // open in parent window
             $txt = '<a href="' . $mitem->link . '" class="' . $menuclass . '" ' . $id . '>' . $mitem->name;
             if ($this->parent->hasSubItems($mitem->id)) {
                 $txt .= '&nbsp;&nbsp;<img border="0" src="' . $this->parent->_params->get('LSPath') . '/img/tabarrow.gif" alt="arrow" />';
             }
             $txt .= '</a>';
             break;
     }
     if ($this->parent->_params->get('menu_images')) {
         $menu_params = new stdClass();
         $menu_params =& new mosParameters($mitem->params);
         $menu_image = $menu_params->def('menu_image', -1);
         if ($menu_image != '-1' && $menu_image) {
             $image = '<img src="' . $mosConfig_live_site . '/images/stories/' . $menu_image . '" border="0" alt="' . $mitem->name . '"/>';
             if ($this->parent->_params->get('menu_images_align')) {
                 $txt = $txt . ' ' . $image;
             } else {
                 $txt = $image . ' ' . $txt;
             }
         }
     }
     return $txt;
 }
示例#2
0
 /**
  * This reformats an URL, appends "option=com_virtuemart" and "Itemid=XX"
  * where XX is the Id of an entry in the table mos_menu with "link: option=com_virtuemart"
  * It also calls sefRelToAbs to apply SEF formatting
  * 
  * @param string $text THE URL
  * @param boolean False: Create a URI like /joomla/index.php?....; True: Create a URI like http://www.domain.com/index.php?....
  * @return string The reformatted URL
  */
 function url($text, $createAbsoluteURI = false, $encodeAmpersands = true, $ignoreSEF = false)
 {
     global $mm_action_url, $page, $mainframe;
     if (!defined('_VM_IS_BACKEND')) {
         $Itemid = "&Itemid=" . $this->getShopItemid();
     } else {
         $Itemid = '';
     }
     switch ($text) {
         case SECUREURL:
             $text = SECUREURL . basename($_SERVER['SCRIPT_NAME']) . "?" . $this->component_name . $Itemid;
             break;
         case URL:
             $text = URL . basename($_SERVER['SCRIPT_NAME']) . "?" . $this->component_name . $Itemid;
             break;
         default:
             $limiter = strpos($text, '?');
             if (!stristr($text, $_SERVER['SCRIPT_NAME']) && $limiter === false) {
                 $text = '?' . $text;
             }
             $appendix = "";
             // now append "&option=com_virtuemart&Itemid=XX"
             if (!strstr($text, "option=")) {
                 $appendix .= "&" . $this->component_name;
             }
             $appendix .= $Itemid;
             $script = basename(substr($text, 0, $limiter));
             if ($script == '') {
                 $script = basename($_SERVER['SCRIPT_NAME']);
             }
             if (!defined('_VM_IS_BACKEND')) {
                 if ($script == 'index3.php') {
                     $script = 'index2.php';
                     // index3.php is not available in the frontend!
                 }
                 $appendix = $script . substr($text, $limiter, strlen($text)) . $appendix;
                 if (class_exists('JRoute') && !$ignoreSEF && $mainframe->getCfg('sef')) {
                     $appendix = JRoute::_(str_replace($script . '&', $script . '?', $appendix));
                 } else {
                     if (function_exists('sefRelToAbs') && !$ignoreSEF && !defined('_JLEGACY')) {
                         $appendix = sefRelToAbs(str_replace($script . '&', $script . '?', $appendix));
                     }
                 }
                 if ($createAbsoluteURI && substr($appendix, 0, 4) != 'http' && ($ignoreSEF || !$mainframe->getCfg('sef'))) {
                     $appendix = URL . $appendix;
                 }
             } elseif ($_SERVER['SERVER_PORT'] == 443) {
                 //$script = strstr($_SERVER['PHP_SELF'], 'index2.php') ? 'index2.php' : 'index3.php';
                 $appendix = SECUREURL . "administrator/{$script}" . substr($text, $limiter, strlen($text) - 1) . $appendix;
             } else {
                 //$script = strstr($_SERVER['PHP_SELF'], 'index2.php') ? 'index2.php' : 'index3.php';
                 $appendix = URL . "administrator/{$script}" . substr($text, $limiter, strlen($text) - 1) . $appendix;
             }
             if (vmIsAdminMode() && strstr($text, 'func') !== false) {
                 $appendix .= '&vmtoken=' . vmSpoofValue($this->getSessionId());
             }
             if (stristr($text, SECUREURL)) {
                 $appendix = str_replace(URL, SECUREURL, $appendix);
             } elseif (stristr($text, URL) && $createAbsoluteURI) {
                 $appendix = str_replace(SECUREURL, URL, $appendix);
             }
             $text = $appendix;
             break;
     }
     if ($encodeAmpersands) {
         $text = vmAmpReplace($text);
     } else {
         $text = str_replace('&amp;', '&', $text);
     }
     return $text;
 }
示例#3
0
    function PrintIcon($link = '', $use_icon = true, $add_text = '')
    {
        global $VM_LANG, $mosConfig_live_site, $mosConfig_absolute_path, $cur_template, $Itemid;
        if (@VM_SHOW_PRINTICON == '1') {
            if (!$link) {
                $query_string = str_replace('only_page=1', 'only_page=0', vmAmpReplace(vmGet($_SERVER, 'QUERY_STRING')));
                $link = 'index2.php?' . $query_string . '&amp;pop=1' . (vmIsJoomla('1.5') ? '&amp;tmpl=component' : '');
            }
            // checks template image directory for image, if non found default are loaded
            if ($use_icon) {
                $text = vmCommonHTML::ImageCheck('printButton.png', '/images/M_images/', NULL, NULL, $VM_LANG->_('CMN_PRINT'), $VM_LANG->_('CMN_PRINT'));
                $text .= shopMakeHtmlSafe($add_text);
            } else {
                $text = '|&nbsp;' . $VM_LANG->_('CMN_PRINT') . '&nbsp;|';
            }
            $isPopup = vmGet($_GET, 'pop');
            if ($isPopup) {
                // Print Preview button - used when viewing page
                $html = '<span class="vmNoPrint">
				<a href="javascript:void(0)" onclick="javascript:window.print(); return false;" title="' . $VM_LANG->_('CMN_PRINT') . '">
				' . $text . '
				</a></span>';
                return $html;
            } else {
                // Print Button - used in pop-up window
                return vmPopupLink($link, $text, 640, 480, '_blank', $VM_LANG->_('CMN_PRINT'));
            }
        }
    }
示例#4
0
 /**
  * This reformats an URL, appends "option=com_virtuemart" and "Itemid=XX"
  * where XX is the Id of an entry in the table mos_menu with "link: option=com_virtuemart"
  * It also calls sefRelToAbs to apply SEF formatting
  * 
  * @param string $text THE URL
  * @param boolean False: Create a URI like /joomla/index.php?....; True: Create a URI like http://www.domain.com/index.php?....
  * @return string The reformatted URL
  */
 function url($text, $createAbsoluteURI = false, $encodeAmpersands = true, $ignoreSEF = false)
 {
     global $mm_action_url, $page, $mainframe;
     if (!defined('_VM_IS_BACKEND')) {
         // Strip the parameters from the $text variable and parse to a temporary array
         $tmp_text = str_replace('amp;', '', substr($text, strpos($text, '?')));
         if (substr($tmp_text, 0, 1) == '?') {
             $tmp_text = substr($tmp_text, 1);
         }
         parse_str($tmp_text, $ii_arr);
         // Init the temp. Itemid
         $tmp_Itemid = '';
         $db = new ps_DB();
         // Check if there is a menuitem for a product_id (highest priority)
         if (!empty($ii_arr['product_id'])) {
             if ($ii_product_id = intval($ii_arr['product_id'])) {
                 $db->query("SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%product_id={$ii_product_id}%' AND published=1");
                 if ($db->next_record()) {
                     $tmp_Itemid = $db->f("id");
                 }
             }
         }
         // Check if there is a menuitem for a category_id
         // This only checks for the exact category ID, it might be good to check for parents also. But at the moment, this would produce a lot of queries
         if (!empty($ii_arr['category_id'])) {
             $ii_cat_id = intval($ii_arr['category_id']);
             if ($ii_cat_id && $tmp_Itemid == '') {
                 $db->query("SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%category_id={$ii_cat_id}%' AND published=1");
                 if ($db->next_record()) {
                     $tmp_Itemid = $db->f("id");
                 }
             }
         }
         // Check if there is a menuitem for a flypage
         if (!empty($ii_arr['flypage'])) {
             $ii_flypage = $db->getEscaped(vmget($ii_arr, 'flypage'));
             if ($ii_flypage && $tmp_Itemid == '') {
                 $db->query("SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%flypage={$ii_flypage}%' AND published=1");
                 if ($db->next_record()) {
                     $tmp_Itemid = $db->f("id");
                 }
             }
         }
         // Check if there is a menuitem for a page
         if (!empty($ii_arr['page'])) {
             $ii_page = $db->getEscaped(vmget($ii_arr, 'page'));
             if ($ii_page && $tmp_Itemid == '') {
                 $db->query("SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%page={$ii_page}%' AND published=1");
                 if ($db->next_record()) {
                     $tmp_Itemid = $db->f("id");
                 }
             }
         }
         // If we haven't found an Itemid, use the standard VM-Itemid
         $Itemid = "&Itemid=" . ($tmp_Itemid ? $tmp_Itemid : $this->getShopItemid());
     } else {
         $Itemid = NULL;
     }
     // split url into base ? path
     $limiter = strpos($text, '?');
     if ($limiter === false) {
         if (!strstr($text, "=")) {
             // $text recognized to be parameter-list (bug?)
             $base = NULL;
             $params = $text;
         } else {
             // text recognized to be url without parameters
             $base = $mm_action_url;
             $params = $text;
         }
     } else {
         // base?params
         $base = substr($text, 0, $limiter);
         $params = substr($text, $limiter + 1);
     }
     // normalize base (cut off multislashes)
     $base = str_replace("//", "/", $base);
     $base = str_replace(":/", "://", $base);
     // add script name to naked base url
     // TODO: Improve
     if ($base == URL || $base == SECUREURL) {
         $base .= basename($_SERVER['SCRIPT_NAME']);
     }
     if (!basename($base)) {
         $base .= basename($_SERVER['SCRIPT_NAME']);
     }
     // append "&option=com_virtuemart&Itemid=XX"
     $params .= !strstr($params, $this->component_name) ? ($params ? "&" : NULL) . $this->component_name : NULL;
     $params .= $Itemid;
     if (vmIsAdminMode() && strstr($text, 'func') !== false) {
         $params .= ($params ? "&" : NULL) . 'vmtoken=' . vmSpoofValue($this->getSessionId());
     }
     if (!defined('_VM_IS_BACKEND')) {
         // index3.php is not available in the frontend!
         $base = str_replace("index3.php", "index2.php", $base);
         $url = basename($base) . "?" . $params;
         // make url absolute
         if ($createAbsoluteURI && !substr($url, 0, 4) != "http") {
             $url = (stristr($text, SECUREURL) ? SECUREURL : URL) . substr($url, $url[0] == '/' ? 1 : 0);
         }
         if (class_exists('JRoute') && !$ignoreSEF && $mainframe->getCfg('sef')) {
             $url = JRoute::_($url);
         } else {
             if (function_exists('sefRelToAbs') && !$ignoreSEF && !defined('_JLEGACY')) {
                 $url = sefRelToAbs($url);
             }
         }
     } else {
         // backend
         $url = ($_SERVER['SERVER_PORT'] == 443 ? SECUREURL : URL) . "administrator/" . basename($base) . "?" . $params;
     }
     $url = $encodeAmpersands ? vmAmpReplace($url) : str_replace('&amp;', '&', $url);
     return $url;
 }