/**
  * Returns Review info tag value
  */
 function getReviewTagValue($tag)
 {
     $output = '';
     // if productid is incorrect returns '' in any case
     if ($this->_productid_invalid) {
         return '';
     }
     switch ($tag) {
         case 'number':
             $output = modApiFunc('Customer_Reviews', 'getProductCustomerReviewNumber', $this->_productid);
             if (!$this->checkReviewAvail(6, 7)) {
                 $output = 0;
             }
             break;
         case 'averagerating':
             $output = modApiFunc('Customer_Reviews', 'getTotalProductRating', $this->_productid);
             $output = $output['total_rating'];
             if (!$this->checkReviewAvail(7)) {
                 $output = 0;
             }
             break;
         case 'link':
             $cid = modApiFunc('CProductListFilter', 'getCurrentCategoryId');
             $r = new Request();
             $r->setView('ProductInfo');
             $r->setAction('SetCurrentProduct');
             $r->setKey('prod_id', $this->_productid);
             $r->setProductID($this->_productid);
             $r->setCategoryID($cid);
             $r->setAnchor('customer_reviews_' . $this->_productid);
             return $r->getURL();
     }
     return $output;
 }
 /**
  * Returns Category info tag value.
  *
  * @param string $tag Short tag name
  * @param int $localized The parameter defines, whether to return localized
  * values or to send as values the constants CATEGORYINFO_LOCALIZED_DATA or
  * CATEGORYINFO_NOT_LOCALIZED_DATA directly from the DB
  * @return string Tag value
  **/
 function getCategoryTagValue($tag, $localized = CATEGORYINFO_DEFAULT_LOCALIZED_MODE)
 {
     global $application;
     /*
      If creating an object the incorrect id was passed to the category, then
      it will return an empty value of any tag.
     */
     if ($this->_fCategoryIDIsIncorrect == true) {
         return $this->debugmode ? 'Category ID is incorrect' : '';
     }
     # Check additional tags
     if (array_key_exists($tag, $this->_fAdditionalTagList)) {
         return $this->_fAdditionalTagList[$tag];
     }
     # Check localization request
     if ($localized == CATEGORYINFO_LOCALIZED_DATA) {
         $this->localized = true;
     } elseif ($localized == CATEGORYINFO_NOT_LOCALIZED_DATA) {
         $this->localized = false;
     }
     # Get Tag value
     $tag = _ml_strtolower(trim($tag));
     switch ($tag) {
         #
         # Process artificial tags
         #
         case $this->_fArtificialTagList['id']:
             return $this->_fCategoryID;
             break;
         case $this->_fArtificialTagList['name']:
             return $this->localized ? prepareHTMLDisplay($this->_fBaseCategoryInfo[0]['name']) : $this->_fBaseCategoryInfo[0]['name'];
             break;
         case $this->_fArtificialTagList['status']:
             $cat_status = "";
             $MessageResources =& $application->getInstance('MessageResources');
             switch ($this->_fBaseCategoryInfo[0]['status']) {
                 case CATEGORY_STATUS_ONLINE:
                     $cat_status = $MessageResources->getMessage('CAT_STATUS_ONLINE');
                     break;
                 case CATEGORY_STATUS_OFFLINE:
                     $cat_status = $MessageResources->getMessage('CAT_STATUS_OFFLINE');
                     break;
                 default:
                     //: report error
                     $cat_status = "";
             }
             return $this->localized ? prepareHTMLDisplay($cat_status) : $this->_fBaseCategoryInfo[0]['status'];
             break;
         case $this->_fArtificialTagList['description']:
             return $this->localized ? prepareHTMLDisplay($this->_fBaseCategoryInfo[0]['descr']) : $this->_fBaseCategoryInfo[0]['descr'];
             break;
         case $this->_fArtificialTagList['largeimage']:
             if ($this->_fImagesData === null) {
                 $this->_getImageInfo();
             }
             $_src = $this->_fImagesData['largeimage_file']['URL'];
             $_width = $this->_fImagesData['largeimage_file']['WIDTH'];
             $_height = $this->_fImagesData['largeimage_file']['HEIGHT'];
             $_alttext = $this->getCategoryTagValue('imagealttext');
             return '<img src="' . $_src . '" width="' . $_width . '" height="' . $_height . '" alt="' . $_alttext . '" />';
             break;
         case $this->_fArtificialTagList['largeimagesrc']:
             if ($this->_fImagesData === null) {
                 $this->_getImageInfo();
             }
             return $this->_fImagesData['largeimage_file']['URL'];
             break;
         case $this->_fArtificialTagList['largeimagewidth']:
             if ($this->_fImagesData === null) {
                 $this->_getImageInfo();
             }
             return $this->_fImagesData['largeimage_file']['WIDTH'];
             break;
         case $this->_fArtificialTagList['largeimageheight']:
             if ($this->_fImagesData === null) {
                 $this->_getImageInfo();
             }
             return $this->_fImagesData['largeimage_file']['HEIGHT'];
             break;
         case $this->_fArtificialTagList['smallimage']:
             if ($this->_fImagesData === null) {
                 $this->_getImageInfo();
             }
             $_src = $this->_fImagesData['smallimage_file']['URL'];
             $_width = $this->_fImagesData['smallimage_file']['WIDTH'];
             $_height = $this->_fImagesData['smallimage_file']['HEIGHT'];
             $_alttext = $this->getCategoryTagValue('imagealttext');
             return '<img src="' . $_src . '" width="' . $_width . '" height="' . $_height . '" alt="' . $_alttext . '" />';
             break;
         case $this->_fArtificialTagList['smallimagesrc']:
             if ($this->_fImagesData === null) {
                 $this->_getImageInfo();
             }
             return $this->_fImagesData['smallimage_file']['URL'];
             break;
         case $this->_fArtificialTagList['smallimagewidth']:
             if ($this->_fImagesData === null) {
                 $this->_getImageInfo();
             }
             return $this->_fImagesData['smallimage_file']['WIDTH'];
             break;
         case $this->_fArtificialTagList['smallimageheight']:
             if ($this->_fImagesData === null) {
                 $this->_getImageInfo();
             }
             return $this->_fImagesData['smallimage_file']['HEIGHT'];
             break;
         case $this->_fArtificialTagList['imagealttext']:
             return $this->localized ? prepareHTMLDisplay($this->_fBaseCategoryInfo[0]['image_descr']) : $this->_fBaseCategoryInfo[0]['image_descr'];
             break;
         case $this->_fArtificialTagList['pagetitle']:
             return $this->localized ? prepareHTMLDisplay($this->_fBaseCategoryInfo[0]['page_title']) : $this->_fBaseCategoryInfo[0]['page_title'];
             break;
         case $this->_fArtificialTagList['metakeywords']:
             return $this->localized ? prepareHTMLDisplay($this->_fBaseCategoryInfo[0]['meta_keywords']) : $this->_fBaseCategoryInfo[0]['meta_keywords'];
             break;
         case $this->_fArtificialTagList['metadescription']:
             return $this->localized ? prepareHTMLDisplay($this->_fBaseCategoryInfo[0]['meta_descr']) : $this->_fBaseCategoryInfo[0]['meta_descr'];
             break;
         case $this->_fArtificialTagList['productsnumber']:
             //               :                                     ,
             //
             if ($this->getShowProductsRecursivelyStatus() == CATEGORY_SHOW_PRODUCTS_RECURSIVELY) {
                 $select_mode_recursiveness = IN_CATEGORY_RECURSIVELY;
             } else {
                 $select_mode_recursiveness = IN_CATEGORY_ONLY;
             }
             return $this->_getProductsNumberInCategory($select_mode_recursiveness, UNIQUE_PRODUCTS);
             break;
         case $this->_fArtificialTagList['productsnumberrecursively']:
             return $this->_getProductsNumberInCategory(IN_CATEGORY_RECURSIVELY, UNIQUE_PRODUCTS);
             break;
         case $this->_fArtificialTagList['productsnumber_non_recursively']:
             return $this->_getProductsNumberInCategory(IN_CATEGORY_ONLY, UNIQUE_PRODUCTS);
             break;
         case $this->_fArtificialTagList['productsnumberrecursively_all_product_links']:
             return $this->_getProductsNumberInCategory(IN_CATEGORY_RECURSIVELY, ALL_PRODUCT_LINKS);
             break;
         case $this->_fArtificialTagList['offlineandonlinesubcategoriesnumber']:
             if ($this->_fSubcategoriesNumber == null) {
                 $this->_fSubcategoriesNumber = sizeof(modApiFunc('Catalog', 'getSubcategoriesFullListWithParent', $this->_fBaseCategoryInfo[0]['id'], false)) - 1;
             }
             return $this->_fSubcategoriesNumber;
         case $this->_fArtificialTagList['hasonlinesubcategories']:
             return modApiFunc('Catalog', 'hasOnlineSubcategories', $this->_fBaseCategoryInfo[0]['id']);
         case $this->_fArtificialTagList['subcategoriesnumber']:
             $OnlineSubCategories = $this->_getOnlineSubcategories();
             $n_subcategories_including_current = sizeof($OnlineSubCategories);
             //                 (Navigator AZ)                                      ,
             //                              .
             //             _loadOnlineSubCategories               Id      Online             ,
             //       id                  ,          Online,        .
             return $n_subcategories_including_current > 0 ? $n_subcategories_including_current - 1 : $n_subcategories_including_current;
             // current is itself offline
             break;
         case $this->_fArtificialTagList['left']:
             return $this->_fBaseCategoryInfo[0]['left1'];
             break;
         case $this->_fArtificialTagList['right']:
             return $this->_fBaseCategoryInfo[0]['right1'];
             break;
         case $this->_fArtificialTagList['level']:
             return $this->_fBaseCategoryInfo[0]['level'];
             break;
         case $this->_fArtificialTagList['parentid']:
             if ($this->_fParentCategoryID == null) {
                 $this->_fParentCategoryID = modApiFunc('Catalog', 'getParentCategoryId', $this->_fCategoryID);
             }
             return $this->_fParentCategoryID;
             break;
         case $this->_fArtificialTagList['recursivestatus']:
             $this->_loadRecursiveStatus();
             $cat_status = "";
             $MessageResources =& $application->getInstance('MessageResources');
             switch ($this->_fRecursiveStatus) {
                 case CATEGORY_STATUS_ONLINE:
                     $cat_status = $MessageResources->getMessage('CAT_STATUS_ONLINE');
                     break;
                 case CATEGORY_STATUS_OFFLINE:
                     $cat_status = $MessageResources->getMessage('CAT_STATUS_OFFLINE');
                     break;
                 default:
                     //: report error
                     $cat_status = "";
             }
             return $this->localized ? prepareHTMLDisplay($cat_status) : $this->_fRecursiveStatus;
             break;
         case $this->_fArtificialTagList['link']:
             $_request = new Request();
             $_request->setView('NavigationBar');
             $_request->setAction("SetCurrCat");
             $_request->setKey("category_id", $this->_fCategoryID);
             $_request->setCategoryID($this->_fCategoryID);
             $_url = $_request->getURL();
             return $_url;
             break;
         case $this->_fArtificialTagList['seo_url_prefix']:
             return $this->_fBaseCategoryInfo[0]['seo_url_prefix'];
             break;
         case $this->_fArtificialTagList['showproductsrecursivelystatus']:
             $raw_status = $this->_fBaseCategoryInfo[0]['show_prod_recurs'];
             $obj =& $application->getInstance('MessageResources');
             if ($this->localized) {
                 if ($raw_status == CATEGORY_DONOTSHOW_PRODUCTS_RECURSIVELY) {
                     return $obj->getMessage('CATEGORY_DONOTSHOW_PRODUCTS_RECURSIVELY');
                 } else {
                     return $obj->getMessage('CATEGORY_SHOW_PRODUCTS_RECURSIVELY');
                 }
             } else {
                 return $raw_status;
             }
             break;
             # If the tag is not defined, return an empty string.
         # If the tag is not defined, return an empty string.
         default:
             return $this->debugmode ? 'The tag is undefined:' . $tag : '';
     }
 }
 function getProductInfoLink($prod_id)
 {
     $cid = modApiFunc('CProductListFilter', 'getCurrentCategoryId');
     $r = new Request();
     $r->setView('ProductInfo');
     $r->setAction('SetCurrentProduct');
     $r->setKey('prod_id', $prod_id);
     $r->setProductID($prod_id);
     $r->setCategoryID($cid);
     return $r->getURL();
 }
 /**
  * Returns the page links line.
  *
  * @return string paginator view in the type of paginal references
  * @ finish the functions on this page
  */
 function output($pag_name, $viewname, $cat_id = -1, $prod_id = -1)
 {
     global $application;
     $viewname = CURRENT_REQUEST_URL;
     #Define whether to output the view or not
     if ($this->NoView) {
         $application->outputTagErrors(true, "PaginatorLine", "Errors");
         return "";
     }
     $this->templateFiller =& $application->getInstance('TemplateFiller');
     $this->template = $application->getBlockTemplate('PaginatorLine');
     $this->templateFiller->setTemplate($this->template);
     $retval = '';
     //Output a paginator view with the page number,
     //form the link of the type ?action=setpage&pgname=$pag_name&pgnum=$i
     $rows_per_page = modAPIFunc('Paginator', 'getPaginatorRowsPerPage', $pag_name);
     if (!$rows_per_page) {
         $rows_per_page = ROWS_PER_PAGE;
     }
     $pages = ceil(modAPIFunc('Paginator', 'getCurrentPaginatorTotalRows') / $rows_per_page);
     $lines = ceil($pages / PAGES_PER_LINE);
     $currentpage = modAPIFunc('Paginator', 'getPaginatorPage', $pag_name);
     $currentrows = modAPIFunc('Paginator', 'getPaginatorRowsPerPage', $pag_name);
     $currentline = ceil($currentpage / PAGES_PER_LINE);
     //$firstpageinline = ($currentline - 1)*PAGES_PER_LINE+1;
     $lastpageinline = $currentline * PAGES_PER_LINE;
     if ($lastpageinline > $pages) {
         $lastpageinline = $pages;
     }
     $firstpageinline = $lastpageinline - PAGES_PER_LINE + 1;
     if ($firstpageinline <= 0) {
         $firstpageinline = 1;
     }
     $this->_Data = array('Local_Items' => '', 'Local_From' => '', 'Local_To' => '', 'Local_Of' => '', 'Local_CurrentPage' => '', 'Local_PagesQty' => '', 'Local_ViewAll' => '');
     $request = new Request();
     $request->setView($viewname);
     $request->setAction('Paginator_SetPage');
     $request->setKey('pgname', $pag_name);
     $request->setKey('pgnum', $currentpage - 1);
     $request->setCategoryID($cat_id);
     $request->setProductID($prod_id);
     $this->_Data = array_merge($this->_Data, array('Local_PageLink' => $request->getURL(), 'Local_PageNumber' => ''));
     $retval = '';
     $paginator_line = '';
     if ($currentpage != 1) {
         $application->registerAttributes($this->_Data);
         $paginator_line .= $this->templateFiller->fill("Prev");
     }
     if ($firstpageinline != 1) {
         $paginator_line .= CZ_getMsg("PAGINATOR_DOTS");
     }
     for ($i = $firstpageinline; $i <= $lastpageinline; $i++) {
         $request = new Request();
         $request->setView($viewname);
         $request->setAction('Paginator_SetPage');
         $request->setKey('pgname', $pag_name);
         $request->setKey('pgnum', $i);
         $request->setCategoryID($cat_id);
         $this->_Data = array_merge($this->_Data, array('Local_PageLink' => $request->getURL(), 'Local_PageNumber' => $i));
         $application->registerAttributes($this->_Data);
         if ($i == $currentpage) {
             $paginator_line .= $this->templateFiller->fill("ItemSelected");
         } else {
             $paginator_line .= $this->templateFiller->fill("Item");
         }
     }
     if ($lastpageinline != $pages) {
         $paginator_line .= CZ_getMsg("PAGINATOR_DOTS");
     }
     $request = new Request();
     $request->setView($viewname);
     $request->setAction('Paginator_SetPage');
     $request->setKey('pgname', $pag_name);
     $request->setKey('pgnum', $currentpage + 1);
     $request->setCategoryID($cat_id);
     $this->_Data = array_merge($this->_Data, array('Local_PageLink' => $request->getURL(), 'Local_PageNumber' => ''));
     if ($currentpage != $pages && $pages != 0) {
         $paginator_line .= $this->templateFiller->fill("Next");
     }
     $request = new Request();
     $request->setView($viewname);
     $request->setAction('Paginator_SetRowsPerPage');
     $request->setKey('pgname', $pag_name);
     $request->setKey('rows', modAPIFunc('Paginator', 'getCurrentPaginatorTotalRows'));
     $request->setCategoryID($cat_id);
     $to = $currentpage * $rows_per_page;
     $total_rows = modAPIFunc('Paginator', 'getCurrentPaginatorTotalRows');
     if ($to > $total_rows) {
         $to = $total_rows;
     }
     $this->_Data = array_merge($this->_Data, array('Local_Items' => $pages > 1 ? $paginator_line : "", 'Local_From' => ($currentpage - 1) * $rows_per_page + 1, 'Local_To' => $to, 'Local_Of' => $total_rows, 'Local_CurrentPage' => $currentpage, 'Local_PagesQty' => $pages, 'Local_ViewAll' => $request->getURL()));
     $application->registerAttributes($this->_Data);
     if ($pages > 1) {
         $retval = $this->templateFiller->fill("Container");
     } else {
         $retval = $this->templateFiller->fill("Empty");
     }
     //        $retval = $this->templateFiller->fill("Container");
     return $retval;
 }
function __info_tag_output($tag, $arg_list)
{
    global $application, $zone;
    #                       .
    $view = $application->getLatestTag();
    list($entity, $attr) = getTagName($tag);
    /*
     *         empty($arg_list)               ,                                 msg
     *                      .
     */
    if ($view != null && is_callable(array($view, 'getTag')) && empty($arg_list)) {
        if (strtolower($tag) == 'viewclassname') {
            $alias = $application->getBlockOverride($view);
            echo strtolower($alias == null ? $view : $alias);
            return;
        }
        $view_obj =& $application->getInstance($view);
        $output = $view_obj->getTag($tag, $arg_list);
        if ($output !== null) {
            echo $output;
            return;
        }
    }
    if (empty($arg_list)) {
        #                        .                   ,                  .
        $params = $application->getTemplateParameters();
        $product_id = $params['product_id'];
        $category_id = $params['category_id'];
        $page_id = @$params['page_id'];
    } else {
        $product_id = $arg_list[0];
        $category_id = $arg_list[0];
        $page_id = $arg_list[0];
    }
    $output = "";
    switch ($entity) {
        case 'attribute':
            if (empty($arg_list) || !array_key_exists(0, $arg_list) || !array_key_exists(1, $arg_list)) {
                break;
            }
            $obj =& $application->getInstance('Catalog');
            $attributeInfo = $obj->getAttributeInfo($arg_list[0], $arg_list[1]);
            $output = $attributeInfo[strtolower($attr)];
            break;
        case 'productreviews':
            if ($product_id == -1) {
                break;
            }
            loadClass('CProductReviewInfo');
            $prcrobj = new CProductReviewInfo($product_id);
            if ($prcrobj !== null) {
                $output = $prcrobj->getReviewTagValue($attr);
            }
            break;
        case 'cmspage':
            if (!$page_id) {
                // trying to get the page_id from the request
                $page_id = modApiFunc('Request', 'getValueByKey', 'page_id');
            }
            loadClass('CCMSPageInfo');
            $cmspageobj = new CCMSPageInfo($page_id);
            $output = $cmspageobj->getCMSPageTagValue($attr, $arg_list);
            break;
        case 'product':
            if ($product_id == -1) {
                break;
            }
            $prdobj = new CProductInfo($product_id);
            if ($prdobj !== null) {
                $output = $prdobj->getProductTagValue($attr);
            }
            break;
        case 'manufacturer':
            $mnf_id = __info_tag_output_find_tag_params($entity, $arg_list);
            $mnf_info = modApiFunc("Manufacturers", "getManufacturerInfo", $mnf_id);
            if ($mnf_id == PARAM_NOT_FOUND || $mnf_id == MANUFACTURER_NOT_DEFINED || $mnf_info === NULL) {
                $output = NULL;
            } else {
                $img_info = modApiFunc("Images", "getImageData", $mnf_info['manufacturer_image_id']);
                switch ($attr) {
                    case 'id':
                        $output = $mnf_info['manufacturer_id'];
                        break;
                    case 'name':
                        $output = $mnf_info['manufacturer_name'];
                        break;
                    case 'url':
                        $output = $mnf_info['manufacturer_site_url'];
                        break;
                    case 'description':
                        $output = $mnf_info['manufacturer_descr'];
                        break;
                    case 'status':
                        $output = $mnf_info['manufacturer_active'] == DB_TRUE ? getMsg('MNF', 'STATUS_ACTIVE') : getMsg('MNF', 'STATUS_INACTIVE');
                        break;
                    case 'image':
                        $output = $img_info['image_data'] === NULL ? "" : getimage_output_cz('mnf_image_' . rand(0, 32768), new image_obj($img_info['image_data']['image_id']));
                        break;
                    case 'imagesrc':
                        $output = $img_info['image_data'] === NULL || !isset($img_info['image_data']) ? "" : $img_info['image_data']['image_src'];
                        break;
                    case 'imagewidth':
                        $output = $img_info['image_data'] === NULL || !isset($img_info['image_data']) ? "" : $img_info['image_data']['image_width'];
                        break;
                    case 'imageheight':
                        $output = $img_info['image_data'] === NULL || !isset($img_info['image_data']) ? "" : $img_info['image_data']['image_height'];
                        break;
                    case 'imagealttext':
                        $output = $img_info['image_data'] === NULL || !isset($img_info['image_data']) ? "" : $img_info['image_data']['image_alt_text'];
                        break;
                    case 'thumbnail':
                        $output = $img_info['image_thumbnail_data'] === NULL || !isset($img_info['image_thumbnail_data']) ? "" : getimage_output_cz('mnf_image_' . rand(0, 32768), new image_obj($img_info['image_thumbnail_data']['image_id']));
                        break;
                    case 'thumbnailsrc':
                        $output = $img_info['image_thumbnail_data'] === NULL || !isset($img_info['image_thumbnail_data']) ? "" : $img_info['image_thumbnail_data']['image_src'];
                        break;
                    case 'thumbnailwidth':
                        $output = $img_info['image_thumbnail_data'] === NULL || !isset($img_info['image_thumbnail_data']) ? "" : $img_info['image_thumbnail_data']['image_width'];
                        break;
                    case 'thumbnailheight':
                        $output = $img_info['image_thumbnail_data'] === NULL || !isset($img_info['image_thumbnail_data']) ? "" : $img_info['image_thumbnail_data']['image_height'];
                        break;
                    case 'thumbnailalttext':
                        $output = $img_info['image_thumbnail_data'] === NULL || !isset($img_info['image_thumbnail_data']) ? "" : $img_info['image_thumbnail_data']['image_alt_text'];
                        break;
                }
            }
            break;
        case 'category':
            if ($category_id == -1) {
                break;
            }
            $catobj =& $application->getInstance('CCategoryInfo', $category_id);
            if ($catobj !== null) {
                $output = $catobj->getCategoryTagValue($attr);
            }
            break;
        case 'msg':
            $obj =& $application->getInstance('MessageResources');
            $output = $obj->getMessage(new ActionMessage($arg_list));
            break;
        case 'xmsg':
            $obj =& $application->getInstance('MessageResources', modApiFunc("Modules_Manager", "getResFileByShortName", $arg_list[0]), 'AdminZone', $arg_list[0]);
            array_shift($arg_list);
            $output = $obj->getMessage(new ActionMessage($arg_list));
            break;
        case 'label':
            $obj =& $application->getInstance('MessageResources', "", 'CustomerZone', "CZ");
            $output = $obj->getMessage(new ActionMessage($arg_list));
            break;
        case 'hinttext':
            $obj =& $application->getInstance('Hint');
            $output = $obj->getHintText($arg_list);
            break;
        case 'hintlink':
            $obj =& $application->getInstance('Hint');
            $output = $obj->getHintLink($arg_list);
            break;
        case 'storeowner':
            $obj =& $application->getInstance('Configuration');
            $output = $obj->getTagValue($tag);
            break;
        case 'pagehelplink':
            loadCoreFile('page_help_tutorial_links.php');
            $obj =& $application->getInstance('HelpLinkCreator');
            $output = $obj->getPageHelpLink($arg_list[0]);
            break;
        case 'videotutoriallink':
            loadCoreFile('page_help_tutorial_links.php');
            $obj =& $application->getInstance('HelpLinkCreator');
            $output = $obj->getTutorialLink($arg_list[0]);
            break;
        case 'shoppingcart':
            $obj =& $application->getInstance('Cart');
            $output = $obj->getCartInfo($tag);
            break;
        case 'paypalproexpresscheckout':
            $output = "";
            break;
        case 'paypalproukexpresscheckout':
            $output = "";
            break;
        case 'pageurl':
            $req = new Request();
            $req->setView($arg_list[0]);
            if (isset($arg_list[1]) and is_array($arg_list[1]) and !empty($arg_list[1])) {
                foreach ($arg_list[1] as $k => $v) {
                    $req->setKey($k, $v);
                }
            }
            if ($arg_list[0] == 'ProductList') {
                if (isset($arg_list[1])) {
                    $category_id = $arg_list[1];
                }
                if (!$category_id) {
                    $plf = $application->getInstance('CProductListFilter');
                    $category_id = $plf->getCurrentCatgoryId();
                    $req->setCategoryID($category_id);
                }
            }
            $output = $req->getURL();
            break;
        case 'customer':
            if ($zone == 'CustomerZone') {
                $account_name = modApiFunc('Customer_Account', 'getCurrentSignedCustomer');
                if ($account_name != null) {
                    preg_match('/^customer(.+)/i', $tag, $m1);
                    if (preg_match('/^(billing|shipping|orders)(.+)/i', $m1[1], $m2)) {
                        $group = $m2[1];
                        $attr = $m2[2];
                    } else {
                        if (in_array(strtolower($attr), array('id', 'status'))) {
                            $group = 'base';
                        } else {
                            $group = 'Customer';
                        }
                        $attr = $m1[1];
                    }
                    $obj =& $application->getInstance('CCustomerInfo', $account_name);
                    if (strtolower($attr) == 'accountname') {
                        $output = prepareHTMLDisplay($obj->getDisplayAccountName());
                        break;
                    }
                    if (strtolower($attr) == 'signouturl') {
                        $r = new Request();
                        $r->setView(CURRENT_REQUEST_URL);
                        $r->setAction('customer_sign_out');
                        $r->setKeyValList(modApiFunc('Request', 'getGETArray'));
                        $output = $r->getURL();
                        break;
                    }
                    if (strtolower($group) != 'orders') {
                        $attr_value = $obj->getPersonInfo($attr, $group);
                        switch (strtolower($attr)) {
                            case 'country':
                                $output = modApiFunc('Location', 'getCountry', $attr_value);
                                break;
                            case 'state':
                                if (modApiFunc('Location', 'getStateCode', $attr_value) != '') {
                                    $output = modApiFunc('Location', 'getState', $attr_value);
                                } else {
                                    $output = prepareHTMLDisplay($attr_value);
                                }
                                break;
                            default:
                                $output = prepareHTMLDisplay($attr_value);
                                break;
                        }
                    } else {
                        $qstat = ORDER_STATUS_ALL;
                        if (isset($arg_list[0]) and is_string($arg_list[0])) {
                            if (defined('ORDER_STATUS_' . strtoupper($arg_list[0]))) {
                                $qstat = constant('ORDER_STATUS_' . strtoupper($arg_list[0]));
                            }
                        }
                        $filter = array('type' => 'quick', 'order_status' => $qstat);
                        $obj->setOrdersHistoryFilter($filter);
                        switch (strtolower($attr)) {
                            case 'quantity':
                                $output = $obj->getOrdersCount();
                                break;
                            case 'totalamount':
                                $output = modApiFunc('Localization', 'currency_format', $obj->getOrdersAmount());
                                break;
                            case 'totalfullypaidamount':
                                $output = modApiFunc('Localization', 'currency_format', $obj->getOrdersFullyPaidAmount());
                                break;
                        }
                    }
                }
            }
            break;
        case 'subscription':
            loadClass('Subscriptions');
            switch ($attr) {
                case 'active':
                    if ($zone == 'CustomerZone') {
                        $signed_in = modApiFunc('Customer_Account', 'getCurrentSignedCustomer') !== null;
                        $topics = modApiFunc('Subscriptions', 'getCustomerTopics', $signed_in);
                        $output = sizeof($topics) > 0 ? 'TRUE' : 'FALSE';
                    }
            }
            break;
        case 'unknown':
            switch ($attr) {
                case 'currentlanguage':
                    $output = modApiFunc('MultiLang', 'getLanguage');
                    break;
                case 'resourcelanguage':
                    $output = modApiFunc('MultiLang', 'getResourceLanguage');
                    break;
                case 'defaultlanguage':
                    $output = modApiFunc('MultiLang', 'getDefaultLanguage');
                    break;
            }
            break;
    }
    echo $output;
}
 /**
  * Adds the product to the cart.
  */
 function onAction()
 {
     global $application;
     $request = $application->getInstance('Request');
     if ($request->getValueByKey('returning') == 'yes' && modApiFunc('Session', 'is_Set', 'WishlistData')) {
         // for returning customers reading the data from the session
         $data = modApiFunc('Session', 'get', 'WishlistData');
         modApiFunc('Session', 'un_Set', 'WishlistData');
     } else {
         $prod_id = $request->getValueByKey('prod_id');
         $data = array('parent_entity' => 'product', 'entity_id' => $prod_id, 'options' => $request->getValueByKey('po'), 'qty' => $request->getValueByKey('quantity_in_cart'));
         // setting qty = 1 if not specified
         if (!$data['qty'] && $data['qty'] !== 0) {
             $data['qty'] = 1;
         }
         $options_sent = $request->getValueByKey('options_sent');
         $data['options_sent'] = $options_sent;
         if ($data['options'] == null) {
             $data['options'] = array();
         }
     }
     // if customer is not logged in keeping the data in session and
     // force customer to login...
     if (!modApiFunc('Customer_Account', 'getCurrentSignedCustomer')) {
         modApiFunc('Session', 'set', 'WishlistData', $data);
         $request = new Request();
         $request->setView(CURRENT_REQUEST_URL);
         $request->setAction('AddToWishlist');
         $request->setKey('returning', 'yes');
         modApiFunc('Session', 'set', 'toURLAfterSignIn', $request->getURL());
         $request = new Request();
         $request->setView('CustomerAccountHome');
         $application->redirect($request);
         return;
     }
     $wl_content = modApiFunc('Wishlist', 'getWishlistContent');
     if (is_array($wl_content)) {
         foreach ($wl_content as $wl) {
             if ($wl['ID'] == $data['entity_id'] && $this->compareOptions($data['options'], $wl['Options'])) {
                 modApiFunc('Wishlist', 'updateWishlistRecord', $wl['wl_id'], $wl['Quantity_In_Cart'] + $data['qty']);
                 $request = new Request();
                 $request->setView(CURRENT_REQUEST_URL);
                 $application->redirect($request);
                 return;
             }
         }
     }
     $result = modApiFunc('Cart', 'processPostedProductData', $data, $data['options_sent'], false);
     if (!$result['is_error']) {
         if (!empty($result['stock_discarded_by_warning'])) {
             modApiFunc('Session', 'set', 'StockDiscardedBy', $result['stock_discarded_by_warning']);
         }
         modApiFunc('Wishlist', 'addToWishlist', $result['data']);
         $request = new Request();
         $request->setView(CURRENT_REQUEST_URL);
         $application->redirect($request);
     } else {
         if ($result['discard_by'] != 'none') {
             modApiFunc('Session', 'set', 'OptionsDiscardedBy', $result['discard_by']);
         }
         if ($result['stock_discarded_by'] != 'none') {
             modApiFunc('Session', 'set', 'StockDiscardedBy', $result['stock_discarded_by']);
         }
         modApiFunc('Session', 'set', 'sentCombination', $result['data']['options']);
         $request = new Request();
         $request->setView('ProductInfo');
         $request->setAction('SetCurrentProduct');
         $request->setKey('prod_id', $prod_id);
         $request->setProductID($prod_id);
         $p = new CProductInfo($prod_id);
         $request->setCategoryID($p->chooseCategoryID());
         $application->redirect($request);
     }
 }
 function getProductInfoLink($product_id, $category_id)
 {
     global $zone;
     if ($zone == 'CustomerZone') {
         $request = new Request();
         $product_type_id = $this->getProductTagValue("TypeID");
         if ($product_type_id == GC_PRODUCT_TYPE_ID) {
             $request->setView('GiftCertificate');
             return $request->getURL();
         }
         $request->setView('ProductInfo');
         $request->setAction('SetCurrentProduct');
         $request->setKey('prod_id', $product_id);
         $request->setCategoryID($category_id);
         $request->setProductID($product_id);
         return $request->getURL();
     } else {
         $request = new Request();
         $request->setView('Catalog_EditProduct');
         $request->setAction('SetCurrentProduct');
         $request->setKey('prod_id', $product_id);
         $request->setCategoryID($category_id);
         $request->setProductID($product_id);
         return $request->getURL();
     }
 }
 /**
  * Adds the product to the cart.
  */
 function onAction()
 {
     global $application;
     $request = $application->getInstance('Request');
     $msgres = $application->getInstance("MessageResources", "messages");
     // checking if wishlist product is being added
     $wl_id = $request->getValueByKey('wl_id');
     if ($wl_id > 0) {
         $data = modApiFunc('Wishlist', 'getWishlistRecordCartData', $wl_id);
         if (!$data) {
             // invalid wishlist record...
             $request = new Request();
             $request->setView('Wishlist');
             $application->redirect($request);
             $this->setStatusError();
             $this->setMessage('Invalid wishlist record');
         }
         $options_sent = $data['options_sent'];
         $prod_id = $data['entity_id'];
     } else {
         $prod_id = $request->getValueByKey('prod_id');
         $data = array('parent_entity' => 'product', 'entity_id' => $prod_id, 'options' => $request->getValueByKey('po'), 'qty' => $request->getValueByKey('quantity_in_cart'), 'colorname' => $request->getValueByKey('colorname'));
         $options_sent = $request->getValueByKey('options_sent');
     }
     // setting qty=1 if quantity_in_stock is not specified
     if (!$data['qty'] && $data['qty'] !== 0) {
         $data['qty'] = 1;
     }
     if ($data['options'] == null) {
         $data['options'] = array();
     }
     $result = modApiFunc('Cart', 'processPostedProductData', $data, $options_sent);
     if (!$result['is_error']) {
         if (!empty($result['stock_discarded_by_warning'])) {
             modApiFunc('Session', 'set', 'StockDiscardedBy', $result['stock_discarded_by_warning']);
         }
         $added = modApiFunc('Cart', 'addToCart', $result['data']);
         $cc = modApiFunc('Cart', 'getCartContent');
         $cartPrice = '';
         $cart_id = $prod_id . "_" . modApiFunc("Product_Options", "getCombinationHash", $result['data']['options']);
         if (!empty($cc)) {
             foreach ($cc as $product) {
                 if ($product["CartID"] == $cart_id) {
                     $cartPrice = modApiFunc("Localization", "format", $product["CartItemSalePrice"], "currency");
                 }
             }
         }
         $this->setStatusSuccess();
         $p = new CProductInfo($prod_id);
         $message = array("<h2>" . $msgres->getMessage('CATALOG_PRODUCT_ADDED') . "</h2>" . "<div class='ajax_message_cart_prod_link'><a href='" . $p->getProductInfoLink($prod_id, $p->chooseCategoryID()) . "'>" . $p->getProductTagValue('name') . "</a></div>" . "<div class='ajax_message_cart_prod_qty'>" . $data['qty'] . "&nbsp;" . $msgres->getMessage('CATALOG_X') . "&nbsp;" . $cartPrice . "</div>");
         // if a wishlist product is being added...
         if ($wl_id > 0 && $added) {
             modApiFunc('Wishlist', 'removeFromWishlist', $wl_id);
             $message[] = 'This product was removed from your Wishlist';
         }
         $this->setMessage($message);
         $request = new Request();
         $request->setView(CURRENT_REQUEST_URL);
         $application->redirect($request);
     } else {
         $this->setStatusError();
         $message = array();
         if ($result['discard_by'] != 'none') {
             modApiFunc('Session', 'set', 'OptionsDiscardedBy', $result['discard_by']);
             $message[] = $msgres->getMessage($result['discard_by']);
         }
         if ($result['stock_discarded_by'] != 'none') {
             modApiFunc('Session', 'set', 'StockDiscardedBy', $result['stock_discarded_by']);
             $message[] = $msgres->getMessage($result['stock_discarded_by']);
         }
         modApiFunc('Session', 'set', 'sentCombination', $result['data']['options']);
         $this->setMessage($message);
         $request = new Request();
         $request->setView('ProductInfo');
         $request->setAction('SetCurrentProduct');
         $request->setKey('prod_id', $prod_id);
         $request->setProductID($prod_id);
         $p = new CProductInfo($prod_id);
         $request->setCategoryID($p->chooseCategoryID());
         $application->redirect($request);
     }
 }
 /**
  * Generates the link for menu item
  */
 function getMenuItemLink($item)
 {
     global $application;
     $result = '';
     switch ($item['item_type']) {
         case CMS_MENU_ITEM_TYPE_TEXT:
             $result = '';
             break;
         case CMS_MENU_ITEM_TYPE_URL:
         case CMS_MENU_ITEM_TYPE_EXTERNAL_URL:
             $result = $item['item_link'];
             break;
         case CMS_MENU_ITEM_TYPE_STATIC_PAGE:
             loadClass('CCMSPageInfo');
             $CMSPage = new CCMSPageInfo($item['item_link']);
             $result = $CMSPage->getCMSPageTagValue('link', array());
             break;
         case CMS_MENU_ITEM_TYPE_SYSTEM_PAGE:
             $r = new Request();
             $r->setView($application->getViewBySection($item['item_link']));
             if (_ml_strtolower($item['item_link']) == 'productlist') {
                 $r->setCategoryID($item['param1']);
                 $r->setAction('SetCurrCat');
                 $r->setKey('category_id', $item['param1']);
             }
             if (_ml_strtolower($item['item_link']) == 'productinfo') {
                 loadClass('CProductInfo');
                 $pr = new CProductInfo($item['param2']);
                 $item['param1'] = $pr->chooseCategoryID();
                 $r->setCategoryID($item['param1']);
                 $r->setProductID($item['param2']);
                 $r->setAction('SetCurrentProduct');
                 $r->setKey('prod_id', $item['param2']);
                 $r->setKey('category_id', $item['param1']);
             }
             $result = $r->getURL();
             break;
     }
     return $result;
 }
 function getLocalLink($prod_id)
 {
     if ($this->_view == CURRENT_REQUEST_URL) {
         return '#add_review_' . $prod_id;
     }
     $cid = modApiFunc('CProductListFilter', 'getCurrentCategoryId');
     $r = new Request();
     $r->setView($this->_view);
     $r->setAction('SetCurrentProduct');
     $r->setKey('prod_id', $prod_id);
     $r->setProductID($prod_id);
     $r->setCategoryID($cid);
     $r->setAnchor('add_review_' . $prod_id);
     return $r->getURL();
 }