当前位置: 首页>>代码示例>>PHP>>正文


PHP Widget::Time方法代码示例

本文整理汇总了PHP中Widget::Time方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::Time方法的具体用法?PHP Widget::Time怎么用?PHP Widget::Time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Widget的用法示例。


在下文中一共展示了Widget::Time方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: view

 public function view()
 {
     // Ensure we have been set $_POST data from Members events
     if (!array_key_exists('members', $_POST)) {
         $this->setHttpStatus(self::HTTP_STATUS_BAD_REQUEST);
         return;
     } else {
         if (!is_writable(CONFIG)) {
             $this->setHttpStatus(self::HTTP_STATUS_ERROR);
             $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 (Symphony::Configuration()->write()) {
         $this->setHttpStatus(self::HTTP_STATUS_OK);
         $this->_Result->appendChild(new XMLElement('message', __('Preferences saved.')));
         $this->_Result->appendChild(new XMLElement('timestamp', '<![CDATA[' . Widget::Time(null, __SYM_TIME_FORMAT__)->generate() . ']]>'));
     }
 }
开发者ID:andrewminton,项目名称:members,代码行数:59,代码来源:content.events.php

示例2: __viewIndex

 public function __viewIndex()
 {
     $this->driver = ExtensionManager::create('globalresourceloader');
     $bIsWritable = true;
     if (!is_writable(CONFIG)) {
         $this->pageAlert(__('The Symphony configuration file, %s, is not writable. You will not be able to save changes to preferences.', array('<code>/manifest/config.php</code>')), Alert::ERROR);
         $bIsWritable = false;
     }
     if (isset($this->_context[1]) == 'saved') {
         $this->pageAlert(__('Global Resource Loader settings updated at %s.', array(Widget::Time()->generate())), Alert::SUCCESS);
     }
     $this->setPageType('form');
     $this->setTitle('Symphony &ndash; ' . __('Global Resources'));
     $this->appendSubheading(__('Global Resources'));
     // Events --------------------------------------------------------
     $container = new XMLElement('fieldset');
     $container->setAttribute('class', 'settings');
     $container->appendChild(new XMLElement('legend', __('Events')));
     $group = new XMLElement('div');
     $group->setAttribute('class', 'two columns');
     $this->__viewIndexEventNames($group);
     $this->__viewIndexEventPages($group);
     $container->appendChild($group);
     $this->Form->appendChild($container);
     // Datasources --------------------------------------------------------
     $container = new XMLElement('fieldset');
     $container->setAttribute('class', 'settings');
     $container->appendChild(new XMLElement('legend', __('Datasources')));
     $group = new XMLElement('div');
     $group->setAttribute('class', 'two columns');
     $this->__viewIndexDSNames($group);
     $this->__viewIndexDSPages($group);
     $container->appendChild($group);
     $this->Form->appendChild($container);
     //---------------------------------------------------------------------
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $attr = array('accesskey' => 's');
     if (!$bIsWritable) {
         $attr['disabled'] = 'disabled';
     }
     $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', $attr));
     $this->Form->appendChild($div);
 }
开发者ID:symphonists,项目名称:globalresourceloader,代码行数:44,代码来源:content.preferences.php

示例3: __viewEdit

 public function __viewEdit()
 {
     $this->doTheEdit();
     if (!($role_id = $this->_context[1])) {
         redirect(Extension_Sections_Event::baseURL() . 'permissions/');
     }
     if (!($existing = RoleManager::fetch($role_id))) {
         throw new SymphonyErrorPage(__('The role you requested to edit does not exist.'), __('Role not found'), 'error');
     }
     // check if sections exist
     $sections = SectionManager::fetch();
     if (!is_array($sections) || empty($sections)) {
         return $this->Form->appendChild($this->buildErrorMessage(__('No sections found. <a href="%s">Create a new one?</a>', array(SYMPHONY_URL . '/blueprints/sections/new/'))));
     }
     // Add in custom assets
     Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/sections_event/assets/sections_event.permissions_single.css', 'screen', 111);
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/sections_event/assets/sections_event.permissions_single.js', 114);
     // Append any Page Alerts from the form's
     if (isset($this->_context[2])) {
         switch ($this->_context[2]) {
             case 'saved':
                 $this->pageAlert(__('Role permissions updated at %1$s. <a href="%2$s" accesskey="a">View all Roles</a>', array($time = Widget::Time('', __SYM_TIME_FORMAT__)->generate(), Extension_Sections_Event::baseURL() . 'permissions/')), Alert::SUCCESS);
                 break;
         }
     }
     $this->setPageType('form');
     $this->setTitle(__('Symphony &ndash; Section permissions &ndash; ') . $existing->get('name'));
     $this->appendSubheading($existing->get('name'));
     if (isset($_POST['permissions'])) {
         $permissions = $_POST['permissions'];
     } else {
         $permissions = array();
         $permissions['fields'] = SE_PerMan::getCrud('field')->fetchAll($role_id);
         $permissions['sections'] = SE_PerMan::getCrud('section')->fetchAll($role_id);
     }
     $this->insertBreadcrumbs(array(Widget::Anchor(__('Section permissions'), Extension_Sections_Event::baseURL() . 'permissions/')));
     $div = new XMLElement('div', null, array('class' => 'permissions clearfix'));
     $div->appendChild($this->buildSectionPermissions($role_id, $permissions));
     $div->appendChild($this->buildFieldPermissions($role_id, $permissions));
     $this->Form->appendChild($div);
     $this->Form->appendChild($this->buildActions());
 }
开发者ID:andrewminton,项目名称:sections_event,代码行数:42,代码来源:content.permissions.php

示例4: __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);
         // 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':
                 $message = __('Data Source updated at %s.', array($time->generate()));
                 break;
             case 'created':
                 $message = __('Data Source created at %s.', array($time->generate()));
         }
         $this->pageAlert($message . ' <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);
     }
     $providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::DATASOURCE);
     $isEditing = false;
     $about = $handle = null;
     $fields = array('name' => null, 'source' => null, 'filter' => null, 'required_url_param' => null, 'negate_url_param' => null, 'param' => null);
     if (isset($_POST['fields'])) {
         $fields = $_POST['fields'];
         if (!in_array($fields['source'], array('authors', 'navigation', 'static_xml')) && !empty($fields['filter']) && is_array($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();
         }
         if ($this->_context[0] == 'edit') {
             $isEditing = true;
         }
     } elseif ($this->_context[0] == 'edit') {
         $isEditing = true;
         $handle = $this->_context[1];
         $existing = DatasourceManager::create($handle, array(), false);
         $order = isset($existing->dsParamORDER) ? $existing->dsParamORDER : 'asc';
         if (!$existing->allowEditorToParse()) {
             redirect(SYMPHONY_URL . '/blueprints/datasources/info/' . $handle . '/');
         }
         $about = $existing->about();
         $fields['name'] = $about['name'];
         $fields['order'] = $order == 'rand' ? 'random' : $order;
         $fields['param'] = isset($existing->dsParamPARAMOUTPUT) ? $existing->dsParamPARAMOUTPUT : null;
         $fields['required_url_param'] = isset($existing->dsParamREQUIREDPARAM) ? trim($existing->dsParamREQUIREDPARAM) : null;
         $fields['negate_url_param'] = isset($existing->dsParamNEGATEPARAM) ? trim($existing->dsParamNEGATEPARAM) : null;
         if (isset($existing->dsParamINCLUDEDELEMENTS) && is_array($existing->dsParamINCLUDEDELEMENTS)) {
             $fields['xml_elements'] = $existing->dsParamINCLUDEDELEMENTS;
         } else {
             $fields['xml_elements'] = array();
         }
         $fields['sort'] = isset($existing->dsParamSORT) ? $existing->dsParamSORT : null;
         $fields['paginate_results'] = isset($existing->dsParamPAGINATERESULTS) ? $existing->dsParamPAGINATERESULTS : 'yes';
         $fields['page_number'] = isset($existing->dsParamSTARTPAGE) ? $existing->dsParamSTARTPAGE : '1';
         $fields['group'] = isset($existing->dsParamGROUP) ? $existing->dsParamGROUP : null;
         $fields['html_encode'] = isset($existing->dsParamHTMLENCODE) ? $existing->dsParamHTMLENCODE : 'no';
         $fields['associated_entry_counts'] = isset($existing->dsParamASSOCIATEDENTRYCOUNTS) ? $existing->dsParamASSOCIATEDENTRYCOUNTS : 'no';
         $fields['redirect_on_empty'] = isset($existing->dsParamREDIRECTONEMPTY) ? $existing->dsParamREDIRECTONEMPTY : 'no';
         $fields['redirect_on_forbidden'] = isset($existing->dsParamREDIRECTONFORBIDDEN) ? $existing->dsParamREDIRECTONFORBIDDEN : 'no';
         $fields['redirect_on_required'] = isset($existing->dsParamREDIRECTONREQUIRED) ? $existing->dsParamREDIRECTONREQUIRED : 'no';
         if (!isset($existing->dsParamFILTERS) || !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 'static_xml':
                     // Symphony 2.3+
                     if (isset($existing->dsParamSTATIC)) {
                         $fields['static_xml'] = trim($existing->dsParamSTATIC);
                         // Handle Symphony 2.2.2 to 2.3 DS's
                     } elseif (isset($existing->dsSTATIC)) {
                         $fields['static_xml'] = trim($existing->dsSTATIC);
                         // Handle pre Symphony 2.2.1 Static DS's
                     } else {
//.........这里部分代码省略.........
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:101,代码来源:content.blueprintsdatasources.php

示例5: __viewEdit

 public function __viewEdit()
 {
     if (!($section_id = SectionManager::fetchIDFromHandle($this->_context['section_handle']))) {
         Administration::instance()->throwCustomError(__('The Section, %s, could not be found.', array('<code>' . $this->_context['section_handle'] . '</code>')), __('Unknown Section'), Page::HTTP_STATUS_NOT_FOUND);
     }
     $section = SectionManager::fetch($section_id);
     $entry_id = intval($this->_context['entry_id']);
     $base = '/publish/' . $this->_context['section_handle'] . '/';
     $new_link = $base . 'new/';
     $filter_link = $base;
     EntryManager::setFetchSorting('id', 'DESC');
     if (!($existingEntry = EntryManager::fetch($entry_id))) {
         Administration::instance()->throwCustomError(__('Unknown Entry'), __('The Entry, %s, could not be found.', array($entry_id)), Page::HTTP_STATUS_NOT_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('id', $entry_id);
         $entry->set('author_id', $existingEntry->get('author_id'));
         $entry->set('section_id', $existingEntry->get('section_id'));
         $entry->set('creation_date', $existingEntry->get('creation_date'));
         $entry->set('modification_date', $existingEntry->get('modification_date'));
         $entry->setDataFromPost($fields, $errors, true);
         // Editing an entry, so need to create some various objects
     } else {
         $entry = $existingEntry;
         $fields = array();
         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));
     // Iterate over the `prepopulate` parameters to build a URL
     // to remember this state for Create New, View all Entries and
     // Breadcrumb links. If `prepopulate` doesn't exist, this will
     // just use the standard pages (ie. no filtering)
     if (isset($_REQUEST['prepopulate'])) {
         $new_link .= $this->getPrepopulateString();
         $filter_link .= $this->getFilterString();
     }
     if (isset($this->_context['flag'])) {
         // These flags are only relevant if there are no errors
         if (empty($this->_errors)) {
             $time = Widget::Time();
             switch ($this->_context['flag']) {
                 case 'saved':
                     $message = __('Entry updated at %s.', array($time->generate()));
                     break;
                 case 'created':
                     $message = __('Entry created at %s.', array($time->generate()));
             }
             $this->pageAlert($message . ' <a href="' . SYMPHONY_URL . $new_link . '" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . $filter_link . '" accesskey="a">' . __('View all Entries') . '</a>', Alert::SUCCESS);
         }
     }
     // Determine the page title
     $field_id = Symphony::Database()->fetchVar('id', 0, sprintf("\n            SELECT `id`\n            FROM `tbl_fields`\n            WHERE `parent_section` = %d\n            ORDER BY `sortorder` LIMIT 1", $section->get('id')));
     if (!is_null($field_id)) {
         $field = FieldManager::fetch($field_id);
     }
     if ($field) {
         $title = $field->prepareReadableValue($existingEntry->getData($field->get('id')), $entry_id, true);
     } else {
         $title = '';
     }
     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->setTitle(__('%1$s &ndash; %2$s &ndash; %3$s', array($title, $section->get('name'), __('Symphony'))));
     $sidebar_fields = $section->fetchFields(null, 'sidebar');
     $main_fields = $section->fetchFields(null, 'main');
     if (!empty($sidebar_fields) && !empty($main_fields)) {
         $this->Form->setAttribute('class', 'two columns');
     } else {
         $this->Form->setAttribute('class', 'columns');
     }
     // Only show the Edit Section button if the Author is a developer. #938 ^BA
     if (Symphony::Author()->isDeveloper()) {
         $this->appendSubheading($title, Widget::Anchor(__('Edit Section'), SYMPHONY_URL . '/blueprints/sections/edit/' . $section_id . '/', __('Edit Section Configuration'), 'button'));
     } else {
         $this->appendSubheading($title);
//.........这里部分代码省略.........
开发者ID:rc1,项目名称:WebAppsWithCmsStartHere,代码行数:101,代码来源:content.publish.php

示例6: __viewEdit

 function __viewEdit($new = false)
 {
     $this->setPageType('form');
     if ($this->_context[2] == 'saved' || $this->_context[3] == 'saved') {
         $this->pageAlert(__(__('Email Sender updated at %1$s. <a href="%2$s" accesskey="c">Create another?</a> <a href="%3$s" accesskey="a">View all Senders</a>'), array(Widget::Time()->generate(), SYMPHONY_URL . '/extension/email_newsletter_manager/senders/new/', SYMPHONY_URL . '/extension/email_newsletter_manager/senders/')), Alert::SUCCESS);
     }
     $senders = new XMLElement('senders');
     $title = __('New Sender');
     $breadcrumbs = array(Widget::Anchor(__('Email Newsletter Senders'), SYMPHONY_URL . '/extension/email_newsletter_manager/senders/'));
     // Fix for 2.4 and XSRF
     if (Symphony::Configuration()->get("enable_xsrf", "symphony") == "yes" && class_exists('XSRF')) {
         $xsrf_input = new XMLElement('xsrf_input');
         $xsrf_input->appendChild(XSRF::formToken());
         $this->_XML->appendChild($xsrf_input);
     }
     if (!$new) {
         $sender = SenderManager::create($this->_context[1]);
         // Make sure the POSTED values are always shown when present.
         // This will make sure the form is always up-to-date, even where there are errors.
         if (!empty($_POST['fields']) && !empty($_POST['settings'])) {
             $posted_array = $_POST['fields'];
             $posted_array[$_POST['settings']['gateway']] = $_POST['settings']['email_' . $_POST['settings']['gateway']];
         }
         $about = empty($_POST['fields']) && empty($_POST['settings']) ? (array) $sender->about() : $posted_array;
         $about['handle'] = Lang::createHandle($about['name'], 225, '-');
         $entry = new XMLElement('entry');
         General::array_to_xml($entry, $about);
         $senders->appendChild($entry);
         $title = $about['name'];
         //$breadcrumbs[] = Widget::Anchor('hi', SYMPHONY_URL . '/extension/email_newsletter_manager/senders/edit/' . $sender->getHandle());
     }
     $el_gateways = new XMLElement('gateways');
     $gateways = EmailGatewayManager::listAll();
     foreach ($gateways as $gateway) {
         // to be removed in later versions. Right now only smtp and sendmail are supported.
         if (in_array($gateway['handle'], array('smtp', 'sendmail', 'amazon_ses'))) {
             $gw = EmailGatewayManager::create($gateway['handle']);
             if (!empty($about[$gateway['handle']])) {
                 $config = $about[$gateway['handle']];
                 if ($gateway['handle'] == 'smtp') {
                     $gw->setFrom($config['from_address'], $config['from_name']);
                     $gw->setHost($config['host']);
                     $gw->setSecure($config['secure']);
                     $gw->setPort($config['port']);
                     $gw->setAuth($config['auth']);
                     $gw->setUser($config['username']);
                     $gw->setPass($config['password']);
                 }
                 if ($gateway['handle'] == 'amazon_ses') {
                     $gw->setFrom($config['from_address'], $config['from_name']);
                     $gw->setAwsKey($config['aws_key']);
                     $gw->setAwsSecretKey($config['aws_secret_key']);
                     $gw->setFallback($config['fallback']);
                     $gw->setReturnPath($config['return_path']);
                 }
                 if ($gateway['handle'] == 'sendmail') {
                     $gw->setFrom($config['from_address'], $config['from_name']);
                 }
             }
             $entry = new XMLElement('entry');
             General::array_to_xml($entry, $gateway);
             $config_panel = new XMLElement('config_panel');
             $config_panel->appendChild($gw->getPreferencesPane());
             $entry->appendChild($config_panel);
             $el_gateways->appendChild($entry);
         }
     }
     $senders->appendChild($el_gateways);
     $this->insertBreadcrumbs($breadcrumbs);
     $this->appendSubheading($title);
     $this->_XML->appendChild($senders);
 }
开发者ID:jonmifsud,项目名称:email_newsletter_manager,代码行数:72,代码来源:content.senders.php

示例7: __form

 public function __form()
 {
     // Handle unknown context
     if (!in_array($this->_context[0], array('new', 'edit'))) {
         Administration::instance()->errorPageNotFound();
     }
     if ($this->_context[0] == 'new' && !Symphony::Author()->isDeveloper() && !Symphony::Author()->isManager()) {
         Administration::instance()->throwCustomError(__('You are not authorised to access this page.'), __('Access Denied'), Page::HTTP_STATUS_UNAUTHORIZED);
     }
     if (isset($this->_context[2])) {
         $time = Widget::Time();
         switch ($this->_context[2]) {
             case 'saved':
                 $message = __('Author updated at %s.', array($time->generate()));
                 break;
             case 'created':
                 $message = __('Author created at %s.', array($time->generate()));
         }
         $this->pageAlert($message . ' <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);
     }
     $this->setPageType('form');
     $isOwner = false;
     $isEditing = $this->_context[0] == 'edit';
     if (isset($_POST['fields'])) {
         $author = $this->_Author;
     } elseif ($this->_context[0] == 'edit') {
         if (!($author_id = (int) $this->_context[1])) {
             redirect(SYMPHONY_URL . '/system/authors/');
         }
         if (!($author = AuthorManager::fetchByID($author_id))) {
             Administration::instance()->throwCustomError(__('The author profile you requested does not exist.'), __('Author not found'), Page::HTTP_STATUS_NOT_FOUND);
         }
     } else {
         $author = new Author();
     }
     if ($isEditing && $author->get('id') == Symphony::Author()->get('id')) {
         $isOwner = true;
     }
     if ($isEditing && !$isOwner && !Symphony::Author()->isDeveloper() && !Symphony::Author()->isManager()) {
         Administration::instance()->throwCustomError(__('You are not authorised to edit other authors.'), __('Access Denied'), Page::HTTP_STATUS_FORBIDDEN);
     }
     $this->setTitle(__($this->_context[0] == 'new' ? '%2$s &ndash; %3$s' : '%1$s &ndash; %2$s &ndash; %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'), 'text', array('autocomplete' => 'off')));
     $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'), 'text', array('autocomplete' => 'off')));
     $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 ((Symphony::Author()->isDeveloper() || Symphony::Author()->isManager()) && !$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('manager', $author->isManager(), __('Manager')));
         if (Symphony::Author()->isDeveloper()) {
             $options[] = 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 rules:
         - Primary account can edit all accounts.
         - Developers can edit all developers, managers and authors, and their own.
         - Managers can edit all Authors, and their own.
         - Authors can edit their own.
     */
     if ($isEditing && !($isOwner || Symphony::Author()->isManager() && $author->isAuthor() || Symphony::Author()->isPrimaryAccount() || Symphony::Author()->isDeveloper() && $author->isPrimaryAccount() === false)) {
         $fieldset->setAttribute('class', 'three columns');
         $label = Widget::Label(null, null, 'column');
//.........这里部分代码省略.........
开发者ID:hotdoy,项目名称:EDclock,代码行数:101,代码来源:content.systemauthors.php

示例8: dAppendPageAlert

 public function dAppendPageAlert()
 {
     $callback = Administration::instance()->getPageCallback();
     // manipulate success message
     if (in_array($callback['context']['page'], array('new', 'edit'))) {
         $flag_create = false;
         $flag_all = false;
         // if entry was created or saved
         if (isset($callback['context']['flag'])) {
             // if there is a limit
             if ($this->_max > 0) {
                 $flag_create = true;
                 // if not static section
                 if ($this->_max > 1) {
                     $flag_all = true;
                 }
             }
         }
         // if the status message must be changed
         if ($flag_create || $flag_all) {
             $alerts = Administration::instance()->Page->Alert;
             // remove old message
             foreach ($alerts as $key => $alert) {
                 /** @var $alert Alert */
                 if ($alert->type === Alert::SUCCESS) {
                     unset($alerts[$key]);
                 }
             }
             $msg_create = '';
             $msg_all = '';
             // create / update message
             if ($flag_create === true) {
                 switch ($callback['context']['flag']) {
                     case 'saved':
                         $msg_create = __('Entry updated at %s.', array(Widget::Time('now')->generate()));
                         break;
                     case 'created':
                         $msg_create = __('Entry created at %s.', array(Widget::Time('now')->generate()));
                         break;
                 }
             }
             // view all message
             if ($flag_all === true) {
                 $link = '/publish/' . $callback['context']['section_handle'] . '/';
                 $msg_all = ' <a href="' . SYMPHONY_URL . $link . '" accesskey="a">' . __('View all Entries') . '</a>';
             }
             // append alert
             $alerts[] = new Alert($msg_create . $msg_all, Alert::SUCCESS);
             // replace Alerts
             Administration::instance()->Page->Alert = $alerts;
         }
     }
 }
开发者ID:rc1,项目名称:WebAppsWithCmsStartHere,代码行数:53,代码来源:extension.driver.php

示例9: __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 &ndash; %2$s &ndash; %3$s' : '%2$s &ndash; %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');
//.........这里部分代码省略.........
开发者ID:valery,项目名称:symphony-2,代码行数:101,代码来源:content.blueprintsevents.php

示例10: getTimeAgo

 /**
  * A wrapper for get, this function will return a HTML string representing
  * an `<abbr>` element which contained the formatted date of now, and an
  * RFC 2822 formatted date (Thu, 21 Dec 2000 16:01:07 +0200) as the title
  * attribute. Symphony uses this in it's status messages so that it can
  * dynamically update how long ago the action took place using Javascript.
  *
  * @deprecated This will be removed in the next version of Symphony
  * @param string $format
  *  A valid PHP date format
  * @return string
  *  A HTML string of an `<abbr>` element with a class of 'timeago' and the current
  *  date (RFC 2822) as the title element. The value is the current time as
  *  specified by the `$format`.
  */
 public static function getTimeAgo($format = __SYM_TIME_FORMAT__)
 {
     $time = Widget::Time($string, $format);
     return $time->generate();
 }
开发者ID:bauhouse,项目名称:Piano-Sonata,代码行数:20,代码来源:class.datetimeobj.php

示例11: __viewEdit

 public function __viewEdit()
 {
     $isNew = true;
     $time = Widget::Time();
     // Verify role exists
     if ($this->_context[0] == 'edit') {
         $isNew = false;
         if (!($role_id = $this->_context[1])) {
             redirect(extension_Members::baseURL() . 'roles/');
         }
         if (!($existing = RoleManager::fetch($role_id))) {
             throw new SymphonyErrorPage(__('The role you requested to edit does not exist.'), __('Role not found'));
         }
     }
     // Add in custom assets
     Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/members/assets/members.roles.css', 'screen', 101);
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/members/assets/members.roles.js', 104);
     // Append any Page Alerts from the form's
     if (isset($this->_context[2])) {
         switch ($this->_context[2]) {
             case 'saved':
                 $this->pageAlert(__('Role updated at %s.', array($time->generate())) . ' <a href="' . extension_members::baseURL() . 'roles/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . extension_members::baseURL() . 'roles/" accesskey="a">' . __('View all Roles') . '</a>', Alert::SUCCESS);
                 break;
             case 'created':
                 $this->pageAlert(__('Role created at %s.', array($time->generate())) . ' <a href="' . extension_members::baseURL() . 'roles/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . extension_members::baseURL() . 'roles/" accesskey="a">' . __('View all Roles') . '</a>', Alert::SUCCESS);
                 break;
         }
     }
     // Has the form got any errors?
     $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);
     }
     $this->setPageType('form');
     if ($isNew) {
         $this->setTitle(__('Symphony &ndash; Member Roles'));
         $this->appendSubheading(__('Untitled'));
         $fields = array('name' => null, 'permissions' => null, 'page_access' => null);
     } else {
         $this->setTitle(__('Symphony &ndash; Member Roles &ndash; ') . $existing->get('name'));
         $this->appendSubheading($existing->get('name'));
         if (isset($_POST['fields'])) {
             $fields = $_POST['fields'];
         } else {
             $fields = array('name' => $existing->get('name'), 'permissions' => $existing->get('event_permissions'), 'page_access' => $existing->get('forbidden_pages'));
         }
     }
     $this->insertBreadcrumbs(array(Widget::Anchor(__('Member Roles'), extension_members::baseURL() . 'roles/')));
     $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::Error($label, $this->_errors['name']));
     } else {
         $fieldset->appendChild($label);
     }
     $this->Form->appendChild($fieldset);
     $events = EventManager::listAll();
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings type-file');
     $fieldset->appendChild(new XMLElement('legend', __('Event Level Permissions')));
     $aTableBody = array();
     if (is_array($events) && !empty($events)) {
         foreach ($events as $event_handle => $event) {
             $permissions = $fields['permissions'][$event_handle];
             $td_name = Widget::TableData($event['name'], 'name');
             $td_permission_create = Widget::TableData(sprintf('<label title="%s">%s <span>%s</span></label>', __('User can create new entries'), Widget::Input("fields[permissions][{$event_handle}][create]", (string) EventPermissions::CREATE, 'checkbox', $permissions['create'] == EventPermissions::CREATE ? array('checked' => 'checked') : NULL)->generate(), 'Create'), 'create');
             $td_permission_none = Widget::TableData(sprintf('<label title="%s">%s <span>%s</span></label>', __('User cannot edit existing entries'), Widget::Input("fields[permissions][{$event_handle}][edit]", (string) EventPermissions::NO_PERMISSIONS, 'radio', $permissions['edit'] == EventPermissions::NO_PERMISSIONS ? array('checked' => 'checked') : NULL)->generate(), 'None'));
             $td_permission_own = Widget::TableData(sprintf('<label title="%s">%s <span>%s</span></label>', __('User can edit their own entries only'), Widget::Input("fields[permissions][{$event_handle}][edit]", (string) EventPermissions::OWN_ENTRIES, 'radio', $permissions['edit'] == EventPermissions::OWN_ENTRIES ? array('checked' => 'checked') : NULL)->generate(), 'Own'));
             $td_permission_all = Widget::TableData(sprintf('<label title="%s">%s <span>%s</span></label>', __('User can edit all entries'), Widget::Input("fields[permissions][{$event_handle}][edit]", (string) EventPermissions::ALL_ENTRIES, 'radio', $permissions['edit'] == EventPermissions::ALL_ENTRIES ? array('checked' => 'checked') : NULL)->generate(), 'All'));
             // Create an Event instance
             $ev = EventManager::create($event_handle, array());
             $aTableBody[] = Widget::TableRow(array($td_name, $td_permission_create, $td_permission_none, $td_permission_own, $td_permission_all), method_exists($ev, 'ignoreRolePermissions') && $ev->ignoreRolePermissions() == true ? 'inactive' : '');
             unset($ev);
         }
     }
     $thead = Widget::TableHead(array(array(__('Event'), 'col', array('class' => 'name')), array(__('Create New'), 'col', array('class' => 'new', 'title' => __('Toggle all'))), array(__('No Edit'), 'col', array('class' => 'edit', 'title' => __('Toggle all'))), array(__('Edit Own'), 'col', array('class' => 'edit', 'title' => __('Toggle all'))), array(__('Edit All'), 'col', array('class' => 'edit', 'title' => __('Toggle all')))));
     $table = Widget::Table($thead, NULL, Widget::TableBody($aTableBody), 'role-permissions');
     $fieldset->appendChild($table);
     $this->Form->appendChild($fieldset);
     // Add Page Permissions [simple Deny/Allow]
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings type-file');
     $fieldset->appendChild(new XMLElement('legend', __('Page Level Permissions')));
     $label = Widget::Label(__('Deny Access'));
     if (!is_array($fields['page_access'])) {
         $fields['page_access'] = array();
     }
     $options = array();
     $pages = PageManager::fetch(false, array('id'));
     if (!empty($pages)) {
         foreach ($pages as $page) {
             $options[] = array($page['id'], in_array($page['id'], $fields['page_access']), '/' . PageManager::resolvePagePath($page['id']));
         }
     }
     $label->appendChild(Widget::Select('fields[page_access][]', $options, array('multiple' => 'multiple')));
     $fieldset->appendChild($label);
     $this->Form->appendChild($fieldset);
//.........这里部分代码省略.........
开发者ID:andrewminton,项目名称:members,代码行数:101,代码来源:content.roles.php

示例12: buildEditor

 public static function buildEditor(XMLElement $wrapper, array &$errors = array(), array $settings = null, $handle = null)
 {
     if (!is_null($handle) && isset($settings[self::getClass()])) {
         $cache = Symphony::ExtensionManager()->getCacheProvider('remotedatasource');
         $cache_id = self::buildCacheID($settings[self::getClass()]);
     }
     // If `clear_cache` is set, clear it..
     if (isset($cache_id) && in_array('clear_cache', Administration::instance()->Page->getContext())) {
         $cache->delete($cache_id);
         Administration::instance()->Page->pageAlert(__('Data source cache cleared at %s.', array(Widget::Time()->generate())) . '<a href="' . SYMPHONY_URL . '/blueprints/datasources/" accesskey="a">' . __('View all Data sources') . '</a>', Alert::SUCCESS);
     }
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings contextual ' . __CLASS__);
     $fieldset->setAttribute('data-context', Lang::createHandle(self::getName()));
     $fieldset->appendChild(new XMLElement('legend', self::getName()));
     $p = new XMLElement('p', __('Use %s syntax to specify dynamic portions of the URL.', array('<code>{' . __('$param') . '}</code>')));
     $p->setAttribute('class', 'help');
     $fieldset->appendChild($p);
     // URL
     $label = Widget::Label(__('URL'));
     $url = isset($settings[self::getClass()]['url']) ? General::sanitize($settings[self::getClass()]['url']) : null;
     $label->appendChild(Widget::Input('fields[' . self::getClass() . '][url]', $url, 'text', array('placeholder' => 'http://')));
     if (isset($errors[self::getClass()]['url'])) {
         $fieldset->appendChild(Widget::Error($label, $errors[self::getClass()]['url']));
     } else {
         $fieldset->appendChild($label);
     }
     // Namespaces
     static::addNamespaces($fieldset, $errors, $settings, $handle);
     // Included Elements
     $label = Widget::Label(__('Included Elements'));
     $help = new XMLElement('i', __('xPath expression'));
     $label->appendChild($help);
     $xpath = isset($settings[self::getClass()]['xpath']) ? stripslashes($settings[self::getClass()]['xpath']) : null;
     $label->appendChild(Widget::Input('fields[' . self::getClass() . '][xpath]', $xpath, 'text', array('placeholder' => '/')));
     if (isset($errors[self::getClass()]['xpath'])) {
         $fieldset->appendChild(Widget::Error($label, $errors[self::getClass()]['xpath']));
     } else {
         $fieldset->appendChild($label);
     }
     $group = new XMLElement('div', null, array('class' => 'three columns'));
     $fieldset->appendChild($group);
     // Caching
     $label = Widget::Label(__('Cache expiration'));
     $label->setAttribute('class', 'column');
     $help = new XMLElement('i', __('in minutes'));
     $label->appendChild($help);
     $cache_time = isset($settings[self::getClass()]['cache']) ? max(0, intval($settings[self::getClass()]['cache'])) : 5;
     $input = Widget::Input('fields[' . self::getClass() . '][cache]', (string) $cache_time);
     $label->appendChild($input);
     if (isset($errors[self::getClass()]['cache'])) {
         $group->appendChild(Widget::Error($label, $errors[self::getClass()]['cache']));
     } else {
         $group->appendChild($label);
     }
     // Timeout
     $label = Widget::Label(__('Timeout'));
     $label->setAttribute('class', 'column');
     $help = new XMLElement('i', __('in seconds'));
     $label->appendChild($help);
     $timeout_time = isset($settings[self::getClass()]['timeout']) ? max(1, intval($settings[self::getClass()]['timeout'])) : 6;
     $label->appendChild(Widget::Input('fields[' . self::getClass() . '][timeout]', (string) $timeout_time, 'text'));
     if (isset($errors[self::getClass()]['timeout'])) {
         $group->appendChild(Widget::Error($label, $errors[self::getClass()]['timeout']));
     } else {
         $group->appendChild($label);
     }
     // Format
     $label = Widget::Label(__('Format'));
     $label->setAttribute('class', 'column');
     $format = isset($settings[self::getClass()]['format']) ? $settings[self::getClass()]['format'] : null;
     $label->appendChild(Widget::Select('fields[' . self::getClass() . '][format]', array(array('xml', $settings[self::getClass()]['format'] == 'xml', 'XML'), array('json', $settings[self::getClass()]['format'] == 'json', 'JSON'), array('csv', $settings[self::getClass()]['format'] == 'csv', 'CSV'), array('txt', $settings[self::getClass()]['format'] == 'txt', 'TEXT')), array('class' => 'picker')));
     if (isset($errors[self::getClass()]['format'])) {
         $group->appendChild(Widget::Error($label, $errors[self::getClass()]['format']));
     } else {
         $group->appendChild($label);
     }
     // Check for existing Cache objects
     if (isset($cache_id)) {
         static::buildCacheInformation($fieldset, $cache, $cache_id);
     }
     $wrapper->appendChild($fieldset);
     // Parameters
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings contextual ' . __CLASS__);
     $fieldset->setAttribute('data-context', Lang::createHandle(self::getName()));
     $fieldset->appendChild(new XMLElement('legend', 'Parameters'));
     $p = new XMLElement('p', __('Appended to datasource handle, eg. %s', array('<code>$ds-handle.parameter-name</code>')));
     $p->setAttribute('class', 'help');
     $fieldset->appendChild($p);
     // Output Parameters
     static::addOutputParameters($fieldset, $errors, $settings, $handle);
     $wrapper->appendChild($fieldset);
 }
开发者ID:hotdoy,项目名称:EDclock,代码行数:94,代码来源:datasource.remote.php

示例13: View

 public function View()
 {
     if (!file_exists(realpath(MANIFEST . '/cron') . '/' . $this->_context[0])) {
         throw new SymphonyErrorPage('The cron task <code>' . $this->_context[0] . '</code> could not be found.', 'Task Not Found');
     }
     $task = (new Lib\CronTask(Symphony::Database()))->load(realpath(MANIFEST . '/cron') . '/' . $this->_context[0]);
     $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[1])) {
         $time = Widget::Time();
         switch ($this->_context[1]) {
             case 'saved':
                 $message = __('Cron task updated at %s.', array($time->generate()));
                 break;
             case 'created':
                 $message = __('Cron task created at %s.', array($time->generate()));
         }
         $this->pageAlert($message, Alert::SUCCESS);
     }
     $this->setPageType('form');
     $this->setTitle(__('%1$s &ndash; %2$s &ndash; %3$s', [$task->name, __('Cron'), __('Symphony')]));
     $this->appendSubheading($task->name);
     if (!empty($_POST)) {
         $fields = $_POST['fields'];
     } else {
         $fields = ['name' => General::sanitize($task->name), 'command' => General::sanitize($task->command), 'description' => General::sanitize($task->description), 'interval' => $task->interval, 'interval-type' => $task->{'interval-type'}, 'start' => !is_null($task->start) ? DateTimeObj::get('Y-m-d H:i:s', $task->start) : null, 'finish' => !is_null($task->finish) ? DateTimeObj::get('Y-m-d H:i:s', $task->finish) : null];
         if ($task->enabled === true) {
             $fields['enabled'] = 'yes';
         }
     }
     // Essentials
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings');
     $fieldset->appendChild(new XMLElement('legend', __('Essentials')));
     $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', '&uarr; 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', '&uarr; 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]', 'Save', 'submit', ['accesskey' => 's']));
     $button = new XMLElement('button', __('Delete'));
     $button->setAttributeArray(['name' => 'action[delete]', 'class' => 'confirm delete', 'title' => 'Delete this task']);
     $div->appendChild($button);
     $this->Form->appendChild($div);
 }
开发者ID:pointybeard,项目名称:cron,代码行数:89,代码来源:content.edit.php

示例14: __viewEdit

 public function __viewEdit($new = false)
 {
     $this->setPageType('form');
     $this->setTitle(sprintf(__("Symphony - Newsletter Recipient Groups - %s", array(), false), ucfirst($this->_context[1])));
     $errors = new XMLElement('errors');
     $context = new XMLElement('context');
     General::array_to_xml($context, $this->_context);
     $this->_XML->appendChild($context);
     // Fix for 2.4 and XSRF
     if (Symphony::Configuration()->get("enable_xsrf", "symphony") == "yes" && class_exists('XSRF')) {
         $xsrf_input = new XMLElement('xsrf_input');
         $xsrf_input->appendChild(XSRF::formToken());
         $this->_XML->appendChild($xsrf_input);
     }
     $section_xml = new XMLElement('sections');
     $sectionManager = new SectionManager($this);
     $sections = $sectionManager->fetch();
     foreach ($sections as $section) {
         $entry = new XMLElement('entry');
         General::array_to_xml($entry, $section->get());
         foreach ($section->fetchFields() as $field) {
             $field_xml = new XMLElement('field');
             General::array_to_xml($field_xml, $field->get());
             $filter_html = new XMLElement('filter_html');
             $field->displayDatasourceFilterPanel($filter_html, NULL, $errors, $section->get('id'));
             $field_xml->appendChild($filter_html);
             $field_elements = new XMLElement('elements');
             General::array_to_xml($field_elements, $field->fetchIncludableElements());
             $field_xml->appendChild($field_elements);
             $entry->appendChild($field_xml);
         }
         $section_xml->appendChild($entry);
     }
     $this->_XML->appendChild($section_xml);
     $title = __('New Group');
     $breadcrumbs = array(Widget::Anchor(__('Email Newsletter Recipients'), SYMPHONY_URL . '/extension/email_newsletter_manager/recipientgroups/'));
     $recipientgroups = new XMLElement('recipientgroups');
     if ($this->_context[2] == 'saved' || $this->_context[3] == 'saved') {
         $this->pageAlert(__(__('Email Recipient updated at %1$s. <a href="%2$s" accesskey="c">Create another?</a> <a href="%3$s" accesskey="a">View all Recipient Groups</a>'), array(Widget::Time()->generate(), SYMPHONY_URL . '/extension/email_newsletter_manager/recipientgroups/new/', SYMPHONY_URL . '/extension/email_newsletter_manager/recipientgroups/')), Alert::SUCCESS);
     }
     if ($new == false) {
         /*
             TODO add POST values to XML
         */
         $group = RecipientgroupManager::create($this->_context[1]);
         if (is_object($group)) {
             $entry = new XMLElement('entry');
             $properties = $group->getProperties();
             $about = $group->about();
             $title = $about['name'];
             General::array_to_xml($entry, $about);
             $source = new XMLElement('source', $properties['source']);
             $entry->appendChild($source);
             // Section Only
             if (is_numeric($properties['source'])) {
                 $fields = new XMLElement('fields');
                 $email = new XMLElement('email', $properties['email']);
                 $fields->appendChild($email);
                 $name = new XMLElement('name');
                 General::array_to_xml($name, $properties['name']);
                 $fields->appendChild($name);
                 $entry->appendChild($fields);
             }
             // Hack to make sure filter data is preserved in the UI when there is an error in the form.
             // For next versions: always do the local/user differentiation in php, rather than xslt.
             // This will make the xslt cleaner and easier to understand and debug.
             if (!empty($_POST['fields'])) {
                 $properties['filters'] = $_POST['fields']['filter'][0];
             }
             if (!empty($properties['filters'])) {
                 $filters = new XMLElement('filters');
                 foreach ($properties['filters'] as $filter => $val) {
                     // Section and Author
                     if ($filter == 'id') {
                         $title = new XMLElement('h4', 'System ID');
                         $label = Widget::Label(__('Value'));
                         $label->appendChild(Widget::Input('fields[filter][' . $properties['source'] . '][id]', General::sanitize($val)));
                         $filter_entry = new XMLElement('entry', NULL, array('id' => 'id', 'data-type' => 'id'));
                         $filter_entry->appendChild($title);
                         $filter_entry->appendChild($label);
                         $filters->appendChild($filter_entry);
                     }
                     if ($filter == 'system:date') {
                         $title = new XMLElement('h4', 'System Date');
                         $label = Widget::Label(__('Value'));
                         $label->appendChild(Widget::Input('fields[filter][' . $properties['source'] . '][system:date]', General::sanitize($val)));
                         $filter_entry = new XMLElement('entry', NULL, array('id' => 'id', 'data-type' => 'system:date'));
                         $filter_entry->appendChild($title);
                         $filter_entry->appendChild($label);
                         $filters->appendChild($filter_entry);
                     }
                     // Section Only
                     if (is_numeric($properties['source'])) {
                         $section = SectionManager::fetch($properties['source']);
                         if (is_object($section)) {
                             $section_fields = $section->fetchFields();
                             foreach ($section_fields as $field) {
                                 $field_ids[] = $field->get('id');
                             }
                             // only add filters to the duplicator if the field id
//.........这里部分代码省略.........
开发者ID:MST-SymphonyCMS,项目名称:email_newsletter_manager,代码行数:101,代码来源:content.recipientgroups.php

示例15: __viewEdit

 public function __viewEdit()
 {
     $this->setPageType('form');
     $fields = array("title" => null, "handle" => null, "parent" => null, "params" => null, "type" => null, "data_sources" => null);
     $existing = $fields;
     $nesting = Symphony::Configuration()->get('pages_table_nest_children', 'symphony') == 'yes';
     // Verify page exists:
     if ($this->_context[0] === 'edit') {
         if (!($page_id = (int) $this->_context[1])) {
             redirect(SYMPHONY_URL . '/blueprints/pages/');
         }
         $existing = PageManager::fetchPageByID($page_id);
         if (!$existing) {
             Administration::instance()->errorPageNotFound();
         } else {
             $existing['type'] = PageManager::fetchPageTypes($page_id);
         }
     }
     // Status message:
     if (isset($this->_context[2])) {
         $flag = $this->_context[2];
         $parent_link_suffix = $message = '';
         $time = Widget::Time();
         if (isset($_REQUEST['parent']) && is_numeric($_REQUEST['parent'])) {
             $parent_link_suffix = "?parent=" . $_REQUEST['parent'];
         } elseif ($nesting && isset($existing) && !is_null($existing['parent'])) {
             $parent_link_suffix = '?parent=' . $existing['parent'];
         }
         switch ($flag) {
             case 'saved':
                 $message = __('Page updated at %s.', array($time->generate()));
                 break;
             case 'created':
                 $message = __('Page created at %s.', array($time->generate()));
         }
         $this->pageAlert($message . ' <a href="' . SYMPHONY_URL . '/blueprints/pages/new/' . $parent_link_suffix . '" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/pages/" accesskey="a">' . __('View all Pages') . '</a>', Alert::SUCCESS);
     }
     // Find values:
     if (isset($_POST['fields'])) {
         $fields = $_POST['fields'];
     } elseif ($this->_context[0] == 'edit') {
         $fields = $existing;
         if (!is_null($fields['type'])) {
             $fields['type'] = implode(', ', $fields['type']);
         }
         $fields['data_sources'] = preg_split('/,/i', $fields['data_sources'], -1, PREG_SPLIT_NO_EMPTY);
         $fields['events'] = preg_split('/,/i', $fields['events'], -1, PREG_SPLIT_NO_EMPTY);
     } elseif (isset($_REQUEST['parent']) && is_numeric($_REQUEST['parent'])) {
         $fields['parent'] = $_REQUEST['parent'];
     }
     $title = $fields['title'];
     if (trim($title) == '') {
         $title = $existing['title'];
     }
     $this->setTitle(__($title ? '%1$s &ndash; %2$s &ndash; %3$s' : '%2$s &ndash; %3$s', array($title, __('Pages'), __('Symphony'))));
     $page_id = isset($page_id) ? $page_id : null;
     if (!empty($title)) {
         $page_url = URL . '/' . PageManager::resolvePagePath($page_id) . '/';
         $this->appendSubheading($title, array(Widget::Anchor(__('View Page'), $page_url, __('View Page on Frontend'), 'button', null, array('target' => '_blank', 'accesskey' => 'v'))));
     } else {
         $this->appendSubheading(!empty($title) ? $title : __('Untitled'));
     }
     if (isset($page_id)) {
         $this->insertBreadcrumbsUsingPageIdentifier($page_id, false);
     } else {
         $_GET['parent'] = isset($_GET['parent']) ? $_GET['parent'] : null;
         $this->insertBreadcrumbsUsingPageIdentifier((int) $_GET['parent'], true);
     }
     // Title --------------------------------------------------------------
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings');
     $fieldset->appendChild(new XMLElement('legend', __('Page Settings')));
     $label = Widget::Label(__('Name'));
     $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);
     // Handle -------------------------------------------------------------
     $group = new XMLElement('div');
     $group->setAttribute('class', 'two columns');
     $column = new XMLElement('div');
     $column->setAttribute('class', 'column');
     $label = Widget::Label(__('Handle'));
     $label->appendChild(Widget::Input('fields[handle]', $fields['handle']));
     if (isset($this->_errors['handle'])) {
         $label = Widget::Error($label, $this->_errors['handle']);
     }
     $column->appendChild($label);
     // Parent ---------------------------------------------------------
     $label = Widget::Label(__('Parent Page'));
     $where = array(sprintf('id != %d', $page_id));
     $pages = PageManager::fetch(false, array('id'), $where, 'title ASC');
     $options = array(array('', false, '/'));
     if (!empty($pages)) {
         foreach ($pages as $page) {
             $options[] = array($page['id'], $fields['parent'] == $page['id'], '/' . PageManager::resolvePagePath($page['id']));
         }
         usort($options, array($this, '__compare_pages'));
     }
//.........这里部分代码省略.........
开发者ID:rc1,项目名称:WebAppsWithCmsStartHere,代码行数:101,代码来源:content.blueprintspages.php


注:本文中的Widget::Time方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。