public function formatHtml() { parent::formatHtml(); if ($this->parent->noAuthorLinks()) { return; } $authors = $this->parent->getAuthors(); $t = new DbPersonInHTML(); $this->html = $t->makeLinks($authors, $this->html); return; foreach ($authors as $author) { $link = $author->getLink(); $name = $author->getShortName(); list($n, $s) = explode(' ', $name); $n = preg_replace('/(..)$/u', '.*?\\b', $n); $s = preg_replace('/(..)$/u', '.*?\\b', $s); $r = "/({$n}\\s+{$s})/u"; if (strpos($this->html, $name) !== false) { $this->html = str_replace($name, $author->getLink(), $this->html); } elseif (preg_match($r, $this->html, $matches)) { $this->html = preg_replace($r, $author->getLink($matches[1]), $this->html); } else { $links[] = $author->getLink(); } } if ($links) { if (sizeof($authors) == 1) { $r = preg_replace('/ \\(.*$/', '', $this->html); $this->html = preg_replace("/^{$r}/u", $authors[0]->getLink($r), $this->html); } else { $this->html .= '<br/>Страницы авторов: ' . implode(',<br/>', $links); } } }
public function getHtml() { $html = parent::getHtml(); $rating = $this->parent->getRating(); $complexity = $this->parent->getComplexity(); if ($rating || $complexity) { $title = sprintf("Рейтинг: %.02f; Сложность: %d", $rating, $complexity); $html = "<span title=\"{$title}\">" . $html . "</span>"; } return $html; }
public function getFb2() { $result = "\n<empty-line/>\n<empty-line/>\n" . parent::getFb2(); return $result; }
function create_form($table_name) { //$ft = new DataManager; //$ff = new DataManager; $db = DataConnection::readOnly(); $dbform = new DbForm(); $dbfield = new DbField(); $param = ""; $fnm = ""; $param['form_method'] = "POST"; $form_add = $table_name . '_create_form'; $form_edit = $table_name . '_edit_form'; $form_delete = $table_name . '_delete_form'; //Saving form parameters for the create form $param['form_id'] = $form_add; $param['form_name'] = $form_add; $param['form_title'] = 'Add New ' . ucwords(str_replace("_", " ", strtolower($table_name))); $param['form_action'] = "javascript:process_information('" . $table_name . "_create_form', '" . $table_name . "_create_form_submit', '" . $table_name . "', null, null, null, null, 'create_row');"; //$ft->dmInsert("" . FORM_TABLE, $param); $create = $dbform->create($param); $form_add_id = $create['id']; //Saving form parameters for edit form $param['form_id'] = $form_edit; $param['form_name'] = $form_edit; $param['form_title'] = 'Edit ' . ucwords(str_replace("_", " ", strtolower($table_name))); $param['form_action'] = "javascript:process_information('" . $table_name . "_edit_form', '" . $table_name . "_edit_form_submit', '" . $table_name . "', null, null, null, null, 'edit_row');"; //$ft->dmInsert("" . FORM_TABLE, $param); $edit = $dbform->create($param); $form_edit_id = $edit['id']; //Saving form parameters for delete form $param['form_id'] = $form_delete; $param['form_name'] = $form_delete; $param['form_title'] = 'Delete ' . ucwords(str_replace("_", " ", strtolower($table_name))); $param['form_action'] = "javascript:process_information('" . $table_name . "_delete_form', '" . $table_name . "_delete_form_submit', '" . $table_name . "', null, null, null, null, 'delete_row');"; //$ft->dmInsert("" . FORM_TABLE, $param); $delete = $dbform->create($param); $form_delete_id = $delete['id']; //$dblink = mysql_connect(NATURAL_DBHOST, NATURAL_DBUSER, NATURAL_DBPASS); /*if (!$dblink) { //die('Could not connect: ' . mysql_error()); natural_set_message('Failed to connect with the database '.NATURAL_DBNAME.'!', 'error'); }*/ $today = date("m-d-Y H:i:s"); $now = date("M-D-Y"); $query = 'SHOW COLUMNS FROM ' . NATURAL_DBNAME . '.' . $table_name; $query_result = mysql_query($query, $dblink); $pdo = new PDO(NATURAL_PDO_DSN_READ, NATURAL_PDO_USER_READ, NATURAL_PDO_PASS_READ); $q = $pdo->prepare('SHOW COLUMNS FROM ' . NATURAL_DBNAME . '.' . $table_name); $q->execute(); $columns = $q->fetchAll(PDO::FETCH_COLUMN); $i = 0; if (count($columns) > 0) { foreach ($columns as $key => $val) { $label = ""; $nam_ar = explode("_", $val); if (is_array($nam_ar)) { for ($x = 0; $x < count($nam_ar); $x++) { if ($nam_ar[$x] != "id") { $label .= ucfirst($nam_ar[$x]) . " "; } } $label = substr($label, 0, -1); } else { $label = ucfirst($val); } $field['form_reference'] = $form_add; $field['form_template_id'] = $form_add_id; $field['field_id'] = $val; $field['field_name'] = $val; $field['form_field_order'] = $i; if ($val == "id") { $field['html_type'] = "hidden"; } else { $field['html_type'] = "text"; } $field['def_val'] = ""; $field['def_label'] = $label; //Insert template new //$ff->dmInsert("" . FIELD_TABLE, $field); $dbfield->create($field); //$form_add_id = $create['id']; //Insert template edit $field['form_reference'] = $form_edit; $field['form_template_id'] = $form_edit_id; $field['def_val'] = "{$val}"; $dbfield->create($field); if ($val == 'id') { //Insert delete id $field['form_reference'] = $form_delete; $field['form_template_id'] = $form_delete_id; $field['def_val'] = "{$val}"; $field['html_type'] = "hidden"; $field['def_label'] = 'ID'; $dbfield->create($field); } if ($i == 1) { //Insert delete message $field['form_reference'] = $form_delete; $field['form_template_id'] = $form_delete_id; $field['field_id'] = 'message'; $field['field_name'] = 'message'; $field['form_field_order'] = $i; $field['def_label'] = ''; $field['def_val'] = 'Are you sure you want to delete this ' . $table_name . '?'; $field['html_type'] = 'message'; $dbfield->create($field); //Insert delete object $field['form_reference'] = $form_delete; $field['form_template_id'] = $form_delete_id; $field['field_id'] = "{$val}"; $field['field_name'] = "{$val}"; $field['form_field_order'] = $i + 1; $field['def_label'] = ''; $field['def_val'] = "{$val}"; $field['html_type'] = 'message'; $dbfield->create($field); } $i++; } $field['form_reference'] = $form_add; $field['form_template_id'] = $form_add_id; $field['field_id'] = "sub"; $field['field_name'] = "sub"; $field['form_field_order'] = $i; $field['def_label'] = ''; $field['def_val'] = ''; $field['html_type'] = 'submit'; $dbfield->create($field); $field['form_reference'] = $form_edit; $field['form_template_id'] = $form_edit_id; $dbfield->create($field); $field['form_reference'] = $form_delete; $field['form_template_id'] = $form_delete_id; $dbfield->create($field); } natural_set_message('Done creating the form for the table ' . $table_name . '!', 'success'); }
function __construct($options = []) { parent::__construct($options); if (array_key_exists('init_with_current_timestamp', $options)) { $this->init_with_current_timestamp = (bool) $options['init_with_current_timestamp']; } $this->type_definition = 'TIMESTAMP'; if ($this->init_with_current_timestamp) { $this->type_definition .= ' DEFAULT CURRENT_TIMESTAMP'; } }
<?php /** * @file: uploader_add_file.php * Server Side Ajax Uplader */ session_start(); require_once '../../bootstrap.php'; $field_id = $_GET['field_id']; // Based on the element id $_GET['field_id'] we can perform validations. $field = new DbField(); $field->byID($field_id); if (!$field->affected > 0) { // DataManager should output the error. return FALSE; } // Field values attributes. if (!empty($field->field_values)) { $field_values = explode('|', $field->field_values); foreach ($field_values as $value) { $option = explode('=', $value); switch ($option[0]) { case 'limit': $field_limit = $option[1]; break; case 'type': $field_type = explode(',', $option[1]); break; case 'size': $field_size = substr($option[1], 0, -1); $field_size_unit = substr($option[1], -1);