コード例 #1
0
/**
 * The function returns the selected block data used in the admin area
 *
 * @param int $block_id
 * @param string $lang_code
 * @param bool $descr if true, the function only returns the description of the block
 * @return array
 */
function fn_get_block_data($block_id, $lang_code = CART_LANGUAGE, $descr = false, $location = '')
{
    $block = db_get_row("SELECT ?:blocks.*, ?:block_descriptions.description FROM ?:blocks LEFT JOIN ?:block_descriptions ON ?:block_descriptions.block_id = ?:blocks.block_id AND ?:block_descriptions.object_type = 'B' AND ?:block_descriptions.lang_code = ?s WHERE ?:blocks.block_id = ?i", $lang_code, $block_id);
    if (empty($block)) {
        return false;
    }
    if ($descr == true) {
        return $block;
    }
    if (!empty($block['item_ids'])) {
        $block['items'] = explode(',', $block['item_ids']);
    }
    if (empty($location)) {
        $location = $block['location'];
    }
    $block['properties'] = fn_unserialize_block_properties($block['properties'], $location, $block['block_type'], $block['text_id']);
    $block_desc = db_get_array("SELECT object_text_id, description FROM ?:block_descriptions WHERE block_id = ?i AND object_id = '0' AND object_type = 'P' AND lang_code = ?s", $block_id, $lang_code);
    if (!empty($block_desc)) {
        foreach ($block_desc as $val) {
            $block['properties'][$val['object_text_id']] = $val['description'];
        }
    }
    return $block;
}
コード例 #2
0
ファイル: fn.cms.php プロジェクト: diedsmiling/busenika
/**
 * Function delete object from the block (product, category, page etc)
 *
 * @param string $object the type of object
 * @param int $object_id
 *
 * @return true
 */
function fn_clean_block_items($object, $object_id)
{
    $blocks = db_get_array("SELECT block_id, text_id, block_type, location, properties FROM ?:blocks WHERE block_type = 'B'");
    $block_ids = array();
    foreach ($blocks as $block) {
        $block_prop = fn_unserialize_block_properties($block['properties'], $block['location'], $block['block_type'], $block['text_id']);
        if (!empty($block_prop['list_object']) && $block_prop['list_object'] == $object) {
            $block_ids[] = $block['block_id'];
        }
    }
    if (!empty($block_ids)) {
        $rm = fn_remove_from_set('?:block_links.item_ids', $object_id);
        db_query("UPDATE ?:block_links SET item_ids = ?p WHERE block_id IN (?n)", $rm, $block_ids);
    }
    return true;
}