/**
 * Generates the link for menu item
 */
function getMenuItemLink($item)
{
    global $application;
    $result = '';
    switch ($item['item_type']) {
        case CMS_MENU_ITEM_TYPE_TEXT:
            $result = 'CMS_MENU_ITEM_TYPE_TEXT';
            return $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;
        case CMS_MENU_ITEM_TYPE_CATEGORY_LIST:
            $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']);
            }
            $result = $r->getURL();
            break;
    }
    return $result;
}
Esempio n. 2
0
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;
}