コード例 #1
0
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s – %2$s', array(__('Authors'), __('Symphony'))));
     if (Administration::instance()->Author->isDeveloper()) {
         $this->appendSubheading(__('Authors'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a new author'), 'create button', NULL, array('accesskey' => 'c')));
     } else {
         $this->appendSubheading(__('Authors'));
     }
     Sortable::initialize($this, $authors, $sort, $order);
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Email Address'), 'sortable' => true, 'handle' => 'email'), array('label' => __('Last Seen'), 'sortable' => true, 'handle' => 'last_seen'));
     if (Administration::instance()->Author->isDeveloper()) {
         $columns = array_merge($columns, array(array('label' => __('User Type'), 'sortable' => true, 'handle' => 'user_type'), array('label' => __('Language'), 'sortable' => true, 'handle' => 'language')));
     }
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($authors) || empty($authors)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($authors as $a) {
             // Setup each cell
             if (Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->get('id') == $a->get('id')) {
                 $td1 = Widget::TableData(Widget::Anchor($a->getFullName(), Administration::instance()->getCurrentPageURL() . 'edit/' . $a->get('id') . '/', $a->get('username'), 'author'));
             } else {
                 $td1 = Widget::TableData($a->getFullName(), 'inactive');
             }
             $td2 = Widget::TableData(Widget::Anchor($a->get('email'), 'mailto:' . $a->get('email'), __('Email this author')));
             if (!is_null($a->get('last_seen'))) {
                 $td3 = Widget::TableData(DateTimeObj::format($a->get('last_seen'), __SYM_DATETIME_FORMAT__));
             } else {
                 $td3 = Widget::TableData(__('Unknown'), 'inactive');
             }
             $td4 = Widget::TableData($a->isDeveloper() ? __("Developer") : __("Author"));
             $languages = Lang::getAvailableLanguages();
             $td5 = Widget::TableData($a->get("language") == NULL ? __("System Default") : $languages[$a->get("language")]);
             if (Administration::instance()->Author->isDeveloper()) {
                 if ($a->get('id') != Administration::instance()->Author->get('id')) {
                     $td3->appendChild(Widget::Input('items[' . $a->get('id') . ']', NULL, 'checkbox'));
                 }
             }
             // Add a row to the body array, assigning each cell to the row
             if (Administration::instance()->Author->isDeveloper()) {
                 $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5));
             } else {
                 $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
             }
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     if (Administration::instance()->Author->isDeveloper()) {
         $tableActions = new XMLElement('div');
         $tableActions->setAttribute('class', 'actions');
         $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected authors?'))));
         $tableActions->appendChild(Widget::Apply($options));
         $this->Form->appendChild($tableActions);
     }
 }
コード例 #2
0
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s – %2$s', array(__('Symphony'), __('Authors'))));
     if (Administration::instance()->Author->isDeveloper()) {
         $this->appendSubheading(__('Authors'), Widget::Anchor(__('Add an Author'), Administration::instance()->getCurrentPageURL() . 'new/', __('Add a new author'), 'create button', NULL, array('accesskey' => 'c')));
     } else {
         $this->appendSubheading(__('Authors'));
     }
     $aTableHead = array(array(__('Name'), 'col'), array(__('Email Address'), 'col'), array(__('Last Seen'), 'col'));
     $aTableBody = array();
     $authors = AuthorManager::fetch();
     if (!is_array($authors) || empty($authors)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($authors as $a) {
             ## Setup each cell
             if (Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->get('id') == $a->get('id')) {
                 $td1 = Widget::TableData(Widget::Anchor($a->getFullName(), Administration::instance()->getCurrentPageURL() . 'edit/' . $a->get('id') . '/', $a->get('username'), 'author'));
             } else {
                 $td1 = Widget::TableData($a->getFullName(), 'inactive');
             }
             $td2 = Widget::TableData(Widget::Anchor($a->get('email'), 'mailto:' . $a->get('email'), __('Email this author')));
             if (!is_null($a->get('last_seen'))) {
                 $td3 = Widget::TableData(DateTimeObj::format($a->get('last_seen'), __SYM_DATETIME_FORMAT__));
             } else {
                 $td3 = Widget::TableData('Unknown', 'inactive');
             }
             if (Administration::instance()->Author->isDeveloper()) {
                 if ($a->get('id') != Administration::instance()->Author->get('id')) {
                     $td3->appendChild(Widget::Input('items[' . $a->get('id') . ']', NULL, 'checkbox'));
                 }
             }
             ## Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     if (Administration::instance()->Author->isDeveloper()) {
         $tableActions = new XMLElement('div');
         $tableActions->setAttribute('class', 'actions');
         $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected authors?'))));
         $tableActions->appendChild(Widget::Select('with-selected', $options));
         $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
         $this->Form->appendChild($tableActions);
     }
 }
コード例 #3
0
ファイル: class.calendar.php プロジェクト: hotdoy/EDclock
 /**
  * Format date
  *
  * @param string $date
  *  date
  * @param int $time
  *  if set to 1, add time
  * @param string $scheme
  *  date and time scheme
  * @param boolean $json
  *  if set to true, return JSON formatted result
  * @return 
  *  returns either an array or JSON object with the status and the parsed value of the given date
  */
 public static function formatDate($date = NULL, $time = 1, $scheme = NULL, $json = false)
 {
     // Get scheme
     if (empty($scheme)) {
         $scheme = __SYM_DATE_FORMAT__;
         if ($time == 1) {
             $scheme = __SYM_DATETIME_FORMAT__;
         }
     }
     // Get current time
     if (empty($date)) {
         $timestamp = time();
     } elseif (ctype_digit($date)) {
         // Switch between milliseconds and seconds
         if (strlen($date) > 10) {
             $date = substr($date, 0, -3);
         }
         $timestamp = $date;
     } else {
         $timestamp = $date;
     }
     // Parse date
     $timestamp = DateTimeObj::format($timestamp, 'U', false);
     // Invalid date
     if ($timestamp === false) {
         $result = array('status' => 'invalid', 'date' => $date, 'timestamp' => false);
     } else {
         $result = array('status' => 'valid', 'date' => DateTimeObj::format($timestamp, $scheme, true, date_default_timezone_get()), 'timestamp' => number_format($timestamp * 1000, 0, '', ''));
     }
     // Return result
     if ($json) {
         return json_encode($result);
     } else {
         return $result;
     }
 }
コード例 #4
0
 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');
         $label = Widget::Label(__('Name'));
         $label->appendChild(Widget::Input('fields[name]', General::sanitize($fields['name'])));
         $div = new XMLElement('div');
         $div->setAttribute('class', 'column');
         if (isset($this->_errors['name'])) {
             $div->appendChild(Widget::Error($label, $this->_errors['name']));
         } else {
             $div->appendChild($label);
         }
         $group->appendChild($div);
         $fieldset->appendChild($group);
         $this->Form->appendChild($fieldset);
         // Filters
         $fieldset = new XMLElement('fieldset');
         $fieldset->setAttribute('class', 'settings pickable');
         $fieldset->appendChild(new XMLElement('legend', __('Filters')));
         $p = new XMLElement('p', __('Event Filters add additional conditions or actions to an event.'));
         $p->setAttribute('class', 'help');
         $fieldset->appendChild($p);
         $filters = isset($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));
         $fieldset->appendChild(Widget::Select('fields[filters][]', $options, array('multiple' => 'multiple', 'id' => 'event-filters')));
         $this->Form->appendChild($fieldset);
         // Connections
         $fieldset = new XMLElement('fieldset');
         $fieldset->setAttribute('class', 'settings');
         $fieldset->appendChild(new XMLElement('legend', __('Attach to Pages')));
         $p = new XMLElement('p', __('The event will only be available on the selected pages.'));
         $p->setAttribute('class', 'help');
         $fieldset->appendChild($p);
         $div = new XMLElement('div');
         $label = Widget::Label(__('Pages'));
         $pages = PageManager::fetch();
         $event_handle = str_replace('-', '_', Lang::createHandle($fields['name']));
         $connections = ResourceManager::getAttachedPages(RESOURCE_TYPE_EVENT, $event_handle);
         $selected = array();
         foreach ($connections as $connection) {
             $selected[] = $connection['id'];
         }
         $options = array();
         foreach ($pages as $page) {
             $options[] = array($page['id'], in_array($page['id'], $selected), PageManager::resolvePageTitle($page['id']));
         }
         $label->appendChild(Widget::Select('fields[connections][]', $options, array('multiple' => 'multiple')));
         $div->appendChild($label);
         $fieldset->appendChild($div);
         $this->Form->appendChild($fieldset);
         // Providers
         if (!empty($providers)) {
             foreach ($providers as $providerClass => $provider) {
                 if ($isEditing && $fields['source'] !== call_user_func(array($providerClass, 'getSource'))) {
                     continue;
                 }
                 call_user_func_array(array($providerClass, 'buildEditor'), array($this->Form, &$this->_errors, $fields, $handle));
             }
         }
     } else {
         // Author
         if (isset($about['author']['website'])) {
             $link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website']));
         } elseif (isset($about['author']['email'])) {
             $link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']);
         } else {
             $link = $about['author']['name'];
         }
         if ($link) {
             $fieldset = new XMLElement('fieldset');
             $fieldset->setAttribute('class', 'settings');
             $fieldset->appendChild(new XMLElement('legend', __('Author')));
             $fieldset->appendChild(new XMLElement('p', $link->generate(false)));
             $this->Form->appendChild($fieldset);
         }
         // Version
         $fieldset = new XMLElement('fieldset');
         $fieldset->setAttribute('class', 'settings');
         $fieldset->appendChild(new XMLElement('legend', __('Version')));
         $version = array_key_exists('version', $about) ? $about['version'] : null;
         $release_date = array_key_exists('release-date', $about) ? $about['release-date'] : filemtime(EventManager::__getDriverPath($handle));
         if (preg_match('/^\\d+(\\.\\d+)*$/', $version)) {
             $fieldset->appendChild(new XMLElement('p', __('%1$s released on %2$s', array($version, DateTimeObj::format($release_date, __SYM_DATE_FORMAT__)))));
         } elseif (!is_null($version)) {
             $fieldset->appendChild(new XMLElement('p', __('Created by %1$s at %2$s', array($version, DateTimeObj::format($release_date, __SYM_DATE_FORMAT__)))));
         } else {
             $fieldset->appendChild(new XMLElement('p', __('Last modified on %s', array(DateTimeObj::format($release_date, __SYM_DATE_FORMAT__)))));
         }
         $this->Form->appendChild($fieldset);
     }
     // If we are editing an event, it assumed that the event has documentation
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('id', 'event-documentation');
     $fieldset->setAttribute('class', 'settings');
     if ($isEditing && method_exists($existing, 'documentation')) {
         $doc = $existing->documentation();
         if ($doc) {
             $fieldset->setValue('<legend>' . __('Documentation') . '</legend>' . PHP_EOL . General::tabsToSpaces(is_object($doc) ? $doc->generate(true, 4) : $doc));
         }
     }
     $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) {
         $button = new XMLElement('button', __('Delete'));
         $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this event'), 'type' => 'submit', 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this event?')));
         $div->appendChild($button);
     }
     if (!$readonly) {
         $this->Form->appendChild($div);
     }
 }
コード例 #5
0
 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 &ndash; %2$s &ndash; %3$s' : '%1$s &ndash; %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 ($readonly) {
         // Author
         if (isset($about['author']['website'])) {
             $link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website']));
         } else {
             if (isset($about['author']['email'])) {
                 $link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']);
             } else {
                 $link = $about['author']['name'];
             }
         }
         $fieldset = new XMLElement('fieldset');
         $fieldset->setAttribute('class', 'settings');
         $fieldset->appendChild(new XMLElement('legend', __('Author')));
         $fieldset->appendChild(new XMLElement('p', $link->generate(false)));
         $this->Form->appendChild($fieldset);
         // Version
         $fieldset = new XMLElement('fieldset');
         $fieldset->setAttribute('class', 'settings');
         $fieldset->appendChild(new XMLElement('legend', __('Version')));
         if (preg_match('/^\\d+(\\.\\d+)*$/', $about['version'])) {
             $fieldset->appendChild(new XMLElement('p', __('%s released on %s', array($about['version'], DateTimeObj::format($about['release-date'], __SYM_DATE_FORMAT__)))));
         } else {
             $fieldset->appendChild(new XMLElement('p', __('Created by %s at %s', array($about['version'], DateTimeObj::format($about['release-date'], __SYM_DATE_FORMAT__)))));
         }
         $this->Form->appendChild($fieldset);
     }
     if ($isEditing) {
         // Description
         $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) {
         $button = new XMLElement('button', __('Delete'));
         $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this event'), 'type' => 'submit', 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this event?')));
         $div->appendChild($button);
     }
     if (!$readonly) {
         $this->Form->appendChild($div);
     }
 }
コード例 #6
0
 public function prepareTableValue($data, XMLElement $link = NULL, $entry_id = null)
 {
     $value = null;
     if (isset($data['value'])) {
         $value = DateTimeObj::format($data['value'], DateTimeObj::getSetting('datetime_format'), true);
     }
     return parent::prepareTableValue(array('value' => $value), $link, $entry_id = null);
 }
コード例 #7
0
 /**
  * Format the $data parameter according to this field's settings.
  *
  * @since Symphony 2.6.0
  * @param array $date
  *  The date to format
  * @return string
  */
 public function formatDate($date)
 {
     // Get format
     $format = 'date_format';
     if ($this->get('time') === 'yes') {
         $format = 'datetime_format';
     }
     return DateTimeObj::format($date, DateTimeObj::getSetting($format));
 }
コード例 #8
0
 public function __viewInfo()
 {
     $this->setPageType('form');
     $datasource = DatasourceManager::create($this->_context[1], array(), false);
     $about = $datasource->about();
     $this->setTitle(__('%1$s &ndash; %2$s &ndash; %3$s', array($about['name'], __('Data Source'), __('Symphony'))));
     $this->appendSubheading($this->_context[0] == 'info' ? $about['name'] : __('Untitled'));
     $this->insertBreadcrumbs(array(Widget::Anchor(__('Data Sources'), SYMPHONY_URL . '/blueprints/datasources/')));
     $this->Form->setAttribute('id', 'controller');
     $link = $about['author']['name'];
     if (isset($about['author']['website'])) {
         $link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website']));
     } elseif (isset($about['author']['email'])) {
         $link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']);
     }
     foreach ($about as $key => $value) {
         $fieldset = null;
         switch ($key) {
             case 'author':
                 if ($link) {
                     $fieldset = new XMLElement('fieldset');
                     $fieldset->appendChild(new XMLElement('legend', __('Author')));
                     $fieldset->appendChild(new XMLElement('p', $link->generate(false)));
                 }
                 break;
             case 'version':
                 $fieldset = new XMLElement('fieldset');
                 $fieldset->appendChild(new XMLElement('legend', __('Version')));
                 $release_date = array_key_exists('release-date', $about) ? $about['release-date'] : filemtime(DatasourceManager::__getDriverPath($this->_context[1]));
                 if (preg_match('/^\\d+(\\.\\d+)*$/', $value)) {
                     $fieldset->appendChild(new XMLElement('p', __('%1$s released on %2$s', array($value, DateTimeObj::format($release_date, __SYM_DATE_FORMAT__)))));
                 } else {
                     $fieldset->appendChild(new XMLElement('p', __('Created by %1$s at %2$s', array($value, DateTimeObj::format($release_date, __SYM_DATE_FORMAT__)))));
                 }
                 break;
             case 'description':
                 $fieldset = new XMLElement('fieldset');
                 $fieldset->appendChild(new XMLElement('legend', __('Description')));
                 $fieldset->appendChild(is_object($about['description']) ? $about['description'] : new XMLElement('p', $about['description']));
                 break;
             case 'example':
                 if (is_callable(array($datasource, 'example'))) {
                     $fieldset = new XMLElement('fieldset');
                     $fieldset->appendChild(new XMLElement('legend', __('Example XML')));
                     $example = $datasource->example();
                     if (is_object($example)) {
                         $fieldset->appendChild($example);
                     } else {
                         $p = new XMLElement('p');
                         $p->appendChild(new XMLElement('pre', '<code>' . str_replace('<', '&lt;', $example) . '</code>'));
                         $fieldset->appendChild($p);
                     }
                 }
                 break;
         }
         if ($fieldset) {
             $fieldset->setAttribute('class', 'settings');
             $this->Form->appendChild($fieldset);
         }
     }
     // Display source
     $file = DatasourceManager::__getClassPath($this->_context[1]) . '/data.' . $this->_context[1] . '.php';
     if (file_exists($file)) {
         $fieldset = new XMLElement('fieldset');
         $fieldset->setAttribute('class', 'settings');
         $fieldset->appendChild(new XMLElement('legend', __('Source')));
         $source = file_get_contents($file);
         $code = new XMLElement('code', htmlspecialchars($source));
         $pre = new XMLElement('pre');
         $pre->appendChild($code);
         $fieldset->appendChild($pre);
         $this->Form->appendChild($fieldset);
     }
 }
コード例 #9
0
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Authors'), __('Symphony'))));
     if (Symphony::Author()->isDeveloper() || Symphony::Author()->isManager()) {
         $this->appendSubheading(__('Authors'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a new author'), 'create button', null, array('accesskey' => 'c')));
     } else {
         $this->appendSubheading(__('Authors'));
     }
     Sortable::initialize($this, $authors, $sort, $order);
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Email Address'), 'sortable' => true, 'handle' => 'email'), array('label' => __('Last Seen'), 'sortable' => true, 'handle' => 'last_seen'));
     if (Symphony::Author()->isDeveloper() || Symphony::Author()->isManager()) {
         $columns = array_merge($columns, array(array('label' => __('User Type'), 'sortable' => true, 'handle' => 'user_type'), array('label' => __('Language'), 'sortable' => true, 'handle' => 'language')));
     }
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&amp;filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($authors) || empty($authors)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))), 'odd'));
     } else {
         foreach ($authors as $a) {
             // Setup each cell
             if (Symphony::Author()->isDeveloper() || Symphony::Author()->isManager() && !$a->isDeveloper() || Symphony::Author()->get('id') == $a->get('id')) {
                 $td1 = Widget::TableData(Widget::Anchor($a->getFullName(), Administration::instance()->getCurrentPageURL() . 'edit/' . $a->get('id') . '/', $a->get('username'), 'author'));
             } else {
                 $td1 = Widget::TableData($a->getFullName(), 'inactive');
             }
             // Can this Author be edited by the current Author?
             if (Symphony::Author()->isDeveloper() || Symphony::Author()->isManager()) {
                 if ($a->get('id') != Symphony::Author()->get('id')) {
                     $td1->appendChild(Widget::Label(__('Select Author %s', array($a->getFullName())), null, 'accessible', null, array('for' => 'author-' . $a->get('id'))));
                     $td1->appendChild(Widget::Input('items[' . $a->get('id') . ']', 'on', 'checkbox', array('id' => 'author-' . $a->get('id'))));
                 }
             }
             $td2 = Widget::TableData(Widget::Anchor($a->get('email'), 'mailto:' . $a->get('email'), __('Email this author')));
             if (!is_null($a->get('last_seen'))) {
                 $td3 = Widget::TableData(DateTimeObj::format($a->get('last_seen'), __SYM_DATETIME_FORMAT__));
             } else {
                 $td3 = Widget::TableData(__('Unknown'), 'inactive');
             }
             if ($a->isDeveloper()) {
                 $type = 'Developer';
             } elseif ($a->isManager()) {
                 $type = 'Manager';
             } else {
                 $type = 'Author';
             }
             $td4 = Widget::TableData(__($type));
             $languages = Lang::getAvailableLanguages();
             $td5 = Widget::TableData($a->get("language") == null ? __("System Default") : $languages[$a->get("language")]);
             // Add a row to the body array, assigning each cell to the row
             if (Symphony::Author()->isDeveloper() || Symphony::Author()->isManager()) {
                 $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5));
             } else {
                 $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
             }
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), null, Widget::TableBody($aTableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading'));
     $this->Form->appendChild($table);
     $version = new XMLElement('p', 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), array('id' => 'version'));
     $this->Form->appendChild($version);
 }
コード例 #10
0
ファイル: field.date.php プロジェクト: valery/symphony-2
 public function prepareTextValue($data, $entry_id = null)
 {
     $value = '';
     if (isset($data['value'])) {
         $value = DateTimeObj::format($data['value'], DateTimeObj::getSetting('datetime_format'), true);
     }
     return $value;
 }
コード例 #11
0
 function index(&$Page, &$Contents, $fields)
 {
     global $warnings;
     global $notices;
     global $languages;
     $Form = new XMLElement('form');
     $Form->setAttribute('action', kINSTALL_FILENAME . ($_GET['lang'] ? '?lang=' . $_GET['lang'] : ''));
     $Form->setAttribute('method', 'post');
     // START ENVIRONMENT SETTINGS
     $Environment = new XMLElement('fieldset');
     $Environment->appendChild(new XMLElement('legend', __('Environment Settings')));
     $Environment->appendChild(new XMLElement('p', __('Symphony is ready to be installed at the following location.')));
     $class = NULL;
     if (defined('kENVIRONMENT_WARNING') && kENVIRONMENT_WARNING == true) {
         $class = 'warning';
     }
     $Environment->appendChild(Widget::label(__('Root Path'), Widget::input('fields[docroot]', $fields['docroot']), $class));
     if (defined('ERROR') && defined('kENVIRONMENT_WARNING')) {
         $Environment->appendChild(new XMLElement('p', $warnings[ERROR], array('class' => 'warning')));
     }
     $Form->appendChild($Environment);
     // START LOCALE SETTINGS
     $Environment = new XMLElement('fieldset');
     $Environment->appendChild(new XMLElement('legend', __('Website Preferences')));
     $Environment->appendChild(Widget::label(__('Name'), Widget::input('fields[general][sitename]', $fields['general']['sitename'])));
     $Fieldset = new XMLElement('fieldset');
     $Fieldset->appendChild(new XMLElement('legend', __('Date and Time')));
     $Fieldset->appendChild(new XMLElement('p', __('Customise how Date and Time values are displayed throughout the Administration interface.')));
     $options = array();
     $groups = array();
     $system_tz = isset($fields['region']['timezone']) ? $fields['region']['timezone'] : date_default_timezone_get();
     foreach (timezone_identifiers_list() as $tz) {
         if (preg_match('/\\//', $tz)) {
             $parts = preg_split('/\\//', $tz, 2, PREG_SPLIT_NO_EMPTY);
             $groups[$parts[0]][] = $parts[1];
         } else {
             $groups[$tz] = $tz;
         }
     }
     foreach ($groups as $key => $val) {
         if (is_array($val)) {
             $tmp = array('label' => $key, 'options' => array());
             foreach ($val as $zone) {
                 $tmp['options'][] = array("{$key}/{$zone}", "{$key}/{$zone}" == $system_tz, str_replace('_', ' ', $zone));
             }
             $options[] = $tmp;
         } else {
             $options[] = array($key, $key == $system_tz, str_replace('_', ' ', $key));
         }
     }
     $Fieldset->appendChild(Widget::label(__('Region'), Widget::Select('fields[region][timezone]', $options)));
     $dateformat = $fields['region']['date_format'];
     $label = Widget::Label(__('Date Format'));
     $dateFormats = array('Y/m/d', 'm/d/Y', 'm/d/y', 'Y-m-d', 'm-d-Y', 'm-d-y', 'd.m.Y', 'j.n.Y', 'd.m.y', 'j.n.y', 'd F Y', 'd M Y', 'j. F Y', 'j. M. Y');
     $dateOptions = array();
     foreach ($dateFormats as $dateOption) {
         $leadingZero = '';
         if (strpos($dateOption, 'j') !== false || strpos($dateOption, 'n') !== false) {
             $leadingZero = ' (' . __('no leading zeros') . ')';
         }
         $dateOptions[] = array($dateOption, $dateformat == $dateOption, DateTimeObj::format('now', $dateOption) . $leadingZero);
     }
     $label->appendChild(Widget::Select('fields[region][date_format]', $dateOptions));
     $Fieldset->appendChild($label);
     $timeformat = $fields['region']['time_format'];
     $label = Widget::Label(__('Time Format'));
     $timeformats = array(array('H:i:s', $timeformat == 'H:i:s', DateTimeObj::get('H:i:s')), array('H:i', $timeformat == 'H:i', DateTimeObj::get('H:i')), array('g:i:s a', $timeformat == 'g:i:s a', DateTimeObj::get('g:i:s a')), array('g:i a', $timeformat == 'g:i a', DateTimeObj::get('g:i a')));
     $label->appendChild(Widget::Select('fields[region][time_format]', $timeformats));
     $Fieldset->appendChild($label);
     $Environment->appendChild($Fieldset);
     $Form->appendChild($Environment);
     // START DATABASE SETTINGS
     $Database = new XMLElement('fieldset');
     $Database->appendChild(new XMLElement('legend', __('Database Connection')));
     $Database->appendChild(new XMLElement('p', __('Please provide Symphony with access to a database.')));
     $class = NULL;
     if (defined('kDATABASE_VERSION_WARNING') && kDATABASE_VERSION_WARNING == true) {
         $class = ' warning';
     }
     ## fields[database][name]
     $label = Widget::label(__('Database'), Widget::input('fields[database][name]', $fields['database']['name']), $class);
     $Database->appendChild($label);
     if (defined('ERROR') && defined('kDATABASE_VERSION_WARNING')) {
         $Database->appendChild(new XMLElement('p', $warnings[ERROR], array('class' => 'warning')));
     }
     $class = NULL;
     if (defined('kDATABASE_CONNECTION_WARNING') && kDATABASE_CONNECTION_WARNING == true) {
         $class = ' warning';
     }
     $Div = new XMLElement('div');
     $Div->setAttribute('class', 'group' . $class);
     ## fields[database][username]
     $Div->appendChild(Widget::label(__('Username'), Widget::input('fields[database][username]', $fields['database']['username'])));
     ## fields[database][password]
     $Div->appendChild(Widget::label(__('Password'), Widget::input('fields[database][password]', $fields['database']['password'], 'password')));
     $Database->appendChild($Div);
     if (defined('ERROR') && defined('kDATABASE_CONNECTION_WARNING')) {
         $Database->appendChild(new XMLElement('p', $warnings[ERROR], array('class' => 'warning')));
     }
     $Fieldset = new XMLElement('fieldset');
     $Fieldset->appendChild(new XMLElement('legend', __('Advanced Configuration')));
     $Fieldset->appendChild(new XMLElement('p', __('Leave these fields unless you are sure they need to be changed.')));
     $Div = new XMLElement('div');
     $Div->setAttribute('class', 'group');
     ## fields[database][host]
     $Div->appendChild(Widget::label(__('Host'), Widget::input('fields[database][host]', $fields['database']['host'])));
     ## fields[database][port]
     $Div->appendChild(Widget::label(__('Port'), Widget::input('fields[database][port]', $fields['database']['port'])));
     $Fieldset->appendChild($Div);
     $class = NULL;
     if (defined('kDATABASE_PREFIX_WARNING') && kDATABASE_PREFIX_WARNING == true) {
         $class = 'warning';
     }
     ## fields[database][prefix]
     $Fieldset->appendChild(Widget::label(__('Table Prefix'), Widget::input('fields[database][prefix]', $fields['database']['prefix']), $class));
     if (defined('ERROR') && defined('kDATABASE_PREFIX_WARNING')) {
         $Fieldset->appendChild(new XMLElement('p', $warnings[ERROR], array('class' => 'warning')));
     }
     $Page->setTemplateVar('TABLE-PREFIX', $fields['database']['prefix']);
     ## Use UTF-8 at all times unless otherwise specified
     $Fieldset->appendChild(Widget::label(__('Always use <code>UTF-8</code> encoding'), Widget::input('fields[database][use-server-encoding]', 'no', 'checkbox', !isset($fields['database']['use-server-encoding']) ? array() : array('checked' => 'checked')), 'option'));
     $Fieldset->appendChild(new XMLElement('p', __("If unchecked, Symphony will use your database's default encoding instead of <code>UTF-8</code>.")));
     $Database->appendChild($Fieldset);
     $Form->appendChild($Database);
     // START PERMISSION SETTINGS
     $Permissions = new XMLElement('fieldset');
     $Permissions->appendChild(new XMLElement('legend', __('Permission Settings')));
     $Permissions->appendChild(new XMLElement('p', __('Symphony needs permission to read and write both files and directories.')));
     $Div = new XMLElement('div');
     $Div->setAttribute('class', 'group');
     $Div->appendChild(Widget::label(__('Files'), Widget::input('fields[permission][file]', $fields['permission']['file'])));
     $Div->appendChild(Widget::label(__('Directories'), Widget::input('fields[permission][directory]', $fields['permission']['directory'])));
     $Permissions->appendChild($Div);
     $Form->appendChild($Permissions);
     // START USER SETTINGS
     $User = new XMLElement('fieldset');
     $User->appendChild(new XMLElement('legend', __('User Information')));
     $User->appendChild(new XMLElement('p', __('Once installed, you will be able to login to the Symphony admin with these user details.')));
     $class = NULL;
     if (defined('kUSER_USERNAME_WARNING') && kUSER_PASSWORD_WARNING == true) {
         $class = 'warning';
     }
     ## fields[user][username]
     $User->appendChild(Widget::label(__('Username'), Widget::input('fields[user][username]', $fields['user']['username']), $class));
     if (defined('ERROR') && defined('kUSER_USERNAME_WARNING')) {
         $User->appendChild(new XMLElement('p', $warnings[ERROR], array('class' => 'warning')));
     }
     $class = NULL;
     if (defined('kUSER_PASSWORD_WARNING') && kUSER_PASSWORD_WARNING == true) {
         $class = ' warning';
     }
     $Div = new XMLElement('div');
     $Div->setAttribute('class', 'group' . $class);
     ## fields[user][password]
     $Div->appendChild(Widget::label(__('Password'), Widget::input('fields[user][password]', $fields['user']['password'], 'password')));
     ## fields[user][confirm-password]
     $Div->appendChild(Widget::label(__('Confirm Password'), Widget::input('fields[user][confirm-password]', $fields['user']['confirm-password'], 'password')));
     $User->appendChild($Div);
     if (defined('ERROR') && defined('kUSER_PASSWORD_WARNING')) {
         $User->appendChild(new XMLElement('p', $warnings[ERROR], array('class' => 'warning')));
     }
     $Fieldset = new XMLElement('fieldset');
     $Fieldset->appendChild(new XMLElement('legend', __('Personal Information')));
     $Fieldset->appendChild(new XMLElement('p', __('Please add the following personal details for this user.')));
     $class = NULL;
     if (defined('kUSER_NAME_WARNING') && kUSER_EMAIL_WARNING == true) {
         $class = ' warning';
     }
     $Div = new XMLElement('div');
     $Div->setAttribute('class', 'group' . $class);
     $Div->appendChild(Widget::label(__('First Name'), Widget::input('fields[user][firstname]', $fields['user']['firstname'])));
     $Div->appendChild(Widget::label(__('Last Name'), Widget::input('fields[user][lastname]', $fields['user']['lastname'])));
     $Fieldset->appendChild($Div);
     if (defined('ERROR') && defined('kUSER_NAME_WARNING')) {
         $Fieldset->appendChild(new XMLElement('p', $warnings[ERROR], array('class' => 'warning')));
     }
     $class = NULL;
     if (defined('kUSER_EMAIL_WARNING') && kUSER_EMAIL_WARNING == true) {
         $class = 'warning';
     }
     ## fields[user][email]
     $Fieldset->appendChild(Widget::label(__('Email Address'), Widget::input('fields[user][email]', $fields['user']['email']), $class));
     if (defined('ERROR') && defined('kUSER_EMAIL_WARNING')) {
         $Fieldset->appendChild(new XMLElement('p', $warnings[ERROR], array('class' => 'warning')));
     }
     $User->appendChild($Fieldset);
     $Form->appendChild($User);
     // START FORM SUBMIT AREA
     $Form->appendChild(new XMLElement('h2', __('Install Symphony')));
     $Form->appendChild(new XMLElement('p', __('Make sure that you delete <code>%s</code> file after Symphony has installed successfully.', array(kINSTALL_FILENAME))));
     $Submit = new XMLElement('div');
     $Submit->setAttribute('class', 'submit');
     ### submit
     $Submit->appendChild(Widget::input('submit', __('Install Symphony'), 'submit'));
     ### action[install]
     $Submit->appendChild(Widget::input('action[install]', 'true', 'hidden'));
     $Form->appendChild($Submit);
     $Contents->appendChild($Form);
     $Page->setTemplateVar('title', __('Install Symphony'));
     $Page->setTemplateVar('tagline', __('Version %s', array(kVERSION)));
     $Page->setTemplateVar('languages', $languages);
 }
コード例 #12
0
 /**
  * This function contains the minimal amount of logic for generating the
  * index table of a given `$resource_type`. The table has name, source, pages
  * release date and author columns. The values for these columns are determined
  * by the resource's `about()` method.
  *
  * As Datasources types can be installed using Providers, the Source column
  * can be overridden with a Datasource's `getSourceColumn` method (if it exists).
  *
  * @param integer $resource_type
  *  Either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE`
  */
 public function __viewIndex($resource_type)
 {
     $manager = ResourceManager::getManagerFromType($resource_type);
     $this->setPageType('table');
     Sortable::initialize($this, $resources, $sort, $order, array('type' => $resource_type));
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Source'), 'sortable' => true, 'handle' => 'source'), array('label' => __('Pages'), 'sortable' => false), array('label' => __('Release Date'), 'sortable' => true, 'handle' => 'release-date'), array('label' => __('Author'), 'sortable' => true, 'handle' => 'author'));
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&amp;filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($resources) || empty($resources)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($resources as $r) {
             // Resource name
             $action = isset($r['can_parse']) && $r['can_parse'] === true ? 'edit' : 'info';
             $name = Widget::TableData(Widget::Anchor($r['name'], SYMPHONY_URL . $_REQUEST['symphony-page'] . $action . '/' . $r['handle'] . '/', $r['handle']));
             // Resource type/source
             if (isset($r['source'], $r['source']['id'])) {
                 $section = Widget::TableData(Widget::Anchor($r['source']['name'], SYMPHONY_URL . '/blueprints/sections/edit/' . $r['source']['id'] . '/', $r['source']['handle']));
             } else {
                 if (isset($r['source']) && class_exists($r['source']['name']) && method_exists($r['source']['name'], 'getSourceColumn')) {
                     $class = call_user_func(array($manager, '__getClassName'), $r['handle']);
                     $section = Widget::TableData(call_user_func(array($class, 'getSourceColumn'), $r['handle']));
                 } else {
                     if (isset($r['source'], $r['source']['name'])) {
                         $section = Widget::TableData($r['source']['name']);
                     } else {
                         $section = Widget::TableData(__('Unknown'), 'inactive');
                     }
                 }
             }
             // Attached pages
             $pages = ResourceManager::getAttachedPages($resource_type, $r['handle']);
             $pagelinks = array();
             $i = 0;
             foreach ($pages as $p) {
                 ++$i;
                 $pagelinks[] = Widget::Anchor($p['title'], SYMPHONY_URL . '/blueprints/pages/edit/' . $p['id'] . '/')->generate() . (count($pages) > $i ? $i % 10 == 0 ? '<br />' : ', ' : '');
             }
             $pages = implode('', $pagelinks);
             if ($pages == '') {
                 $pagelinks = Widget::TableData(__('None'), 'inactive');
             } else {
                 $pagelinks = Widget::TableData($pages, 'pages');
             }
             // Release date
             $releasedate = Widget::TableData(Lang::localizeDate(DateTimeObj::format($r['release-date'], __SYM_DATETIME_FORMAT__)));
             // Authors
             $author = $r['author']['name'];
             if ($author) {
                 if (isset($r['author']['website'])) {
                     $author = Widget::Anchor($r['author']['name'], General::validateURL($r['author']['website']));
                 } else {
                     if (isset($r['author']['email'])) {
                         $author = Widget::Anchor($r['author']['name'], 'mailto:' . $r['author']['email']);
                     }
                 }
             }
             $author = Widget::TableData($author);
             $author->appendChild(Widget::Input('items[' . $r['handle'] . ']', null, 'checkbox'));
             $aTableBody[] = Widget::TableRow(array($name, $section, $pagelinks, $releasedate, $author));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm'));
     $pages = $this->pagesFlatView();
     $group_attach = array('label' => __('Attach to Page'), 'options' => array());
     $group_detach = array('label' => __('Detach from Page'), 'options' => array());
     $group_attach['options'][] = array('attach-all-pages', false, __('All'));
     $group_detach['options'][] = array('detach-all-pages', false, __('All'));
     foreach ($pages as $p) {
         $group_attach['options'][] = array('attach-to-page-' . $p['id'], false, $p['title']);
         $group_detach['options'][] = array('detach-from-page-' . $p['id'], false, $p['title']);
     }
     $options[] = $group_attach;
     $options[] = $group_detach;
     /**
      * Allows an extension to modify the existing options for this page's
      * With Selected menu. If the `$options` parameter is an empty array,
      * the 'With Selected' menu will not be rendered.
      *
      * @delegate AddCustomActions
      * @since Symphony 2.3.2
      * @param string $context
      * '/blueprints/datasources/' or '/blueprints/events/'
      * @param array $options
      *  An array of arrays, where each child array represents an option
      *  in the With Selected menu. Options should follow the same format
      *  expected by `Widget::__SelectBuildOption`. Passed by reference.
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomActions', $_REQUEST['symphony-page'], array('options' => &$options));
     if (!empty($options)) {
         $tableActions->appendChild(Widget::Apply($options));
         $this->Form->appendChild($tableActions);
     }
 }
コード例 #13
0
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Authors'), __('Symphony'))));
     if (Administration::instance()->Author->isDeveloper()) {
         $this->appendSubheading(__('Authors'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a new author'), 'create button', NULL, array('accesskey' => 'c')));
     } else {
         $this->appendSubheading(__('Authors'));
     }
     Sortable::initialize($this, $authors, $sort, $order);
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Email Address'), 'sortable' => true, 'handle' => 'email'), array('label' => __('Last Seen'), 'sortable' => true, 'handle' => 'last_seen'));
     if (Administration::instance()->Author->isDeveloper()) {
         $columns = array_merge($columns, array(array('label' => __('User Type'), 'sortable' => true, 'handle' => 'user_type'), array('label' => __('Language'), 'sortable' => true, 'handle' => 'language')));
     }
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&amp;filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($authors) || empty($authors)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($authors as $a) {
             // Setup each cell
             if (Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->get('id') == $a->get('id')) {
                 $td1 = Widget::TableData(Widget::Anchor($a->getFullName(), Administration::instance()->getCurrentPageURL() . 'edit/' . $a->get('id') . '/', $a->get('username'), 'author'));
             } else {
                 $td1 = Widget::TableData($a->getFullName(), 'inactive');
             }
             $td2 = Widget::TableData(Widget::Anchor($a->get('email'), 'mailto:' . $a->get('email'), __('Email this author')));
             if (!is_null($a->get('last_seen'))) {
                 $td3 = Widget::TableData(DateTimeObj::format($a->get('last_seen'), __SYM_DATETIME_FORMAT__));
             } else {
                 $td3 = Widget::TableData(__('Unknown'), 'inactive');
             }
             $td4 = Widget::TableData($a->isDeveloper() ? __("Developer") : __("Author"));
             $languages = Lang::getAvailableLanguages();
             $td5 = Widget::TableData($a->get("language") == NULL ? __("System Default") : $languages[$a->get("language")]);
             if (Administration::instance()->Author->isDeveloper()) {
                 if ($a->get('id') != Administration::instance()->Author->get('id')) {
                     $td3->appendChild(Widget::Input('items[' . $a->get('id') . ']', NULL, 'checkbox'));
                 }
             }
             // Add a row to the body array, assigning each cell to the row
             if (Administration::instance()->Author->isDeveloper()) {
                 $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5));
             } else {
                 $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
             }
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     if (Administration::instance()->Author->isDeveloper()) {
         $tableActions = new XMLElement('div');
         $tableActions->setAttribute('class', 'actions');
         $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected authors?'))));
         /**
          * Allows an extension to modify the existing options for this page's
          * With Selected menu. If the `$options` parameter is an empty array,
          * the 'With Selected' menu will not be rendered.
          *
          * @delegate AddCustomActions
          * @since Symphony 2.3.2
          * @param string $context
          * '/system/authors/'
          * @param array $options
          *  An array of arrays, where each child array represents an option
          *  in the With Selected menu. Options should follow the same format
          *  expected by `Widget::__SelectBuildOption`. Passed by reference.
          */
         Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/system/authors/', array('options' => &$options));
         if (!empty($options)) {
             $tableActions->appendChild(Widget::Apply($options));
             $this->Form->appendChild($tableActions);
         }
     }
 }
コード例 #14
0
 public function prepareTableValue($data, XMLElement $link = NULL)
 {
     $value = null;
     if (isset($data['gmt']) && !is_null($data['gmt'])) {
         $value = DateTimeObj::format($data['gmt'], __SYM_DATETIME_FORMAT__, true);
     }
     return parent::prepareTableValue(array('value' => $value), $link);
 }
コード例 #15
0
 public function __viewInfo()
 {
     $this->setPageType('form');
     $datasource = DatasourceManager::create($this->_context[1], array(), false);
     $about = $datasource->about();
     $this->setTitle(__('%1$s &ndash; %2$s &ndash; %3$s', array($about['name'], __('Data Source'), __('Symphony'))));
     $this->appendSubheading($about['name']);
     $this->Form->setAttribute('id', 'controller');
     $link = $about['author']['name'];
     if (isset($about['author']['website'])) {
         $link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website']));
     } elseif (isset($about['author']['email'])) {
         $link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']);
     }
     foreach ($about as $key => $value) {
         $fieldset = NULL;
         switch ($key) {
             case 'author':
                 if ($link) {
                     $fieldset = new XMLElement('fieldset');
                     $fieldset->appendChild(new XMLElement('legend', __('Author')));
                     $fieldset->appendChild(new XMLElement('p', $link->generate(false)));
                 }
                 break;
             case 'version':
                 $fieldset = new XMLElement('fieldset');
                 $fieldset->appendChild(new XMLElement('legend', __('Version')));
                 if (preg_match('/^\\d+(\\.\\d+)*$/', $value)) {
                     $fieldset->appendChild(new XMLElement('p', __('%1$s released on %2$s', array($value, DateTimeObj::format($about['release-date'], __SYM_DATE_FORMAT__)))));
                 } else {
                     $fieldset->appendChild(new XMLElement('p', __('Created by %1$s at %2$s', array($value, DateTimeObj::format($about['release-date'], __SYM_DATE_FORMAT__)))));
                 }
                 break;
             case 'description':
                 $fieldset = new XMLElement('fieldset');
                 $fieldset->appendChild(new XMLElement('legend', __('Description')));
                 $fieldset->appendChild(is_object($about['description']) ? $about['description'] : new XMLElement('p', $about['description']));
             case 'example':
                 if (is_callable(array($datasource, 'example'))) {
                     $fieldset = new XMLElement('fieldset');
                     $fieldset->appendChild(new XMLElement('legend', __('Example XML')));
                     $example = $datasource->example();
                     if (is_object($example)) {
                         $fieldset->appendChild($example);
                     } else {
                         $p = new XMLElement('p');
                         $p->appendChild(new XMLElement('pre', '<code>' . str_replace('<', '&lt;', $example) . '</code>'));
                         $fieldset->appendChild($p);
                     }
                 }
                 break;
         }
         if ($fieldset) {
             $fieldset->setAttribute('class', 'settings');
             $this->Form->appendChild($fieldset);
         }
     }
 }
コード例 #16
0
 /**
  * This function contains the minimal amount of logic for generating the
  * index table of a given `$resource_type`. The table has name, source, pages
  * release date and author columns. The values for these columns are determined
  * by the resource's `about()` method.
  *
  * As Datasources types can be installed using Providers, the Source column
  * can be overridden with a Datasource's `getSourceColumn` method (if it exists).
  *
  * @param integer $resource_type
  *  Either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE`
  */
 public function __viewIndex($resource_type)
 {
     $manager = ResourceManager::getManagerFromType($resource_type);
     $this->setPageType('table');
     Sortable::initialize($this, $resources, $sort, $order, array('type' => $resource_type));
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Source'), 'sortable' => true, 'handle' => 'source'), array('label' => __('Pages'), 'sortable' => false), array('label' => __('Release Date'), 'sortable' => true, 'handle' => 'release-date'), array('label' => __('Author'), 'sortable' => true, 'handle' => 'author'));
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&amp;filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($resources) || empty($resources)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($resources as $r) {
             // Resource name
             $action = $r['can_parse'] ? 'edit' : 'info';
             $name = Widget::TableData(Widget::Anchor($r['name'], SYMPHONY_URL . $_REQUEST['symphony-page'] . $action . '/' . $r['handle'] . '/', $r['handle']));
             // Resource type/source
             if (isset($r['source']['id'])) {
                 $section = Widget::TableData(Widget::Anchor($r['source']['name'], SYMPHONY_URL . '/blueprints/sections/edit/' . $r['source']['id'] . '/', $r['source']['handle']));
             } else {
                 if (class_exists($r['source']['name']) && method_exists($r['source']['name'], 'getSourceColumn')) {
                     $class = call_user_func(array($manager, '__getClassName'), $r['handle']);
                     $section = Widget::TableData(call_user_func(array($class, 'getSourceColumn'), $r['handle']));
                 } else {
                     if (isset($r['source']['name'])) {
                         $section = Widget::TableData($r['source']['name']);
                     } else {
                         $section = Widget::TableData(__('Unknown'), 'inactive');
                     }
                 }
             }
             // Attached pages
             $pages = ResourceManager::getAttachedPages($resource_type, $r['handle']);
             $pagelinks = array();
             $i = 0;
             foreach ($pages as $p) {
                 ++$i;
                 $pagelinks[] = Widget::Anchor($p['title'], SYMPHONY_URL . '/blueprints/pages/edit/' . $p['id'] . '/')->generate() . (count($pages) > $i ? $i % 10 == 0 ? '<br />' : ', ' : '');
             }
             $pages = implode('', $pagelinks);
             if ($pages == '') {
                 $pagelinks = Widget::TableData(__('None'), 'inactive');
             } else {
                 $pagelinks = Widget::TableData($pages, 'pages');
             }
             // Release date
             $releasedate = Widget::TableData(Lang::localizeDate(DateTimeObj::format($r['release-date'], __SYM_DATETIME_FORMAT__)));
             // Authors
             $author = $r['author']['name'];
             if (isset($r['author']['website'])) {
                 $author = Widget::Anchor($r['author']['name'], General::validateURL($r['author']['website']));
             } else {
                 if (isset($r['author']['email'])) {
                     $author = Widget::Anchor($r['author']['name'], 'mailto:' . $r['author']['email']);
                 }
             }
             $author = Widget::TableData($author);
             $author->appendChild(Widget::Input('items[' . $r['handle'] . ']', null, 'checkbox'));
             $aTableBody[] = Widget::TableRow(array($name, $section, $pagelinks, $releasedate, $author));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm'));
     $pages = $this->pagesFlatView();
     $group_attach = array('label' => __('Attach to Page'), 'options' => array());
     $group_detach = array('label' => __('Detach from Page'), 'options' => array());
     $group_attach['options'][] = array('attach-all-pages', false, __('All'));
     $group_detach['options'][] = array('detach-all-pages', false, __('All'));
     foreach ($pages as $p) {
         $group_attach['options'][] = array('attach-to-page-' . $p['id'], false, $p['title']);
         $group_detach['options'][] = array('detach-from-page-' . $p['id'], false, $p['title']);
     }
     $options[] = $group_attach;
     $options[] = $group_detach;
     $tableActions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($tableActions);
 }