コード例 #1
0
 protected function viewSuccess()
 {
     $symphonyUrl = URL . '/' . Symphony::Configuration()->get('admin-path', 'symphony');
     $this->Form->setAttribute('action', $symphonyUrl);
     $div = new XMLElement('div');
     $div->appendChild(new XMLElement('h2', __('The floor is yours')));
     $div->appendChild(new XMLElement('p', __('Thanks for taking the quick, yet epic installation journey with us. It’s now your turn to shine!')));
     $this->Form->appendChild($div);
     $ul = new XMLElement('ul');
     foreach ($this->_params['disabled-extensions'] as $handle) {
         $ul->appendChild(new XMLElement('li', '<code>' . $handle . '</code>'));
     }
     if ($ul->getNumberOfChildren() !== 0) {
         $this->Form->appendChild(new XMLElement('p', __('Looks like the following extensions couldn’t be enabled and must be manually installed. It’s a minor setback in our otherwise prosperous future together.')));
         $this->Form->appendChild($ul);
     }
     $this->Form->appendChild(new XMLElement('p', __('I think you and I will achieve great things together. Just one last thing: how about we remove the %s folder and secure the safety of our relationship?', array('<code>' . basename(INSTALL) . '</code>'))));
     $submit = new XMLElement('div', null, array('class' => 'submit'));
     $submit->appendChild(Widget::Input('submit', __('Okay, now take me to the login page'), 'submit'));
     $this->Form->appendChild($submit);
 }
コード例 #2
0
 /**
  * Adjust the publish index screen
  * @param $context
  *  The context
  * @param $callback
  *  The callback
  * @return mixed
  */
 private function adjustIndex($context, $callback)
 {
     $data = $this->getCurrentAuthorRoleData();
     if ($data == false || Administration::instance()->Author()->isDeveloper()) {
         return;
     }
     // Set the hidden fields:
     $hiddenFields = array();
     foreach ($data['fields'] as $id_field => $rules) {
         if ($rules['hidden'] == 1) {
             // This field is hidden.
             array_push($hiddenFields, $id_field);
         }
     }
     $section = $callback['context']['section_handle'];
     foreach ($data['sections'] as $id_section => $rules) {
         if ($rules['handle'] == $section) {
             // Check if there are rules:
             if ($rules['create'] == 0) {
                 // It is not allowed to create new items:
                 $children = current($context['oPage']->Context->getChildrenByName('ul'))->getChildrenByName('li');
                 foreach ($children as $key => $child) {
                     if (strpos($child->getValue(), __('Create New')) !== false) {
                         $value = $child->getValue();
                         $child->setValue('<span>' . strip_tags(str_replace(__('Create New'), '', $value)) . '</span><span class="create" />');
                     }
                 }
             }
             if ($rules['own_entries'] == 1 || $rules['edit'] == 0 || $rules['delete'] == 0 || $rules['use_filter'] == 1) {
                 // For only show entries created by this author:
                 // Get a list of entry id's created by this author:
                 $id_author = Administration::instance()->Author()->get('id');
                 if ($rules['own_entries'] == 1) {
                     // Only get the ID's of the current author to begin with:
                     $results = Symphony::Database()->fetch('SELECT `id` FROM `tbl_entries` WHERE `author_id` = ' . $id_author . ';');
                 } else {
                     // Get all the ID's:
                     $results = Symphony::Database()->fetch('SELECT `id` FROM `tbl_entries`;');
                 }
                 $ids = array();
                 foreach ($results as $result) {
                     $ids[] = $result['id'];
                 }
                 // Add or remove ID's from the filter:
                 if ($rules['use_filter'] == 1) {
                     $rule = explode(':', $rules['filter_rule']);
                     if (count($rule) == 2) {
                         // Valid filter, now get the ID's:
                         $filteredIDs = array();
                         $action = $rule[0];
                         $idsArr = explode(',', $rule[1]);
                         foreach ($idsArr as $idExpr) {
                             $a = explode('-', trim($idExpr));
                             if (count($a) == 1) {
                                 // Regular ID
                                 $filteredIDs[] = $a[0];
                             } elseif (count($a) == 2) {
                                 // Range
                                 $from = $a[0];
                                 $to = $a[1];
                                 if ($to >= $from) {
                                     for ($i = $from; $i <= $to; $i++) {
                                         $filteredIDs[] = $i;
                                     }
                                 }
                             }
                         }
                         switch ($action) {
                             case 'show':
                                 // Only show the given ids. Well that's easy:
                                 $ids = $filteredIDs;
                                 break;
                             case 'hide':
                                 // Remove the filtered ids from the ids-array:
                                 $ids = array_diff($ids, $filteredIDs);
                                 break;
                         }
                     }
                 }
                 // Now, check each table row:
                 $newContents = new XMLElement('div', null, $context['oPage']->Contents->getAttributes());
                 foreach ($context['oPage']->Contents->getChildren() as $contentsChild) {
                     if ($contentsChild->getName() == 'form') {
                         $newForm = new XMLElement('form', null, $contentsChild->getAttributes());
                         foreach ($contentsChild->getChildren() as $formChild) {
                             // only show entries created by this author, or which are allowed by the filter:
                             if ($formChild->getName() == 'table' && ($rules['own_entries'] == 1 || $rules['use_filter'] == 1)) {
                                 $newTable = new XMLElement('table', null, $formChild->getAttributes());
                                 foreach ($formChild->getChildren() as $tableChild) {
                                     if ($tableChild->getName() == 'tbody') {
                                         $newTableBody = new XMLElement('tbody', null, $tableChild->getAttributes());
                                         foreach ($tableChild->getChildren() as $tableRow) {
                                             // Check the ID:
                                             $id = explode('-', $tableRow->getAttribute('id'));
                                             if (in_array($id[1], $ids)) {
                                                 $newTableBody->appendChild($tableRow);
                                             }
                                         }
                                         $newTable->appendChild($newTableBody);
                                     } else {
                                         $newTable->appendChild($tableChild);
                                     }
                                 }
                                 $newForm->appendChild($newTable);
                             } elseif ($formChild->getName() == 'div' && $formChild->getAttribute('class') == 'actions') {
                                 // Only proceed if you can either edit or delete. Otherwise it would have much sense to have an apply-button here...
                                 if ($rules['delete'] == 1 || $rules['edit'] == 1) {
                                     $child = self::findChildren($formChild, 'select');
                                     $child = $child[0];
                                     $newSelect = new XMLElement('select', null, $child->getAttributes());
                                     foreach ($child->getChildren() as $selectChild) {
                                         // See if delete is allowed:
                                         if ($selectChild->getAttribute('value') == 'delete' && $rules['delete'] == 1) {
                                             $newSelect->appendChild($selectChild);
                                         } elseif ($selectChild->getName() == 'optgroup' && $rules['edit'] == 1) {
                                             // Check if the field that is edited is not a hidden field, because then editing is not allowed:
                                             $optGroupChildren = $selectChild->getChildren();
                                             if (!empty($optGroupChildren)) {
                                                 $value = $optGroupChildren[0]->getAttribute('value');
                                                 $a = explode('-', str_replace('toggle-', '', $value));
                                                 if (!in_array($a[0], $hiddenFields)) {
                                                     $newSelect->appendChild($selectChild);
                                                 }
                                             }
                                         } elseif ($selectChild->getName() == 'option' && $selectChild->getAttribute('value') != 'delete' && ($rules['edit'] == 1 || $rules['delete'] == 1)) {
                                             $newSelect->appendChild($selectChild);
                                         }
                                     }
                                     // if the new select has only one entry,
                                     // it is the dummy entry and we can discard it
                                     if ($newSelect->getNumberOfChildren() > 1) {
                                         self::replaceChild($formChild, $newSelect);
                                         $newForm->appendChild($formChild);
                                     }
                                 }
                             } else {
                                 $newForm->appendChild($formChild);
                             }
                         }
                         $newContents->appendChild($newForm);
                         $context['oPage']->Form = $newForm;
                     } else {
                         $newContents->appendChild($contentsChild);
                     }
                 }
                 $context['oPage']->Contents = $newContents;
             }
         }
     }
 }