Beispiel #1
0
function smarty_function_pico_list($params, &$smarty)
{
    $mydirname = @$params['dir'] . @$params['dirname'];
    $cat_ids = @$params['id'] . @$params['cat_id'];
    $order = empty($params['order']) ? 'o.created_time DESC' : $params['order'];
    $limit_params = @$params['limit'];
    $template = @$params['template'];
    $var_name = @$params['item'] . @$params['assign'];
    if (empty($mydirname)) {
        $mydirname = $smarty->get_template_vars('mydirname');
    }
    if (empty($mydirname)) {
        echo 'error ' . __FUNCTION__ . ' [specify dirname]';
        return;
    }
    require_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/blocks/blocks.php';
    if ($var_name) {
        // just assign
        $assigns = b_pico_list_show(array($mydirname, $cat_ids, $order, $limit_params, $template, 'disable_renderer' => true));
        $smarty->assign($var_name, $assigns);
    } else {
        // display
        $block = b_pico_list_show(array($mydirname, $cat_ids, $order, $limit_params, $template));
        echo @$block['content'];
    }
}
Beispiel #2
0
function smarty_function_pico_ef_list($params, &$smarty)
{
    $mydirname = @$params['dir'] . @$params['dirname'];
    $cat_ids = @$params['id'] . @$params['cat_id'];
    $sortby = empty($params['sortby']) ? '' : $params['sortby'];
    $order = empty($params['order']) ? '' : $params['order'];
    $limit_params = @$params['limit'];
    $template = @$params['template'];
    $var_name = @$params['item'] . @$params['assign'];
    //errors
    if (empty($mydirname)) {
        $mydirname = $smarty->get_template_vars('mydirname');
    }
    if (empty($mydirname)) {
        echo 'error ' . __FUNCTION__ . ' [specify dirname]';
        return;
    }
    $error_vals = array('created_time_formatted', 'modified_time_formatted', 'expiring_time_formatted');
    if (in_array($sortby, $error_vals)) {
        echo 'error ' . __FUNCTION__ . ' [please use unixtime format]';
        return;
    }
    //fetch and unserialize
    require_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/blocks/blocks.php';
    $contents = b_pico_list_show(array($mydirname, $cat_ids, '', $limit_params, $template, 'disable_renderer' => true));
    $default_vals = array('link', 'poster_uname', 'modifier_uname', 'votes_avg', 'subject', 'body', 'tags_array', 'cat_title', 'can_vote', 'id', 'created_time_formatted', 'modified_time_formatted', 'expiring_time_formatted', 'subject_raw', 'body_raw', 'isadminormod', 'public', 'can_read', 'can_readfull', 'can_edit', 'can_delete', 'content_id', 'permission_id', 'vpath', 'cat_id', 'weight', 'created_time', 'modified_time', 'expiring_time', 'last_cached_time', 'poster_uid', 'poster_ip', 'modifier_uid', 'modifier_ip', 'subject_waiting', 'locked', 'visible', 'approval', 'use_cache', 'allow_comment', 'show_in_navi', 'show_in_menu', 'viewed', 'votes_sum', 'votes_count', 'comments_count', 'htmlheader', 'htmlheader_waiting', 'body_waiting', 'body_cached', 'filters', 'tags', 'extra_fields', 'redundants', 'for_search');
    foreach ($contents['contents'] as $k => $v) {
        $unserialized_ef = pico_common_unserialize($v['extra_fields']);
        $contents['contents'][$k]['extra_fields_items'] = $unserialized_ef;
        if (in_array($sortby, $default_vals)) {
            $contents['contents'][$k]['extra_fields_sortby'] = $v[$sortby];
        } elseif (strpos($sortby, 'dateof_') === 0) {
            $udate = pico_common_get_server_timestamp(strtotime($unserialized_ef[$sortby]));
            $contents['contents'][$k]['extra_fields_sortby'] = $udate;
        } else {
            $contents['contents'][$k]['extra_fields_sortby'] = $unserialized_ef[$sortby];
        }
        $contents['contents'][$k]['extra_fields_count'] = count($unserialized_ef);
    }
    //	$contents['contents']['count'] = count( $contents['contents'] ) ;
    //sort
    foreach ($contents['contents'] as $key => $row) {
        $extra_fields_sortby[$key] = $row['extra_fields_sortby'];
    }
    if ($order == 'SORT_DESC' || $order == 'DESC') {
        array_multisort($extra_fields_sortby, SORT_DESC, $contents['contents']);
    } else {
        array_multisort($extra_fields_sortby, SORT_ASC, $contents['contents']);
    }
    // assign or display
    if ($var_name) {
        $smarty->assign($var_name, $contents['contents']);
        $smarty->assign($var_name . '_count', count($contents['contents']));
    } else {
        echo '<pre>';
        var_dump(@$contents['contents']);
        echo '</pre>';
    }
}