public function findFields()
 {
     $sectionManager = new SectionManager($this->_engine);
     $sections = $sectionManager->fetch(null, 'ASC', 'name');
     $groups = $options = array();
     if (is_array($sections) and !empty($sections)) {
         foreach ($sections as $section) {
             $groups[$section->get('id')] = array('fields' => $section->fetchFields(), 'section' => $section);
         }
     }
     foreach ($groups as $group) {
         if (!is_array($group['fields'])) {
             continue;
         }
         $fields = array();
         foreach ($group['fields'] as $field) {
             if ($field->get('type') == 'groupname') {
                 $selected = $this->get('child_field_id') == $field->get('id');
                 $fields[] = array($field->get('id'), $selected, $field->get('label'));
             }
         }
         if (empty($fields)) {
             continue;
         }
         $options[] = array('label' => $group['section']->get('name'), 'options' => $fields);
     }
     return $options;
 }
 function view()
 {
     $this->_Parent->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 70);
     $create_button = Widget::Anchor('Create a New Role', extension_members::baseURL() . 'new/', 'Create a new role', 'create button');
     $this->setPageType('table');
     $this->appendSubheading('Member Roles ' . $create_button->generate(false));
     $aTableHead = array(array('Name', 'col'), array('Members', 'col'));
     $roles = $this->_driver->fetchRoles();
     $aTableBody = array();
     if (!is_array($roles) || empty($roles)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', NULL, count($aTableHead)))));
     } else {
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($this->_Parent->Database->fetchVar('parent_section', 0, "SELECT `parent_section` FROM `tbl_fields` WHERE `id` = '" . $this->_driver->usernameAndPasswordField() . "' LIMIT 1"));
         $bEven = true;
         $role_field_name = $this->_Parent->Database->fetchVar('element_name', 0, "SELECT `element_name` FROM `tbl_fields` WHERE `id` = '" . $this->_driver->roleField() . "' LIMIT 1");
         foreach ($roles as $role) {
             $member_count = $this->_Parent->Database->fetchVar('count', 0, "SELECT COUNT(*) AS `count` FROM `tbl_entries_data_" . $this->_driver->roleField() . "` WHERE `role_id` = '" . $role->id() . "'");
             ## Setup each cell
             $td1 = Widget::TableData(Widget::Anchor($role->name(), extension_members::baseURL() . 'edit/' . $role->id() . '/', NULL, 'content'));
             $td2 = Widget::TableData(Widget::Anchor("{$member_count}", URL . '/symphony/publish/' . $section->get('handle') . '/?filter=' . $role_field_name . ':' . $role->id()));
             ## Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2), $bEven ? 'odd' : NULL);
             $bEven = !$bEven;
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
     $this->Form->appendChild($table);
 }
Beispiel #3
0
 public function __viewIndex()
 {
     $sm = new SectionManager($this->_Parent);
     $section = $sm->fetch($sm->fetchIDFromHandle($_GET['section']));
     $field_id = $_GET['field'];
     $fields = $section->fetchFields();
     foreach ($fields as $field) {
         if ($field->get('id') == $field_id) {
             $upload_field = $field;
         }
     }
     if (!$upload_field) {
         die('0|Invalid Field ID');
     }
     $status = $upload_field->checkPostFieldData($_FILES['Filedata'], $message);
     if ($status != Field::__OK__) {
         die($status . '|' . $message);
     }
     $processData = $upload_field->processRawFieldData($_FILES['Filedata'], $status, $message);
     if ($status != Field::__OK__) {
         die($status . '|' . $message);
     }
     echo Field::__OK__ . '|' . $processData['file'];
     die;
 }
 public function saveVersion(&$context)
 {
     $section = $context['section'];
     $entry = $context['entry'];
     $fields = $context['fields'];
     // if saved from an event, no section is passed, so resolve
     // section object from the entry
     if (is_null($section)) {
         $sm = new SectionManager(Symphony::Engine());
         $section = $sm->fetch($entry->get('section_id'));
     }
     // if we *still* can't resolve a section then something is
     // probably quite wrong, so don't try and save version history
     if (is_null($section)) {
         return;
     }
     // does this section have en Entry Version field, should we store the version?
     $has_entry_versions_field = FALSE;
     // is this an update to an existing version, or create a new version?
     $is_update = $fields['entry-versions'] != 'yes';
     // find the Entry Versions field in the section and remove its presence from
     // the copied POST array, so that its value is not saved against the version
     foreach ($section->fetchFields() as $field) {
         if ($field->get('type') == 'entry_versions') {
             unset($fields[$field->get('element_name')]);
             $has_entry_versions_field = TRUE;
         }
     }
     if (!$has_entry_versions_field) {
         return;
     }
     $version = EntryVersionsManager::saveVersion($entry, $fields, $is_update, $entry_version_field_name);
     $context['messages'][] = array('version', 'passed', $version);
 }
 function generate($items, $subsection_field, $subsection_id, $entry_id = NULL, $full = false)
 {
     if (!is_array($items)) {
         $items = array($items);
     }
     $this->_Items = $items;
     // Fetch subsection meta data
     $meta = Administration::instance()->Database->fetch("SELECT filter_tags, caption, show_preview\n\t\t\t\tFROM tbl_fields_subsectionmanager\n\t\t\t\tWHERE field_id = '{$subsection_field}'\n\t\t\t\tLIMIT 1");
     // Get display mode
     if ($meta[0]['show_preview'] == 'yes') {
         $mode = 'preview';
     } else {
         $mode = 'plain';
     }
     // Fetch entry data
     $sectionManager = new SectionManager($this->_Parent);
     $subsection = $sectionManager->fetch($subsection_id, 'ASC', 'name');
     $fields = $subsection->fetchFields();
     $entries = $this->__filterEntries($subsection_id, $fields, $meta[0]['filter_tags'], $entry_id);
     // Check caption
     $caption = $meta[0]['caption'];
     if ($caption == '') {
         // Fetch name of primary field in subsection
         $primary = Administration::instance()->Database->fetch("SELECT element_name\n\t\t\t\t\tFROM tbl_fields\n\t\t\t\t\tWHERE parent_section = '{$subsection_id}'\n\t\t\t\t\tAND sortorder = '0'\n\t\t\t\t\tLIMIT 1");
         $caption = '{$' . $primary[0]['element_name'] . '}';
     }
     // Layout subsection data
     $data = $this->__layoutSubsection($entries, $fields, $caption, $mode, $full);
     return $data;
 }
 public function entrySaved($context)
 {
     require_once MANIFEST . '/jit-recipes.php';
     require_once MANIFEST . '/jit-precaching.php';
     require_once TOOLKIT . '/class.fieldmanager.php';
     $fm = new FieldManager(Symphony::Engine());
     $section = $context['section'];
     if (!$section) {
         require_once TOOLKIT . '/class.sectionmanager.php';
         $sm = new SectionManager(Symphony::Engine());
         $section = $sm->fetch($context['entry']->get('section_id'));
     }
     // iterate over each field in this entry
     foreach ($context['entry']->getData() as $field_id => $data) {
         // get the field meta data
         $field = $fm->fetch($field_id);
         // iterate over the field => recipe mapping
         foreach ($cached_recipes as $cached_recipe) {
             // check a mapping exists for this section/field combination
             if ($section->get('handle') != $cached_recipe['section']) {
                 continue;
             }
             if ($field->get('element_name') != $cached_recipe['field']) {
                 continue;
             }
             // iterate over the recipes mapped for this section/field combination
             foreach ($cached_recipe['recipes'] as $cached_recipe_name) {
                 // get the file name, includes path relative to workspace
                 $file = $data['file'];
                 if (!isset($file) || is_null($file)) {
                     continue;
                 }
                 // trim the filename from path
                 $uploaded_file_path = explode('/', $file);
                 array_pop($uploaded_file_path);
                 // image path relative to workspace
                 if (is_array($uploaded_file_path)) {
                     $uploaded_file_path = implode('/', $uploaded_file_path);
                 }
                 // iterate over all JIT recipes
                 foreach ($recipes as $recipe) {
                     // only process if the recipe has a URL Parameter (name)
                     if (is_null($recipe['url-parameter'])) {
                         continue;
                     }
                     // if not using wildcard, only process specified recipe names
                     if ($cached_recipe_name != '*' && $cached_recipe_name != $recipe['url-parameter']) {
                         continue;
                     }
                     // process the image using the usual JIT URL and get the result
                     $image_data = file_get_contents(URL . '/image/' . $recipe['url-parameter'] . $file);
                     // create a directory structure that matches the JIT URL structure
                     General::realiseDirectory(WORKSPACE . '/image-cache/' . $recipe['url-parameter'] . $uploaded_file_path);
                     // save the image to disk
                     file_put_contents(WORKSPACE . '/image-cache/' . $recipe['url-parameter'] . $file, $image_data);
                 }
             }
         }
     }
 }
 public function displaySettingsPanel(&$wrapper, $errors = NULL)
 {
     parent::displaySettingsPanel($wrapper, $errors);
     $sectionManager = new SectionManager($this->_engine);
     $sections = $sectionManager->fetch(NULL, 'ASC', 'sortorder');
     $options = array();
     // iterate over sections to build list of fields
     if (is_array($sections) && !empty($sections)) {
         foreach ($sections as $section) {
             $section_fields = $section->fetchFields();
             if (!is_array($section_fields)) {
                 continue;
             }
             $fields = array();
             foreach ($section_fields as $f) {
                 // only show select box link fields
                 if ($f->get('type') == 'selectbox_link') {
                     $fields[] = array($f->get('id'), $this->get('related_sbl_id') == $f->get('id'), $f->get('label'));
                 }
             }
             if (!empty($fields)) {
                 $options[] = array('label' => $section->get('name'), 'options' => $fields);
             }
         }
     }
     $group = new XMLElement('div', NULL, array('class' => 'group'));
     $label = Widget::Label(__('Child Select Box Link'));
     $label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][related_sbl_id]', $options));
     if (isset($errors['related_sbl_id'])) {
         $group->appendChild(Widget::wrapFormElementWithError($label, $errors['related_sbl_id']));
     } else {
         $group->appendChild($label);
     }
     $wrapper->appendChild($group);
 }
 public function initaliseAdminPageHead($context)
 {
     $page = Administration::instance()->Page;
     if ($page instanceof contentPublish) {
         $callback = Administration::instance()->getPageCallback();
         if ($callback['context']['page'] !== 'edit') {
             return;
         }
         $sm = new SectionManager(Administration::instance());
         $current_section = $sm->fetch($sm->fetchIDFromHandle($callback['context']['section_handle']));
         $current_section_hash = $this->serialiseSectionSchema($current_section);
         $duplicate_sections = array();
         foreach ($sm->fetch() as $section) {
             $section_hash = $this->serialiseSectionSchema($section);
             if ($section_hash == $current_section_hash && $section->get('handle')) {
                 $duplicate_sections[$section->get('handle')] = $section->get('name');
             }
         }
         if (count($duplicate_sections) < 2) {
             $duplicate_sections = NULL;
         }
         Administration::instance()->Page->addElementToHead(new XMLElement('script', "Symphony.Context.add('duplicate-entry', " . json_encode(array('current-section' => $callback['context']['section_handle'], 'duplicate-sections' => $duplicate_sections)) . ");", array('type' => 'text/javascript')), time());
         $page->addScriptToHead(URL . '/extensions/duplicate_entry/assets/duplicate_entry.js', 10001);
         // add particular css for SSM
         Administration::instance()->Page->addElementToHead(new XMLElement('style', "body.inline.subsection #duplicate-entry { display: none; visibility: collapse }", array('type' => 'text/css')), time() + 101);
     }
 }
 function fetchVisibleFieldID($section)
 {
     $sectionManager = new SectionManager($this->_Parent);
     $linked_section = $sectionManager->fetch($section);
     $li_field = current($linked_section->fetchVisibleColumns());
     return $li_field->get('id');
 }
 public function view()
 {
     $this->_driver = $this->_Parent->ExtensionManager->create('export_entry');
     $this->target = $_GET['section'];
     $this->fieldID = $_GET['field'];
     if (!$this->validate()) {
         $this->_status = self::STATUS_BAD;
         $this->generate();
         return false;
     }
     $sectionManager = new SectionManager($this->_Parent);
     $entryManager = new EntryManager($this->_Parent);
     $section = $sectionManager->fetch($this->target);
     $fields = $section->fetchFields();
     /*	Get all the fields from the target section
      **	Loop them for the section Link field
      */
     foreach ($fields as $field) {
         if ($field->get("id") == $this->fieldID) {
             if ($field->get('type') == "bilink") {
                 $linked_section_id = $field->get("linked_section_id");
                 $linked_field_id = $field->get("linked_field_id");
             } else {
                 if ($field->get('type') == "selectbox_link") {
                     $linked_section_id = Symphony::Database()->fetchVar("parent_section_id", 0, "SELECT parent_section_id \n\t\t\t\t\t\t\tFROM `tbl_sections_association` \n\t\t\t\t\t\t\tWHERE `child_section_field_id` = {$field->get("id")}\n\t\t\t\t\t\t\tLIMIT 1");
                     $linked_field_id = $field->get("related_field_id");
                 } else {
                     if ($field->get('type') == "checkbox") {
                         $linked_section_id = false;
                         $el = new XMLElement("entry", 'Yes');
                         $el->setAttribute('id', 'yes');
                         $this->_Result->appendChild($el);
                         $el = new XMLElement("entry", 'No');
                         $el->setAttribute('id', 'no');
                         $this->_Result->appendChild($el);
                     }
                 }
             }
         }
     }
     if ($linked_section_id) {
         /*	Got the linked field, now get the other end of the
          **	link. Use the first Visible column as the output handle
          */
         $linked_field_id = $this->_driver->fetchVisibleFieldID($linked_section_id);
         /*	Foreach entry in the linked section, display the first
          **	column to be selected
          */
         $entries = $entryManager->fetch(null, $linked_section_id);
         foreach ($entries as $entry) {
             $data = current($entryManager->fetch($entry->get('id'), $linked_section_id));
             $values = $data->getData($linked_field_id);
             $el = new XMLElement("entry", General::sanitize($values['value']));
             $el->setAttribute('id', $entry->get('id'));
             $this->_Result->appendChild($el);
         }
     }
 }
Beispiel #11
0
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('Member Roles'))));
     if (is_null(extension_Members::getFieldHandle('role')) && !is_null(extension_Members::getMembersSection())) {
         $this->pageAlert(__('There is no Member: Role field in the active Members section. <a href="%s%d/">Add Member: Role field?</a>', array(SYMPHONY_URL . '/blueprints/sections/edit/', extension_Members::getMembersSection())), Alert::NOTICE);
     }
     $this->appendSubheading(__('Member Roles'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a Role'), 'create button', NULL, array('accesskey' => 'c')));
     $roles = RoleManager::fetch();
     $aTableHead = array(array(__('Name'), 'col'), array(__('Members'), 'col'));
     $aTableBody = array();
     if (!is_array($roles) || empty($roles)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead)))));
     } else {
         if (is_null(extension_Members::getMembersSection())) {
             $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('No Member section has been specified in <a href="%s">Preferences</a>. Please do this first.', array(SYMPHONY_URL . '/system/preferences/')), 'inactive', NULL, count($aTableHead)))));
         } else {
             $sectionManager = new SectionManager(Administration::instance());
             $section = $sectionManager->fetch(extension_Members::getMembersSection());
             $with_selected_roles = array();
             $hasRoles = !is_null(extension_Members::getFieldHandle('role'));
             foreach ($roles as $role) {
                 // Setup each cell
                 $td1 = Widget::TableData(Widget::Anchor($role->get('name'), Administration::instance()->getCurrentPageURL() . 'edit/' . $role->get('id') . '/', null, 'content'));
                 if ($role->get('id') != Role::PUBLIC_ROLE) {
                     $td1->appendChild(Widget::Input("items[{$role->get('id')}]", null, 'checkbox'));
                 }
                 // Get the number of members for this role, as long as it's not the Public Role.
                 if ($hasRoles && $role->get('id') != Role::PUBLIC_ROLE) {
                     $member_count = Symphony::Database()->fetchVar('count', 0, sprintf("SELECT COUNT(*) AS `count` FROM `tbl_entries_data_%d` WHERE `role_id` = %d", extension_Members::getField('role')->get('id'), $role->get('id')));
                     $td2 = Widget::TableData(Widget::Anchor("{$member_count}", SYMPHONY_URL . '/publish/' . $section->get('handle') . '/?filter=' . extension_Members::getFieldHandle('role') . ':' . $role->get('id')));
                 } else {
                     if ($role->get('id') == Role::PUBLIC_ROLE) {
                         $td2 = Widget::TableData(__('This is the role assumed by the general public.'));
                     } else {
                         $td2 = Widget::TableData(__('None'), 'inactive');
                     }
                 }
                 // Add cells to a row
                 $aTableBody[] = Widget::TableRow(array($td1, $td2));
                 if ($hasRoles && $role->get('id') != Role::PUBLIC_ROLE) {
                     $with_selected_roles[] = array("move::" . $role->get('id'), false, $role->get('name'));
                 }
             }
         }
     }
     $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(0 => array(null, false, __('With Selected...')), 2 => array('delete', false, __('Delete'), 'confirm'), 3 => array('delete-members', false, __('Delete Members'), 'confirm'));
     if (count($with_selected_roles) > 0) {
         $options[1] = array('label' => __('Move Members To'), 'options' => $with_selected_roles);
     }
     $tableActions->appendChild(Widget::Select('with-selected', $options));
     $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
     $this->Form->appendChild($tableActions);
 }
 public function displaySettingsPanel(&$wrapper, $errors = NULL)
 {
     Field::displaySettingsPanel($wrapper, $errors);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $label = Widget::Label('Options');
     $sectionManager = new SectionManager($this->_engine);
     $sections = $sectionManager->fetch(NULL, 'ASC', 'name');
     $field_groups = array();
     if (is_array($sections) && !empty($sections)) {
         foreach ($sections as $section) {
             $field_groups[$section->get('id')] = array('fields' => $section->fetchFields(), 'section' => $section);
         }
     }
     $options = array();
     foreach ($field_groups as $group) {
         if (!is_array($group['fields'])) {
             continue;
         }
         $fields = array();
         foreach ($group['fields'] as $f) {
             if ($f->get('id') != $this->get('id') && $f->canPrePopulate() && !is_null($this->get('related_field_id'))) {
                 $fields[] = array($f->get('id'), in_array($f->get('id'), $this->get('related_field_id')), $f->get('label'));
             }
         }
         if (is_array($fields) && !empty($fields)) {
             $options[] = array('label' => $group['section']->get('name'), 'options' => $fields);
         }
     }
     $label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][related_field_id][]', $options, array('multiple' => 'multiple')));
     $div->appendChild($label);
     // set field type
     $label = Widget::Label('Field Type');
     $type_options = array(array('select', $this->get('field_type') == 'select', 'Select Box'), array('autocomplete', $this->get('field_type') == 'autocomplete', 'Autocomplete Input'));
     $label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][field_type]', $type_options));
     $div->appendChild($label);
     // Allow selection of multiple items
     $label = Widget::Label();
     $input = Widget::Input('fields[' . $this->get('sortorder') . '][allow_multiple_selection]', 'yes', 'checkbox');
     if ($this->get('allow_multiple_selection') == 'yes') {
         $input->setAttribute('checked', 'checked');
     }
     $label->setValue($input->generate() . ' Allow selection of multiple options');
     $div->appendChild($label);
     if (isset($errors['related_field_id'])) {
         $wrapper->appendChild(Widget::wrapFormElementWithError($div, $errors['related_field_id']));
     } else {
         $wrapper->appendChild($div);
     }
     ## Maximum entries
     $label = Widget::Label();
     $input = Widget::Input('fields[' . $this->get('sortorder') . '][limit]', $this->get('limit'));
     $input->setAttribute('size', '3');
     $label->setValue('Limit to the ' . $input->generate() . ' most recent entries');
     $wrapper->appendChild($label);
     $this->appendShowColumnCheckbox($wrapper);
     $this->appendRequiredCheckbox($wrapper);
 }
 private function __doit($source, $fields, &$result, $entry_id = NULL, $cookie = NULL)
 {
     include_once TOOLKIT . '/class.sectionmanager.php';
     include_once TOOLKIT . '/class.entrymanager.php';
     $sectionManager = new SectionManager($this->_Parent);
     if (!($section = $sectionManager->fetch($source))) {
         $result->setAttribute('result', 'error');
         $result->appendChild(new XMLElement('message', 'Section is invalid'));
         return false;
     }
     $entryManager = new EntryManager($this->_Parent);
     if (isset($entry_id) && $entry_id != NULL) {
         $entry =& $entryManager->fetch($entry_id);
         $entry = $entry[0];
         if (!is_object($entry)) {
             $result->setAttribute('result', 'error');
             $result->appendChild(new XMLElement('message', 'Invalid Entry ID specified. Could not create Entry object.'));
             return false;
         }
     } else {
         $entry =& $entryManager->create();
         $entry->set('section_id', $source);
     }
     if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($fields, $errors, $entry->get('id') ? true : false)) {
         $result->setAttribute('result', 'error');
         $result->appendChild(new XMLElement('message', 'Entry encountered errors when saving.'));
         foreach ($errors as $field_id => $message) {
             $field = $entryManager->fieldManager->fetch($field_id);
             $result->appendChild(new XMLElement($field->get('element_name'), NULL, array('type' => $fields[$field->get('element_name')] == '' ? 'missing' : 'invalid')));
         }
         if (isset($cookie) && is_object($cookie)) {
             $result->appendChild($cookie);
         }
         return false;
     } elseif (__ENTRY_OK__ != $entry->setDataFromPost($fields, $errors, false, $entry->get('id') ? true : false)) {
         $result->setAttribute('result', 'error');
         $result->appendChild(new XMLElement('message', 'Entry encountered errors when saving.'));
         foreach ($errors as $err) {
             $field = $entryManager->fieldManager->fetch($err['field_id']);
             $result->appendChild(new XMLElement($field->get('element_name'), NULL, array('type' => 'invalid')));
         }
         if (isset($cookie) && is_object($cookie)) {
             $result->appendChild($cookie);
         }
         return false;
     } else {
         if (!$entry->commit()) {
             $result->setAttribute('result', 'error');
             $result->appendChild(new XMLElement('message', 'Unknown errors where encountered when saving.'));
             if (isset($cookie) && is_object($cookie)) {
                 $result->appendChild($cookie);
             }
             return false;
         }
     }
     return $entry;
 }
 public function __construct(&$parent)
 {
     parent::__construct($parent);
     $this->_uri = URL . '/symphony/extension/search_index';
     $sectionManager = new SectionManager($this->_Parent);
     $this->_sections = $sectionManager->fetch(NULL, 'ASC', 'name');
     $this->_indexes = SearchIndex::getIndexes();
     $this->_section = NULL;
     $this->_index = NULL;
 }
 public function getSectionId()
 {
     $sectionManager = new SectionManager(Frontend::instance());
     $section_id = $sectionManager->fetchIDFromHandle(General::sanitize($_REQUEST['MUUsource']));
     if (!($section = $sectionManager->fetch($section_id))) {
         return NULL;
     } else {
         return $section_id;
     }
 }
 public function view()
 {
     $sectionManager = new SectionManager(Administration::instance());
     $fieldManager = new FieldManager(Administration::instance());
     // Fetch sections & populate a dropdown with the available upload fields
     $section = $sectionManager->fetch($_GET['section']);
     foreach ($section->fetchFields() as $field) {
         if (!preg_match(Extension_BulkImporter::$supported_fields['upload'], $field->get('type'))) {
             continue;
         }
         $element = new XMLElement("field", General::sanitize($field->get('label')), array('id' => $field->get('id'), 'type' => $field->get('type')));
         $this->_Result->appendChild($element);
     }
     // Check to see if any Sections link to this using the Section Associations table
     $associations = Symphony::Database()->fetch(sprintf("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t`child_section_field_id`\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`tbl_sections_association`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`parent_section_id` = %d\n\t\t\t\t", Symphony::Database()->cleanValue($_GET['section'])));
     if (is_array($associations) && !empty($associations)) {
         foreach ($associations as $related_field) {
             $field = $fieldManager->fetch($related_field['child_section_field_id']);
             if (!preg_match(Extension_BulkImporter::$supported_fields['section'], $field->get('type'))) {
                 continue;
             }
             $element = new XMLElement("section", General::sanitize($field->get('label')), array('id' => $field->get('id'), 'type' => $field->get('type'), 'section' => $sectionManager->fetch($field->get('parent_section'))->get('name')));
             $this->_Result->appendChild($element);
         }
     }
     // Check for Subsection Manager
     if (Symphony::ExtensionManager()->fetchStatus('subsectionmanager') == EXTENSION_ENABLED) {
         $associations = Symphony::Database()->fetch(sprintf("\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t`field_id`\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`tbl_fields_subsectionmanager`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`subsection_id` = %d\n\t\t\t\t\t", Symphony::Database()->cleanValue($_GET['section'])));
         if (is_array($associations) && !empty($associations)) {
             foreach ($associations as $related_field) {
                 $field = $fieldManager->fetch($related_field['field_id']);
                 if (!preg_match(Extension_BulkImporter::$supported_fields['section'], $field->get('type'))) {
                     continue;
                 }
                 $element = new XMLElement("section", General::sanitize($field->get('label')), array('id' => $field->get('id'), 'type' => $field->get('type'), 'section' => $sectionManager->fetch($field->get('parent_section'))->get('name')));
                 $this->_Result->appendChild($element);
             }
         }
     }
     // Check for BiLink
     if (Symphony::ExtensionManager()->fetchStatus('bilinkfield') == EXTENSION_ENABLED) {
         $associations = Symphony::Database()->fetch(sprintf("\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t`field_id`\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`tbl_fields_bilink`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`linked_section_id` = %d\n\t\t\t\t\t", Symphony::Database()->cleanValue($_GET['section'])));
         if (is_array($associations) && !empty($associations)) {
             foreach ($associations as $related_field) {
                 $field = $fieldManager->fetch($related_field['field_id']);
                 if (!preg_match(Extension_BulkImporter::$supported_fields['section'], $field->get('type'))) {
                     continue;
                 }
                 $element = new XMLElement("section", General::sanitize($field->get('label')), array('id' => $field->get('id'), 'type' => $field->get('type'), 'section' => $sectionManager->fetch($field->get('parent_section'))->get('name')));
                 $this->_Result->appendChild($element);
             }
         }
     }
 }
 public static function updateSections()
 {
     $files = General::listStructure(WORKSPACE . '/sections', array(), false);
     $engine =& Symphony::Engine();
     $sectionManager = new SectionManager($engine);
     $fieldManager = new FieldManager($engine);
     if (is_array($files['filelist']) && !empty($files['filelist'])) {
         foreach ($files['filelist'] as $filename) {
             $data = @file_get_contents(WORKSPACE . "/sections/{$filename}");
             // Create DOMDocument instance
             $xml = new DOMDocument();
             $xml->preserveWhiteSpace = false;
             $xml->formatOutput = true;
             $xml->loadXML($data);
             // XPath for querying nodes
             $xpath = new DOMXPath($xml);
             $editing = false;
             $section_guid = $xpath->query('/section/@guid')->item(0)->value;
             $sections = Symphony::Database()->fetchCol('guid', "SELECT * FROM `tbl_sections`");
             if (in_array($section_guid, $sections)) {
                 $editing = true;
             }
             // Meta data
             $meta = array();
             $meta_nodes = $xpath->query('/section/meta/*');
             foreach ($meta_nodes as $node) {
                 $meta[$node->tagName] = $node->textContent;
             }
             if ($editing) {
                 Symphony::Database()->update($meta, 'tbl_sections', "guid = {$section_guid}");
             } else {
                 $section_id = $sectionManager->add($meta);
             }
             // Fields
             $fields = array();
             $field_nodes = $xpath->query('/section/fields/entry');
             foreach ($field_nodes as $node) {
                 $field = array();
                 foreach ($node->childNodes as $childNode) {
                     $field[$childNode->tagName] = $childNode->textContent;
                 }
                 $fields[] = $field;
             }
             self::removeMissingFields($fields, $fieldManager);
             if (is_array($fields) && !empty($fields)) {
                 foreach ($fields as $data) {
                     $field = $fieldManager->create($data['type']);
                     $field->setFromPOST($data);
                     $field->commit();
                 }
             }
         }
     }
 }
 function fetchVisibleFieldID($section)
 {
     if (isset(Extension_export_entry::$section_visible[$section])) {
         return Extension_export_entry::$section_visible[$section];
     }
     $sectionManager = new SectionManager($this->_Parent);
     $linked_section = $sectionManager->fetch($section);
     $li_field = current($linked_section->fetchVisibleColumns());
     Extension_export_entry::$section_visible[$section] = $li_field->get('id');
     return Extension_export_entry::$section_visible[$section];
 }
 public function __construct(&$parent)
 {
     parent::__construct($parent);
     $sectionManager = new SectionManager(Administration::instance());
     $this->_entryManager = new EntryManager(Administration::instance());
     // cache array of all sections
     $this->_sections = $sectionManager->fetch(NULL, 'ASC', 'name');
     $this->_section = null;
     // cache array of all indexes
     $this->_indexes = SearchIndex::getIndexes();
     $this->_index = null;
 }
 function displaySettingsPanel(&$wrapper, $errors = NULL)
 {
     parent::displaySettingsPanel($wrapper, $errors);
     $label = Widget::Label(__('Connected Upload Field'));
     $sectionManager = new SectionManager($this->_engine);
     $sections = $sectionManager->fetch(NULL, 'ASC', 'name');
     $field_groups = array();
     if (is_array($sections) && !empty($sections)) {
         foreach ($sections as $section) {
             $field_groups[$section->get('id')] = array('fields' => $section->fetchFields(), 'section' => $section);
         }
     }
     $options = array(array('', false, __('None Selected')));
     foreach ($field_groups as $group) {
         if (!is_array($group['fields'])) {
             continue;
         }
         $fields = array();
         foreach ($group['fields'] as $f) {
             if ($f->get('id') != $this->get('id') && $f->get('type') == 'upload') {
                 $fields[] = array($f->get('id'), $this->get('related_field_id') == $f->get('id'), $f->get('label'));
             }
         }
         if (is_array($fields) && !empty($fields)) {
             $options[] = array('label' => $group['section']->get('name'), 'options' => $fields);
         }
     }
     $label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][related_field_id]', $options));
     if (isset($errors['related_field_id'])) {
         $wrapper->appendChild(Widget::wrapFormElementWithError($label, $errors['related_field_id']));
     } else {
         $wrapper->appendChild($label);
     }
     $label = Widget::Label(__('Filter by Tags or Categories') . '<i>' . __('Comma Separated List') . '</i>');
     $label->appendChild(Widget::Input('fields[' . $this->get('sortorder') . '][filter_tags]', $this->get('filter_tags')));
     $wrapper->appendChild($label);
     $wrapper->appendChild($this->getFilter());
     $label = Widget::Label();
     $input = Widget::Input('fields[' . $this->get('sortorder') . '][allow_multiple_selection]', 'yes', 'checkbox');
     if ($this->get('allow_multiple_selection') == 'yes') {
         $input->setAttribute('checked', 'checked');
     }
     $label->setValue(__('%s Allow selection of multiple options', array($input->generate())));
     $wrapper->appendChild($label);
     $label = Widget::Label();
     $input = Widget::Input('fields[' . $this->get('sortorder') . '][show_count]', 'yes', 'checkbox');
     if ($this->get('show_count') == 'yes') {
         $input->setAttribute('checked', 'checked');
     }
     $label->setValue(__('%s Show file count instead of file names in entry overview', array($input->generate())));
     $wrapper->appendChild($label);
     $this->appendShowColumnCheckbox($wrapper);
 }
Beispiel #21
0
 public function view()
 {
     Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 9126341);
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/members/assets/scripts.js', 9126342);
     $create_button = Widget::Anchor(__('Create a new role'), extension_members::baseURL() . 'roles_new/', __('Create a new role'), 'create button');
     $this->setPageType('table');
     $this->appendSubheading(__('Member Roles ') . $create_button->generate(false));
     $aTableHead = array(array(__('Name'), 'col'), array(__('Members'), 'col'));
     $roles = $this->_driver->fetchRoles();
     $aTableBody = array();
     if (!is_array($roles) || empty($roles)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', NULL, count($aTableHead)))));
     } elseif (is_null(extension_members::memberSectionID())) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('No Member section has been specified in <a href="' . URL . '/symphony/extension/members/setup/">Member Setup</a>. Please do this first.'), 'inactive', NULL, count($aTableHead)))));
     } else {
         $sectionManager = new SectionManager($this->_Parent);
         $section = $sectionManager->fetch($this->_driver->memberSectionID());
         $bEven = true;
         $role_field_name = Symphony::Database()->fetchVar('element_name', 0, "SELECT `element_name` FROM `tbl_fields` WHERE `id` = '" . $this->_driver->roleField() . "' LIMIT 1");
         $with_selected_roles = array();
         foreach ($roles as $role) {
             $member_count = Symphony::Database()->fetchVar('count', 0, "SELECT COUNT(*) AS `count` FROM `tbl_entries_data_" . $this->_driver->roleField() . "` WHERE `role_id` = '" . $role->id() . "'");
             ## Setup each cell
             $td1 = Widget::TableData(Widget::Anchor($role->name(), extension_members::baseURL() . 'roles_edit/' . $role->id() . '/', NULL, 'content'));
             if (extension_Members::GUEST_ROLE_ID == $role->id()) {
                 $td2 = Widget::TableData(__('N/A'), 'inactive');
             } else {
                 $td2 = Widget::TableData(Widget::Anchor("{$member_count}", URL . '/symphony/publish/' . $section->get('handle') . '/?filter=' . $role_field_name . ':' . $role->id()));
             }
             if (!in_array($role->id(), array(extension_Members::GUEST_ROLE_ID, extension_Members::INACTIVE_ROLE_ID))) {
                 $td2->appendChild(Widget::Input("items[" . $role->id() . "]", null, 'checkbox'));
             }
             ## Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2), $bEven ? 'odd' : NULL);
             if ($role->id() != extension_Members::GUEST_ROLE_ID) {
                 $with_selected_roles[] = array("move::" . $role->id(), false, $role->name());
             }
             $bEven = !$bEven;
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), 2 => array('delete-members', false, __('Delete Members')), array('delete', false, __('Delete')));
     if (count($with_selected_roles) > 0) {
         $options[1] = array('label' => __('Move Members To'), 'options' => $with_selected_roles);
     }
     ksort($options);
     $tableActions->appendChild(Widget::Select('with-selected', $options, array('id' => 'with-selected')));
     $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
     $this->Form->appendChild($tableActions);
 }
 public function initialize($context = null)
 {
     if (!$this->initialized) {
         $sectionManager = new SectionManager($this->_Parent);
         $sections = $this->_Parent->Database->fetchCol('id', "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\ts.id\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`tbl_sections` AS s\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t3 = (\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\tcount(*)\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t`tbl_fields` AS f\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tf.parent_section = s.id\n\t\t\t\t\t\t\t\tAND f.type IN (\n\t\t\t\t\t\t\t\t\t'memberemail',\n\t\t\t\t\t\t\t\t\t'memberpassword',\n\t\t\t\t\t\t\t\t\t'memberstatus'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t");
         foreach ($sections as $section_id) {
             $this->sessions[] = new FMM_Session($this, $this->_Parent, $this->_Parent->Database, $sectionManager->fetch($section_id));
         }
         $this->initialized = true;
     }
     return true;
 }
Beispiel #23
0
 /**
  * Builds captions based on $_POST values.
  *
  * @return json object - { id: caption }
  */
 public function __viewIndex()
 {
     $related_section_id = intval($_POST['related_section_id']);
     $field_id = intval($_POST['field_id']);
     $items = explode(',', $_POST['items']);
     $id = array();
     foreach ($items as $item) {
         array_push($id, intval($item));
     }
     // fetch field data
     $sectionManager = new SectionManager($this->_Parent);
     $section = $sectionManager->fetch($related_section_id, 'ASC', 'name');
     $fields = $section->fetchFields();
     // fetch entry data
     $entryManager = new EntryManager($this->_Parent);
     $entries = $entryManager->fetch($id, $related_section_id);
     // create formated captions
     $result = array();
     $template = Administration::instance()->Database->fetch("SELECT `caption` \n\t\t\t\tFROM `tbl_fields_mediathek` \n\t\t\t\tWHERE `related_section_id` = " . $related_section_id . " \n\t\t\t\tAND `field_id`= " . $field_id . " \n\t\t\t\tLIMIT 0 , 1");
     $template = $template[0]['caption'];
     if (empty($template)) {
         $template = '{$' . $fields[0]->get('element_name') . '}';
     }
     foreach ($entries as $entry) {
         $caption = $template;
         $file = '';
         $entry_data = $entry->getData();
         foreach ($fields as $field) {
             $field_name = $field->get('element_name');
             $field_id = $field->get('id');
             $field_data = $entry_data[$field_id]['value'];
             if (is_array($field_data)) {
                 $field_value = implode(', ', $field_data);
             } elseif (empty($field_data) && $entry_data[$field_id]['file']) {
                 $field_value = $entry_data[$field_id]['file'];
             } else {
                 $field_value = $field_data;
             }
             $caption = str_replace('{$' . $field_name . '}', $field_value, $caption);
             // get file
             if (strpos($field->get('type'), 'upload') !== false && !empty($entry_data[$field->get('id')]['file'])) {
                 $file = $this->buildAttachment($entry_data[$field->get('id')]['file']);
             }
         }
         $result[$entry->_fields['id']] = '<span>' . $caption . '</span>' . $file;
     }
     if (empty($result)) {
         exit;
     }
     echo json_encode($result);
     exit;
 }
Beispiel #24
0
 public function appendPreferences($context)
 {
     include_once TOOLKIT . '/class.sectionmanager.php';
     $sectionManager = new SectionManager($context['parent']);
     $sections = $sectionManager->fetch(NULL, 'ASC', 'name');
     $field_groups = array();
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', 'Forum'));
     $p = new XMLElement('p', 'This field is the section link that ties comments to discussions.');
     $p->setAttribute('class', 'help');
     $group->appendChild($p);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $label = Widget::Label('Discussion Section');
     $options = array();
     foreach ($sections as $s) {
         $options[] = array($s->get('id'), Symphony::Configuration()->get('discussion-section', 'forum') == $s->get('id'), $s->get('name'));
     }
     $label->appendChild(Widget::Select('settings[forum][discussion-section]', $options));
     $div->appendChild($label);
     $label = Widget::Label('Comment Section');
     $options = array();
     foreach ($sections as $s) {
         $options[] = array($s->get('id'), Symphony::Configuration()->get('comment-section', 'forum') == $s->get('id'), $s->get('name'));
     }
     $label->appendChild(Widget::Select('settings[forum][comment-section]', $options));
     $div->appendChild($label);
     $group->appendChild($div);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $div->appendChild($this->createFieldSelector('Discussion Member Link', 'member-link-field', 'memberlink', $sections));
     $div->appendChild($this->createFieldSelector('Discussion Last Post', 'discussion-last-post-field', 'memberlink', $sections));
     $group->appendChild($div);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $div->appendChild($this->createFieldSelector('Discussion Last Active (Date)', 'discussion-last-active-field', 'date', $sections));
     $div->appendChild($this->createFieldSelector('Earliest Unread Discussion Cutoff (Date)', 'unread-cutoff-field', 'date', $sections));
     $group->appendChild($div);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $div->appendChild($this->createFieldSelector('Pinned Flag', 'pinned-field', 'checkbox', $sections));
     $div->appendChild($this->createFieldSelector('Locked Flag', 'locked-field', 'checkbox', $sections));
     $group->appendChild($div);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $div->appendChild($this->createFieldSelector('Comment Discussion Link', 'comment-discussion-link-field', 'selectbox_link', $sections));
     $div->appendChild($this->createFieldSelector('Comment Member Link', 'comment-member-link-field', 'memberlink', $sections));
     $group->appendChild($div);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     $div->appendChild($this->createFieldSelector('Comment Creation Date', 'comment-creation-date-field', 'date', $sections));
     $div->appendChild($this->createFieldSelector('Comment Text Field', 'comment-field', 'textarea', $sections));
     $group->appendChild($div);
     $context['wrapper']->appendChild($group);
 }
 public function appendScripts($context)
 {
     $callback = $context['parent']->getPageCallback();
     if (in_array($callback['driver'], array('blueprintspages', 'blueprintsutilities'))) {
         $context['parent']->Page->addScriptToHead(URL . '/extensions/zencoding/assets/zen_textarea.min.js', 1000, false);
     }
     if ($callback['driver'] == 'publish') {
         $sectionManager = new SectionManager($context['parent']);
         $section_id = $sectionManager->fetchIDFromHandle($callback['context']['section_handle']);
         if ($this->__isAllowedSection($section_id)) {
             $context['parent']->Page->addScriptToHead(URL . '/extensions/zencoding/assets/zen_textarea.min.js', 1000, false);
         }
     }
 }
 public function build($context)
 {
     // Build the page:
     $this->setTitle('Symphony - File Browser for CKEditor');
     $this->addElementToHead(new XMLElement('meta', NULL, array('http-equiv' => 'Content-Type', 'content' => 'text/html; charset=UTF-8')), 0);
     $this->addElementToHead(new XMLElement('meta', NULL, array('http-equiv' => 'X-UA-Compatible', 'content' => 'IE=edge,chrome=1')), 1);
     $this->addStylesheetToHead(URL . '/symphony/assets/css/symphony.css', 'screen', 68);
     $this->addStylesheetToHead(URL . '/symphony/assets/css/admin.css', 'screen', 69);
     $this->addStylesheetToHead(URL . '/extensions/ckeditor/assets/filebrowser.css', 'screen', 70);
     $this->addScriptToHead(URL . '/symphony/assets/js/jquery.js', 50);
     $this->addScriptToHead(URL . '/extensions/ckeditor/assets/jquery.form.js', 51);
     $this->addScriptToHead(URL . '/extensions/ckeditor/assets/filebrowser.js', 52);
     $this->addHeaderToPage('Content-Type', 'text/html; charset=UTF-8');
     $this->Html->setDTD('<!DOCTYPE html>');
     // Check for unauthorized access:
     if (!Administration::instance()->isLoggedIn()) {
         $this->_Parent->customError(E_USER_ERROR, __('Access Denied'), __('You are not authorised to access this page.'));
         exit;
     }
     $body = new XMLElement('div', '', array('id' => 'body'));
     $left = new XMLElement('div', '', array('class' => 'left'));
     $right = new XMLElement('div', '', array('class' => 'right'));
     $left->appendChild(new XMLElement('h3', __('Section')));
     // Get the sections:
     $sectionManager = new SectionManager($this);
     $sections = $sectionManager->fetch();
     // Check which sections are allowed:
     $data = Symphony::Configuration()->get('sections', 'ckeditor');
     $checkedSections = $data != false ? explode(',', $data) : array();
     if (count($checkedSections) > 0) {
         $list = new XMLElement('ul');
         foreach ($sections as $section) {
             if (in_array($section->get('id'), $checkedSections)) {
                 $item = new XMLElement('li');
                 $attributes = array('href' => '#', 'id' => $section->get('id'));
                 $link = new XMLElement('a', $section->get('name'), $attributes);
                 $item->appendChild($link);
                 $list->appendChild($item);
             }
         }
         $left->appendChild($list);
     } else {
         $left->appendChild(new XMLElement('p', __('There are no sections available. Please select which sections are permitted to use the CKEditor file upload feature in the Symphony System Preferences.')));
     }
     $body->appendChild($left);
     $body->appendChild($right);
     $this->Body->appendChild($body);
 }
 public function __viewIndex()
 {
     header('content-type: text/javascript');
     $sm = new SectionManager($this->_Parent);
     $section_id = $sm->fetchIDFromHandle($_GET['section']);
     $section = $sm->fetch($section_id);
     $em = new EntryManager($this->_Parent);
     $entry_id = $_GET['entry'];
     $e = $em->fetch($entry_id);
     $fields = array();
     $data = $e[0]->getData();
     foreach ($section->fetchFieldsSchema() as $field) {
         // Set field names and take strange date field name into account
         $field['element_name'] = $field['type'] == 'date' ? 'fields[' . $field['element_name'] . ']' . $field['element_name'] : 'fields[' . $field['element_name'] . ']';
         // Populate field elements with value, depending on field type
         switch ($field['type']) {
             case 'author':
                 $fields[$field['element_name']] = $data[$field['id']]['author_id'];
                 break;
             case 'upload':
                 $fields[$field['element_name']] = $data[$field['id']]['file'];
                 break;
             case 'selectbox_link':
                 $fields[$field['element_name']] = $data[$field['id']]['relation_id'];
                 break;
             case 'input':
             case 'textarea':
             case 'taglist':
             case 'select':
             case 'checkbox':
             case 'date':
             case 'order_entries':
                 $fields[$field['element_name']] = $data[$field['id']]['value'];
                 break;
             default:
                 if (!empty($data[$field['id']]['value'])) {
                     $fields[$field['element_name']] = $data[$field['id']]['value'];
                 } else {
                     // Fall back on first array element
                     // Add field type to switch for accurate specification
                     $fields[$field['element_name']] = $data[$field['id']][0];
                 }
                 break;
         }
     }
     echo 'jQuery(document).ready(function() { jQuery(\'form\').populate(' . json_encode($fields) . ")});\n";
     exit;
 }
 public static function hasInstance($ext_name = NULL, $section_handle)
 {
     $sid = SectionManager::fetchIDFromHandle($section_handle);
     $section = SectionManager::fetch($sid);
     $fm = $section->fetchFields($ext_name);
     return is_array($fm) && !empty($fm);
 }
 public static function init()
 {
     if (REST_API::getOutputFormat() == 'csv') {
         REST_API::sendError(sprintf('%s output format not supported.', strtoupper(REST_API::getOutputFormat())), 401, 'xml');
     }
     $request_uri = REST_API::getRequestURI();
     $section_reference = $request_uri[0];
     $sections = NULL;
     if (is_null($section_reference)) {
         $sections = SectionManager::fetch();
     } elseif (is_numeric($section_reference)) {
         $sections = SectionManager::fetch($section_reference);
     } else {
         $section_id = SectionManager::fetchIDFromHandle($section_reference);
         if ($section_id) {
             $sections = SectionManager::fetch($section_id);
         }
     }
     if (!is_array($sections)) {
         $sections = array($sections);
     }
     if (!reset($sections) instanceof Section) {
         REST_API::sendError(sprintf("Section '%s' not found.", $section_reference), 404);
     }
     self::$_sections = $sections;
 }
Beispiel #30
0
 public function initializeAdmin($context)
 {
     $page = Administration::instance()->Page;
     $context = $page->getContext();
     $callback = Administration::instance()->getPageCallback();
     // only proceed on New or Edit publish pages
     if ($page instanceof contentPublish and in_array($context['page'], array('new', 'edit'))) {
         $page->addStylesheetToHead(URL . '/extensions/publish_tabs/assets/publish_tabs.publish.css', 'screen', 9001);
         $page->addScriptToHead(URL . '/extensions/publish_tabs/assets/publish_tabs.publish.js', 9002);
         include_once TOOLKIT . '/class.sectionmanager.php';
         $section_id = SectionManager::fetchIDFromHandle($callback['context']['section_handle']);
         $section = SectionManager::fetch($section_id);
         if (!$section instanceof Section) {
             return;
         }
         $tabs = array();
         $current_tab = '';
         $index = -1;
         foreach ($section->fetchFieldsSchema() as $i => $field) {
             if ($i == 0 && $field['type'] != 'publish_tabs') {
                 $current_tab = 'untitled-tab';
                 $tabs[++$index]['tab_id'] = $current_tab;
             }
             if ($field['type'] == 'publish_tabs') {
                 $current_tab = $field['id'];
                 $tabs[++$index]['tab_id'] = $current_tab;
             } else {
                 $tabs[$index][$field['location']][] = 'field-' . $field['id'];
             }
         }
         $page->addElementToHead(new XMLElement('script', "Symphony.Context.add('publish-tabs', " . json_encode($tabs) . ")", array('type' => 'text/javascript')), 9003);
     }
 }