<?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)
 *
 */

  /*===================================================
    ShowFormEditLink()
  ===================================================*/

  function ShowFormEditLink() {

    // vars global configuration
    global $category_separator, $admin_template_path;

    // vars url & form
    global $id;

    // vars messages
    global $msg;

    // vars template

    // generate custom field

    $links_obj                                    = new clsLink;
    $links_obj->table_name                        = "idx_link";
    $links_obj->category_table_name               = "idx_category";
    $links_obj->autogenerate_form_text            = $msg["30001"];
    $links_obj->autogenerate_form_textarea        = $msg["30002"];
    $links_obj->autogenerate_form_image           = $msg["30004"];
    $links_obj->autogenerate_form_file            = $msg["30006"];
    $links_obj->autogenerate_form_select          = $msg["30007"];
    $links_obj->autogenerate_form_multiselect     = $msg["30008"];
    $links_obj->autogenerate_form_checkbox        = $msg["30009"];
    $links_obj->autogenerate_form_radio           = $msg["30010"];
    $links_obj->autogenerate_form_date            = $msg["30011"];
    $links_obj->autogenerate_form_datetime        = $msg["30012"];
    $links_obj->autogenerate_form_template        = $admin_template_path . "link_custom_field_form.html";
    $links_obj->header                            = $msg["20061"];
    $links_obj->template_file                     = $admin_template_path . "link_edit_form.html";
    $links_obj->Modify("display_form",$id,true);

  }


  /*===================================================
    ProcessFormEditLink()
  ===================================================*/

  function ProcessFormEditLink() {

    // vars global configuration
    global $category_separator, $admin_template_path;

    // vars url & form
    global $id, $title, $url, $description, $cat, $contact_name, $email, $bid,
      $password, $add_cat1, $add_cat2, $keywords, $reciprocal_url;

    // vars messages
    global $msg;

    // vars template
    global $message;

    // verify input
  //print $add_cat1.$add_cat2;
    if(empty($title)) $error_msg = $msg["20071"];
    elseif(empty($url)) $error_msg = $msg["20072"];
    elseif(empty($cat)) $error_msg = $msg["20073"];
    elseif (!empty($email) && !IsEmailAddress($email)) $error_msg = $msg["20074"];
    elseif (!empty($bid) && !IsMoney($bid)) $error_msg = $msg["20075"];

    if(empty($error_msg)) {

      $links_obj = new clsLink;
        $links_obj->table_name = "idx_link";
      $links_obj->category_table_name = "idx_category";
      $links_obj->editor_table_name = "idx_editor";
      $links_obj->user_table_name = "idx_users";

      $modify_result = $links_obj->Modify("process_form",$id,true);

      // update updated flag
      $links_obj->UpdateUpdatedFlag();

      $message = $msg["20101"].$msg["30015"];
    }
    else $message = $error_msg;

    DisplayTemplate($admin_template_path . "message.html", "\$message");

  }


  /*===================================================
    main
  ===================================================*/

  include "../application.php";
  
  RunPreFilter(__FILE__);

  DisplayTemplate($admin_template_path . "header.html");
  if (empty($pflag)) {
    ShowFormEditLink();
  }
  elseif ($pflag == 'edit') {
    ProcessFormEditLink();
  }
  DisplayTemplate($admin_template_path . "footer.html");

  RunPostFilter(__FILE__);

?>