public function main() { $design = CMSDesign::getInstance(); $FileContent = htmlspecialchars(file_get_contents($this->tplFile)); $date = date('Y-m-d H:i', filemtime($this->tplFile)); $design->begin($this->aBegin); $design->documentBegin(); if (!empty($this->aButton)) { $design->buttons($this->aButton); } $design->formBegin(); $design->header(_msg('Редактировать шаблон') . ' :' . $this->title . ' <br/> <span style="color:#AAAAFF">' . _msg('FILE_TEMPLATE_DATE_MODIFIED') . ' : ' . $date . '</span>'); $design->submit('submit', _msg('Применить')); $design->br(); $this->outputComment(); $design->tableBegin(); ?> <tr> <td width="80%" valign="top"> <textarea style="width:100%;align:center; height:500px;" name="content"><?php echo $FileContent; ?> </textarea> </td> </tr> <?php $design->tableEnd(); $design->br(); $design->submit('submit', _msg('Применить')); $design->formEnd(); $design->documentEnd(); $design->end(); $this->output(); }
public function show($id) { // Получаем ряд $id = intval($id); $this->nId = $id; try { // Получаем детей $aChild = Sitemap::selectChild($id); if ($id != 0) { $aRow = Sitemap_Sample::get($id); } else { $aRow = null; } /*$aData = array(); foreach ($aChild as $row) { $aData[] = $row['id']; }*/ $aData = $aChild; // $this->formatDesign($aRow); // Выводим форму сортировки print UParser::parsePHPFile(LIB_PATH . 'sitemap/controller/tpl/order.tpl', array('szTitle' => $this->szTitle, 'aBegin' => $this->aBegin, 'id' => $id, 'back' => $this->back, 'aData' => $aData)); $this->output(); } catch (SiteMapException $e) { $this->addError(_msg('Ряд не найден в бд')); $this->jump('./'); } }
/** * Проверяет страницу, если она скрипт редиректит на страницу скрипта, иначе возвращает модель класса * @return */ protected function getModel($id) { // Получаем документ try { $aRow = SiteMap_Sample::get($id); $this->aSitemap = $aRow; } catch (SiteMapException $e) { $this->AddError(_msg('Документ не найден')); $this->jump('./'); } if (!empty($aRow['script'])) { if (!empty($aRow['script_admin_url'])) { $this->jump(\Extasy\CMS::getDashboardWWWRoot() . $aRow['script_admin_url']); } else { $this->addError('У данного скрипта нету панели редактирования'); $this->jump('./'); } } else { $this->szDocumentName = $aRow['document_name']; $this->nId = $aRow['document_id']; $validator = new \Extasy\Validators\IsModelClassNameValidator($aRow['document_name']); if (!$validator->isValid()) { throw new \ForbiddenException('Not a model class:' . $aRow['document_name']); } $szClassName = $aRow['document_name']; } $this->document = new $szClassName(); $found = $this->document->get($this->nId); if (empty($found)) { throw new NotFoundException('Document with id=' . $this->nId . ' not found'); } return $szClassName; }
public function postEdit($id) { $this->model = new $this->modelName(); $this->model->get($id); $this->model->updateFromPost($_POST); $this->addAlert(_msg('Документ был успешно обновлен')); $this->nId = $id; $jumpTo = $this->generateEditUrl(); $this->jump($jumpTo); }
protected function delete($szDocument, $nId) { $this->aOutput['reponse'] = ''; $this->aOutput['error'] = ''; try { SiteMap::removeDocument($szDocument, $nId); $this->aOutput['response'] = _msg('Документ успешно удален'); } catch (SitemapException $e) { $this->aOutput['error'] = _msg('Ошибка при удалении. Возможно документ не поддерживается, либо уже удален'); } $this->output(); }
function __construct($aBegin, $szTitle, $szConfigPath, $aButton = array()) { parent::__construct(); $this->addPost('submit', 'post'); $this->config = new Config(); $this->path = $szConfigPath; $aResultBegin = array(); foreach ($aBegin as $key => $row) { $aResultBegin[_msg($key)] = $row; } $this->aBegin = $aResultBegin; $this->szTitle = _msg($szTitle); $this->aButton = $aButton; }
public function post($document_name, $parent) { try { $nResult = $this->createDocument($document_name, $parent); } catch (SiteMapException $e) { if (DEBUG == 1) { $this->aOutput['error'] = $e->getMessage(); } else { $this->aOutput['error'] = _msg('Ошибка при добавлении превью. Возможно документ не сущестует, либо такое превью уже существует'); } $this->output(); } catch (Exception $e) { if (DEBUG == 1) { $this->aOutput['error'] = $e->getMessage(); } else { $this->aOutput['error'] = _msg('Документ "' . $document_name . '" не вернул все данные для создания превью'); } } $this->output(); }
public function main() { require_once CONTROL_PATH . 'input.php'; require_once CONTROL_PATH . 'htmlarea.php'; // $oSubject = new CInput(); $oRecipient = new CInput(); $oContent = new CHtmlarea(); $oSubject->name = 'subject'; $oRecipient->name = 'to'; $oContent->name = 'content'; // width:99% $oSubject->style = 'width:300px;'; $oRecipient->style = 'width:300px;'; // Собираем данные для отображения $szTitle = 'Отправка письма'; $aBegin = array('Почта' => '#', $szTitle => '#'); $aButton = array('Перейти к настройке smtp' => 'config.php', 'История отсылки почты' => 'logs.php'); // Отображаем $design = CMSDesign::getInstance(); $design->begin($aBegin, $szTitle); $design->documentBegin(); $design->header($szTitle); $design->buttons($aButton); $design->br(); $design->formBegin('index.php'); $design->submit('submit', _msg('Послать')); $design->tableBegin(); $design->row2cell('Получатель (адрес email)', $oRecipient->generate()); $design->row2cell('Тема письма', $oSubject->generate()); $design->row2cell('Сообщение', $oContent->generate()); $design->TableEnd(); $design->submit('submit', _msg('Послать')); $design->formEnd(); $design->end(); $this->output(); }
function getFormValue() { require_once CONTROL_PATH . 'select.php'; $aData = $this->loadAllRows(); $szNameField = $this->fieldInfo['cross_name']; $szIndex = $this->fieldInfo['cross_index']; $aList = array(); foreach ($aData as $key => $value) { $aList[$key] = array('id' => $value[$szIndex], 'name' => $value[$szNameField]); } array_unshift($aList, array('id' => 0, 'name' => _msg('Пусто'))); $oSelect = new CSelect(); $oSelect->name = $this->szFieldName; $oSelect->values = $aList; $oSelect->current = $this->aValue; return $oSelect->generate(); }
public function defaultOutput($begin, $title, $data) { $input = new CInput(); $design = CMSDesign::getInstance(); $this->outputHeader($begin, $title); $design->formBegin(); $design->submit('submit', _msg('Сохранить')); $design->tableBegin(); // $input->name = 'login'; $input->value = isset($data['login']) ? $data['login'] : ''; $design->row2cell('Логин', $input); $input->name = 'password'; $input->value = isset($data['password']) ? $data['password'] : ''; $design->row2cell('Пароль', $input); $rights = isset($data['rights']) ? $data['rights'] : ''; $design->row2cell('Права', $this->displayRights($rights)); $design->tableEnd(); if (isset($data['id'])) { $design->hidden('id', $data['id']); } $design->submit('submit', _msg('Сохранить')); $design->formEnd(); $this->outputFooter(); $this->output(); }
/** * * @param unknown_type $lastSQL */ protected function outputRequestForm($lastSQL) { $design = CMSDesign::getInstance(); $design->formBegin('', 'post', 'sql_request'); $design->submit('submit', _msg('Послать запрос')); ?> <textarea style="width:100%" name="sql" id="sql_textarea"><?php echo $lastSQL; ?> </textarea> <script type="text/javascript">document.getElementById('sql_textarea').focus();</script> <?php $design->submit('submit', _msg('Послать запрос')); $design->formEnd(); }
public function test_msg() { $actual = _msg('some message'); $this->assertEquals('some message', $actual); }
/** * Отображает форму * @return */ public function output($aData = null, $aButton = null, $aColumn = array(), $szTitle = '') { $listFields = explode(',', $this->typeInfo['list_fields']); $design = CMSDesign::getInstance(); $this->outputHeader($this->viewBeginPath, $szTitle); if (!empty($aButton)) { $design->buttons($aButton); } $this->outputBeforeList(); $design->formBegin(); $design->tableBegin(); $design->tableHeader($aColumn); foreach ($aData as $row) { $this->outputListRow($row, $listFields); } $design->tableEnd(); if (!$this->bBlockDelete) { $design->submit('delete', _msg('Удалить')); } if (!empty($this->typeInfo['has_parent']) && !empty($_REQUEST['parent'])) { $design->hidden('parent', htmlspecialchars($_REQUEST['parent'])); } $design->hidden('typeName', $this->modelName); $design->formEnd(); $this->outputFooter(); parent::output(); }
public static function onSetting($type, $fieldname, $key, $value) { switch ($key) { case 'setDefault': self::setDefaultValue($type, $fieldname, $value); $szMessage = _msg('Сохранено'); break; default: $szMessage = _msg('Неизвестная команда'); break; } return sprintf('alert(%s)', to_ajax_string($szMessage)); }
/** * (non-PHPdoc) * @see adminPage::output() */ public function output(extasyDocument $doc = null, $szTitle = '', $bEdit = true) { if (!empty($this->typeInfo['edit_fields'])) { $design = CMSDesign::getInstance(); $design->begin($this->viewBeginPath, $szTitle); $design->documentBegin(); $design->header($szTitle); $design->formBegin(); $design->hidden('typeName', $this->modelName); if ($bEdit) { $design->hidden('id', $doc->id); $design->submit('submit', _msg('Сохранить')); } else { $design->submit('submit', _msg('Добавить')); } $design->tableBegin(); $fieldList = explode(',', $this->typeInfo['edit_fields']); foreach ($fieldList as $fieldName) { $title = !empty($this->typeInfo['fields'][$fieldName]['title']) ? $this->typeInfo['fields'][$fieldName]['title'] : $fieldName; $help = !empty($this->typeInfo['fields'][$fieldName]['cms_help']) ? $this->typeInfo['fields'][$fieldName]['cms_help'] : ''; $design->row2cell($title, $doc->attr($fieldName, true)->getAdminFormValue(), $help); } $design->TableEnd(); foreach ($this->aBackUrlParams as $key => $row) { $design->hidden($key, htmlspecialchars($row)); } if ($bEdit) { $design->submit('submit', _msg('Сохранить')); } else { $design->submit('submit', _msg('Добавить')); } $design->formEnd(); $design->documentEnd(); $design->end(); } else { if ($bEdit) { $doc->getAdminUpdateForm(); } else { $doc->getAdminInsertForm(); } } parent::output(); }
/** * Собирает информацию по текущему элементу (набор кнопок + возможность сортировки) */ public function getInformation() { $aInfo = Sitemap_Sample::get($this->nParent); $szUrl = $this->standalone ? 'index.php' : 'page-list.php'; if (empty($aInfo)) { throw new Exception('Page not found'); } $this->orderCondition = '`order` asc'; if (!empty($aInfo['script'])) { $aChild = Sitemap_Sample::selectScriptChild($aInfo['script']); foreach ($aChild as $key => $row) { $aChild[$key] = $row['document_name']; } } else { $validator = new \Extasy\Validators\ModelConfigValidator($aInfo['document_name'], array('sitemap', RegisteredDocument::ChildrenConfigName)); if ($validator->isValid()) { $aChild = $validator->getData(); } else { $aChild = array(); } } // Формируем блок кнопок // Добавляем в блок кнопки добавления документа // Если более 3 доступных документов для добавления формируем селект if (sizeof($aChild) > 3) { $useSelect = 1; require_once CONTROL_PATH . 'select.php'; $select = new CSelect(); $select->name = 'document_name'; $select->id = 'document_name'; $items = array(array('id' => '-1', 'name' => 'Добавить...')); } else { } foreach ($aChild as $documentName) { $title = call_user_func(array($documentName, 'getLabel'), \Extasy\Model\Model::labelAddItem); $href = $szUrl . '?parent=' . $this->nParent . '&add=' . $documentName; if (empty($useSelect)) { $this->aButton[$title] = $href; } else { $items[] = array('id' => $href, 'name' => $title); } } if (!empty($useSelect)) { $select->values = $items; $select->current = '-1'; $this->aButton[] = array('code' => $select); } if (!empty($aInfo['document_name']) || !empty($aInfo['script_admin_url'])) { $this->aButton[_msg('Редактировать')] = \Extasy\CMS::getDashboardWWWRoot() . 'sitemap/edit.php?id=' . $aInfo['id']; } $this->aButton[_msg('Сортировать')] = \Extasy\CMS::getDashboardWWWRoot() . 'sitemap/order.php?id=' . $aInfo['id']; }
$thumbFile = $uploadDir . $d . _DS_ . $post[$name]; if (is_file($thumbFile) && file_exists($thumbFile)) { unlink($thumbFile); } } } } } else { $error = $file->getError(); validation_addError($name, $error['message']); } } if (count(validation_get('errors'))) { $errors = validation_get('errors'); # if there is any validation error and if there was any uploaded file $data['error'] = array('id' => $errors[0]['htmlID'], 'plain' => $errors[0]['msg'], 'html' => _msg($errors, 'error', 'html')); $data['value'] = $post[$name]; } if (!$data['savedId'] && isset($post[$name . '-id']) && $post[$name . '-id']) { # if there was any saved data in db $data['savedId'] = $post[$name . '-id']; } } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>AsyncFileUploader</title> <script language="javascript"> var parent = window.top;
/** * 操作数据初台化方法 * @param array $post_data 需要操作的POST数据含 有数据 行为方法 模型类 * @param array $get_data 需要操作的POST数据含 有数据 行为方法 模型类 */ public function init($post_data) { /* * 从传过来的数据获取需要使用的数据模型并获取行为动作 */ //extract($get_post_data, EXTR_OVERWRITE); if (empty($post_data)) { return _msg("fail", "数据不能为空"); } else { $action = strtolower($post_data["module_action"]); //行为动作 add $data = $this->{$action}($post_data); return $data; } }
* @since PHPLucidFrame v 1.0.0 * @copyright Copyright (c), PHPLucidFrame. * @author Sithu K. <*****@*****.**> * @link http://phplucidframe.com * @license http://www.opensource.org/licenses/mit-license.php MIT License * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE */ ?> <!DOCTYPE html> <html lang="<?php echo _lang(); ?> "> <head> <title><?php echo _title('Site Error'); ?> </title> <?php include _i('inc/tpl/head.php'); ?> </head> <body> <?php _msg($error->message, isset($error->type) ? $error->type : 'error'); ?> </body> </html>
/** * Отображает форму редактирования элемента * * @param $aTabSheet array, хеш-массив имен вкладок и полей внутри их * @param $aButtons array, хеш-массив кнопок необходимых к выводу */ public function getAdminUpdateForm($aTabSheet = array(), $aButtons = array(), $begin = array(), $title = '') { if ($this->withSitemap) { $this->needSitemapData(); } // Получаем информацию о типе данных, его полях $aType = static::getFieldsInfo(); // Если пусты вкладки редактировании, то ищем информацию о них в самом типе if (empty($aTabSheet)) { if (!empty($aType['cms_tabsheets'])) { $aTabSheet = $aType['cms_tabsheets']; // Применяем автоматическую сортировку ksort($aTabSheet); // А теперь вырезаем лидирующие цифры $tmp = $aTabSheet; $aTabSheet = array(); foreach ($tmp as $key => $row) { $key = preg_replace('#^[0-9]+#', '', $key); $aTabSheet[$key] = $row; } } else { throw new Exception('Form layout empty. It must be defined in child class!'); } } // $nCounter = 0; foreach ($aTabSheet as $key => $row) { $aResultTabSheet[] = array('id' => 'tab_' . $nCounter, 'title' => $key); $nCounter++; } // Добавляем вкладку о свойствах документа в карте сайта1 if ($this->withSitemap) { $this->needSitemapData(); $aResultTabSheet[] = array('id' => 'tab_sitemap', 'title' => 'Свойства'); } // Выводим заголовок документа $design = CMSDesign::getInstance(); if (isset($this->columns['name'])) { $titleTemplate = 'Редактирование "%s"'; $szTitle = sprintf($titleTemplate, cuttext($this->name->getValue(), 48)); // 48!!! } else { $szTitle = self::getLabel(self::labelEditItem); } if (!empty($begin)) { $aBegin = $begin; } else { $aParent = Sitemap_CMS::getParents($this->sitemapInfo['id']); // Вырезаем самих себя из массива array_pop($aParent); $aBegin = Sitemap_CMS::selectBegin($aParent, $szTitle); $submenu = Sitemap_CMS::generateDocumentSubmenu($this->getModelName(), $this->sitemapInfo, $aBegin); $aButtons = array_merge($aButtons, $submenu); } $page = new AdminPage(); $page->outputHeader($aBegin, $szTitle); // выводим кнопки, если они есть if (!empty($aButtons)) { $design->buttons($aButtons); } // Вывод всех вкладок $design->formBegin(); $design->submit('submit', _msg('APPLY')); $design->tabSheetBegin($aResultTabSheet); foreach ($aResultTabSheet as $key => $row) { if ($key == sizeof($aResultTabSheet) - 1) { if ($this->withSitemap) { // Вывод вкладки свойств-документа $this->outputSitemapTabSheet($row); continue; } else { } } // Вывод вкладки на редактиование $this->outputFormTabSheet($design, $row, $aTabSheet[$row['title']], $aType['fields'], $this->columns); } $design->tabSheetEnd(); // Завершаем вывод формы if ($this->withSitemap) { $design->hidden('sitemapId', $this->sitemapInfo['id']); } else { $design->hidden('typeName', Static::ModelName); $design->hidden('id', $this->id->getValue()); } $design->submit('submit', _msg('APPLY')); $design->formEnd(); $page->outputFooter(); }