Exemple #1
0
/**
 * Gets page data
 *
 * @param mixed $page_id Page identifier
 * @param string $lang_code 2 letters language code
 * @param bool $preview Page data for preview (ignore cahce)
 * @return array|bool Page data on success, false otherwise
 */
function fn_get_page_data($page_id, $lang_code = CART_LANGUAGE, $preview = false, $area = AREA)
{
    static $cache = array();
    if (empty($page_id)) {
        return false;
    }
    fn_set_hook('get_page_data_pre', $page_id, $lang_code, $preview, $area);
    if (empty($cache[$page_id])) {
        $condition = fn_get_company_condition('?:pages.company_id');
        if ($area != 'A' && !$preview) {
            $condition .= " AND (" . fn_find_array_in_set($_SESSION['auth']['usergroup_ids'], '?:pages.usergroup_ids', true) . ")";
        }
        $field_list = "?:pages.*, ?:page_descriptions.*";
        $join = " INNER JOIN ?:page_descriptions ON ?:pages.page_id = ?:page_descriptions.page_id";
        $condition .= db_quote(" AND ?:pages.page_type IN (?a)", array_keys(fn_get_page_object_by_type()));
        fn_set_hook('pre_get_page_data', $field_list, $join, $condition, $lang_code);
        $page_data = db_get_row("SELECT {$field_list} FROM ?:pages ?p WHERE ?:pages.page_id = ?i AND ?:page_descriptions.lang_code = ?s ?p", $join, $page_id, $lang_code, $condition);
        if (empty($page_data) || $area != 'A' && ($page_data['status'] == 'D' || $page_data['use_avail_period'] == 'Y' && ($page_data['avail_from_timestamp'] > TIME || $page_data['avail_till_timestamp'] < TIME)) && empty($preview)) {
            return false;
        }
        fn_set_hook('get_page_data', $page_data, $lang_code, $preview, $area);
        // Generate meta description automatically
        if (empty($page_data['meta_description']) && defined('AUTO_META_DESCRIPTION') && $area != 'A') {
            $page_data['meta_description'] = fn_generate_meta_description($page_data['description']);
        }
        $cache[$page_id] = $page_data;
    }
    return !empty($cache[$page_id]) ? $cache[$page_id] : false;
}
Exemple #2
0
function fn_get_page_data($page_id, $lang_code = CART_LANGUAGE, $preview = false)
{
    static $cache = array();
    if (empty($page_id)) {
        return false;
    }
    if (empty($cache[$page_id])) {
        $condition = '';
        $condition .= fn_get_company_condition('?:pages.company_id');
        if (AREA != 'A') {
            $condition .= " AND (" . fn_find_array_in_set($_SESSION['auth']['usergroup_ids'], '?:pages.usergroup_ids', true) . ")";
        }
        $cache[$page_id] = db_get_row("SELECT * FROM ?:pages INNER JOIN ?:page_descriptions ON ?:pages.page_id = ?:page_descriptions.page_id WHERE ?:pages.page_id = ?i AND ?:page_descriptions.lang_code = ?s ?p", $page_id, $lang_code, $condition);
        if (empty($cache[$page_id]) || AREA != 'A' && ($cache[$page_id]['status'] == 'D' || $cache[$page_id]['use_avail_period'] == 'Y' && ($cache[$page_id]['avail_from_timestamp'] > TIME || $cache[$page_id]['avail_till_timestamp'] < TIME)) && empty($preview)) {
            return false;
        }
        fn_set_hook('get_page_data', $cache[$page_id], $lang_code);
        // Generate meta description automatically
        if (empty($cache[$page_id]['meta_description']) && defined('AUTO_META_DESCRIPTION') && AREA != 'A') {
            $cache[$page_id]['meta_description'] = fn_generate_meta_description($cache[$page_id]['description']);
        }
    }
    return !empty($cache[$page_id]) ? $cache[$page_id] : false;
}
/**
 * Gets product feature variant data
 *
 * @param int $variant_id Variant identifier
 * @param string $lang_code 2-letters language code
 * @return array Variant data
 */
function fn_get_product_feature_variant($variant_id, $lang_code = CART_LANGUAGE)
{
    $fields = "*";
    $join = db_quote("LEFT JOIN ?:product_feature_variant_descriptions ON ?:product_feature_variant_descriptions.variant_id = ?:product_feature_variants.variant_id AND ?:product_feature_variant_descriptions.lang_code = ?s", $lang_code);
    $condition = db_quote("?:product_feature_variants.variant_id = ?i", $variant_id);
    /**
     * Changes SQL parameters before select product feature variant data
     *
     * @param string $fields     String of comma-separated SQL fields to be selected in an SQL-query
     * @param string $join       String with the complete JOIN information (JOIN type, tables and fields) for an SQL-query
     * @param string $condition  String containing SQL-query condition possibly prepended with a logical operator (AND or OR)
     * @param int    $variant_id Variant identifier
     * @param string $lang_code  2-letters language code
     */
    fn_set_hook('get_product_feature_variant_before_select', $fields, $join, $condition, $variant_id, $lang_code);
    $var = db_get_row("SELECT {$fields} FROM ?:product_feature_variants {$join} WHERE {$condition}");
    if (empty($var)) {
        return false;
    }
    $var['image_pair'] = fn_get_image_pairs($variant_id, 'feature_variant', 'V', true, true, $lang_code);
    if (empty($var['meta_description']) && defined('AUTO_META_DESCRIPTION') && AREA != 'A') {
        $var['meta_description'] = fn_generate_meta_description($var['description']);
    }
    /**
     * Changes product feature variant data
     *
     * @param array  $var        Variant data
     * @param int    $feature_id Feature identifier
     * @param string $lang_code  2-letters language code
     */
    fn_set_hook('get_product_feature_variant_post', $var, $variant_id, $lang_code);
    return $var;
}
Exemple #4
0
function fn_get_product_feature_variant($variant_id, $lang_code = CART_LANGUAGE)
{
    $var = db_get_row("SELECT * FROM ?:product_feature_variants LEFT JOIN ?:product_feature_variant_descriptions ON ?:product_feature_variant_descriptions.variant_id = ?:product_feature_variants.variant_id AND ?:product_feature_variant_descriptions.lang_code = ?s WHERE ?:product_feature_variants.variant_id = ?i ORDER BY ?:product_feature_variants.position, ?:product_feature_variant_descriptions.variant", $lang_code, $variant_id);
    if (empty($var)) {
        return false;
    }
    $var['image_pair'] = fn_get_image_pairs($variant_id, 'feature_variant', 'V', true, true, $lang_code);
    if (empty($var['meta_description']) && defined('AUTO_META_DESCRIPTION') && AREA != 'A') {
        $var['meta_description'] = fn_generate_meta_description($var['description']);
    }
    return $var;
}