本文整理汇总了PHP中DateTimeObj::getTimeAgo方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeObj::getTimeAgo方法的具体用法?PHP DateTimeObj::getTimeAgo怎么用?PHP DateTimeObj::getTimeAgo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeObj
的用法示例。
在下文中一共展示了DateTimeObj::getTimeAgo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
public function view()
{
// Ensure we have been set $_POST data from Members events
if (!array_key_exists('members', $_POST)) {
$this->_status = AjaxPage::STATUS_BAD;
return;
} else {
if (!is_writable(CONFIG)) {
$this->_status = AjaxPage::STATUS_BAD;
$this->_Result->appendChild(new XMLElement('message', __('The Symphony configuration file, <code>/manifest/config.php</code>, is not writable. You will not be able to save changes to preferences.')));
return;
}
}
$settings = $_POST['members'];
// Generate Recovery Code
if (isset($settings['generate-recovery-code-template'])) {
Symphony::Configuration()->set('generate-recovery-code-template', implode(',', array_filter($settings['generate-recovery-code-template'])), 'members');
} else {
if ($settings['event'] == 'generate-recovery-code') {
Symphony::Configuration()->remove('generate-recovery-code-template', 'members');
}
}
// Reset Password
if (isset($settings['reset-password-template'])) {
Symphony::Configuration()->set('reset-password-template', implode(',', array_filter($settings['reset-password-template'])), 'members');
} else {
if ($settings['event'] == 'reset-password') {
Symphony::Configuration()->remove('reset-password-template', 'members');
}
}
if ($settings['event'] == 'reset-password') {
Symphony::Configuration()->set('reset-password-auto-login', $settings['auto-login'], 'members');
}
// Regenerate Activation Code
if (isset($settings['regenerate-activation-code-template'])) {
Symphony::Configuration()->set('regenerate-activation-code-template', implode(',', array_filter($settings['regenerate-activation-code-template'])), 'members');
} else {
if ($settings['event'] == 'regenerate-activation-code') {
Symphony::Configuration()->remove('regenerate-activation-code-template', 'members');
}
}
// Activate Account
if (isset($settings['activate-account-template'])) {
Symphony::Configuration()->set('activate-account-template', implode(',', array_filter($settings['activate-account-template'])), 'members');
} else {
if ($settings['event'] == 'activate-account') {
Symphony::Configuration()->remove('activate-account-template', 'members');
}
}
if ($settings['event'] == 'activate-account') {
Symphony::Configuration()->set('activate-account-auto-login', $settings['auto-login'], 'members');
}
// Return successful
if (Administration::instance()->saveConfig()) {
$this->_status = AjaxPage::STATUS_OK;
$this->_Result->appendChild(new XMLElement('message', __('Preferences saved.')));
$this->_Result->appendChild(new XMLElement('timestamp', '<![CDATA[' . DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__) . ']]>'));
}
}
示例2: appendScriptToHead
public function appendScriptToHead($context)
{
$this->static_section_name = '';
$entryManager = new EntryManager($this->_Parent);
$sections = $this->_Parent->Database->fetch("SELECT section_id AS id, handle FROM tbl_fields_static_section LEFT JOIN tbl_sections ON tbl_fields_static_section.section_id = tbl_sections.id");
$this->section_data = array('handles' => array(), 'entries' => array());
foreach ($sections as $key => $value) {
$this->section_data['handles'][] = $value['handle'];
$result = $entryManager->fetch(NULL, $value['id'], NULL, NULL, NULL, NULL, false, false);
if (count($result) > 0) {
$this->section_data['entries'][] = $result[0]['id'];
} else {
$this->section_data['entries'][] = NULL;
}
}
$this->_page = Administration::instance()->Page;
$section_handle = $this->_page->_context['section_handle'];
$context = $this->_page->_context['page'];
$url_entry = $this->_page->_context['entry_id'];
$flag = $this->_page->_context['flag'];
if (isset($section_handle)) {
$section = $this->_Parent->Database->fetchRow(0, "SELECT id, name FROM tbl_sections WHERE handle='{$section_handle}'");
$field = $this->_Parent->Database->fetchRow(0, "SELECT id FROM tbl_fields_static_section WHERE section_id=" . $section['id']);
if ($field) {
$entry = $this->getSectionEntry($section_handle);
if ($context == 'new' && $entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/');
}
if ($context == 'index') {
if ($entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/');
} else {
redirect(URL . '/symphony/publish/' . $section_handle . '/new/');
}
}
if ($context == 'edit') {
if (!$entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/new/');
}
if ($url_entry != $entry) {
redirect(URL . '/symphony/publish/' . $section_handle . '/edit/' . $entry . '/');
}
}
if ($flag == 'saved' || $flag == 'created') {
$flag_msg = 'Entry updated at %1$s.';
if ($flag == 'created') {
$flag_msg = 'Entry created at %1$s.';
}
$this->_page->pageAlert(__($flag_msg, array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__))), Alert::SUCCESS);
}
$this->static_section_name = $section['name'];
}
}
}
示例3: view
public function view()
{
$about = array();
if ($this->_context[0] && !is_object($this->formatter)) {
$this->formatter = $this->_Parent->FormatterManager->create($this->_context[0]);
}
if (is_object($this->formatter)) {
$about = $this->_Parent->FormatterManager->about($this->_context[0]);
}
if ($_SESSION['templatedtextformatters-alert']) {
switch ($_SESSION['templatedtextformatters-alert']) {
case 'saved':
$this->pageAlert(__('Templated Text Formatter updated at %1$s. <a href="%2$s" accesskey="c">Create another?</a> <a href="%3$s" accesskey="a">View all Templated Text Formatters</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), SYMPHONY_URL . '/extension/templatedtextformatters/edit/', SYMPHONY_URL . '/extension/templatedtextformatters')), Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Templated Text Formatter created at %1$s. <a href="%2$s" accesskey="c">Create another?</a> <a href="%3$s" accesskey="a">View all Templated Text Formatters</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), SYMPHONY_URL . '/extension/templatedtextformatters/edit/', SYMPHONY_URL . '/extension/templatedtextformatters')), Alert::SUCCESS);
break;
}
unset($_SESSION['templatedtextformatters-alert']);
}
$fields = $_POST['fields'];
$this->setPageType('form');
$this->setTitle(__('%1$s – %2$s – %3$s', array(__('Symphony'), __('Templated Text Formatters'), $fields['name'] ? $fields['name'] : $about['name'])));
$this->appendSubheading($fields['name'] ? $fields['name'] : ($about['name'] ? $about['name'] : 'Untitled'));
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Essentials')));
$div = new XMLElement('div');
$div->setAttribute('class', 'group');
$label = Widget::Label(__('Name'));
if (isset($about['name'])) {
$label->appendChild(new XMLElement('i', __('Change will disconnect this formatter from any chains and/or fields it may have been added to!')));
}
$label->appendChild(Widget::Input('fields[name]', $fields['name'] ? $fields['name'] : $about['name']));
$div->appendChild(isset($this->_errors['name']) ? $this->wrapFormElementWithError($label, $this->_errors['name']) : $label);
$label = Widget::Label(__('Type'));
$types = $this->_driver->listTypes();
$options = array();
if ($about['templatedtextformatters-type']) {
$options[] = array($about['templatedtextformatters-type'], TRUE, $about['templatedtextformatters-type']);
} else {
foreach ($types as $t => $info) {
$options[] = array($t, $fields['type'] ? $fields['type'] == $t : FALSE, $info['name'] ? $info['name'] : $t);
}
}
$label->appendChild(Widget::Select('fields[type]', $options, array('id' => 'context')));
$div->appendChild($label);
$fieldset->appendChild($div);
$div = new XMLElement('div');
$label = Widget::Label(__('Description'));
$label->appendChild(new XMLElement('i', __('Optional')));
$label->appendChild(Widget::Input('fields[description]', General::sanitize(isset($fields['description']) ? $fields['description'] : $about['description'])));
$div->appendChild(isset($this->_errors['description']) ? $this->wrapFormElementWithError($label, $this->_errors['description']) : $label);
$fieldset->appendChild($div);
$this->Form->appendChild($fieldset);
if (is_object($this->formatter) && method_exists($this->formatter, 'ttf_form')) {
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Format Options')));
$this->formatter->ttf_form($fieldset, $this);
$this->Form->appendChild($fieldset);
}
if (is_object($this->formatter)) {
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Testing grounds')));
$p = new XMLElement('p', __('For now, You have to save changes each time You want to see updated output'));
$p->setAttribute('class', 'help');
$fieldset->appendChild($p);
$div = new XMLElement('div');
$div->setAttribute('class', 'group');
$label = Widget::Label(__('Test input'));
$label->appendChild(Widget::Textarea('fields[testin]', 5, 50, $fields['testin']));
$div->appendChild($label);
$label = Widget::Label(__('Test output'));
$temp = '';
if ($fields['testin']) {
$temp = $this->formatter->run($fields['testin']);
}
$label->appendChild(Widget::Textarea('fields[testout]', 5, 50, $temp));
$div->appendChild($label);
$fieldset->appendChild($div);
$this->Form->appendChild($fieldset);
}
$div = new XMLElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Input('action[save]', $about['handle'] ? __('Save Changes') : __('Create formatter'), 'submit', array('accesskey' => 's')));
if ($about['name']) {
$button = new XMLElement('button', __('Delete'));
$button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this formatter')));
$div->appendChild($button);
}
$this->Form->appendChild($div);
}
示例4: __viewEdit
public function __viewEdit()
{
$section_id = $this->_context[1];
$sectionManager = new SectionManager($this->_Parent);
if (!($section = $sectionManager->fetch($section_id))) {
$this->_Parent->customError(E_USER_ERROR, __('Unknown Section'), __('The Section you are looking for could not be found.'), false, true);
}
$meta = $section->get();
$fieldManager = new FieldManager($this->_Parent);
$types = array();
$formHasErrors = 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);
}
if (isset($this->_context[2])) {
switch ($this->_context[2]) {
case 'saved':
$this->pageAlert(__('Section updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Sections</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/sections/new/', URL . '/symphony/blueprints/sections/')), Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Section created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Sections</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/sections/new/', URL . '/symphony/blueprints/sections/')), 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);
}
$meta['subsection'] = $meta['subsection'] == 'yes' ? 1 : 0;
$meta['entry_order'] = isset($meta['entry_order']) ? $meta['entry_order'] : 'date';
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(__('Symphony'), __('Sections'), $meta['name'])));
$this->appendSubheading($meta['name']);
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Essentials')));
$div = new XMLElement('div', NULL, array('class' => 'group'));
$namediv = new XMLElement('div', NULL);
$label = Widget::Label('Name');
$label->appendChild(Widget::Input('meta[name]', $meta['name']));
if (isset($this->_errors['name'])) {
$namediv->appendChild(Widget::wrapFormElementWithError($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 Publish menu', array($input->generate(false))));
$namediv->appendChild($label);
$div->appendChild($namediv);
$navgroupdiv = new XMLElement('div', NULL);
$sectionManager = new SectionManager($this->_Parent);
$sections = $sectionManager->fetch(NULL, 'ASC', 'sortorder');
$label = Widget::Label(__('Navigation Group') . ' <i>' . __('Choose only one. Created if does not exist') . '</i>');
$label->appendChild(Widget::Input('meta[navigation_group]', $meta['navigation_group']));
if (isset($this->_errors['navigation_group'])) {
$navgroupdiv->appendChild(Widget::wrapFormElementWithError($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);
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Fields')));
$div = new XMLElement('div');
$h3 = new XMLElement('h3', __('Fields'));
$h3->setAttribute('class', 'label');
$div->appendChild($h3);
$ol = new XMLElement('ol');
$ol->setAttribute('id', 'fields-duplicator');
//.........这里部分代码省略.........
示例5: __viewEdit
public function __viewEdit()
{
if (!($section_id = SectionManager::fetchIDFromHandle($this->_context['section_handle']))) {
Administration::instance()->customError(__('Unknown Section'), __('The Section you are looking for, %s, could not be found.', array('<code>' . $this->_context['section_handle'] . '</code>')));
}
$section = SectionManager::fetch($section_id);
$entry_id = intval($this->_context['entry_id']);
EntryManager::setFetchSorting('id', 'DESC');
if (!($existingEntry = EntryManager::fetch($entry_id))) {
Administration::instance()->customError(__('Unknown Entry'), __('The entry you are looking for could not be found.'));
}
$existingEntry = $existingEntry[0];
// If there is post data floating around, due to errors, create an entry object
if (isset($_POST['fields'])) {
$fields = $_POST['fields'];
$entry =& EntryManager::create();
$entry->set('section_id', $existingEntry->get('section_id'));
$entry->set('id', $entry_id);
$entry->setDataFromPost($fields, $errors, true);
} else {
$entry = $existingEntry;
if (!$section) {
$section = SectionManager::fetch($entry->get('section_id'));
}
}
/**
* Just prior to rendering of an Entry edit form.
*
* @delegate EntryPreRender
* @param string $context
* '/publish/edit/'
* @param Section $section
* @param Entry $entry
* @param array $fields
*/
Symphony::ExtensionManager()->notifyMembers('EntryPreRender', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
if (isset($this->_context['flag'])) {
$link = 'publish/' . $this->_context['section_handle'] . '/new/';
list($flag, $field_id, $value) = preg_split('/:/i', $this->_context['flag'], 3);
if (isset($_REQUEST['prepopulate'])) {
$link .= '?';
foreach ($_REQUEST['prepopulate'] as $field_id => $value) {
$link .= "prepopulate[{$field_id}]={$value}&";
}
$link = preg_replace("/&\$/", '', $link);
}
// These flags are only relevant if there are no errors
if (empty($this->_errors)) {
switch ($flag) {
case 'saved':
$this->pageAlert(__('Entry updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/' . $link . '" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/" accesskey="a">' . __('View all Entries') . '</a>', Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Entry created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/' . $link . '" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/" accesskey="a">' . __('View all Entries') . '</a>', Alert::SUCCESS);
break;
}
}
}
// Determine the page title
$field_id = Symphony::Database()->fetchVar('id', 0, "SELECT `id` FROM `tbl_fields` WHERE `parent_section` = '" . $section->get('id') . "' ORDER BY `sortorder` LIMIT 1");
$field = FieldManager::fetch($field_id);
$title = trim(strip_tags($field->prepareTableValue($existingEntry->getData($field->get('id')), NULL, $entry_id)));
if (trim($title) == '') {
$title = __('Untitled');
}
// Check if there is a field to prepopulate
if (isset($_REQUEST['prepopulate'])) {
foreach ($_REQUEST['prepopulate'] as $field_id => $value) {
$this->Form->prependChild(Widget::Input("prepopulate[{$field_id}]", rawurlencode($value), 'hidden'));
}
}
$this->setPageType('form');
$this->Form->setAttribute('enctype', 'multipart/form-data');
$this->Form->setAttribute('class', 'two columns');
$this->setTitle(__('%1$s – %2$s – %3$s', array($title, $section->get('name'), __('Symphony'))));
// Only show the Edit Section button if the Author is a developer. #938 ^BA
if (Administration::instance()->Author->isDeveloper()) {
$this->appendSubheading($title, Widget::Anchor(__('Edit Section'), SYMPHONY_URL . '/blueprints/sections/edit/' . $section_id, __('Edit Section Configuration'), 'button'));
} else {
$this->appendSubheading($title);
}
$this->insertBreadcrumbs(array(Widget::Anchor($section->get('name'), SYMPHONY_URL . '/publish/' . $this->_context['section_handle'])));
$this->Form->appendChild(Widget::Input('MAX_FILE_SIZE', Symphony::Configuration()->get('max_upload_size', 'admin'), 'hidden'));
$primary = new XMLElement('fieldset');
$primary->setAttribute('class', 'primary column');
$sidebar_fields = $section->fetchFields(NULL, 'sidebar');
$main_fields = $section->fetchFields(NULL, 'main');
if ((!is_array($main_fields) || empty($main_fields)) && (!is_array($sidebar_fields) || empty($sidebar_fields))) {
$message = __('Fields must be added to this section before an entry can be created.');
if (Administration::instance()->Author->isDeveloper()) {
$message .= ' <a href="' . SYMPHONY_URL . '/blueprints/sections/edit/' . $section->get('id') . '/" accesskey="c">' . __('Add fields') . '</a>';
}
$this->pageAlert($message, Alert::ERROR);
} else {
if (is_array($main_fields) && !empty($main_fields)) {
foreach ($main_fields as $field) {
$primary->appendChild($this->__wrapFieldWithDiv($field, $entry));
}
$this->Form->appendChild($primary);
}
//.........这里部分代码省略.........
示例6: __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. <a href="#error">See below for details.</a>'), Alert::ERROR);
}
if (isset($this->_context[2])) {
switch ($this->_context[2]) {
case 'saved':
$this->pageAlert(__('Event updated at %1$s. <a href="%2$s" accesskey="c">Create another?</a> <a href="%3$s" accesskey="a">View all Events</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), SYMPHONY_URL . '/blueprints/events/new/', SYMPHONY_URL . '/blueprints/components/')), Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Event created at %1$s. <a href="%2$s" accesskey="c">Create another?</a> <a href="%3$s" accesskey="a">View all Events</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), SYMPHONY_URL . '/blueprints/events/new/', SYMPHONY_URL . '/blueprints/components/')), Alert::SUCCESS);
break;
}
}
$isEditing = $readonly ? true : false;
$fields = array();
$sectionManager = new SectionManager($this->_Parent);
if ($this->_context[0] == 'edit' || $this->_context[0] == 'info') {
$isEditing = true;
$handle = $this->_context[1];
$EventManager = new EventManager($this->_Parent);
$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();
$fields['filters'] = $existing->eParamFILTERS;
}
if (isset($_POST['fields'])) {
$fields = $_POST['fields'];
}
$this->setPageType('form');
$this->setTitle(__($isEditing ? '%1$s – %2$s – %3$s' : '%1$s – %2$s', array(__('Symphony'), __('Events'), $about['name'])));
$this->appendSubheading($isEditing ? $about['name'] : __('Untitled'));
if (!$readonly) {
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Essentials')));
$group = new XMLElement('div');
$group->setAttribute('class', 'group');
$label = Widget::Label(__('Name'));
$label->appendChild(Widget::Input('fields[name]', General::sanitize($fields['name'])));
$div = new XMLElement('div');
if (isset($this->_errors['name'])) {
$div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['name']));
} else {
$div->appendChild($label);
}
$group->appendChild($div);
$label = Widget::Label(__('Source'));
$sections = $sectionManager->fetch(NULL, 'ASC', 'name');
$options = array();
if (is_array($sections) && !empty($sections)) {
foreach ($sections as $s) {
$options[] = array($s->get('id'), $fields['source'] == $s->get('id'), General::sanitize($s->get('name')));
}
}
$label->appendChild(Widget::Select('fields[source]', $options, array('id' => 'context')));
$div = new XMLElement('div');
if (isset($this->_errors['source'])) {
$div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['source']));
} else {
$div->appendChild($label);
}
$group->appendChild($div);
$fieldset->appendChild($group);
$label = Widget::Label(__('Filter Options'));
$filters = is_array($fields['filters']) ? $fields['filters'] : array();
$options = array(array('admin-only', in_array('admin-only', $filters), __('Admin Only')), array('send-email', in_array('send-email', $filters), __('Send Notification Email')), array('expect-multiple', in_array('expect-multiple', $filters), __('Allow Multiple')));
/**
* Allows adding of new filter rules to the Event filter rule select box
*
* @delegate AppendEventFilter
* @param string $context
* '/blueprints/events/(edit|new|info)/'
* @param array $selected
* An array of all the selected filters for this Event
* @param array $options
* An array of all the filters that are available, passed by reference
*/
Symphony::ExtensionManager()->notifyMembers('AppendEventFilter', '/blueprints/events/' . $this->_context[0] . '/', array('selected' => $filters, 'options' => &$options));
$label->appendChild(Widget::Select('fields[filters][]', $options, array('multiple' => 'multiple')));
$fieldset->appendChild($label);
$this->Form->appendChild($fieldset);
}
if ($isEditing) {
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$doc = $existing->documentation();
$fieldset->setValue('<legend>' . __('Description') . '</legend>' . self::CRLF . General::tabsToSpaces(is_object($doc) ? $doc->generate(true) : $doc, 2));
$this->Form->appendChild($fieldset);
}
$div = new XMLElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Input('action[save]', $isEditing ? __('Save Changes') : __('Create Event'), 'submit', array('accesskey' => 's')));
if ($isEditing) {
//.........这里部分代码省略.........
示例7: __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)));
//.........这里部分代码省略.........
示例8: __viewEdit
public function __viewEdit()
{
$sectionManager = new SectionManager($this->_Parent);
if (!($section_id = $sectionManager->fetchIDFromHandle($this->_context['section_handle']))) {
Administration::instance()->customError(__('Unknown Section'), __('The Section you are looking for, <code>%s</code>, could not be found.', array($this->_context['section_handle'])));
}
$section = $sectionManager->fetch($section_id);
$entry_id = intval($this->_context['entry_id']);
$entryManager = new EntryManager($this->_Parent);
$entryManager->setFetchSorting('id', 'DESC');
if (!($existingEntry = $entryManager->fetch($entry_id))) {
Administration::instance()->customError(__('Unknown Entry'), __('The entry you are looking for could not be found.'));
}
$existingEntry = $existingEntry[0];
// If there is post data floating around, due to errors, create an entry object
if (isset($_POST['fields'])) {
$fields = $_POST['fields'];
$entry =& $entryManager->create();
$entry->set('section_id', $existingEntry->get('section_id'));
$entry->set('id', $entry_id);
$entry->setDataFromPost($fields, $error, true);
} else {
$entry = $existingEntry;
if (!$section) {
$section = $sectionManager->fetch($entry->get('section_id'));
}
}
/**
* Just prior to rendering of an Entry edit form.
*
* @delegate EntryPreRender
* @param string $context
* '/publish/new/'
* @param Section $section
* @param Entry $entry
* @param array $fields
*/
Symphony::ExtensionManager()->notifyMembers('EntryPreRender', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
if (isset($this->_context['flag'])) {
$link = 'publish/' . $this->_context['section_handle'] . '/new/';
list($flag, $field_id, $value) = preg_split('/:/i', $this->_context['flag'], 3);
if (is_numeric($field_id) && $value) {
$link .= "?prepopulate[{$field_id}]={$value}";
$this->Form->prependChild(Widget::Input("prepopulate[{$field_id}]", rawurlencode($value), 'hidden'));
}
switch ($flag) {
case 'saved':
$this->pageAlert(__('Entry updated at %1$s. <a href="%2$s" accesskey="c">Create another?</a> <a href="%3$s" accesskey="a">View all Entries</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), SYMPHONY_URL . "/{$link}", SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/')), Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Entry created at %1$s. <a href="%2$s" accesskey="c">Create another?</a> <a href="%3$s" accesskey="a">View all Entries</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), SYMPHONY_URL . "/{$link}", SYMPHONY_URL . '/publish/' . $this->_context['section_handle'] . '/')), Alert::SUCCESS);
break;
}
}
### Determine the page title
$field_id = Symphony::Database()->fetchVar('id', 0, "SELECT `id` FROM `tbl_fields` WHERE `parent_section` = '" . $section->get('id') . "' ORDER BY `sortorder` LIMIT 1");
$field = $entryManager->fieldManager->fetch($field_id);
$title = trim(strip_tags($field->prepareTableValue($existingEntry->getData($field->get('id')), NULL, $entry_id)));
if (trim($title) == '') {
$title = 'Untitled';
}
// Check if there is a field to prepopulate
if (isset($_REQUEST['prepopulate'])) {
$field_id = array_shift(array_keys($_REQUEST['prepopulate']));
$value = stripslashes(rawurldecode(array_shift($_REQUEST['prepopulate'])));
$this->Form->prependChild(Widget::Input("prepopulate[{$field_id}]", rawurlencode($value), 'hidden'));
}
$this->setPageType('form');
$this->Form->setAttribute('enctype', 'multipart/form-data');
$this->setTitle(__('%1$s – %2$s – %3$s', array(__('Symphony'), $section->get('name'), $title)));
$this->appendSubheading($title);
$this->Form->appendChild(Widget::Input('MAX_FILE_SIZE', Symphony::Configuration()->get('max_upload_size', 'admin'), 'hidden'));
###
$primary = new XMLElement('fieldset');
$primary->setAttribute('class', 'primary');
$sidebar_fields = $section->fetchFields(NULL, 'sidebar');
$main_fields = $section->fetchFields(NULL, 'main');
if ((!is_array($main_fields) || empty($main_fields)) && (!is_array($sidebar_fields) || empty($sidebar_fields))) {
$primary->appendChild(new XMLElement('p', __('It looks like you\'re trying to create an entry. Perhaps you want fields first? <a href="%s">Click here to create some.</a>', array(SYMPHONY_URL . '/blueprints/sections/edit/' . $section->get('id') . '/'))));
} else {
if (is_array($main_fields) && !empty($main_fields)) {
foreach ($main_fields as $field) {
$primary->appendChild($this->__wrapFieldWithDiv($field, $entry));
}
$this->Form->appendChild($primary);
}
if (is_array($sidebar_fields) && !empty($sidebar_fields)) {
$sidebar = new XMLElement('fieldset');
$sidebar->setAttribute('class', 'secondary');
foreach ($sidebar_fields as $field) {
$sidebar->appendChild($this->__wrapFieldWithDiv($field, $entry));
}
$this->Form->appendChild($sidebar);
}
}
$div = new XMLElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's')));
$button = new XMLElement('button', __('Delete'));
$button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this entry'), 'type' => 'submit', 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this entry?')));
//.........这里部分代码省略.........
示例9: __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
//.........这里部分代码省略.........
示例10: __viewEdit
function __viewEdit()
{
$sectionManager = new SectionManager($this->_Parent);
if (!($section_id = $sectionManager->fetchIDFromHandle($this->_context['section_handle']))) {
$this->_Parent->customError(E_USER_ERROR, __('Unknown Section'), __('The Section you are looking for, <code>%s</code>, could not be found.', array($this->_context['section_handle'])), false, true);
}
$section = $sectionManager->fetch($section_id);
$entry_id = intval($this->_context['entry_id']);
$entryManager = new EntryManager($this->_Parent);
$entryManager->setFetchSorting('id', 'DESC');
if (!($existingEntry = $entryManager->fetch($entry_id))) {
$this->_Parent->customError(E_USER_ERROR, __('Unknown Entry'), __('The entry you are looking for could not be found.'), false, true);
}
$existingEntry = $existingEntry[0];
// If there is post data floating around, due to errors, create an entry object
if (isset($_POST['fields'])) {
$fields = $_POST['fields'];
$entry =& $entryManager->create();
$entry->set('section_id', $existingEntry->get('section_id'));
$entry->set('id', $entry_id);
$entry->setDataFromPost($fields, $error, true);
} else {
$entry = $existingEntry;
if (!$section) {
$section = $sectionManager->fetch($entry->get('section_id'));
}
}
if (isset($this->_context['flag'])) {
$link = 'publish/' . $this->_context['section_handle'] . '/new/';
list($flag, $field_id, $value) = preg_split('/:/i', $this->_context['flag'], 3);
if (is_numeric($field_id) && $value) {
$link .= "?prepopulate[{$field_id}]={$value}";
}
switch ($flag) {
case 'saved':
$this->pageAlert(__('Entry updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Entries</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . "/symphony/{$link}", URL . '/symphony/publish/' . $this->_context['section_handle'] . '/')), Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Entry created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Entries</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . "/symphony/{$link}", URL . '/symphony/publish/' . $this->_context['section_handle'] . '/')), Alert::SUCCESS);
break;
}
}
### Determine the page title
$field_id = $this->_Parent->Database->fetchVar('id', 0, "SELECT `id` FROM `tbl_fields` WHERE `parent_section` = '" . $section->get('id') . "' ORDER BY `sortorder` LIMIT 1");
$field = $entryManager->fieldManager->fetch($field_id);
$title = trim(strip_tags($field->prepareTableValue($existingEntry->getData($field->get('id')), NULL, $entry_id)));
if (trim($title) == '') {
$title = 'Untitled';
}
$this->setPageType('form');
$this->Form->setAttribute('enctype', 'multipart/form-data');
$this->setTitle(__('%1$s – %2$s – %3$s', array(__('Symphony'), $section->get('name'), $title)));
$this->appendSubheading($title);
$this->Form->appendChild(Widget::Input('MAX_FILE_SIZE', $this->_Parent->Configuration->get('max_upload_size', 'admin'), 'hidden'));
###
$primary = new XMLElement('fieldset');
$primary->setAttribute('class', 'primary');
$sidebar_fields = $section->fetchFields(NULL, 'sidebar');
$main_fields = $section->fetchFields(NULL, 'main');
if ((!is_array($main_fields) || empty($main_fields)) && (!is_array($sidebar_fields) || empty($sidebar_fields))) {
$primary->appendChild(new XMLElement('p', __('It looks like your trying to create an entry. Perhaps you want custom fields first? <a href="%s">Click here to create some.</a>', array(URL . '/symphony/blueprints/sections/edit/' . $section->get('id') . '/'))));
} else {
if (is_array($main_fields) && !empty($main_fields)) {
foreach ($main_fields as $field) {
$primary->appendChild($this->__wrapFieldWithDiv($field, $entry));
}
$this->Form->appendChild($primary);
}
if (is_array($sidebar_fields) && !empty($sidebar_fields)) {
$sidebar = new XMLElement('fieldset');
$sidebar->setAttribute('class', 'secondary');
foreach ($sidebar_fields as $field) {
$sidebar->appendChild($this->__wrapFieldWithDiv($field, $entry));
}
$this->Form->appendChild($sidebar);
}
}
$div = new XMLElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's')));
$button = new XMLElement('button', __('Delete'));
$button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this entry')));
$div->appendChild($button);
$this->Form->appendChild($div);
}
示例11: __viewEdit
public function __viewEdit()
{
$layout = new Layout();
$left = $layout->createColumn(Layout::LARGE);
$right = $layout->createColumn(Layout::SMALL);
$this->_existing_file = isset($this->_context[1]) ? $this->_context[1] . '.xsl' : NULL;
## Handle unknown context
if (!in_array($this->_context[0], array('new', 'edit'))) {
throw new AdministrationPageNotFoundException();
}
## Edit Utility context
if ($this->_context[0] == 'edit') {
$file_abs = UTILITIES . '/' . $this->_existing_file;
$filename = $this->_existing_file;
if (!is_file($file_abs) && !is_readable($file_abs)) {
redirect(ADMIN_URL . '/blueprints/utilities/new/');
}
$fields['name'] = $filename;
$fields['template'] = file_get_contents($file_abs);
$this->Form->setAttribute('action', ADMIN_URL . '/blueprints/utilities/edit/' . $this->_context[1] . '/');
} else {
$fields['name'] = '';
$fields['template'] = file_get_contents(TEMPLATES . '/template.utility.txt');
$filename = '';
}
$formHasErrors = $this->errors->valid();
if ($formHasErrors) {
$this->alerts()->append(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), AlertStack::ERROR);
}
if (isset($this->_context[2])) {
switch ($this->_context[2]) {
case 'saved':
$this->alerts()->append(__('Utility updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/utilities/new/', ADMIN_URL . '/blueprints/utilities/')), AlertStack::SUCCESS);
break;
case 'created':
$this->alerts()->append(__('Utility created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/utilities/new/', ADMIN_URL . '/blueprints/utilities/')), AlertStack::SUCCESS);
break;
}
}
$this->setTitle(__($this->_context[0] == 'new' ? '%1$s – %2$s' : '%1$s – %2$s – %3$s', array(__('Symphony'), __('Utilities'), $filename)));
$this->appendSubheading($this->_context[0] == 'new' ? __('New Utility') : $filename);
if (!empty($_POST)) {
$fields = $_POST['fields'];
}
$fieldset = Widget::Fieldset(__('Essentials'));
$label = Widget::Label(__('Name'));
$label->appendChild(Widget::Input('fields[name]', $fields['name']));
$fieldset->appendChild(isset($this->errors->name) ? Widget::wrapFormElementWithError($label, $this->errors->name) : $label);
$label = Widget::Label(__('XSLT'));
$label->appendChild(Widget::Textarea('fields[template]', $fields['template'], array('rows' => 30, 'cols' => 80, 'class' => 'code')));
$fieldset->appendChild(isset($this->errors->template) ? Widget::wrapFormElementWithError($label, $this->errors->template) : $label);
$left->appendChild($fieldset);
$utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
$utilities = $utilities['filelist'];
if (is_array($utilities) && !empty($utilities)) {
$fieldset = Widget::Fieldset(__('Utilities'));
$ul = $this->createElement('ul');
$ul->setAttribute('id', 'utilities');
$i = 0;
foreach ($utilities as $util) {
$li = $this->createElement('li');
if ($i++ % 2 != 1) {
$li->setAttribute('class', 'odd');
}
$li->appendChild(Widget::Anchor($util, ADMIN_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', array()));
$ul->appendChild($li);
}
$fieldset->appendChild($ul);
$right->appendChild($fieldset);
}
$layout->appendTo($this->Form);
$div = $this->createElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Submit('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Utility'), array('accesskey' => 's')));
if ($this->_context[0] == 'edit') {
$div->appendChild(Widget::Submit('action[delete]', __('Delete'), array('class' => 'confirm delete', 'title' => __('Delete this utility'))));
}
$this->Form->appendChild($div);
}
示例12: __form
public function __form()
{
$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(__('Data source updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/datasources/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/datasources/" accesskey="a">' . __('View all Data sources') . '</a>', Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Data source created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/datasources/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/datasources/" accesskey="a">' . __('View all Data sources') . '</a>', Alert::SUCCESS);
break;
}
}
}
$providers = Symphony::ExtensionManager()->getProvidersOf('data-sources');
if (isset($_POST['fields'])) {
$fields = $_POST['fields'];
$fields['paginate_results'] = $fields['paginate_results'] == 'on' ? 'yes' : 'no';
if (!in_array($fields['source'], array('authors', 'navigation', 'dynamic_xml', 'static_xml')) && is_array($fields['filter']) && !empty($fields['filter'])) {
$filters = array();
foreach ($fields['filter'] as $f) {
foreach ($f as $key => $val) {
$filters[$key] = $val;
}
}
$fields['filter'][$fields['source']] = $filters;
}
if (!isset($fields['xml_elements']) || !is_array($fields['xml_elements'])) {
$fields['xml_elements'] = array();
}
} else {
if ($this->_context[0] == 'edit') {
$isEditing = true;
$handle = $this->_context[1];
$existing =& DatasourceManager::create($handle, array(), false);
$cache_id = null;
if (!$existing->allowEditorToParse()) {
redirect(SYMPHONY_URL . '/blueprints/datasources/info/' . $handle . '/');
}
$about = $existing->about();
$cache = new Cacheable(Symphony::Database());
$fields['name'] = $about['name'];
$fields['order'] = $existing->dsParamORDER == 'rand' ? 'random' : $existing->dsParamORDER;
$fields['param'] = $existing->dsParamPARAMOUTPUT;
$fields['required_url_param'] = trim($existing->dsParamREQUIREDPARAM);
if (isset($existing->dsParamINCLUDEDELEMENTS) && is_array($existing->dsParamINCLUDEDELEMENTS)) {
$fields['xml_elements'] = $existing->dsParamINCLUDEDELEMENTS;
} else {
$fields['xml_elements'] = array();
}
$fields['sort'] = $existing->dsParamSORT;
$fields['paginate_results'] = isset($existing->dsParamPAGINATERESULTS) ? $existing->dsParamPAGINATERESULTS : 'yes';
$fields['page_number'] = $existing->dsParamSTARTPAGE;
$fields['group'] = isset($existing->dsParamGROUP) ? $existing->dsParamGROUP : null;
$fields['html_encode'] = isset($existing->dsParamHTMLENCODE) ? $existing->dsParamHTMLENCODE : 'no';
$fields['associated_entry_counts'] = $existing->dsParamASSOCIATEDENTRYCOUNTS;
if (is_null($fields['associated_entry_counts'])) {
$fields['associated_entry_counts'] = 'yes';
}
if ($existing->dsParamREDIRECTONEMPTY == 'yes') {
$fields['redirect_on_empty'] = 'yes';
}
if (!is_array($existing->dsParamFILTERS)) {
$existing->dsParamFILTERS = array();
}
if (!empty($existing->dsParamFILTERS)) {
$existing->dsParamFILTERS = array_map('stripslashes', $existing->dsParamFILTERS);
}
$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 == false) {
switch ($fields['source']) {
case 'authors':
$fields['filter']['author'] = $existing->dsParamFILTERS;
break;
case 'navigation':
$fields['filter']['navigation'] = $existing->dsParamFILTERS;
break;
case 'dynamic_xml':
$fields['dynamic_xml']['namespace'] = $existing->dsParamFILTERS;
$fields['dynamic_xml']['url'] = $existing->dsParamURL;
$fields['dynamic_xml']['xpath'] = $existing->dsParamXPATH;
$fields['dynamic_xml']['cache'] = $existing->dsParamCACHE;
$fields['dynamic_xml']['timeout'] = isset($existing->dsParamTIMEOUT) ? $existing->dsParamTIMEOUT : 6;
break;
case 'static_xml':
$existing->grab();
if (!isset($existing->dsParamSTATIC)) {
//.........这里部分代码省略.........
示例13: __viewForm
protected function __viewForm()
{
// Show page alert:
if ($this->failed) {
$this->alerts()->append(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), AlertStack::ERROR);
} else {
if (!is_null($this->status)) {
switch ($this->status) {
case 'saved':
$this->alerts()->append(__('Data source updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/datasources/new/', ADMIN_URL . '/blueprints/datasources/')), AlertStack::SUCCESS);
break;
case 'created':
$this->alerts()->append(__('Data source created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/datasources/new/', ADMIN_URL . '/blueprints/datasources/')), AlertStack::SUCCESS);
break;
}
}
}
if (!$this->datasource instanceof Datasource || is_null($this->datasource->about()->name) || strlen(trim($this->datasource->about()->name)) == 0) {
$this->setTitle(__('%1$s – %2$s – %3$s', array(__('Symphony'), __('Data Sources'), __('Untitled'))));
$this->appendSubheading(General::sanitize(__('Data Source')));
} else {
$this->setTitle(__('%1$s – %2$s – %3$s', array(__('Symphony'), __('Data Sources'), $this->datasource->about()->name)));
$this->appendSubheading(General::sanitize($this->datasource->about()->name));
}
// Track type with a hidden field:
if ($this->editing || $this->editing && isset($_POST['type'])) {
$input = Widget::Input('type', $this->type, 'hidden');
$this->Form->appendChild($input);
} else {
$header = $this->xpath('//h2')->item(0);
$options = array();
foreach ($this->types as $type) {
$options[] = array($type->class, $this->type == $type->class, $type->name);
}
usort($options, 'General::optionsSort');
$select = Widget::Select('type', $options);
$header->prependChild($select);
$header->prependChild(new DOMText(__('New')));
}
if ($this->datasource instanceof Datasource) {
$this->datasource->view($this->Form, $this->errors);
}
$actions = $this->createElement('div');
$actions->setAttribute('class', 'actions');
$save = Widget::Submit('action[save]', $this->editing ? __('Save Changes') : __('Create Data Source'), array('accesskey' => 's'));
if (!$this->datasource instanceof Datasource) {
$save->setAttribute('disabled', 'disabled');
}
$actions->appendChild($save);
if ($this->editing == true) {
$actions->appendChild(Widget::Submit('action[delete]', __('Delete'), array('class' => 'confirm delete', 'title' => __('Delete this data source'))));
}
$this->Form->appendChild($actions);
}
示例14: view
public function view()
{
if (!($role_id = $this->_context[0])) {
redirect(extension_members::baseURL());
}
if (!($existing = $this->_driver->fetchRole($role_id, true))) {
throw new SymphonyErrorPage(__('The role you requested to edit does not exist.'), __('Role not found'), 'error');
}
if (isset($this->_context[1])) {
switch ($this->_context[1]) {
case 'saved':
$this->pageAlert(__('Role updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Roles</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), extension_members::baseURL() . 'roles_new/', extension_members::baseURL() . 'roles/')), Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Role created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Roles</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), extension_members::baseURL() . 'roles_new/', extension_members::baseURL() . 'roles/')), Alert::SUCCESS);
break;
}
}
Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 9125341);
Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/members/assets/jquery-ui.css', 'screen', 9125342);
Administration::instance()->Page->addScriptToHead(URL . '/extensions/members/assets/jquery-ui.js', 9126342);
Administration::instance()->Page->addScriptToHead(URL . '/extensions/members/assets/members.js', 9126343);
$formHasErrors = 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>'), AdministrationPage::PAGE_ALERT_ERROR);
}
$this->setPageType('form');
$this->setTitle('Symphony – Member Roles – ' . $existing->name());
$this->appendSubheading($existing->name());
$fields = array();
if (isset($_POST['fields'])) {
$fields = $_POST['fields'];
} else {
$fields['name'] = $existing->name();
$fields['permissions'] = $existing->eventPermissions();
$fields['page_access'] = $existing->forbiddenPages();
}
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings type-file');
$fieldset->appendChild(new XMLElement('legend', 'Essentials'));
$label = Widget::Label('Name');
$label->appendChild(Widget::Input('fields[name]', General::sanitize($fields['name'])));
if (isset($this->_errors['name'])) {
$fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['name']));
} else {
$fieldset->appendChild($label);
}
$this->Form->appendChild($fieldset);
$EventManager = new EventManager($this->_Parent);
$events = $EventManager->listAll();
if (is_array($events) && !empty($events)) {
foreach ($events as $handle => $e) {
$show_in_role_permissions = method_exists("event{$handle}", 'showInRolePermissions') && call_user_func(array("event{$handle}", 'showInRolePermissions')) === true ? true : false;
if (!$e['can_parse'] && !$show_in_role_permissions) {
unset($events[$handle]);
}
}
}
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings type-file');
$fieldset->appendChild(new XMLElement('legend', 'Event Level Permissions'));
$aTableHead = array(array('Event', 'col'), array('Create', 'col'), array('Edit', 'col'));
$aTableBody = array();
/*
<tr class="global">
<td>Set Global Permissions</td>
<td class="add">
<input type="checkbox" name="add-global" value="no"/>
</td>
<td class="edit">
<p class="global-slider"></p>
<span>n/a</span>
</td>
<!--<td class="delete">
<p class="global-slider"></p>
<span>n/a</span>
</td>-->
</tr>
*/
## Setup each cell
$td1 = Widget::TableData('Global Permissions');
$td2 = Widget::TableData(Widget::Input('global-add', '1', 'checkbox'), 'add');
$td3 = Widget::TableData(NULL, 'edit');
$td3->appendChild(new XMLElement('p', NULL, array('class' => 'global-slider')));
$td3->appendChild(new XMLElement('span', 'n/a'));
$td4 = Widget::TableData(NULL, 'delete');
$td4->appendChild(new XMLElement('p', NULL, array('class' => 'global-slider')));
$td4->appendChild(new XMLElement('span', 'n/a'));
## Add a row to the body array, assigning each cell to the row
$aTableBody[] = Widget::TableRow(array($td1, $td2, $td3), 'global');
//, $td4
if (is_array($events) && !empty($events)) {
foreach ($events as $event_handle => $event) {
$permissions = $fields['permissions'][$event_handle];
## Setup each cell
$td1 = Widget::TableData($event['name']);
$td2 = Widget::TableData(Widget::Input("fields[permissions][{$event_handle}][create]", '1', 'checkbox', $permissions['create'] == 1 ? array('checked' => 'checked') : NULL), 'add');
$td3 = Widget::TableData(NULL, 'edit');
$td3->appendChild(new XMLElement('p', NULL, array('class' => 'slider')));
$span = new XMLElement('span');
//.........这里部分代码省略.........
示例15: __actionIndex
public function __actionIndex()
{
if (@isset($_POST['action']['save'])) {
// extract the settings
$settings = @$_POST['settings'];
// extract all the pages
$this->_pages = $this->__getPages();
// create an empty datasource array for each page
$page_datasources = array();
foreach ($this->_pages as $page) {
$page_datasources[$page['id']] = array();
}
// loop through the datasources and add to each page
foreach ($settings as $datasource => $pages) {
foreach ($pages as $page) {
$page_datasources[$page][] = $datasource;
}
}
// loop through the final datasources and add to the database
$error = false;
foreach ($page_datasources as $page => $datasources) {
// create the fields to be updated
$fields = array('data_sources' => @implode(',', $datasources));
// update the fields
if (!Symphony::Database()->update($fields, 'tbl_pages', "`id` = '{$page}'")) {
$error = true;
break;
}
}
// show the success message
if (!$error) {
$this->pageAlert(__('Datasources updated at %1$s.', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__))), Alert::SUCCESS);
return;
}
// show the error message
$this->pageAlert(__('Unknown errors occurred while attempting to save. Please check your <a href="%s">activity log</a>.', array(URL . '/symphony/system/log/')), Alert::ERROR);
}
}