<?php

/**
 *
 * INDEXU
 * Copyright(C), Nicecoder, 2000-2006, All Rights Reserved.
 *
 * INDEXU(tm) is protected by Indonesia and International copyright laws.
 * Unauthorized use or distribution of INDEXU(tm) is strictly prohibited,
 * violators will be prosecuted. To obtain a license for using INDEXU(tm),
 * please register at Nicecoder home page at http://www.nicecoder.com
 *
 * Author:
 *    Dody Rachmat Wicaksono (dody@nicecoder.com)
 *    M. Zuber (zubby@nicecoder.com)
 *
 */

function block_sort_links($params) {
  global $dbConn;

  if (!$params['template']) {
    $params['template'] = 'block.sort_links.html';
  }

  $use_pagerank = $params['use_pagerank'];
  $use_custom_field = $params['use_custom_field'];
  $exclude_custom_field = $params['exclude_custom_field'];

  $tpl = new Template;

  $links_obj = new clsLink;
  $links_obj->table_name = "idx_link";

  $fields = $links_obj->GetFields();
  $num_fields = @count($fields);
  $i = $links_obj->custom_field_offset;
  while ($i < $num_fields) {
    if ($links_obj->fields_type[$i] == "IMAGE" || $links_obj->fields_type[$i] == "FILE") {
      $i++;
      continue;
    }
    $field['field_name'] = $links_obj->fields_name[$i];
    $field['field_text'] = $links_obj->fields_text[$i];
    if (!$field['field_text']) {
      $field['field_text'] = ucwords(str_replace('_', ' ', $field['field_name']));
    }
    $custom_fields[] = $field;
    $i++;
  }

  $tpl->assign('sort_by', $_COOKIE['COOKIE_SORT_BY']);
  $tpl->assign('sort_order', $_COOKIE['COOKIE_SORT_ORDER']);
  $tpl->assign('use_pagerank', $use_pagerank);
  $tpl->assign('use_custom_field', $use_custom_field);
  $tpl->assign('exclude_custom_field', $exclude_custom_field);
  $tpl->assign('custom_fields', $custom_fields);
  $tpl->display("blocks/" . $params['template']);
}

?>
