本文整理汇总了PHP中Widget::Error方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::Error方法的具体用法?PHP Widget::Error怎么用?PHP Widget::Error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::Error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayPublishPanel
public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
{
// Check 'mode' exists; otherwise set manually from 'editable'
$mode = $this->get('mode');
if (!$mode) {
if ($this->get('editable') == 'yes') {
$mode = 'normal';
} else {
$mode = 'hidden';
}
}
// Render the field only if it's not hidden
if ($mode != 'hidden') {
$name = $this->get('element_name');
$edited_local = DateTimeObj::get(__SYM_DATETIME_FORMAT__, $data['local']);
$current_local = DateTimeObj::get(__SYM_DATETIME_FORMAT__, null);
$label = Widget::Label($this->get('label'));
if ($mode == 'disabled') {
$input = Widget::Input("{$name}-display", $edited_local);
$input->setAttribute('disabled', 'disabled');
} else {
$note = new XMLElement('i', __('Previous value: %s', array($edited_local)));
$label->appendChild($note);
$input = Widget::Input("fields{$fieldnamePrefix}[{$name}]", $current_local);
}
$label->appendChild($input);
$label->setAttribute('class', 'date');
if (!is_null($flagWithError)) {
$label = Widget::Error($label, $error);
}
$wrapper->appendChild($label);
}
}
示例2: displayPublishPanel
function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
{
$note = isset($data['value']) ? $data['value'] : $this->get('note');
$editable = $this->get('editable');
# Add <div>
$div = new XMLElement("div", $note, array("id" => Lang::createHandle($this->get('label')), "class" => "publishnotes-note"));
$wrapper->appendChild($div);
# Editable
if (isset($editable) && $editable) {
$wrapper->setAttribute('class', $wrapper->getAttribute('class') . " editable");
$edit = new XMLElement("a", __("Edit note"), array("class" => "publishnotes-edit", "href" => "#edit"));
$wrapper->appendChild($edit);
# Add <textarea>
$label = Widget::Label("Edit: " . $this->get('label'), NULL, Lang::createHandle($this->get('label')));
$textarea = Widget::Textarea('fields' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix, 8, 50, strlen($note) != 0 ? General::sanitize($note) : NULL);
$label->appendChild($textarea);
$control = new XMLElement("div", '<input type="submit" value="Change note"/> or <a href="#">cancel</a>', array("class" => "control"));
$label->appendChild($control);
if ($flagWithError != NULL) {
$wrapper->appendChild(Widget::Error($label, $flagWithError));
} else {
$wrapper->appendChild($label);
}
}
}
示例3: displayPublishPanel
public function displayPublishPanel(&$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL)
{
$value = $data['value'];
$label = Widget::Label($this->get('label'));
$label->appendChild(Widget::Input('fields' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix, (string) (strlen($value) != 0 ? $value : $this->getNewNumber()), 'text', array('readonly' => 'readonly')));
if ($flagWithError != NULL) {
$wrapper->appendChild(Widget::Error($label, $flagWithError));
} else {
$wrapper->appendChild($label);
}
}
示例4: buildSummaryBlock
public function buildSummaryBlock($errors = null)
{
$order = $this->get('sortorder');
$div = new XMLElement('div');
$div->appendChild(Widget::Input("fields[{$order}][location]", 'main', 'hidden'));
$label = Widget::Label(__('Label'));
$label->appendChild(Widget::Input("fields[{$order}][label]", $this->get('label')));
if (isset($errors['label'])) {
$label = Widget::Error($label, $errors['label']);
}
$div->appendChild($label);
return $div;
}
示例5: displayPublishPanel
public function displayPublishPanel(&$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL)
{
$label = Widget::Label($this->get('label'));
$label->appendChild(new XMLElement('a', __('Select Link'), array('style' => 'float: right;', 'onclick' => "\n document.getElementById('unique_link_" . $this->get('id') . "').select(); return false;\n ")));
$link = str_replace('[URL]', URL, $this->get('link'));
$link = str_replace('[CODE]', $data['code'], $link);
$value = $data === null ? __('A link will automaticly be generated when you save this entry') : $link;
$label->appendChild(Widget::Input('fields' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix, $value, 'text', array('id' => 'unique_link_' . $this->get('id'), 'readonly' => 'readonly', 'style' => 'background: #eee; color: #666; border: 1px solid #ccc;')));
if ($flagWithError != NULL) {
$wrapper->appendChild(Widget::Error($label, $flagWithError));
} else {
$wrapper->appendChild($label);
}
}
示例6: displayPublishPanel
public function displayPublishPanel(XMLElement &$wrapper, $data = null, $error = null, $prefix = null, $postfix = null, $entry_id = null)
{
$field_id = $this->get('id');
$handle = $this->get('element_name');
// Identity
$label = Widget::Label($this->get('label'));
if (!($this->get('required') == 'yes')) {
$label->appendChild(new XMLElement('i', __('Optional')));
}
$label->appendChild(Widget::Input("fields{$prefix}[{$handle}]{$postfix}", $data['value']));
// Error?
if (!is_null($error)) {
$wrapper->appendChild(Widget::Error($label, $error));
} else {
$wrapper->appendChild($label);
}
}
示例7: displayPublishPanel
public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
{
Extension_ExpressionField::appendAssets();
$handle = $this->get('element_name');
// Defaults -----------------------------------------------------------
$wrapper->appendChild(Widget::Input("fields{$fieldnamePrefix}[{$handle}][is_cased]{$fieldnamePostfix}", 'no', 'hidden'));
$wrapper->appendChild(Widget::Input("fields{$fieldnamePrefix}[{$handle}][is_regexp]{$fieldnamePostfix}", 'no', 'hidden'));
// Expression ---------------------------------------------------------
$label = Widget::Label(__('Expression'));
$label->appendChild(Widget::Input("fields{$fieldnamePrefix}[{$handle}][value]{$fieldnamePostfix}", General::sanitize($data['value'])));
if (isset($error)) {
$label = Widget::Error($label, $flagWithError);
}
$wrapper->appendChild($label);
$help = new XMLElement('p');
$help->setAttribute('class', 'help');
$help->setValue(__('Use %s as a wild-card unless regular expressions are enabled.', array('<code>*</code>')));
$wrapper->appendChild($help);
// Cased? -------------------------------------------------------------
$settings = new XMLElement('div', null, array('class' => 'frame'));
$input = Widget::Input("fields{$fieldnamePrefix}[{$handle}][is_cased]{$fieldnamePostfix}", 'yes', 'checkbox', $data['is_cased'] == 'yes' ? array('checked' => 'checked') : null);
$label = Widget::Label(__('%s Case sensitive?', array($input->generate())));
$settings->appendChild($label);
$help = new XMLElement('p');
$help->setAttribute('class', 'help');
$help->setValue(__('Treat upper case and lower case letters differently.'));
$settings->appendChild($help);
// Regexp? ------------------------------------------------------------
$input = Widget::Input("fields{$fieldnamePrefix}[{$handle}][is_regexp]{$fieldnamePostfix}", 'yes', 'checkbox', $data['is_regexp'] == 'yes' ? array('checked' => 'checked') : null);
$label = Widget::Label(__('%s Regular expressions?', array($input->generate())));
$settings->appendChild($label);
$help = new XMLElement('p');
$help->setAttribute('class', 'help');
$help->setValue(__('Advanced matching with <a href="%s">Perl compatible regular expressions</a>.', array(SYMPHONY_URL . '/extension/expressionfield/documentation/')));
$settings->appendChild($help);
$wrapper->appendChild($settings);
}
示例8: displayPublishPanel
public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
{
$value = null;
if (isset($data['value'])) {
$value = is_array($data['value']) ? self::__tagArrayToString($data['value']) : $data['value'];
}
$label = Widget::Label($this->get('label'));
if ($this->get('required') != 'yes') {
$label->appendChild(new XMLElement('i', __('Optional')));
}
$label->appendChild(Widget::Input('fields' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix, strlen($value) != 0 ? General::sanitize($value) : null));
if ($flagWithError != null) {
$wrapper->appendChild(Widget::Error($label, $flagWithError));
} else {
$wrapper->appendChild($label);
}
if ($this->get('pre_populate_source') != null) {
$existing_tags = $this->getToggleStates();
if (is_array($existing_tags) && !empty($existing_tags)) {
$taglist = new XMLElement('ul');
$taglist->setAttribute('class', 'tags');
$taglist->setAttribute('data-interactive', 'data-interactive');
foreach ($existing_tags as $tag) {
$taglist->appendChild(new XMLElement('li', General::sanitize($tag)));
}
$wrapper->appendChild($taglist);
}
}
}
示例9: displayPublishPanel
public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
{
$value = isset($data['author_id']) ? $data['author_id'] : null;
if ($this->get('default_to_current_user') === 'yes' && empty($data) && empty($_POST)) {
$value = array(Symphony::Author()->get('id'));
}
if (!is_array($value)) {
$value = array($value);
}
$options = array();
if ($this->get('required') !== 'yes') {
$options[] = array(null, false, null);
}
// Custom where to only show Authors based off the Author Types setting
$types = $this->get('author_types');
if (!empty($types)) {
$types = implode('","', $this->get('author_types'));
$where = 'user_type IN ("' . $types . '")';
}
$authors = AuthorManager::fetch('id', 'ASC', null, null, $where);
$found = false;
foreach ($authors as $a) {
if (in_array($a->get('id'), $value)) {
$found = true;
}
$options[] = array($a->get('id'), in_array($a->get('id'), $value), $a->getFullName());
}
// Ensure the selected Author is included in the options (incase
// the settings change after the original entry was created)
if (!$found && !is_null($value)) {
$authors = AuthorManager::fetchByID($value);
foreach ($authors as $a) {
$options[] = array($a->get('id'), in_array($a->get('id'), $value), $a->getFullName());
}
}
$fieldname = 'fields' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix;
if ($this->get('allow_multiple_selection') === 'yes') {
$fieldname .= '[]';
}
$label = Widget::Label($this->get('label'));
if ($this->get('required') !== 'yes') {
$label->appendChild(new XMLElement('i', __('Optional')));
}
$label->appendChild(Widget::Select($fieldname, $options, $this->get('allow_multiple_selection') === 'yes' ? array('multiple' => 'multiple') : null));
if ($flagWithError != null) {
$wrapper->appendChild(Widget::Error($label, $flagWithError));
} else {
$wrapper->appendChild($label);
}
}
示例10: buildSummaryBlock
/**
* Construct the html block to display a summary of this field, which is the field
* Label and it's location within the section. Any error messages generated are
* appended to the optional input error array. This function calls
* `buildLocationSelect` once it is completed
*
* @see buildLocationSelect()
* @param array $errors (optional)
* an array to append html formatted error messages to. this defaults to null.
* @return XMLElement
* the root XML element of the html display of this.
*/
public function buildSummaryBlock($errors = null)
{
$div = new XMLElement('div');
// Publish label
$label = Widget::Label(__('Label'));
$label->appendChild(Widget::Input('fields[' . $this->get('sortorder') . '][label]', $this->get('label')));
if (isset($errors['label'])) {
$div->appendChild(Widget::Error($label, $errors['label']));
} else {
$div->appendChild($label);
}
// Handle + placement
$group = new XMLElement('div');
$group->setAttribute('class', 'two columns');
$label = Widget::Label(__('Handle'));
$label->setAttribute('class', 'column');
$label->appendChild(Widget::Input('fields[' . $this->get('sortorder') . '][element_name]', $this->get('element_name')));
if (isset($errors['element_name'])) {
$group->appendChild(Widget::Error($label, $errors['element_name']));
} else {
$group->appendChild($label);
}
// Location
$group->appendChild($this->buildLocationSelect($this->get('location'), 'fields[' . $this->get('sortorder') . '][location]'));
$div->appendChild($group);
return $div;
}
示例11: __form
public function __form($readonly = false)
{
$formHasErrors = is_array($this->_errors) && !empty($this->_errors);
if ($formHasErrors) {
$this->pageAlert(__('An error occurred while processing this form. See below for details.'), Alert::ERROR);
// These alerts are only valid if the form doesn't have errors
} elseif (isset($this->_context[2])) {
$time = Widget::Time();
switch ($this->_context[2]) {
case 'saved':
$this->pageAlert(__('Event updated at %s.', array($time->generate())) . ' <a href="' . SYMPHONY_URL . '/blueprints/events/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/events/" accesskey="a">' . __('View all Events') . '</a>', Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Event created at %s.', array($time->generate())) . ' <a href="' . SYMPHONY_URL . '/blueprints/events/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/events/" accesskey="a">' . __('View all Events') . '</a>', Alert::SUCCESS);
break;
}
}
$isEditing = $readonly ? true : false;
$fields = array("name" => null, "filters" => null);
$about = array("name" => null);
$providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::EVENT);
if (isset($_POST['fields'])) {
$fields = $_POST['fields'];
if ($this->_context[0] == 'edit') {
$isEditing = true;
}
} elseif ($this->_context[0] == 'edit' || $this->_context[0] == 'info') {
$isEditing = true;
$handle = $this->_context[1];
$existing = EventManager::create($handle);
$about = $existing->about();
if ($this->_context[0] == 'edit' && !$existing->allowEditorToParse()) {
redirect(SYMPHONY_URL . '/blueprints/events/info/' . $handle . '/');
}
$fields['name'] = $about['name'];
$fields['source'] = $existing->getSource();
$provided = false;
if (!empty($providers)) {
foreach ($providers as $providerClass => $provider) {
if ($fields['source'] == call_user_func(array($providerClass, 'getClass'))) {
$fields = array_merge($fields, $existing->settings());
$provided = true;
break;
}
}
}
if (!$provided) {
if (isset($existing->eParamFILTERS)) {
$fields['filters'] = $existing->eParamFILTERS;
}
}
}
// Handle name on edited changes, or from reading an edited datasource
if (isset($about['name'])) {
$name = $about['name'];
} elseif (isset($fields['name'])) {
$name = $fields['name'];
}
$this->setPageType('form');
$this->setTitle(__($isEditing ? '%1$s – %2$s – %3$s' : '%2$s – %3$s', array($about['name'], __('Events'), __('Symphony'))));
$this->appendSubheading($isEditing ? $about['name'] : __('Untitled'));
$this->insertBreadcrumbs(array(Widget::Anchor(__('Events'), SYMPHONY_URL . '/blueprints/events/')));
if (!$readonly) {
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Essentials')));
// Target
$sources = new XMLElement('div', null, array('class' => 'apply actions'));
$div = new XMLElement('div');
$label = Widget::Label(__('Target'), null, 'apply-label-left');
$sources->appendChild($label);
$sources->appendChild($div);
$sections = SectionManager::fetch(null, 'ASC', 'name');
$options = array();
$section_options = array();
$source = isset($fields['source']) ? $fields['source'] : null;
if (is_array($sections) && !empty($sections)) {
$section_options = array('label' => __('Sections'), 'options' => array());
foreach ($sections as $s) {
$section_options['options'][] = array($s->get('id'), $source == $s->get('id'), General::sanitize($s->get('name')));
}
}
$options[] = $section_options;
// Loop over the event providers
if (!empty($providers)) {
$p = array('label' => __('From extensions'), 'options' => array());
foreach ($providers as $providerClass => $provider) {
$p['options'][] = array($providerClass, $fields['source'] == $providerClass, $provider);
}
$options[] = $p;
}
$div->appendChild(Widget::Select('source', $options, array('id' => 'event-context')));
if (isset($this->_errors['source'])) {
$this->Context->prependChild(Widget::Error($sources, $this->_errors['source']));
} else {
$this->Context->prependChild($sources);
}
$this->Form->appendChild(Widget::Input('fields[source]', $options[0]['options'][0][0], 'hidden', array('id' => 'event-source')));
// Name
$group = new XMLElement('div');
//.........这里部分代码省略.........
示例12: render
function render()
{
$this->setPageType('form');
$fields = array();
// If we're editing, make sure the item exists
if ($this->_context[0]) {
if (!($doc_id = $this->_context[0])) {
redirect(URL . '/symphony/extension/documenter/manage');
}
$existing = Symphony::Database()->fetchRow(0, "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\td.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`tbl_documentation` AS d\n\t\t\t\t\tWHERE\n\t\t\t\t\t\td.id = '{$doc_id}'\n\t\t\t\t\tLIMIT 1\n\t\t\t\t");
if (!$existing) {
$this->_Parent->customError(E_USER_ERROR, __('Documentation Item not found'), __('The documentation item you requested to edit does not exist.'), false, true, 'error', array('header' => 'HTTP/1.0 404 Not Found'));
}
}
// Build the status message
if (isset($this->_context[1])) {
if ($this->_context[1] == 'saved') {
$this->pageAlert(__('Documentation Item updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Documentation</a>', array(Widget::Time()->generate(__SYM_TIME_FORMAT__), URL . '/symphony/extension/documenter/new/', URL . '/symphony/extension/documenter/')), Alert::SUCCESS);
} else {
$this->pageAlert(__('Documentation Item created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Documentation</a>', array(Widget::Time()->generate(__SYM_TIME_FORMAT__), URL . '/symphony/extension/documenter/new/', URL . '/symphony/extension/documenter/')), Alert::SUCCESS);
}
}
// Find values
if (isset($_POST['fields'])) {
$fields = $_POST['fields'];
} else {
if ($this->_context[0]) {
$fields = $existing;
$fields['content'] = General::sanitize($fields['content']);
}
}
$title = $fields['title'];
if (trim($title) == '') {
$title = $existing['title'];
}
// Start building the page
$this->setTitle(__($title ? '%1$s – %2$s – %3$s' : '%1$s – %2$s', array(__('Symphony'), __('Documentation'), $title)));
$this->appendSubheading($title ? $title : __('Untitled'));
// Start building the fieldsets
$this->Form->setAttribute('class', 'two columns');
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'primary column');
// Title text input
$label = Widget::Label(__('Title'));
$label->appendChild(Widget::Input('fields[title]', General::sanitize($fields['title'])));
if (isset($this->_errors['title'])) {
$label = Widget::Error($label, $this->_errors['title']);
}
$fieldset->appendChild($label);
// Content textarea
$label = Widget::Label(__('Content'));
$content = Widget::Textarea('fields[content]', 30, 80, $fields['content']);
if (Symphony::Configuration()->get('text-formatter', 'documentation') != 'none') {
$content->setAttribute('class', Symphony::Configuration()->get('text-formatter', 'documentation'));
}
$label->appendChild($content);
$fieldset->appendChild(isset($this->_errors['content']) ? Widget::Error($label, $this->_errors['content']) : $label);
$fieldset->appendChild(Widget::Input('autogenerate', __('Auto-generate content according to selected section(s)'), 'button', array('class' => 'button')));
$this->Form->appendChild($fieldset);
// Pages multi-select
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'secondary column');
$label = Widget::Label(__('Pages'));
if (!is_array($fields['pages'])) {
$pages_array = explode(',', $fields['pages']);
} else {
$pages_array = $fields['pages'];
}
$options = array();
// Generate a list of sectionField-data for auto-generation of documentation:
$arr = array();
// Build the options list using the navigation array
foreach (Administration::instance()->Page->_navigation as $menu) {
$items = array();
foreach ($menu['children'] as $item) {
$items[] = array($item['link'], in_array($item['link'], $pages_array), $menu['name'] . " > " . $item['name']);
// If it's a section, add New and Edit pages
// NOTE: This will likely break when extensions add custom nav groups
if ($menu['name'] != 'Blueprints' and $menu['name'] != 'System') {
$items[] = array($item['link'] . 'new/', in_array($item['link'] . 'new/', $pages_array), $menu['name'] . " > " . $item['name'] . " New");
$items[] = array($item['link'] . 'edit/', in_array($item['link'] . 'edit/', $pages_array), $menu['name'] . " > " . $item['name'] . " Edit");
}
// Generate a list of sectionField-data for auto-generation of documentation:
if ($item['type'] == 'section') {
$arr2 = array('name' => $item['name'], 'link' => $item['link'], 'items' => array());
$fields = FieldManager::fetch(null, $item['section']['id']);
foreach ($fields as $field) {
/* @var $field Field */
$arr2['items'][] = array('label' => $field->get('label'));
}
$arr[] = $arr2;
}
}
$options[] = array('label' => $menu['name'], 'options' => $items);
}
Administration::instance()->Page->addElementToHead(new XMLElement('script', 'var sectionFields = ' . json_encode($arr) . ';', array('type' => 'text/javascript')));
$label->appendChild(Widget::Select('fields[pages][]', $options, array('multiple' => 'multiple', 'id' => 'documenter-pagelist')));
if (isset($this->_errors['pages'])) {
$label = Widget::Error($label, $this->_errors['pages']);
}
//.........这里部分代码省略.........
示例13: __form
public function __form()
{
require_once TOOLKIT . '/class.field.php';
// Handle unknown context
if (!in_array($this->_context[0], array('new', 'edit'))) {
Administration::instance()->errorPageNotFound();
}
if ($this->_context[0] == 'new' && !Administration::instance()->Author->isDeveloper()) {
Administration::instance()->customError(__('Access Denied'), __('You are not authorised to access this page.'));
}
if (isset($this->_context[2])) {
switch ($this->_context[2]) {
case 'saved':
$this->pageAlert(__('Author updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/system/authors/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/system/authors/" accesskey="a">' . __('View all Authors') . '</a>', Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Author created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/system/authors/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/system/authors/" accesskey="a">' . __('View all Authors') . '</a>', Alert::SUCCESS);
break;
}
}
$this->setPageType('form');
$isOwner = false;
if (isset($_POST['fields'])) {
$author = $this->_Author;
} else {
if ($this->_context[0] == 'edit') {
if (!($author_id = $this->_context[1])) {
redirect(SYMPHONY_URL . '/system/authors/');
}
if (!($author = AuthorManager::fetchByID($author_id))) {
Administration::instance()->customError(__('Author not found'), __('The author profile you requested does not exist.'));
}
} else {
$author = new Author();
}
}
if ($this->_context[0] == 'edit' && $author->get('id') == Administration::instance()->Author->get('id')) {
$isOwner = true;
}
if ($this->_context[0] == 'edit' && !$isOwner && !Administration::instance()->Author->isDeveloper()) {
Administration::instance()->customError(__('Access Denied'), __('You are not authorised to edit other authors.'));
}
$this->setTitle(__($this->_context[0] == 'new' ? '%2$s – %3$s' : '%1$s – %2$s – %3$s', array($author->getFullName(), __('Authors'), __('Symphony'))));
$this->appendSubheading($this->_context[0] == 'new' ? __('Untitled') : $author->getFullName());
$this->insertBreadcrumbs(array(Widget::Anchor(__('Authors'), SYMPHONY_URL . '/system/authors/')));
// Essentials
$group = new XMLElement('fieldset');
$group->setAttribute('class', 'settings');
$group->appendChild(new XMLElement('legend', __('Essentials')));
$div = new XMLElement('div');
$div->setAttribute('class', 'two columns');
$label = Widget::Label(__('First Name'), NULL, 'column');
$label->appendChild(Widget::Input('fields[first_name]', $author->get('first_name')));
$div->appendChild(isset($this->_errors['first_name']) ? Widget::Error($label, $this->_errors['first_name']) : $label);
$label = Widget::Label(__('Last Name'), NULL, 'column');
$label->appendChild(Widget::Input('fields[last_name]', $author->get('last_name')));
$div->appendChild(isset($this->_errors['last_name']) ? Widget::Error($label, $this->_errors['last_name']) : $label);
$group->appendChild($div);
$label = Widget::Label(__('Email Address'));
$label->appendChild(Widget::Input('fields[email]', $author->get('email')));
$group->appendChild(isset($this->_errors['email']) ? Widget::Error($label, $this->_errors['email']) : $label);
$this->Form->appendChild($group);
// Login Details
$group = new XMLElement('fieldset');
$group->setAttribute('class', 'settings');
$group->appendChild(new XMLElement('legend', __('Login Details')));
$div = new XMLElement('div');
$label = Widget::Label(__('Username'));
$label->appendChild(Widget::Input('fields[username]', $author->get('username')));
$div->appendChild(isset($this->_errors['username']) ? Widget::Error($label, $this->_errors['username']) : $label);
// Only developers can change the user type. Primary account should NOT be able to change this
if (Administration::instance()->Author->isDeveloper() && !$author->isPrimaryAccount()) {
// Create columns
$div->setAttribute('class', 'two columns');
$label->setAttribute('class', 'column');
// User type
$label = Widget::Label(__('User Type'), NULL, 'column');
$options = array(array('author', false, __('Author')), array('developer', $author->isDeveloper(), __('Developer')));
$label->appendChild(Widget::Select('fields[user_type]', $options));
$div->appendChild($label);
}
$group->appendChild($div);
// Password
$fieldset = new XMLElement('fieldset', NULL, array('class' => 'two columns', 'id' => 'password'));
$legend = new XMLElement('legend', __('Password'));
$help = new XMLElement('i', __('Leave password fields blank to keep the current password'));
$fieldset->appendChild($legend);
$fieldset->appendChild($help);
// Password reset
if ($this->_context[0] == 'edit' && (!Administration::instance()->Author->isDeveloper() || $isOwner === true)) {
$fieldset->setAttribute('class', 'three columns');
$label = Widget::Label(NULL, NULL, 'column');
$label->appendChild(Widget::Input('fields[old-password]', NULL, 'password', array('placeholder' => __('Old Password'))));
$fieldset->appendChild(isset($this->_errors['old-password']) ? Widget::Error($label, $this->_errors['password']) : $label);
}
// New password
$callback = Administration::instance()->getPageCallback();
$placeholder = $callback['context'][0] == 'edit' ? __('New Password') : __('Password');
$label = Widget::Label(NULL, NULL, 'column');
$label->appendChild(Widget::Input('fields[password]', NULL, 'password', array('placeholder' => $placeholder)));
//.........这里部分代码省略.........
示例14: __viewIndex
public function __viewIndex()
{
$this->setPageType('form');
$this->setTitle(__('%1$s – %2$s – %3$s', array(__("New"), __('Cron'), __('Symphony'))));
$this->appendSubheading(__('Untitled'));
$formHasErrors = (bool) (is_array($this->_errors) && !empty($this->_errors));
if ($formHasErrors) {
$this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR);
}
// Essentials
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Essentials')));
if (!empty($_POST)) {
$fields = $_POST['fields'];
} else {
$fields = ['interval' => 60];
}
$label = Widget::Label('Name');
$label->appendChild(Widget::Input('fields[name]', $fields['name']));
$fieldset->appendChild(isset($this->_errors['name']) ? Widget::Error($label, $this->_errors['name']) : $label);
$label = Widget::Label('Command');
$label->appendChild(Widget::Input('fields[command]', $fields['command']));
$fieldset->appendChild(isset($this->_errors['command']) ? Widget::Error($label, $this->_errors['command']) : $label);
$p = new XMLElement('p', '↑ This is any command that can be executed from the command line.');
$p->setAttribute('class', 'help');
$fieldset->appendChild($p);
$label = Widget::Label('Description <i>Optional</i>');
$label->appendChild(Widget::Input('fields[description]', $fields['description']));
$fieldset->appendChild(isset($this->_errors['description']) ? Widget::Error($label, $this->_errors['description']) : $label);
$label = Widget::Label();
$input = Widget::Input('fields[interval]', (string) max(1, $fields['interval']), null, array('size' => '6'));
$options = [['minute', $fields['interval'] == 'minute', 'minutes'], ['hour', $fields['interval'] == 'hour', 'hours'], ['day', $fields['interval'] == 'day', 'days'], ['week', $fields['interval'] == 'week', 'weeks']];
$select = Widget::Select('fields[interval-type]', $options, ['class' => 'inline', 'style' => 'display: inline; width: auto;']);
$label->setValue(__('Run this task every %s %s', [$input->generate(false), $select->generate(false)]));
if (isset($this->_errors['interval'])) {
$fieldset->appendChild(Widget::Error($label, $this->_errors['interval']));
} else {
$fieldset->appendChild($label);
}
$label = Widget::Label();
$input = Widget::Input('fields[enabled]', 'yes', 'checkbox', isset($fields['enabled']) ? array('checked' => 'checked') : null);
$label->setValue(__('%s Enable this task', array($input->generate(false))));
$fieldset->appendChild($label);
$p = new XMLElement('p', '↑ Unless a <strong>start date</strong> has been specified, this task will be executed once the current date plus the interval specified has passed.');
$p->setAttribute('class', 'help');
$fieldset->appendChild($p);
$this->Form->appendChild($fieldset);
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Timing')));
$group = new XMLElement('div', null, array('class' => 'group'));
$label = Widget::Label('Start Date <i>Optional</i>');
$label->appendChild(Widget::Input('fields[start]', $fields['start']));
$group->appendChild(isset($this->_errors['start']) ? Widget::Error($label, $this->_errors['start']) : $label);
$label = Widget::Label('Finish Date <i>Optional</i>');
$label->appendChild(Widget::Input('fields[finish]', $fields['finish']));
$group->appendChild(isset($this->_errors['finish']) ? Widget::Error($label, $this->_errors['finish']) : $label);
$fieldset->appendChild($group);
$p = new XMLElement('p', 'This task will be not run until after the <strong>start date</strong>, and will cease to trigger beyond the <strong>finish date</strong>.');
$p->setAttribute('class', 'help');
$fieldset->appendChild($p);
$this->Form->appendChild($fieldset);
$div = new XMLElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Input('action[save]', 'Create', 'submit', array('accesskey' => 's')));
$this->Form->appendChild($div);
}
示例15: __viewEdit
public function __viewEdit()
{
$section_id = $this->_context[1];
if (!($section = SectionManager::fetch($section_id))) {
Administration::instance()->throwCustomError(__('The Section, %s, could not be found.', array($section_id)), __('Unknown Section'), Page::HTTP_STATUS_NOT_FOUND);
}
$meta = $section->get();
$section_id = $meta['id'];
$types = array();
$formHasErrors = is_array($this->_errors) && !empty($this->_errors);
if ($formHasErrors) {
$this->pageAlert(__('An error occurred while processing this form. See below for details.'), Alert::ERROR);
} else {
if (isset($this->_context[2])) {
switch ($this->_context[2]) {
case 'saved':
$this->pageAlert(__('Section updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/sections/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/sections/" accesskey="a">' . __('View all Sections') . '</a>', Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Section created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/sections/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/sections/" accesskey="a">' . __('View all Sections') . '</a>', Alert::SUCCESS);
break;
}
}
}
if (isset($_POST['fields'])) {
$fields = array();
if (is_array($_POST['fields']) && !empty($_POST['fields'])) {
foreach ($_POST['fields'] as $position => $data) {
if ($fields[$position] = FieldManager::create($data['type'])) {
$fields[$position]->setArray($data);
$fields[$position]->set('sortorder', $position);
}
}
}
} else {
$fields = FieldManager::fetch(NULL, $section_id);
$fields = array_values($fields);
}
if (isset($_POST['meta'])) {
$meta = $_POST['meta'];
$meta['hidden'] = isset($meta['hidden']) ? 'yes' : 'no';
if ($meta['name'] == '') {
$meta['name'] = $section->get('name');
}
}
$this->setPageType('form');
$this->setTitle(__('%1$s – %2$s – %3$s', array($meta['name'], __('Sections'), __('Symphony'))));
$this->appendSubheading($meta['name'], Widget::Anchor(__('View Entries'), SYMPHONY_URL . '/publish/' . $section->get('handle'), __('View Section Entries'), 'button'));
$this->insertBreadcrumbs(array(Widget::Anchor(__('Sections'), SYMPHONY_URL . '/blueprints/sections/')));
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Essentials')));
$div = new XMLElement('div', NULL, array('class' => 'two columns'));
$namediv = new XMLElement('div', NULL, array('class' => 'column'));
$label = Widget::Label(__('Name'));
$label->appendChild(Widget::Input('meta[name]', General::sanitize($meta['name'])));
if (isset($this->_errors['name'])) {
$namediv->appendChild(Widget::Error($label, $this->_errors['name']));
} else {
$namediv->appendChild($label);
}
$label = Widget::Label();
$input = Widget::Input('meta[hidden]', 'yes', 'checkbox', $meta['hidden'] == 'yes' ? array('checked' => 'checked') : NULL);
$label->setValue(__('%s Hide this section from the back-end menu', array($input->generate(false))));
$namediv->appendChild($label);
$div->appendChild($namediv);
$navgroupdiv = new XMLElement('div', NULL, array('class' => 'column'));
$sections = SectionManager::fetch(NULL, 'ASC', 'sortorder');
$label = Widget::Label(__('Navigation Group'));
$label->appendChild(Widget::Input('meta[navigation_group]', $meta['navigation_group']));
if (isset($this->_errors['navigation_group'])) {
$navgroupdiv->appendChild(Widget::Error($label, $this->_errors['navigation_group']));
} else {
$navgroupdiv->appendChild($label);
}
if (is_array($sections) && !empty($sections)) {
$ul = new XMLElement('ul', NULL, array('class' => 'tags singular'));
$groups = array();
foreach ($sections as $s) {
if (in_array($s->get('navigation_group'), $groups)) {
continue;
}
$ul->appendChild(new XMLElement('li', $s->get('navigation_group')));
$groups[] = $s->get('navigation_group');
}
$navgroupdiv->appendChild($ul);
}
$div->appendChild($navgroupdiv);
$fieldset->appendChild($div);
$this->Form->appendChild($fieldset);
/**
* Allows extensions to add elements to the header of the Section Editor
* form. Usually for section settings, this delegate is passed the current
* `$meta` array and the `$this->_errors` array.
*
* @delegate AddSectionElements
* @since Symphony 2.2
* @param string $context
* '/blueprints/sections/'
* @param XMLElement $form
//.........这里部分代码省略.........