<?php
/******************************************************************************/
//                                                                            //
//                             Smarty plugin                                  //
//                            @package Smarty                                 //
//							 @subpackage plugins                              //
//                        http://life-style.uz/                               //
//                   produced by Life Style, life-style.uz                    //
//                                                                            //
/******************************************************************************/

function smarty_function_fetch_blocks($params, &$smarty){

	$assign        = fetch_getParam('assign', $params, 'blocks');
	$fields        = fetch_getParam('fields', $params, 'blockId, sectionId, title, alias, content, status, position');
	$status        = fetch_getParam('status', $params, 'V');
    $sectionId     = (int) fetch_getParam('section', $params);
    $sectionInfo  = fetch_getParam('sectionInfo', $params, false);

	/* conditions */
	if($sectionId > 0) {
        connect()->where('sectionId', $sectionId);
    }

	$blocks = connect('blocks')->select($fields)->where('status', $status)->orderBy('orderBy ASC')->getAll('array');
    $blocks = prepareBlocks($blocks, $sectionInfo);
//	print_r($blocks);
	$smarty->assign($assign, $blocks);

	return null;
}
?>