* Gate - Wiki engine and web-interface for WebTester Server * * Implementation of time datatype * * Copyright (c) 2008-2009 Sergey I. Sharybin <*****@*****.**> * * This program can be distributed under the terms of the GNU GPL. * See the file COPYING. */ global $IFACE; if ($IFACE != "SPAWNING NEW IFACE" || $_GET['IFACE'] != '') { print 'HACKERS?'; die; } if ($_CDCTime_ != '#CDCTime_included#') { $_CDCTime_ = '#CDCTime_included#'; class CDCTime extends CDCVirtual { function CDCTime() { $this->SetClassName('CDCTime'); } function DrawEditorForm($name, $formname = '', $init = true) { global $CORE; $CORE->AddStyle('time'); tplp('back/timepicker', array('name' => $formname . '_' . $name, 'value' => $this->GetValue())); } } content_Register_DCClass('CDCTime', 'Время'); }
$_CDCDate_ = '#CDCDate_included#'; class CDCDate extends CDCVirtual { function CDCDate() { $this->SetClassName('CDCDate'); } function DrawEditorForm($name, $formname = '', $init = true) { calendar($formname . '_' . $name, $this->GetValue()); } function GetDBFieldType() { return 'DATE'; } function SettingsForm() { print '<span class="shade">Настройки класса «Дата» отсутствуют</span>'; } function Value() { global $months; $v = $this->GetValue(); $y = preg_replace('/([0-9]+)\\-([0-9]+)\\-([0-9]+)/si', '\\1', $v); $m = preg_replace('/([0-9]+)\\-([0-9]+)\\-([0-9]+)/si', '\\2', $v); $d = preg_replace('/([0-9]+)\\-([0-9]+)\\-([0-9]+)/si', '\\3', $v); return $d . ', ' . $months[$m] . ' ' . $y; } } content_Register_DCClass('CDCDate', 'Дата'); }
$this->SetClassName('CDCCheckBox'); } function DrawEditorForm($name, $formname = '', $init = true) { $value = $this->val; $dummy = $formname . '_' . $name; println('<div><input type="checkbox" name="' . $dummy . '"' . ($value ? ' checked' : '') . ' class="cb"> Активен</div>'); } function ReceiveValue($field, $formname = '') { if ($_POST[$formname . '_' . $field]) { $this->val = true; } else { $this->val = false; } } function BuildQueryValue() { $v = 'TRUE'; if (!$this->val) { $v = 'FALSE'; } return "{$v}"; } function GetDBFieldType() { return 'BOOL'; } } content_Register_DCClass('CDCCheckBox', 'Флажок'); }
return 'if (!isnumber (getElementById ("CDCText_nLines").value)) {alert ("Указанное количество строк не является правильным натуральным числом."); return false;}' . "\n" . 'if (getElementById ("CDCText_nLines").value<1) {alert ("Минимально возможное количество строк - одна."); return false;}'; } function ReceiveSettings() { global $_POST; $this->SetSetting('nlines', $_POST['CDCText_nLines']); return true; } function DrawEditorForm($name, $formname = '', $init = true) { $value = htmlspecialchars(ecranvars($this->val)); $dummy = $formname . '_' . $name; if ($this->settings['nlines'] == 1) { print "<input type=\"text\" class=\"txt block\" id=\"{$dummy}\" name=\"{$dummy}\" value=\"{$value}\">"; } else { $nlines = $this->settings['nlines']; print "<textarea class=\"block\" name=\"{$dummy}\" id=\"{$dummy}\" rows=\"{$nlines}\">{$value}</textarea>"; } } function BuildCheckImportancy($var, $formname = '') { $dummy = $formname . '_' . $var; return "(qtrim (getElementById ('{$dummy}').value)!='')"; } function GetDBFieldType() { return 'LONGTEXT'; } } content_Register_DCClass('CDCText', 'Текстовое поле'); }
function ReceiveValue($field, $formname = '') { $this->SpawnStorage(); $data = $_FILES[$formname . '_' . $field]; $r = $this->Comporator($data['size'], $this->settings['size'], 'Размер', 1, 'байт'); if ($r != '') { add_info($r); return false; } $fn = $this->storage->Put($data, user_id()); $this->storage->Accept($fn); $this->val = $fn; return true; } function DestroyValue() { $this->SpawnStorage(); $this->storage->Unlink($this->GetValue()); } function Value() { $this->SpawnStorage(); return $this->storage->GetFullURL($this->GetValue()); } function BuildCheckImportancy($var, $formname = '') { return '(getElementById ("' . $formname . '_' . $var . '").value != "")'; } } content_Register_DCClass('CDCFile', 'Файл'); }
$dummy = trim($items[$i]); if ($dummy != '') { $arr[] = $dummy; } } $this->settings['items'] = $arr; } function DrawEditorForm($name, $formname = '', $init = true) { $value = $this->val; $items = $this->settings['items']; $dummy = $formname . '_' . $name; println('<select name="' . $dummy . ';?>" class="block">'); for ($i = 0; $i < count($items); $i++) { $it = $items[$i]; println('<option value="' . htmlspecialchars($it) . '"' . ($it == $value ? ' selected' : '') . '>' . $it . '</option>'); } println('</select>'); } function BuildCheckImportancy($var, $formname = '') { $dummy = $formname . '_' . $var; return "(qtrim (getElementById ('{$dummy}').value)!='')"; } function GetDBFieldType() { return 'LONGTEXT'; } } content_Register_DCClass('CDCComboBox', 'Выпадающий список'); }
function NewContentSpawned($field, $content_id = -1) { manage_storage_refcount_inc($this->settings['storage']); } function PerformContentDeletion($field, $content_id = -1) { manage_storage_refcount_dec($this->settings['storage']); } function ReceiveValue($field, $formname = '') { CDCVirtual::ReceiveValue($field, $formname); $this->SpawnStorage(); $this->storage->Accept($this->GetValue()); } function DestroyValue() { $this->SpawnStorage(); $this->storage->Unlink($this->GetValue()); } function Value() { $this->SpawnStorage(); return $this->storage->GetFullURL($this->GetValue()); } function BuildCheckImportancy($var, $formname = '') { return '(getElementById ("' . $formname . '_' . $var . '").value!="")'; } } content_Register_DCClass('CDCImage', 'Изображение'); }
$c->ReceiveContentSettings($title, $field); $tmp = $c->GetSettings(); $this->settings['data'][$sfield] = $tmp['data']; } function ReceiveImageSettings($title, $field) { $this->ReceiveLimitsSettings('CDCImage', $title, $field . '_image', 'image'); } function ReceiveFileSettings($title, $field) { $this->ReceiveLimitsSettings('CDCFile', $title, $field . '_file', 'file'); } function ReceiveContentSettings($title, $field) { $this->ReceiveImageSettings($title, $field); $this->ReceiveFileSettings($title, $field); return true; } function ReceiveValue($field, $formname = '') { $old_val = $this->GetValue(); CDCVirtual::ReceiveValue($field, $formname); $this->SetValue(iframe_accept_content($formname . '_' . $field, $old_val)); } function DestroyValue() { iframe_destroy_content($this->GetValue()); } } content_Register_DCClass('CDCIFrame', 'Визуально редактирыемый текст с форматированием'); }