public function displaySettingsPanel(&$wrapper, $errors = null) { parent::displaySettingsPanel($wrapper, $errors); ## Destination Folder $ignore = array('/workspace/events', '/workspace/data-sources', '/workspace/text-formatters', '/workspace/pages', '/workspace/utilities'); $directories = General::listDirStructure(WORKSPACE, null, true, DOCROOT, $ignore); $label = Widget::Label(__('Destination Directory')); $options = array(); $options[] = array('/workspace', false, '/workspace'); if (!empty($directories) && is_array($directories)) { foreach ($directories as $d) { $d = '/' . trim($d, '/'); if (!in_array($d, $ignore)) { $options[] = array($d, $this->get('destination') == $d, $d); } } } $label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][destination]', $options)); if (isset($errors['destination'])) { $wrapper->appendChild(Widget::wrapFormElementWithError($label, $errors['destination'])); } else { $wrapper->appendChild($label); } $this->buildValidationSelect($wrapper, $this->get('validator'), 'fields[' . $this->get('sortorder') . '][validator]', 'upload'); $div = new XMLElement('div', NULL, array('class' => 'compact')); $this->appendRequiredCheckbox($div); $this->appendShowColumnCheckbox($div); $wrapper->appendChild($div); }
function displaySettingsPanel(&$wrapper, $errors = NULL) { Field::displaySettingsPanel($wrapper, $errors); $div = new XMLElement('div', NULL, array('class' => 'group')); $ignore = array('/workspace/events', '/workspace/data-sources', '/workspace/text-formatters', '/workspace/pages', '/workspace/utilities'); $directories = General::listDirStructure(WORKSPACE, NULL, 'asc', DOCROOT, $ignore); $label = Widget::Label(__('Destination Directory')); $options = array(); $options[] = array('/workspace', false, '/workspace'); if (!empty($directories) && is_array($directories)) { foreach ($directories as $d) { $d = '/' . trim($d, '/'); if (!in_array($d, $ignore)) { $options[] = array($d, $this->get('destination') == $d, $d); } } } $label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][destination]', $options)); if (isset($errors['destination'])) { $wrapper->appendChild(Widget::wrapFormElementWithError($label, $errors['destination'])); } else { $wrapper->appendChild($label); } $this->appendRequiredCheckbox($wrapper); $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); $this->appendShowColumnCheckbox($wrapper); }
public function displaySettingsPanel(XMLElement &$wrapper, $errors = null) { parent::displaySettingsPanel($wrapper, $errors); // Destination Folder $ignore = array('/workspace/events', '/workspace/data-sources', '/workspace/text-formatters', '/workspace/pages', '/workspace/utilities'); $directories = General::listDirStructure(WORKSPACE, null, true, DOCROOT, $ignore); $label = Widget::Label(__('Destination Directory')); $options = array(); $options[] = array('/workspace', false, '/workspace'); if (!empty($directories) && is_array($directories)) { foreach ($directories as $d) { $d = '/' . trim($d, '/'); if (!in_array($d, $ignore)) { $options[] = array($d, $this->get('destination') == $d, $d); } } } $label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][destination]', $options)); if (isset($errors['destination'])) { $wrapper->appendChild(Widget::Error($label, $errors['destination'])); } else { $wrapper->appendChild($label); } // Validation rule $this->buildValidationSelect($wrapper, $this->get('validator'), 'fields[' . $this->get('sortorder') . '][validator]', 'upload', $errors); // Requirements and table display $this->appendStatusFooter($wrapper); }
public function displaySettingsPanel(&$wrapper, $errors = null) { parent::displaySettingsPanel($wrapper, $errors); $order = $this->get('sortorder'); // Destination -------------------------------------------------------- $ignore = array('events', 'data-sources', 'text-formatters', 'pages', 'utilities'); $directories = General::listDirStructure(WORKSPACE, true, 'asc', DOCROOT, $ignore); $label = Widget::Label('Destination Directory'); $options = array(array('/workspace', false, '/workspace')); if (!empty($directories) and is_array($directories)) { foreach ($directories as $d) { $d = '/' . trim($d, '/'); if (!in_array($d, $ignore)) { $options[] = array($d, $this->get('destination') == $d, $d); } } } $label->appendChild(Widget::Select("fields[{$order}][destination]", $options)); if (isset($errors['destination'])) { $label = Widget::wrapFormElementWithError($label, $errors['destination']); } $wrapper->appendChild($label); // Validator ---------------------------------------------------------- $this->buildValidationSelect($wrapper, $this->get('validator'), "fields[{$order}][validator]", 'upload'); $this->appendRequiredCheckbox($wrapper); $this->appendShowColumnCheckbox($wrapper); }
public function displaySettingsPanel(&$wrapper, $errors = null) { parent::displaySettingsPanel($wrapper, $errors); $order = $this->get('sortorder'); // Group Size --------------------------------------------------------- $ignore = array('events', 'data-sources', 'text-formatters', 'pages', 'utilities'); $directories = General::listDirStructure(WORKSPACE, true, 'asc', DOCROOT, $ignore); $label = Widget::Label('Group Size'); $input = Widget::Input("fields[{$order}][nth_entry]", $this->get('nth_entry')); $label->appendChild($input); $wrapper->appendChild($label); }
public function displaySettingsPanel(&$wrapper, $errors = NULL) { // get current section id parent::displaySettingsPanel($wrapper, $errors); $section_id = Administration::instance()->Page->_context[1]; //choose page $label = Widget::Label(__('xsl:fo page')); $pages = Symphony::Database()->fetch("SELECT tbl_pages.id FROM `tbl_pages` LEFT JOIN `tbl_pages_types` ON tbl_pages.id=tbl_pages_types.page_id WHERE tbl_pages_types.type = 'fop' ORDER BY sortorder ASC"); if (!empty($pages)) { foreach ($pages as $page) { $options[] = array($page['id'], $page['id'] == $this->get('page'), '/' . Administration::instance()->resolvePagePath($page['id'])); } } $label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][page]', $options)); $wrapper->appendChild($label); ## Destination Folder $ignore = array('/workspace/events', '/workspace/data-sources', '/workspace/text-formatters', '/workspace/pages', '/workspace/utilities'); $directories = General::listDirStructure(WORKSPACE, null, true, DOCROOT, $ignore); $label = Widget::Label(__('Destination Directory')); $options = array(); $options[] = array('/workspace', false, '/workspace'); if (!empty($directories) && is_array($directories)) { foreach ($directories as $d) { $d = '/' . trim($d, '/'); if (!in_array($d, $ignore)) { $options[] = array($d, $this->get('destination') == $d, $d); } } } $label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][destination]', $options)); if (isset($errors['destination'])) { $wrapper->appendChild(Widget::wrapFormElementWithError($label, $errors['destination'])); } else { $wrapper->appendChild($label); } //filename $label = Widget::Label(__('Filename pattern')); $label->appendChild(new XMLElement('i', 'You can use xPath to build dinamic values')); $label->appendChild(Widget::Input('fields[' . $this->get('sortorder') . '][filename]', $this->get('filename'))); $wrapper->appendChild($label); $available_fields = $this->findAllFields($section_id); if (is_array($available_fields) && !empty($available_fields)) { $fieldslist = new XMLElement('ul'); $fieldslist->setAttribute('class', 'tags inline'); foreach ($available_fields as $field) { $fieldslist->appendChild(new XMLElement('li', '{' . $field . '}')); } $wrapper->appendChild($fieldslist); } }
public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null) { if (!is_dir(DOCROOT . $this->get('destination') . '/')) { $flagWithError = __('The destination directory, %s, does not exist.', array('<code>' . $this->get('destination') . '</code>')); } elseif (!$flagWithError && !is_writable(DOCROOT . $this->get('destination') . '/')) { $flagWithError = __('Destination folder is not writable.') . ' ' . __('Please check permissions on %s.', array('<code>' . $this->get('destination') . '</code>')); } $label = Widget::Label($this->get('label')); $label->setAttribute('class', 'file'); // Destination Folder $ignore = array('/workspace/events', '/workspace/data-sources', '/workspace/text-formatters', '/workspace/pages', '/workspace/utilities'); //Select only the Child directories of the Section Editor Chosen Directory $overridedirectories = str_replace('/workspace', '', $this->get('destination')); $directories = General::listDirStructure(WORKSPACE . $overridedirectories, null, true, DOCROOT, $ignore); $options = array(); $options[] = array($this->get('destination'), false, $this->get('destination')); if (!empty($directories) && is_array($directories)) { foreach ($directories as $d) { $d = '/' . trim($d, '/'); if (!in_array($d, $ignore)) { $options[] = array($d, $this->get('destination') == $d, $d); } } } if ($this->get('required') != 'yes') { $label->appendChild(new XMLElement('i', __('Optional'))); } //Start of input/upload field code $span = new XMLElement('span', NULL, array('class' => 'enhanced_frame enhanced_upload')); //Render the upload field or reflect the uploaded file stored in DB. if ($data['file']) { $span->appendChild(Widget::Anchor('/workspace' . $data['file'], URL . '/workspace' . $data['file'], null, 'enhanced_file')); } $span->appendChild(Widget::Input('fields' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix, $data['file'], $data['file'] ? 'hidden' : 'file', array('class' => 'enhanced_file'))); if ($this->get('override') == 'yes') { //$override = new XMLELement('span', NULL, array('class' => 'enhanced_upload')); //Allow selection of a child folder to upload the image $choosefolder = Widget::Select('fields[enhanced_upload_field]' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix . '[directory]', $options, array('class' => 'enhanced_upload_select_' . (!$data['file'] ? 'show' : 'hidden'))); //$choosefolder = Widget::Select('directory', $options, array('class' => 'enhanced_upload_select_'.(!$data['file'] ? 'show':'hidden'))); $span->appendChild($choosefolder); //$label->appendChild($override); } $label->appendChild($span); if ($flagWithError != NULL) { $wrapper->appendChild(Widget::Error($label, $flagWithError)); } else { $wrapper->appendChild($label); } }
public function getStrings($context) { // Set context path if ($context == 'symphony') { $path = DOCROOT . '/symphony'; } else { $path = EXTENSIONS . '/' . $context; } // Parse files $strings = $this->getFiles($path, array()); $folders = General::listDirStructure($path); foreach ($folders as $folder) { $strings = $this->getFiles($folder, $strings); } if (empty($strings) && $context != 'symphony') { return array(); } // Get navigation and date string if ($context == 'symphony') { $strings = array_merge($strings, $this->__findNavigationStrings()); $strings = array_merge($strings, $this->__getDateStrings()); } // Remove duplicated $strings = array_unique($strings); // Sort array if ($this->_Sort == true) { natcasesort($strings); } // Generate correct keys and values $strings = array_combine($strings, array_fill(0, count($strings), NULL)); // Return strings return $strings; }
" /></label> <label><input name="fields[select_multiple]" type="checkbox" <?php print General::fieldValue("checkbox", $fields['select_multiple'], "", "on"); ?> /> Allow selection of multiple items</label> <?php } elseif ($fields['type'] == 'checkbox') { ?> <label><input name="fields[default_state]" type="checkbox" <?php print General::fieldValue("checkbox", $fields['default_state'], "", "checked"); ?> /> Check this Custom field by default.</label> <?php } elseif ($fields['type'] == 'upload') { $directories = General::listDirStructure(WORKSPACE, true, "asc", DOCROOT); $ignore = array("events", "data-sources", "text-formatters", "pages", "masters", "utilities"); ?> <label>Destination Folder <select name="fields[destination_folder]"> <option value="workspace/" <?php print $fields['destination_folder'] == "workspace/" ? ' selected="selected"' : ""; ?> >workspace/</option> <?php foreach ($directories as $d) { if (!in_array($d, $ignore)) { ?> <option value="<?php print ltrim($d, '/'); ?>
/** * Will return an associative array of all extensions and their about information * * @param string $filter * Allows a regular expression to be passed to return only extensions whose * folders match the filter. * @return array * An associative array with the key being the extension folder and the value * being the extension's about information */ public function listAll($filter = '/^((?![-^?%:*|"<>]).)*$/') { $result = array(); $extensions = General::listDirStructure(EXTENSIONS, $filter, false, EXTENSIONS); if (is_array($extensions) && !empty($extensions)) { foreach ($extensions as $extension) { $e = trim($extension, '/'); if ($about = $this->about($e)) { $result[$e] = $about; } } } return $result; }
public function __viewDo() { if (count($_POST) > 0 && count($this->_errors) > 0) { if (is_array($this->_errors)) { $this->pageAlert("\n\t\t\t\t\t\tAn error occurred while processing this form.\n\t\t\t\t\t\t<a href=\"#error\">" . $this->parseErrors() . " Rolling back.</a>", AdministrationPage::PAGE_ALERT_ERROR); } } elseif (count($_POST) > 0) { $this->pageAlert("Successfully added a whole slew of entries, {$this->_entries_count} to be exact. \n\t\t\t\t\tTo do it again, <a href=\"{$this->_uri}/\">Give it another go below.</a>", Alert::SUCCESS, array('created', URL, 'extension/multipleuploadinjector')); } $this->setPageType('form'); $this->Form->setAttribute('enctype', 'multipart/form-data'); $this->setTitle('Symphony – Add Multiple Files From a Folder'); // // Edit: // if ($this->_action == 'edit') { // if (!$this->_valid && count($this->_errors) == 0) // if (count($this->_files) > 0) { // $this->appendSubHeading('Added '.implode(', ',$this->_files)); // } // } // else $this->appendSubheading('Inject!'); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', 'Essentials')); $div = new XMLElement('div'); $div->setAttribute('class', 'group'); $label = Widget::Label(__('Source (where these are all going)')); $sectionManager = new SectionManager($this->_Parent); $sections = $sectionManager->fetch(); $options[0]['label'] = 'Sections'; foreach ($sections as $section) { $s = $section->fetchFields(); $go = false; foreach ($s as $f) { if (in_array($f->get('type'), $this->_driver->getTypes())) { $go = true; } } if ($go) { $field_groups[$section->get('id')] = array('fields' => $section->fetchFields(), 'section' => $section); $options[0]['options'][] = array($section->get('id'), $_POST['fields']['source'] == $section->get('id'), $section->get('name')); } } $label->appendChild(Widget::Select('fields[source]', $options, array('id' => 'context'))); $div->appendChild($label); $label = Widget::Label(__('Directory where images are stored')); $options = array(); $options[] = array('/workspace' . $this->_driver->getMUI(), false, '/workspace' . $this->_driver->getMUI()); $ignore = array('events', 'data-sources', 'text-formatters', 'pages', 'utilities'); $directories = General::listDirStructure(WORKSPACE . $this->_driver->getMUI(), true, 'asc', DOCROOT, $ignore); if (!empty($directories) && is_array($directories)) { foreach ($directories as $d) { $d = '/' . trim($d, '/'); if (!in_array($d, $ignore)) { $options[] = array($d, $d == '/workspace' . $this->_driver->getMUI() . '/' . date('Y-m-d') ? true : false, $d); } } } $label->appendChild(Widget::Select('fields[sourcedir]', $options)); $div->appendChild($label); $fieldset->appendChild($div); $div = new XMLElement('div'); $div->setAttribute('class', 'group'); $label = Widget::Label(__('Delete directory and contents after successful import?')); $label->appendChild(Widget::Input('fields[remove]', null, 'checkbox')); $div->appendChild($label); $fieldset->appendChild($div); $this->Form->appendChild($fieldset); /* now the section fields */ $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings contextual ' . __('sections') . ' ' . __('authors') . ' ' . __('navigation') . ' ' . __('Sections') . ' ' . __('System')); $fieldset->appendChild(new XMLElement('legend', __('Choose Default Values'))); $entryManager = new EntryManager($this->_Parent); foreach ($field_groups as $section_id => $section_data) { // create a dummy entry $entry = $entryManager->create(); $entry->set('section_id', $section_id); $div = new XMLElement('div'); $div->setAttribute('class', 'contextual ' . $section_id); $primary = new XMLElement('fieldset'); $primary->setAttribute('class', 'primary'); $sidebar_fields = $section_data['section']->fetchFields(); // $main_fields = $section_data['section']->fetchFields(NULL, 'main'); // if(is_array($main_fields) && !empty($main_fields)){ // foreach($main_fields as $field){ // if (!in_array($field->get('type'),$this->_driver->getTypes())) // $primary->appendChild($this->__wrapFieldWithDiv($field)); // } // $div->appendChild($primary); // } if (is_array($sidebar_fields) && !empty($sidebar_fields)) { $sidebar = new XMLElement('fieldset'); $sidebar->setAttribute('class', 'primary'); foreach ($sidebar_fields as $field) { if (!in_array($field->get('type'), $this->_driver->getTypes())) { $sidebar->appendChild($this->__wrapFieldWithDiv($field, $entry, $section_id, null, null)); } } $div->appendChild($sidebar); } $fieldset->appendChild($div); } $this->Form->appendChild($fieldset); $submit = Widget::Input('action[save]', 'Process files', 'submit', array('accesskey' => 's')); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild($submit); $this->Form->appendChild($div); }
function listDirStructure($dir = ".", $recurse = true, $sort = "asc", $strip_root = NULL, $exclude = array(), $ignore_hidden = true) { $filter_pattern_match = false; if (isset($filters) && !is_array($filters)) { $filter_pattern_match = true; } $files = array(); if (!($handle = @opendir($dir))) { return array(); } while (($file = @readdir($handle)) != false) { if ($file != '.' && $file != '..' && (!$ignore_hidden || $ignore_hidden && $file[0] != '.')) { if (@is_dir("{$dir}/{$file}")) { if ($recurse) { $files[] = str_replace($strip_root, "", $dir) . "/{$file}/"; $files = @array_merge($files, General::listDirStructure("{$dir}/{$file}", $recurse, $sort, $strip_root, $exclude, $ignore_hidden)); } } } } @closedir($handle); return $files; }
public function displaySettingsPanel(SymphonyDOMElement $wrapper, MessageStack $messages) { parent::displaySettingsPanel($wrapper, $messages); $order = $this->sortorder; // Destination -------------------------------------------------------- $ignore = array('events', 'data-sources', 'text-formatters', 'pages', 'utilities'); $directories = General::listDirStructure(WORKSPACE, true, 'asc', DOCROOT, $ignore); $label = Widget::Label('Destination Directory'); $options = array(array('/workspace', false, '/workspace')); if (!empty($directories) and is_array($directories)) { foreach ($directories as $d) { $d = '/' . trim($d, '/'); if (!in_array($d, $ignore)) { $options[] = array($d, $this->destination == $d, $d); } } } $label->appendChild(Widget::Select('destination', $options)); if ($messages->{'destination'}) { $label = Widget::wrapFormElementWithError($label, $messages->{'destination'}); } $wrapper->appendChild($label); // Validator ---------------------------------------------------------- $this->appendValidationSelect($wrapper, $this->validator, 'validator', __('Validation Rule'), 'upload'); $options_list = $wrapper->ownerDocument->createElement('ul'); $options_list->setAttribute('class', 'options-list'); $this->appendShowColumnCheckbox($options_list); $this->appendRequiredCheckbox($options_list); // Serialise ---------------------------------------------------------- $label = Widget::Label(__('Serialise file names')); $input = Widget::Input('serialise', 'yes', 'checkbox'); if ($this->serialise == 'yes') { $input->setAttribute('checked', 'checked'); } $label->prependChild($input); $options_list->appendChild($label); $wrapper->appendChild($options_list); }
public function displaySettingsPanel(&$wrapper, $errors = null) { parent::displaySettingsPanel($wrapper, $errors); $order = $this->get('sortorder'); ## Destination Folder $ignore = array('/workspace/events', '/workspace/data-sources', '/workspace/text-formatters', '/workspace/pages', '/workspace/utilities'); $directories = General::listDirStructure(WORKSPACE, true, 'asc', DOCROOT, $ignore); $label = Widget::Label(__('Destination Directory')); $options = array(); $options[] = array('/workspace', false, '/workspace'); if (!empty($directories) && is_array($directories)) { foreach ($directories as $d) { $d = '/' . trim($d, '/'); if (!in_array($d, $ignore)) { $options[] = array($d, $this->get('destination') == $d, $d); } } } $label->appendChild(Widget::Select('fields[' . $this->get('sortorder') . '][destination]', $options)); if (isset($errors['destination'])) { $wrapper->appendChild(Widget::wrapFormElementWithError($label, $errors['destination'])); } else { $wrapper->appendChild($label); } //$this->buildValidationSelect($wrapper, $this->get('validator'), 'fields['.$this->get('sortorder').'][validator]', 'upload'); /*--------------------------------------------------------------------- Limiting ---------------------------------------------------------------------*/ $group = new XMLElement('div'); $group->setAttribute('class', 'group triple'); $input = Widget::Input("fields[{$order}][maximum_filesize]", $this->get('maximum_filesize')); $input->setAttribute('size', '12'); $label = Widget::Label(__('Limit image file size to %s MB', array($input->generate()))); if (isset($errors['maximum_filesize'])) { $group->appendChild(Widget::wrapFormElementWithError($label, $errors['maximum_filesize'])); } else { $group->appendChild($label); } $input = Widget::Input("fields[{$order}][maximum_dimension_width]", $this->get('maximum_dimension_width')); $input->setAttribute('size', '6'); $label = Widget::Label(__('Limit image width size to %s pixels', array($input->generate()))); if (isset($errors['maximum_dimension_width'])) { $group->appendChild(Widget::wrapFormElementWithError($label, $errors['maximum_dimension_width'])); } else { $group->appendChild($label); } $input = Widget::Input("fields[{$order}][maximum_dimension_height]", $this->get('maximum_dimension_height')); $input->setAttribute('size', '6'); $label = Widget::Label(__('Limit image height size to %s pixels', array($input->generate()))); if (isset($errors['maximum_dimension_height'])) { $group->appendChild(Widget::wrapFormElementWithError($label, $errors['maximum_dimension_height'])); } else { $group->appendChild($label); } $wrapper->appendChild($group); $input = Widget::Input("fields[{$order}][resize_long_edge_dimension]", $this->get('resize_long_edge_dimension')); $input->setAttribute('size', '6'); $label = Widget::Label(__('Resize images to have a long edge of %s pixels, maintaining aspect. <em>(Note: This should be less than any width or height restrictions above.)</em>', array($input->generate()))); if (isset($errors['resize_long_edge_dimension'])) { $wrapper->appendChild(Widget::wrapFormElementWithError($label, $errors['resize_long_edge_dimension'])); } else { $wrapper->appendChild($label); } $this->appendRequiredCheckbox($wrapper); $this->appendShowColumnCheckbox($wrapper); }