Ejemplo n.º 1
0
    }
} elseif ($config['mode'] == 'p') {
    error_reporting(0);
}
// Database connection is optional
$sql = false;
if (isset($config['db_host']) and $config['db_host']) {
    $sql = new Sql($config['db_host'], $config['db_user'], $config['db_password'], $config['db_database']);
    // Connect to DB
    Sql::$mode = $config['mode'];
}
if (!isset($config['use_mvc']) or $config['use_mvc'] === false) {
    $template = new MVC();
}
//Otherways it is a mess with google
ini_set('url_rewriter.tags', "");
ini_set('session.use_trans_sid', false);
if (isset($_SERVER["HTTP_HOST"])) {
    session_start();
}
//Don't start the session for a console app.
$config['date_format'] = '%d %b %Y';
$config['time_format'] = '%d %b %Y, %h:%i %p';
$config['date_format_php'] = phpDateFormat($config['date_format']);
$config['time_format_php'] = phpDateFormat($config['time_format']);
$abs = $config['site_absolute_path'];
$config['code_path'] = preg_replace("/includes/", '', dirname(__FILE__));
//Auto-include the application.php file
if (isset($config['site_relative_path']) and file_exists($config['site_relative_path'] . 'includes/application.php')) {
    include $config['site_relative_path'] . 'includes/application.php';
}
Ejemplo n.º 2
0
 // Enum - Select tag
 if ($field_type == 'select') {
     $html->buildInput($field, $name, 'select', $value, array('options' => $data));
     // Date Field.
 } elseif ($field_type == 'datetime' or $field_type == 'date') {
     if ($field_type == 'datetime') {
         $js_date_format = $GLOBALS['config']['time_format'];
     } else {
         $js_date_format = $GLOBALS['config']['date_format'];
     }
     if ($value and $value != '0000-00-00 00:00:00' and $value != '0000-00-00') {
         $value = date(phpDateFormat($js_date_format), strtotime($value));
     } elseif ($this->action == 'add' and $field == 'added_on') {
         $value = date(phpDateFormat($js_date_format));
     } elseif ($this->action == 'edit' and $field == 'edited_on') {
         $value = date(phpDateFormat($js_date_format));
     } else {
         $value = '';
     }
     $js_date_format = jsDateFormat($js_date_format);
     $html->buildInput($field, $name, 'text', $value, array('class' => 'text-long'), "<input class='button' type='button' value=' ... ' id='date_button_{$field}' />");
     $print_time = 1;
     // I use this method to make sure this is called only after the calendar.js files are loaded.
     $js_code .= <<<JS_END
tCalendar.setup({
t\tinputField\t: "{$field}",\t\t\t\t// id of the input field
t\tifFormat\t: "{$js_date_format}",\t// format of the input field
t\tprintsTime\t: {$print_time},\t\t\t// will display a time selector
t\tbutton\t\t: "date_button_{$field}",\t// trigger for the calendar (button ID)
t\tsingleClick\t: true,\t// double-click mode
t\ttimeFormat\t: 12,\t// The time format - 12 hr clock or the 24 Hr clock.
Ejemplo n.º 3
0
 function makeListingDisplayData()
 {
     if (!$this->current_page_data) {
         return;
     }
     global $config;
     $total_rows = count($this->current_page_data);
     for ($i = 0; $i < $total_rows; $i++) {
         $row = $this->current_page_data[$i];
         foreach ($this->listing_fields as $field_name) {
             $f = $this->fields[$field_name];
             $value = '';
             if ($f['type'] != 'virtual' and isset($row[$field_name])) {
                 $value = $row[$field_name];
             }
             $new_value = '';
             switch ($f['type']) {
                 // Enum - or the listing.
                 case 'enum':
                     if ($f['data'] and isset($f['data'][$value])) {
                         $new_value = $f['data'][$value];
                     } else {
                         $new_value = $value;
                     }
                     break;
                 case 'datetime':
                     if ($value != '0000-00-00 00:00:00') {
                         $new_value = date(phpDateFormat($config['time_format']), strtotime($value));
                     }
                     break;
                 case 'date':
                     if ($value != '0000-00-00 00:00:00') {
                         $new_value = date(phpDateFormat($config['date_format']), strtotime($value));
                     }
                     break;
                 case 'virtual':
                     //Not actually a DB column.
                     if ($f['data']) {
                         $new_value = eval("return " . $f['data']['html'] . ';');
                     }
                     break;
                 case 'varchar':
                 default:
                     $new_value = $value;
             }
             switch ($f['field_type']) {
                 case 'select':
                     if ($f['data'] and isset($f['data'][$value])) {
                         $new_value = $f['data'][$value];
                     } else {
                         $new_value = $value;
                     }
                     break;
             }
             switch ($f['value_type']) {
                 case 'url':
                     $url = $value;
                     if (!empty($f['data']['url'])) {
                         $url = eval('return ' . $f['data']['url'] . ';');
                     }
                     if (!empty($f['data']['text'])) {
                         $value = eval('return ' . $f['data']['text'] . ';');
                     }
                     $new_value = "<a href='" . $url . "'>{$value}</a>";
                     break;
                 case 'function':
                     $new_value = $value;
                     if (!empty($f['data']['function'])) {
                         $new_value = call_user_func($f['data']['function'], $value);
                     }
             }
             $this->current_page_data[$i][$field_name] = $new_value;
         }
     }
 }