Example #1
0
function fn_format_products_items($products, $params = array(), $lang_code = CART_LANGUAGE)
{
    $items_data = array();
    $default_params = array('max_item' => Registry::get('addons.rss_feed.category_max_products_items'), 'rss_sort_by' => 'U', 'rss_display_image' => 'Y', 'rss_display_price' => 'Y', 'rss_display_original_price' => 'Y', 'rss_display_add_to_cart' => 'Y');
    $params = array_merge($default_params, $params);
    foreach ($products as $key => $product_data) {
        //format enclosure field for fn_array_to_xml function (enclosure@url=http://url.com@length=50000@type=image/jpeg)
        $enclosure = array('enclosure', 'url=' . fn_format_image_url($product_data), 'length=50000', 'type=image/jpeg');
        $enclosure = implode('@', $enclosure);
        $items_data[$key] = array('title' => $product_data['product'], 'link' => fn_url('products.view?product_id=' . $product_data['product_id'], 'C', 'current', $lang_code, true), 'pubDate' => fn_format_rss_time($params['rss_sort_by'] == 'U' ? $product_data['updated_timestamp'] : $product_data['timestamp']), 'description' => fn_generate_product_description($product_data, $params, $lang_code), $enclosure => '');
    }
    return $items_data;
}
Example #2
0
function fn_news_and_emails_generate_rss_feed(&$items_data, &$additional_data, &$block_data, &$lang_code)
{
    if (!empty($block_data['content']['filling']) && $block_data['content']['filling'] == 'news') {
        $params = array('sort_by' => 'timestamp', 'period' => 'A', 'limit' => !empty($block_data['properties']['max_item']) ? $block_data['properties']['max_item'] : 3);
        list($news, ) = fn_get_news($params, 0, $lang_code);
        $additional_data['title'] = !empty($block_data['properties']['feed_title']) ? $block_data['properties']['feed_title'] : __('news') . '::' . __('page_title', '', $lang_code);
        $additional_data['description'] = !empty($block_data['properties']['feed_description']) ? $block_data['properties']['feed_description'] : $additional_data['title'];
        $additional_data['link'] = fn_url('news.list', 'C', 'http', $lang_code);
        $additional_data['language'] = $lang_code;
        $additional_data['lastBuildDate'] = $news[0]['date'];
        //we can use first element because news sorting by data
        foreach ($news as $key => $data) {
            $items_data[$key] = array('title' => $data['news'], 'link' => fn_url('news.view?news_id=' . $data['news_id'], 'C', 'http', $lang_code, true), 'pubDate' => fn_format_rss_time($data['date']), 'description' => $data['description']);
        }
    }
}