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);
     }
 }
 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);
             }
         }
     }
 }
 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;
 }
 private function createEntryFromPost()
 {
     include_once TOOLKIT . '/class.sectionmanager.php';
     include_once TOOLKIT . '/class.entrymanager.php';
     // section id
     $source = $this->getSection();
     $section = SectionManager::fetch($source);
     $fields = $section->fetchFields();
     $entry = null;
     if ($id > 0) {
         // edit
         $entry = EntryManager::fetch($id);
         if (empty($entry)) {
             throw new Exception(sprintf(__('Entry id %s not found'), $id));
         }
         $entry = $entry[0];
     } else {
         // create
         $entry = EntryManager::create();
         $entry->set('section_id', $source);
     }
     foreach ($fields as $f) {
         $data = $this->getFieldValue($f->get('element_name'));
         if ($data != null) {
             $entry->setData($f->get('id'), $data);
         }
     }
     if (!$entry->commit()) {
         throw new Exception(sprintf('Could not create entry: %s', mysql_error()));
     }
     return $entry;
 }
 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);
 }
 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);
 }
Exemplo n.º 7
0
 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 generate($subsection_field, $subsection_id, $items = NULL, $recurse = 0, $flags = self::GETEVERYTHING)
 {
     static $done = array();
     if ($done[$subsection_field] >= $recurse + 1) {
         return array('options' => array(), 'html' => '', 'preview' => '');
     }
     $done[$subsection_field] += 1;
     // Fetch subsection meta data
     $meta = Symphony::Database()->fetch("SELECT filter_tags, caption, droptext, show_preview\n\t\t\t\tFROM tbl_fields_subsectionmanager\n\t\t\t\tWHERE field_id = '" . intval($subsection_field) . "'\n\t\t\t\tLIMIT 1");
     // Get display mode
     if ($meta[0]['show_preview'] == 1) {
         $mode = 'preview';
         $flags |= self::GETPREVIEW;
     } else {
         $mode = 'plain';
     }
     // Fetch entry data
     $subsection = SectionManager::fetch($subsection_id, 'ASC', 'name');
     $fields = $subsection->fetchFields();
     $entries = $this->__filterEntries($subsection_id, $fields, $meta[0]['filter_tags'], $items, $flags & self::GETALLITEMS);
     $droptext = $meta[0]['droptext'];
     // Check caption
     $caption = $meta[0]['caption'];
     if ($caption == '') {
         // Fetch name of primary field in subsection
         $primary = Symphony::Database()->fetch("SELECT element_name\n\t\t\t\t\tFROM tbl_fields\n\t\t\t\t\tWHERE parent_section = '" . intval($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, $droptext, $mode, $flags);
     $done[$subsection_field] -= 1;
     return $data;
 }
Exemplo n.º 9
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);
     }
 }
Exemplo n.º 10
0
 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);
                 }
             }
         }
     }
 }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 private function checkTemplates($pageId, $prefix = '')
 {
     // Link templates:
     $templates = Symphony::Database()->fetch(sprintf('SELECT * FROM `tbl_ckeditor_link_templates` WHERE `page_id` = %d;', $pageId));
     $entryTree = array();
     foreach ($templates as $template) {
         $section = SectionManager::fetch($template['section_id']);
         $entries = EntryManager::fetch(null, $template['section_id']);
         $fields = $section->fetchFields();
         foreach ($entries as $entry) {
             $link = $template['link'];
             // Replace the ID:
             $link = str_replace('{$id}', $entry->get('id'), $link);
             $data = $entry->getData();
             foreach ($fields as $field) {
                 // Replace the placeholders with the value:
                 // Check if the field has a 'handle':
                 $testData = $field->processRawFieldData('test', $field->__OK__);
                 if (isset($testData['handle'])) {
                     $link = str_replace('{$' . $field->get('element_name') . '}', $data[$field->get('id')]['handle'], $link);
                 }
             }
             $entryTree[] = array('handle' => $data[$field->get('id')]['handle'], 'path' => '', 'url' => $link, 'title' => $prefix . ' › ' . General::sanitize($data[$template['field_id']]['value']));
         }
     }
     return $entryTree;
 }
Exemplo n.º 13
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;
 }
Exemplo n.º 14
0
 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;
 }
 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);
 }
 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);
 }
Exemplo n.º 17
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);
 }
Exemplo n.º 18
0
 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);
         }
     }
 }
 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;
 }
Exemplo n.º 20
0
 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);
 }
Exemplo n.º 21
0
 public function __construct()
 {
     parent::__construct();
     // 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;
 }
Exemplo n.º 22
0
 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;
     }
 }
Exemplo n.º 23
0
 public function __construct()
 {
     parent::__construct();
     $this->_uri = SYMPHONY_URL . '/extension/search_index';
     $this->_sections = SectionManager::fetch(NULL, 'ASC', 'name');
     $this->_indexes = SearchIndex::getIndexes();
     $this->_section = NULL;
     $this->_index = NULL;
     $this->_weightings = array(__('Highest'), __('High'), __('Medium (none)'), __('Low'), __('Lowest'));
 }
 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;
 }
Exemplo n.º 25
0
 public static function findSection($handle)
 {
     if (!is_numeric($handle)) {
         $handle = SectionManager::fetchIDFromHandle($handle);
     }
     $ret = SectionManager::fetch($handle);
     if (!is_object($ret)) {
         self::throwEx('Section does not exist');
     }
     return $ret;
 }
Exemplo n.º 26
0
 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];
 }
 /**
  * Return the count of the number of entries in a particular section.
  *
  * @param integer $section_id
  *  The ID of the Section where the Entries are to be counted
  * @param string $where
  *  Any custom WHERE clauses
  * @param string $joins
  *  Any custom JOIN's
  * @param boolean $group
  *  Whether the entries need to be grouped by Entry ID or not
  * @return integer
  */
 public function fetchCount($section_id = null, $where = null, $joins = null, $group = false)
 {
     if (is_null($section_id)) {
         return false;
     }
     $section = $this->sectionManager->fetch($section_id);
     if (!is_object($section)) {
         return false;
     }
     $sql = "\n\t\t\t\tSELECT count(" . ($group ? 'DISTINCT ' : '') . "`e`.id) as `count`\n\t\t\t\tFROM `tbl_entries` AS `e`\n\t\t\t\t{$joins}\n\t\t\t\tWHERE `e`.`section_id` = '{$section_id}'\n\t\t\t\t{$where}\n\t\t\t";
     return Symphony::Database()->fetchVar('count', 0, $sql);
 }
Exemplo n.º 28
0
 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);
 }
 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;
 }
Exemplo n.º 30
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);
 }