<?php

require_once '../class/url.class.php';
require_once '../class/record.class.php';
require_once '../thinkedit.init.php';
$url = new url();
$url->setParam('id', 7);
$url->setParam('action', 'move');
$url->setParam('locale', 'en');
$url->unSetParam('id');
echo '<pre>';
echo $url->render();
// try it with ./url.test.php?test_class=record&test_type=article&test_id=5
// and with url.test.php?test_class=record&test_type=article
echo $url->getParam('test');
$record = new record('article');
$record->set('id', 5);
$url->addObject($record, 'my_');
echo '<hr>';
echo $url->render();
$object = $url->getObject('test_');
$object->load();
echo '<hr>';
print_r($object);
 /**
  * Given a type and an id, instantiate a record
  * If no id given, instantiate a new empty record of type, using the right class for this record type
  * For instance if it is a multilingual table, it will return a multilingual record object (@todo)
  *
  **/
 function newRecord($table, $id = false, $data = false)
 {
     // will include the right module class if needed, for example, specialized modules like ftp datasource
     // currently the base module is used
     if ($table != '') {
         // optimization : file is required on top of this class file
         // optimization removed, because no real speed impact found
         // find if the record has a locale field
         $multilingual = false;
         if (isset($this->config['table'][$table]['field'])) {
             foreach ($this->config['table'][$table]['field'] as $field) {
                 if ($field['type'] == 'locale') {
                     $multilingual = true;
                 }
             }
         }
         if ($multilingual) {
             require_once 'record.multilingual.class.php';
             $record = new record_multilingual($table);
         } else {
             require_once 'record.class.php';
             $record = new record($table);
         }
         if ($id) {
             $record->set('id', $id);
         }
         if ($data) {
             $record->loadByArray($data);
         }
         return $record;
     } else {
         trigger_error('thinkedit::newRecord() $table not defined');
     }
 }
 /**
  * Given a type and an id, instantiate a record
  * If no id given, instantiate a new empty record of type, using the right class for this record type
  * For instance if it is a multilingual table, it will return a multilingual record object (@todo)
  *
  **/
 function newRecord($table, $id = false, $data = false)
 {
     // will include the right module class if needed, for example, specialized modules like ftp datasource
     // currently the base module is used
     if ($table != '') {
         // optimization : file is required on top of this class file
         require_once 'record.class.php';
         $record = new record($table);
         if ($id) {
             $record->set('id', $id);
         }
         if ($data) {
             $record->loadByArray($data);
         }
         return $record;
     } else {
         trigger_error('thinkedit::newRecord() $table not defined');
     }
 }