public function listTypes()
 {
     static $result;
     if (is_array($result)) {
         return $result;
     }
     $extensions = ExtensionManager::listInstalledHandles();
     if (!is_array($extensions) || empty($extensions)) {
         return array();
     }
     $result = array();
     foreach ($extensions as $e) {
         $path = EXTENSIONS . "/{$e}/template";
         if (!is_dir($path)) {
             continue;
         }
         $structure = General::listStructure($path, '/^formatter.[\\w-]+.tpl$/', false, 'ASC', $path);
         if (is_array($structure['filelist']) && !empty($structure['filelist'])) {
             foreach ($structure['filelist'] as $t) {
                 $type = preg_replace(array('/^formatter./i', '/.tpl$/i'), '', $t);
                 $result[$type] = array('path' => $path);
             }
         }
     }
     return $result;
 }
 /**
  *
  * Utility function that loads all the drivers
  * in the drivers directory
  * @throws ServiceDriverException
  */
 private static final function loadDrivers()
 {
     // if the pointer is null, then we sould load the drivers
     if (self::$drivers == null) {
         // create a new array
         self::$drivers = array();
         // get all files in the drivers folders
         $drivers = General::listStructure(OEMBED_DRIVERS_DIR, '/class.service[a-zA-Z0-9]+.php/', false, 'asc');
         // for each file found
         foreach ($drivers['filelist'] as $class) {
             $class = basename($class);
             try {
                 // include the class code
                 require_once OEMBED_DRIVERS_DIR . $class;
                 // get class name
                 $class = str_replace(array('class.', '.php'), '', $class);
                 // create new instance
                 $class = new $class($url);
                 // add the class to the stack
                 self::$drivers[$class->getName()] = $class;
             } catch (Exception $ex) {
                 throw new ServiceDriverException($url, $ex);
             }
         }
     }
 }
 function listAll()
 {
     $result = array();
     $people = array();
     $structure = General::listStructure(TEXTFORMATTERS, '/formatter.[\\w-]+.php/', false, 'ASC', TEXTFORMATTERS);
     if (is_array($structure['filelist']) && !empty($structure['filelist'])) {
         foreach ($structure['filelist'] as $f) {
             $f = str_replace(array('formatter.', '.php'), '', $f);
             $result[$f] = $this->about($f);
         }
     }
     $extensionManager = new ExtensionManager($this->_Parent);
     $extensions = $extensionManager->listInstalledHandles();
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $e) {
             if (!is_dir(EXTENSIONS . "/{$e}/text-formatters")) {
                 continue;
             }
             $tmp = General::listStructure(EXTENSIONS . "/{$e}/text-formatters", '/formatter.[\\w-]+.php/', false, 'ASC', EXTENSIONS . "/{$e}/text-formatters");
             if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                 foreach ($tmp['filelist'] as $f) {
                     $f = preg_replace(array('/^formatter./i', '/.php$/i'), '', $f);
                     $result[$f] = $this->about($f);
                 }
             }
         }
     }
     ksort($result);
     return $result;
 }
 public function listAll($sort_column = 'name', $sort_direction = 'asc')
 {
     //header('content-type: text/plain');
     $this->_sort_column = $sort_column;
     $this->_sort_direction = $sort_direction;
     $result = array();
     $path = $this->__getPath();
     $structure = General::listStructure($path, '/import.[\\w-]+.php/', false, 'ASC', $path);
     if (is_array($structure['filelist']) and !empty($structure['filelist'])) {
         foreach ($structure['filelist'] as $file) {
             $file = self::__getHandleFromFilename($file);
             //var_dump($this->__getClassName($file));
             if ($about = $this->about($file)) {
                 $classname = $this->__getClassName($file);
                 $path = $this->__getDriverPath($file);
                 $about['handle'] = $file;
                 if (is_callable(array($classname, 'allowEditorToParse'))) {
                     $about['can_parse'] = @call_user_func(array(&$classname, 'allowEditorToParse'));
                 } else {
                     $about['can_parse'] = false;
                 }
                 if (is_callable(array($classname, 'getSource'))) {
                     $about['source'] = @call_user_func(array(&$classname, 'getSource'));
                 } else {
                     $about['source'] = null;
                 }
                 $result[] = $about;
             }
         }
     }
     usort($result, array($this, "__sort"));
     return $result;
 }
 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 listAll()
 {
     $result = array();
     $people = array();
     $structure = General::listStructure(EVENTS, '/event.[\\w-]+.php/', false, 'ASC', EVENTS);
     if (is_array($structure['filelist']) && !empty($structure['filelist'])) {
         foreach ($structure['filelist'] as $f) {
             $f = self::__getHandleFromFilename($f);
             //preg_replace(array('/^event./i', '/.php$/i'), '', $f);
             if ($about = $this->about($f)) {
                 $classname = $this->__getClassName($f);
                 $path = $this->__getDriverPath($f);
                 $can_parse = false;
                 $type = NULL;
                 if (is_callable(array($classname, 'allowEditorToParse'))) {
                     $can_parse = @call_user_func(array(&$classname, 'allowEditorToParse'));
                 }
                 if (is_callable(array($classname, 'getType'))) {
                     $type = @call_user_func(array(&$classname, 'getType'));
                 }
                 $about['can_parse'] = $can_parse;
                 $about['type'] = $type;
                 $result[$f] = $about;
             }
         }
     }
     //$structure = General::listStructure(EXTENSIONS, array(), false, 'ASC', EXTENSIONS);
     //$extensions = $structure['dirlist'];
     $extensionManager = new ExtensionManager($this->_Parent);
     $extensions = $extensionManager->listInstalledHandles();
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $e) {
             if (!is_dir(EXTENSIONS . "/{$e}/events")) {
                 continue;
             }
             $tmp = General::listStructure(EXTENSIONS . "/{$e}/events", '/event.[\\w-]+.php/', false, 'ASC', EXTENSIONS . "/{$e}/events");
             if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                 foreach ($tmp['filelist'] as $f) {
                     $f = $f = self::__getHandleFromFilename($f);
                     if ($about = $this->about($f)) {
                         $classname = $this->__getClassName($f);
                         $can_parse = false;
                         $type = NULL;
                         $about['can_parse'] = $can_parse;
                         $about['type'] = $type;
                         $result[$f] = $about;
                     }
                 }
             }
         }
     }
     ksort($result);
     return $result;
 }
 public static function getLatestVersion($entry_id)
 {
     $files = General::listStructure(MANIFEST . '/versions/' . $entry_id . '/', '/.xml$/', false, 'desc');
     if (!is_array($files['filelist'])) {
         $files['filelist'] = array();
     }
     natsort($files['filelist']);
     $files['filelist'] = array_reverse($files['filelist']);
     $file = reset($files['filelist']);
     $entry = new DomDocument();
     $entry->load(MANIFEST . '/versions/' . $entry_id . '/' . $file);
     return $entry;
 }
Пример #8
0
 public function addJavaScriptAndCSS()
 {
     $callback = Symphony::Engine()->getPageCallback();
     if ($callback['driver'] != 'blueprintsdatasources' || !is_array($callback['context'])) {
         return;
     }
     // Find data source handle.
     $handle = NULL;
     if ($callback['context'][0] == 'edit' && !empty($callback['context'][1])) {
         $handle = $callback['context'][1];
     }
     // Find current XPath values.
     $parametrisator = array('xslt' => false, 'xpaths' => array());
     if (isset($_POST['parametrisator'])) {
         $parametrisator['xslt'] = $_POST['parametrisator']['xslt'];
         if (isset($_POST['parametrisator']['xpaths']) && isset($_POST['parametrisator']['xpaths']['name'])) {
             $parametrisator['xpaths'] = array_combine($_POST['parametrisator']['xpaths']['name'], $_POST['parametrisator']['xpaths']['xpath']);
         } else {
             $parametrisator['xpaths'] = array();
         }
     } else {
         if (!empty($handle)) {
             $datasourceManager = new DatasourceManager(Symphony::Engine());
             $existing =& $datasourceManager->create($handle, NULL, false);
             if (!empty($existing)) {
                 if (is_array($existing->dsParamParametrisator)) {
                     $parametrisator = $existing->dsParamParametrisator;
                 }
                 if (!empty($existing->dsParamROOTELEMENT)) {
                     $handle = $existing->dsParamROOTELEMENT;
                 }
             }
         }
     }
     // Remove empty values
     $parametrisator['xpaths'] = array_filter($parametrisator['xpaths']);
     // Get list of utilities
     $xsltfile = $parametrisator['xslt'];
     $parametrisator['xslt'] = '<option value="">' . __('Disabled') . '</option>';
     $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
     if (is_array($utilities) && is_array($utilities['filelist'])) {
         foreach ($utilities['filelist'] as $utility) {
             $parametrisator['xslt'] .= '<option value="' . $utility . '"' . ($xsltfile == $utility ? ' selected="selected"' : '') . '>' . $utility . '</option>';
         }
     }
     // Let our script know sort and order values.
     Administration::instance()->Page->addElementToHead(new XMLElement('script', "Symphony.Context.add('parametrisator', " . json_encode(array('xslt' => $parametrisator['xslt'], 'xpaths' => $parametrisator['xpaths'], 'handle' => $handle)) . ");", array('type' => 'text/javascript')), 100);
     // Append scripts and styles for field settings pane
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/parametrisator/assets/parametrisator.settings.js', 101, false);
 }
 public static function listAll()
 {
     $result = array();
     $structure = General::listStructure(WORKSPACE . '/email-newsletters', '/recipient_group.[\\w-]+.php/', false, 'ASC', WORKSPACE . '/email-newsletters');
     if (is_array($structure['filelist']) && !empty($structure['filelist'])) {
         foreach ($structure['filelist'] as $f) {
             $f = self::__getHandleFromFilename($f);
             if ($about = self::about($f)) {
                 $classname = self::__getClassName($f);
                 $path = self::__getDriverPath($f);
                 $can_parse = false;
                 $type = NULL;
                 if (method_exists($classname, 'allowEditorToParse')) {
                     $can_parse = call_user_func(array($classname, 'allowEditorToParse'));
                 }
                 if (method_exists($classname, 'getSource')) {
                     $type = call_user_func(array($classname, 'getSource'));
                 }
                 $about['can_parse'] = $can_parse;
                 $about['type'] = $type;
                 $result[$f] = $about;
             }
         }
     }
     $extensions = Symphony::ExtensionManager()->listInstalledHandles();
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $e) {
             if (!is_dir(EXTENSIONS . "/{$e}/email-newsletters")) {
                 continue;
             }
             $tmp = General::listStructure(EXTENSIONS . "/{$e}/email-newsletters", '/recipient_group.[\\w-]+.php/', false, 'ASC', EXTENSIONS . "/{$e}/email-newsletters");
             if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                 foreach ($tmp['filelist'] as $f) {
                     $f = self::__getHandleFromFilename($f);
                     if ($about = self::about($f)) {
                         $about['can_parse'] = false;
                         $about['type'] = NULL;
                         $result[$f] = $about;
                     }
                 }
             }
         }
     }
     ksort($result);
     return $result;
 }
Пример #10
0
 public function fetchTypes()
 {
     $structure = General::listStructure(TOOLKIT . '/fields', '/field.[a-z0-9_-]+.php/i', false, 'asc', TOOLKIT . '/fields');
     $extensions = $this->_Parent->ExtensionManager->listInstalledHandles();
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $handle) {
             if (is_dir(EXTENSIONS . '/' . $handle . '/fields')) {
                 $tmp = General::listStructure(EXTENSIONS . '/' . $handle . '/fields', '/field.[a-z0-9_-]+.php/i', false, 'asc', EXTENSIONS . '/' . $handle . '/fields');
                 if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                     $structure['filelist'] = array_merge($structure['filelist'], $tmp['filelist']);
                 }
             }
         }
         $structure['filelist'] = General::array_remove_duplicates($structure['filelist']);
     }
     $types = array();
     foreach ($structure['filelist'] as $filename) {
         $types[] = str_replace(array('field.', '.php'), '', $filename);
     }
     return $types;
 }
 function listAll()
 {
     $result = array();
     $people = array();
     $structure = General::listStructure(TEXTFORMATTERS, '/formatter.[\\w-]+.php/', false, "asc", TEXTFORMATTERS);
     if (is_array($structure['filelist']) && !empty($structure['filelist'])) {
         foreach ($structure['filelist'] as $f) {
             $f = str_replace(array("formatter.", ".php"), "", $f);
             if ($about = $this->about($f)) {
                 $result[$f] = $about;
             }
         }
     }
     $structure = General::listStructure(CAMPFIRE, array(), false, "asc", CAMPFIRE);
     $owners = $structure['dirlist'];
     if (is_array($owners) && !empty($owners)) {
         foreach ($owners as $o) {
             $services = General::listStructure(CAMPFIRE . "/{$o}", array(), false, "asc", CAMPFIRE . "/{$o}");
             if (is_array($services) && !empty($services)) {
                 foreach ($services['dirlist'] as $s) {
                     $tmp = General::listStructure(CAMPFIRE . "/{$o}/{$s}/text-formatters", '/formatter.[\\w-]+.php/', false, "asc", CAMPFIRE . "/{$o}/{$s}/text-formatters");
                     if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                         foreach ($tmp['filelist'] as $f) {
                             $f = str_replace(array("formatter.", ".php"), "", $f);
                             if ($about = $this->about($f, NULL, CAMPFIRE . "/{$o}/{$s}/text-formatters")) {
                                 $result[$f] = $about;
                             }
                         }
                     }
                 }
             }
         }
     }
     ksort($result);
     return $result;
 }
 /**
  * Fetch all languages available in the core language folder and the language extensions.
  * The function stores all language information in the public variable `$_languages`.
  * It contains an array with the name, source, path and status of each language.
  * Furthermore it add an array of all extensions available in a specific language. The language
  * status (enabled/disabled) can only be determined when the Extension Manager has been
  * initialized before. During installation all extension status are set to disabled.
  */
 public static function fetch()
 {
     self::$_languages = array();
     // Fetch list of active extensions
     $enabled = array();
     if (class_exists('Symphony')) {
         $enabled = Symphony::ExtensionManager()->listInstalledHandles();
     }
     // Fetch core languages
     $directory = General::listStructure(LANG);
     foreach ($directory['filelist'] as $file) {
         self::$_languages = array_merge(self::$_languages, self::fetchLanguage('core', LANG, $file, $enabled));
     }
     // Fetch extensions
     $extensions = new DirectoryIterator(EXTENSIONS);
     // Language extensions
     foreach ($extensions as $extension) {
         $folder = $extension->getPathname() . '/lang';
         $directory = General::listStructure($folder);
         if (is_array($directory['filelist']) && !empty($directory['filelist'])) {
             foreach ($directory['filelist'] as $file) {
                 $temp = self::fetchLanguage($extension->getFilename(), $folder, $file, $enabled);
                 $lang = key($temp);
                 // Core translations
                 if (strpos($extension->getFilename(), 'lang_') !== false) {
                     // Prepare merging
                     if (array_key_exists($lang, self::$_languages)) {
                         unset($temp[$lang]['name']);
                         unset(self::$_languages[$lang]['status']);
                     }
                     // Merge
                     self::$_languages = array_merge_recursive(self::$_languages, $temp);
                 } else {
                     // Create language if not exists
                     if (!array_key_exists($lang, self::$_languages)) {
                         $language = array($lang => array('name' => $temp[$lang]['name'], 'status' => LANGUAGE_DISABLED, 'extensions' => array()));
                         self::$_languages = array_merge(self::$_languages, $language);
                     }
                     // Merge
                     self::$_languages[$lang]['extensions'][$temp[$lang]['source']] = $temp[$lang]['path'];
                 }
             }
         }
     }
 }
    function view()
    {
        $this->_existing_file = isset($this->_context[1]) ? $this->_context[1] . '.xsl' : NULL;
        ## Handle unknown context
        if (!in_array($this->_context[0], array('new', 'edit'))) {
            $this->_Parent->errorPageNotFound();
        }
        ## Edit Utility context
        if ($this->_context[0] == 'edit') {
            $file_abs = UTILITIES . '/' . $this->_existing_file;
            $filename = $this->_existing_file;
            if (!@is_file($file_abs)) {
                redirect(URL . '/symphony/blueprints/utilities/new/');
            }
            $fields['name'] = $filename;
            $fields['body'] = @file_get_contents($file_abs);
            $this->Form->setAttribute('action', URL . '/symphony/blueprints/utilities/edit/' . $this->_context[1] . '/');
        } else {
            $fields['body'] = '<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template name="">

</xsl:template>

</xsl:stylesheet>';
        }
        $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
        if ($formHasErrors) {
            $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR);
        }
        if (isset($this->_context[2])) {
            switch ($this->_context[2]) {
                case 'saved':
                    $this->pageAlert(__('Utility updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Utilities</a>', array(DateTimeObj::get(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/utilities/new/', URL . '/symphony/blueprints/components/')), Alert::SUCCESS);
                    break;
                case 'created':
                    $this->pageAlert(__('Utility created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Utilities</a>', array(DateTimeObj::get(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/utilities/new/', URL . '/symphony/blueprints/components/')), Alert::SUCCESS);
                    break;
            }
        }
        $this->setTitle(__($this->_context[0] == 'new' ? '%1$s &ndash; %2$s' : '%1$s &ndash; %2$s &ndash; %3$s', array(__('Symphony'), __('Utilities'), $filename)));
        $this->appendSubheading($this->_context[0] == 'new' ? __('Untitled') : $filename);
        if (!empty($_POST)) {
            $fields = $_POST['fields'];
        }
        $fields['body'] = General::sanitize($fields['body']);
        $fieldset = new XMLElement('fieldset');
        $fieldset->setAttribute('class', 'primary');
        $label = Widget::Label(__('Name'));
        $label->appendChild(Widget::Input('fields[name]', $fields['name']));
        $fieldset->appendChild(isset($this->_errors['name']) ? $this->wrapFormElementWithError($label, $this->_errors['name']) : $label);
        $label = Widget::Label(__('Body'));
        $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code')));
        $fieldset->appendChild(isset($this->_errors['body']) ? $this->wrapFormElementWithError($label, $this->_errors['body']) : $label);
        $this->Form->appendChild($fieldset);
        $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
        $utilities = $utilities['filelist'];
        if (is_array($utilities) && !empty($utilities)) {
            $div = new XMLElement('div');
            $div->setAttribute('class', 'secondary');
            $h3 = new XMLElement('h3', __('Utilities'));
            $h3->setAttribute('class', 'label');
            $div->appendChild($h3);
            $ul = new XMLElement('ul');
            $ul->setAttribute('id', 'utilities');
            $i = 0;
            foreach ($utilities as $util) {
                $li = new XMLElement('li');
                if ($i++ % 2 != 1) {
                    $li->setAttribute('class', 'odd');
                }
                $li->appendChild(Widget::Anchor($util, URL . '/symphony/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL));
                $ul->appendChild($li);
            }
            $div->appendChild($ul);
            $this->Form->appendChild($div);
        }
        $div = new XMLElement('div');
        $div->setAttribute('class', 'actions');
        $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Utility'), 'submit', array('accesskey' => 's')));
        if ($this->_context[0] == 'edit') {
            $button = new XMLElement('button', __('Delete'));
            $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this utility')));
            $div->appendChild($button);
        }
        $this->Form->appendChild($div);
    }
    public function displaySettingsPanel(&$wrapper, $errors = null)
    {
        parent::displaySettingsPanel($wrapper, $errors);
        $order = $this->get('sortorder');
        /*---------------------------------------------------------------------
        			Text Formatter
        		---------------------------------------------------------------------*/
        $group = new XMLElement('div');
        $group->setAttribute('class', 'two columns');
        $group->appendChild($this->buildFormatterSelect($this->get('formatter'), "fields[{$order}][formatter]", __('Text Formatter')));
        /*---------------------------------------------------------------------
        			XSLT
        		---------------------------------------------------------------------*/
        $label = Widget::Label('XSLT Utility');
        $label->setAttribute('class', 'column');
        $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
        $utilities = $utilities['filelist'] ? $utilities['filelist'] : array();
        $xsltfile = $this->get('xsltfile');
        $options = array();
        $options[] = array('', empty($xsltfile), __('Disabled'));
        if (is_array($utilities)) {
            foreach ($utilities as $utility) {
                $options[] = array($utility, $xsltfile == $utility, $utility);
            }
        }
        $label->appendChild(Widget::Select("fields[{$order}][xsltfile]", $options));
        $help = new XMLElement('p');
        $help->setAttribute('class', 'help');
        $help->setAttribute('style', 'margin-bottom:0');
        $help->setValue(__('XSLT will be applied to <code>entry</code> XML before <code>Expression</code> is evaluated.'));
        $label->appendChild($help);
        $group->appendChild($label);
        $wrapper->appendChild($group);
        /*---------------------------------------------------------------------
        			Expression
        		---------------------------------------------------------------------*/
        $label = Widget::Label('Expression');
        $label->setAttribute('class', 'column');
        $label->appendChild(Widget::Input("fields[{$order}][expression]", $this->get('expression')));
        $help = new XMLElement('p');
        $help->setAttribute('class', 'help');
        $help->setValue(__('
				To access the other fields, use XPath: <code>{entry/field-one} static text {entry/field-two}</code>.
			'));
        $label->appendChild($help);
        $wrapper->appendChild($label);
        /*---------------------------------------------------------------------
        			Fetch Associated Entry Counts
        		---------------------------------------------------------------------*/
        $compact = new XMLElement('div');
        $compact->setAttribute('class', 'two columns');
        $label = Widget::Label();
        $label->setAttribute('class', 'column');
        $input = Widget::Input("fields[{$order}][fetch_associated_counts]", 'yes', 'checkbox');
        if ($this->get('fetch_associated_counts') == 'yes') {
            $input->setAttribute('checked', 'checked');
        }
        $label->setValue($input->generate() . ' ' . __('Fetch associated entry counts for XPath'));
        $compact->appendChild($label);
        /*---------------------------------------------------------------------
        			Allow Override
        		---------------------------------------------------------------------*/
        /*
        $label = Widget::Label();
        $input = Widget::Input("fields[{$order}][allow_override]", 'yes', 'checkbox');
        
        if ($this->get('allow_override') == 'yes') {
        	$input->setAttribute('checked', 'checked');
        }
        
        $label->setValue($input->generate() . ' Allow value to be manually overridden');
        $wrapper->appendChild($label);
        */
        /*---------------------------------------------------------------------
        			Hide input
        		---------------------------------------------------------------------*/
        $label = Widget::Label();
        $label->setAttribute('class', 'column');
        $input = Widget::Input("fields[{$order}][hide]", 'yes', 'checkbox');
        if ($this->get('hide') == 'yes') {
            $input->setAttribute('checked', 'checked');
        }
        $label->setValue($input->generate() . ' ' . __('Hide this field on publish page'));
        $compact->appendChild($label);
        $this->appendShowColumnCheckbox($compact);
        $wrapper->appendChild($compact);
    }
Пример #15
0
 function __actionDo()
 {
     if (!isset($_POST['fields']['source']) or $_POST['fields']['source'] <= 0) {
         $this->_errors[] = 'You didn\'t choose a source, perhaps you don\'t have any sections with an upload field in them?';
         $this->_valid = false;
         return;
     }
     if (!isset($_POST['fields']['sourcedir']) or !preg_match('/^\\/workspace\\/uploads\\/mui/i', $_POST['fields']['sourcedir'])) {
         $this->_errors[] = 'Fail!';
         $this->_valid = false;
         return;
     }
     $this->_section_id = $_POST['fields']['source'];
     // section id
     $entryManager = new EntryManager($this->_Parent);
     $sectionManager = new SectionManager($this->_Parent);
     $section = $sectionManager->fetch($this->_section_id);
     // get all the fields for the types we support, and get ready to put the filename in them
     foreach ($this->_driver->getTypes() as $type) {
         $f = $section->fetchFields($type);
         if (count($f) > 0) {
             foreach ($f as $field) {
                 $field_names[] = $field;
             }
         }
         //array($field->get('element_name'), $field->get('destination'));
     }
     $files = General::listStructure(DOCROOT . $_POST['fields']['sourcedir']);
     if (count($files['filelist']) == 0) {
         $this->_errors[] = "There are no files in this directory: {$_POST['fields']['sourcedir']}.";
         $this->_valid = false;
         return;
     }
     // a list of all the entries so we can rollback
     $entries = array();
     foreach ($files['filelist'] as $k => $f) {
         $continue = false;
         $this->_files[] = $f;
         $entry =& $entryManager->create();
         $entry->set('section_id', $this->_section_id);
         $entry->set('author_id', $this->_Parent->Author->get('id'));
         $entry->set('creation_date', DateTimeObj::get('Y-m-d H:i:s'));
         $entry->set('creation_date_gmt', DateTimeObj::getGMT('Y-m-d H:i:s'));
         $chkfields = $fields = $_POST['fields'][$this->_section_id];
         // loop over all the supported fields
         foreach ($field_names as $field) {
             $dest = $field->get('destination');
             $name = $field->get('element_name');
             $tmp_name = DOCROOT . $_POST['fields']['sourcedir'] . '/' . $f;
             $new_name = DOCROOT . $dest . '/' . $f;
             /* if you don't want to rollback implement this */
             // if($field->get('validator') != NULL){
             //     $rule = $field->get('validator');
             //
             // 		// skip this file since it doesn't validate
             //     if(!General::validateString($tmp_name, $rule)) {
             // 			;
             // 			// $continue = true;
             // 		}
             // }
             $type = trim(shell_exec('file -b --mime ' . escapeshellarg($tmp_name)));
             $size = filesize($tmp_name);
             // setup fields to check the post
             $chkfields[$name][name] = $f;
             $chkfields[$name][type] = $type;
             $chkfields[$name][tmp_name] = $tmp_name;
             $chkfields[$name][error] = 0;
             $chkfields[$name][size] = $size;
             // an array to copy the files after
             $copy[] = array($tmp_name, $new_name);
             // setup upload fields as they should be as if they were processed
             $fields[$name][file] = preg_replace("/^\\/workspace/", '', $dest) . '/' . $f;
             $fields[$name][size] = $size;
             $fields[$name][mimetype] = $type;
             $fields[$name][meta] = serialize($this->getMetaInfo(DOCROOT . $fields[$name][file], $type));
         }
         // skip the file if it doesn't validate
         // if ($continue == true) continue;
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($chkfields, $this->_errors)) {
             $this->_ignored_files[] = $f;
             break;
         }
         // now we can copy the files to their new location since everything's validated
         foreach ($copy as $c) {
             if (@copy($c[0], $c[1])) {
                 @chmod($c[1], intval(0755, 8));
             } else {
                 $this->_errors[] = "Couldn't copy the files to the {$dest} directory. ";
                 return;
             }
         }
         // setup the data, process it
         if (__ENTRY_OK__ != $this->setDataFromPost($entry, $fields, $this->_errors, false, false, $entries)) {
             $this->_ignored_files[] = $f;
             break;
         }
         // commit the entry if we made it
         if (!$entry->commit()) {
             define_safe('__SYM_DB_INSERT_FAILED__', true);
         } else {
             $this->_valid = true;
         }
     }
     // rollback, delete all entries by id
     if ($this->_valid == false && count($entries) > 0) {
         $entryManager->delete($entries);
         return;
     }
     // if we made it here, and they want us to delete the files, it shall beDOCROOT . $_POST['fields']['sourcedir']
     if (isset($_POST['fields']['remove']) && $_POST['fields']['remove'] == 'on' && $this->_valid == true) {
         foreach ($files['filelist'] as $k => $f) {
             unlink(DOCROOT . $_POST['fields']['sourcedir'] . '/' . $f);
         }
         // already sanitized the sourcedir so no one can accidentally delete stuff
         // 	from anywhere but the uploads directory, make sure not to delete mui dir
         if ($_POST['fields']['sourcedir'] != '/workspace' . $this->_driver->getMUI()) {
             rmdir(DOCROOT . $_POST['fields']['sourcedir']);
         }
     }
     $this->_entries_count = count($files['filelist']) - count($this->_ignored_files);
 }
 function view()
 {
     $this->appendSubheading(__('Components'));
     $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
     $utilities = $utilities['filelist'];
     $ul = new XMLElement('ul');
     $ul->setAttribute('id', 'components');
     $ul->setAttribute('class', 'triple group');
     ### EVENTS ###
     $EventManager = new EventManager($this->_Parent);
     $events = $EventManager->listAll();
     $li = new XMLElement('li');
     $h3 = new XMLElement('h3', __('Events'));
     $h3->appendChild(Widget::Anchor(__('Create New'), URL . '/symphony/blueprints/events/new/', __('Create a new event'), 'create button'));
     $li->appendChild($h3);
     $list = new XMLElement('ul');
     $list->setSelfClosingTag(false);
     if (is_array($events) && !empty($events)) {
         foreach ($events as $e) {
             $item = new XMLElement('li');
             $item->appendChild(Widget::Anchor($e['name'], URL . '/symphony/blueprints/events/' . ($e['can_parse'] ? 'edit' : 'info') . '/' . strtolower($e['handle']) . '/', 'event.' . $e['handle'] . '.php'));
             $item->setAttribute('class', 'external');
             $list->appendChild($item);
         }
     }
     $li->appendChild($list);
     $ul->appendChild($li);
     ######
     ### DATASOURCES ###
     $DSManager = new DatasourceManager($this->_Parent);
     $datasources = $DSManager->listAll();
     $li = new XMLElement('li');
     $h3 = new XMLElement('h3', __('Data Sources'));
     $h3->appendChild(Widget::Anchor(__('Create New'), URL . '/symphony/blueprints/datasources/new/', __('Create a new data source'), 'create button'));
     $li->appendChild($h3);
     $list = new XMLElement('ul');
     $list->setSelfClosingTag(false);
     if (is_array($datasources) && !empty($datasources)) {
         foreach ($datasources as $ds) {
             $item = new XMLElement('li');
             if ($ds['can_parse']) {
                 $item->appendChild(Widget::Anchor($ds['name'], URL . '/symphony/blueprints/datasources/edit/' . strtolower($ds['handle']) . '/', 'data.' . $ds['handle'] . '.php'));
             } else {
                 $item->appendChild(Widget::Anchor($ds['name'], URL . '/symphony/blueprints/datasources/info/' . strtolower($ds['handle']) . '/', 'data.' . $ds['handle'] . '.php'));
             }
             $list->appendChild($item);
         }
     }
     $li->appendChild($list);
     $ul->appendChild($li);
     ######
     ### UTILITIES ###
     $li = new XMLElement('li');
     $h3 = new XMLElement('h3', __('Utilities'));
     $h3->appendChild(Widget::Anchor(__('Create New'), URL . '/symphony/blueprints/utilities/new/', __('Create a new utility'), 'create button'));
     $li->appendChild($h3);
     $list = new XMLElement('ul');
     $list->setSelfClosingTag(false);
     if (is_array($utilities) && !empty($utilities)) {
         foreach ($utilities as $u) {
             $item = new XMLElement('li');
             $item->appendChild(Widget::Anchor($u, URL . '/symphony/blueprints/utilities/edit/' . str_replace('.xsl', '', $u) . '/'));
             $list->appendChild($item);
         }
     }
     $li->appendChild($list);
     $ul->appendChild($li);
     ######
     $this->Form->appendChild($ul);
 }
 /**
  * Finds all available Text Formatter's by searching the `TEXTFORMATTERS` folder
  * and in all installed extension folders. Returns an associative array of formatters.
  *
  * @see toolkit.Manager#about()
  * @return array
  *  Associative array of formatters with the key being the handle of the formatter
  *  and the value being the text formatter's description.
  */
 public function listAll()
 {
     $result = array();
     $structure = General::listStructure(TEXTFORMATTERS, '/formatter.[\\w-]+.php/', false, 'ASC', TEXTFORMATTERS);
     if (is_array($structure['filelist']) && !empty($structure['filelist'])) {
         foreach ($structure['filelist'] as $f) {
             $f = $this->__getHandleFromFilename($f);
             $result[$f] = $this->about($f);
         }
     }
     $extensions = Symphony::ExtensionManager()->listInstalledHandles();
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $e) {
             if (!is_dir(EXTENSIONS . "/{$e}/text-formatters")) {
                 continue;
             }
             $tmp = General::listStructure(EXTENSIONS . "/{$e}/text-formatters", '/formatter.[\\w-]+.php/', false, 'ASC', EXTENSIONS . "/{$e}/text-formatters");
             if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                 foreach ($tmp['filelist'] as $f) {
                     $f = $this->__getHandleFromFilename($f);
                     $result[$f] = $this->about($f);
                 }
             }
         }
     }
     ksort($result);
     return $result;
 }
 public function __form()
 {
     $this->setPageType('form');
     $this->_existing_file = isset($this->_context[1]) ? $this->_context[1] . '.xsl' : NULL;
     $this->Form->setAttribute('class', 'columns');
     $filename = $this->_existing_file;
     // Handle unknown context
     if (!in_array($this->_context[0], array('new', 'edit'))) {
         Administration::instance()->errorPageNotFound();
     }
     // Edit Utility context
     if ($this->_context[0] == 'edit') {
         $file_abs = UTILITIES . '/' . $this->_existing_file;
         if (!is_file($file_abs)) {
             redirect(SYMPHONY_URL . '/blueprints/utilities/new/');
         }
         $fields['name'] = $filename;
         $fields['body'] = @file_get_contents($file_abs);
         $this->Form->setAttribute('action', SYMPHONY_URL . '/blueprints/utilities/edit/' . $this->_context[1] . '/');
     } else {
         $fields['body'] = file_get_contents(PageManager::getTemplate('blueprints.utility'));
     }
     $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
     if ($formHasErrors) {
         $this->pageAlert(__('An error occurred while processing this form. See below for details.'), Alert::ERROR);
     }
     // These alerts are only valid if the form doesn't have errors
     if (isset($this->_context[2])) {
         switch ($this->_context[2]) {
             case 'saved':
                 $this->pageAlert(__('Utility updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/utilities/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/utilities/" accesskey="a">' . __('View all Utilities') . '</a>', Alert::SUCCESS);
                 break;
             case 'created':
                 $this->pageAlert(__('Utility created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/utilities/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/utilities/" accesskey="a">' . __('View all Utilities') . '</a>', Alert::SUCCESS);
                 break;
         }
     }
     $this->setTitle(__($this->_context[0] == 'new' ? '%2$s &ndash; %3$s' : '%1$s &ndash; %2$s &ndash; %3$s', array($filename, __('Utilities'), __('Symphony'))));
     $this->appendSubheading($this->_context[0] == 'new' ? __('Untitled') : $filename);
     $this->insertBreadcrumbs(array(Widget::Anchor(__('Utilities'), SYMPHONY_URL . '/blueprints/utilities/')));
     if (!empty($_POST)) {
         $fields = $_POST['fields'];
     }
     $fields['body'] = htmlentities($fields['body'], ENT_COMPAT, 'UTF-8');
     $fields['name'] = isset($fields['name']) ? $fields['name'] : null;
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'primary column');
     $label = Widget::Label(__('Name'));
     $label->appendChild(Widget::Input('fields[name]', $fields['name']));
     $fieldset->appendChild(isset($this->_errors['name']) ? Widget::Error($label, $this->_errors['name']) : $label);
     $label = Widget::Label(__('Body'));
     $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code')));
     $fieldset->appendChild(isset($this->_errors['body']) ? Widget::Error($label, $this->_errors['body']) : $label);
     $this->Form->appendChild($fieldset);
     $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
     $utilities = $utilities['filelist'];
     if (is_array($utilities) && !empty($utilities)) {
         $this->Form->setAttribute('class', 'two columns');
         $div = new XMLElement('div');
         $div->setAttribute('class', 'secondary column');
         $p = new XMLElement('p', __('Utilities'));
         $p->setAttribute('class', 'label');
         $div->appendChild($p);
         $frame = new XMLElement('div', null, array('class' => 'frame'));
         $ul = new XMLElement('ul');
         $ul->setAttribute('id', 'utilities');
         foreach ($utilities as $util) {
             $li = new XMLElement('li');
             $li->appendChild(Widget::Anchor($util, SYMPHONY_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL));
             $ul->appendChild($li);
         }
         $frame->appendChild($ul);
         $div->appendChild($frame);
         $this->Form->appendChild($div);
     }
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Utility'), 'submit', array('accesskey' => 's')));
     if ($this->_context[0] == 'edit') {
         $button = new XMLElement('button', __('Delete'));
         $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this utility'), 'type' => 'submit', 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this Utility?')));
         $div->appendChild($button);
     }
     $this->Form->appendChild($div);
 }
 /**
  * Returns an array of all gateways.
  * Each item in the array will contain the return value of the about()
  * function of each gateway.
  *
  * @return array
  */
 public static function listAll()
 {
     $result = array();
     $structure = General::listStructure(EMAILGATEWAYS, '/email.[\\w-]+.php/', false, 'ASC', EMAILGATEWAYS);
     if (is_array($structure['filelist']) && !empty($structure['filelist'])) {
         foreach ($structure['filelist'] as $f) {
             $f = str_replace(array('email.', '.php'), '', $f);
             $result[$f] = self::about($f);
         }
     }
     $extensions = Symphony::ExtensionManager()->listInstalledHandles();
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $e) {
             if (!is_dir(EXTENSIONS . "/{$e}/email-gateways")) {
                 continue;
             }
             $tmp = General::listStructure(EXTENSIONS . "/{$e}/email-gateways", '/email.[\\w-]+.php/', false, 'ASC', EXTENSIONS . "/{$e}/email-gateways");
             if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                 foreach ($tmp['filelist'] as $f) {
                     $f = preg_replace(array('/^email./i', '/.php$/i'), '', $f);
                     $result[$f] = self::about($f);
                 }
             }
         }
     }
     ksort($result);
     return $result;
 }
Пример #20
0
 function pruneLogs($age = 5)
 {
     $logs = array();
     $logs = General::listStructure(LOGS, array("log"), false, 'asc');
     if (!empty($logs)) {
         foreach ($logs['filelist'] as $f) {
             $name = basename($f, ".log");
             if (General::dateDiff(strtotime($name)) > intval($age)) {
                 @unlink(LOGS . "/" . $f);
             }
         }
     }
     return true;
 }
 public function __viewTemplate()
 {
     $this->setPageType('form');
     $this->Form->setAttribute('action', URL . '/symphony/blueprints/pages/template/' . $this->_context[1] . '/');
     $filename = $this->_context[1] . '.xsl';
     $file_abs = PAGES . '/' . $filename;
     if (!@is_file($file_abs)) {
         redirect(URL . '/symphony/blueprints/pages/');
     }
     $fields['body'] = @file_get_contents($file_abs);
     $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
     if ($formHasErrors) {
         $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR);
     }
     // Status message:
     if (isset($this->_context[2])) {
         $this->pageAlert(__('%s %s at %s. <a href="%s">View all %s</a>', array(__('Page'), 'updated', DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/pages/', __('Pages'))), Alert::SUCCESS);
     }
     $this->setTitle(__($filename ? '%1$s &ndash; %2$s &ndash; %3$s' : '%1$s &ndash; %2$s', array(__('Symphony'), __('Pages'), $filename)));
     $this->appendSubheading($filename ? $filename : __('Untitled'));
     if (!empty($_POST)) {
         $fields = $_POST['fields'];
     }
     $fields['body'] = General::sanitize($fields['body']);
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'primary');
     $label = Widget::Label(__('Body'));
     $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code')));
     if (isset($this->_errors['body'])) {
         $label = $this->wrapFormElementWithError($label, $this->_errors['body']);
     }
     $fieldset->appendChild($label);
     $this->Form->appendChild($fieldset);
     $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
     $utilities = $utilities['filelist'];
     if (is_array($utilities) && !empty($utilities)) {
         $div = new XMLElement('div');
         $div->setAttribute('class', 'secondary');
         $h3 = new XMLElement('h3', __('Utilities'));
         $h3->setAttribute('class', 'label');
         $div->appendChild($h3);
         $ul = new XMLElement('ul');
         $ul->setAttribute('id', 'utilities');
         foreach ($utilities as $index => $util) {
             $li = new XMLElement('li');
             if ($index % 2 != 1) {
                 $li->setAttribute('class', 'odd');
             }
             $li->appendChild(Widget::Anchor($util, URL . '/symphony/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL));
             $ul->appendChild($li);
         }
         $div->appendChild($ul);
         $this->Form->appendChild($div);
     }
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's')));
     $this->Form->appendChild($div);
 }
    function __form()
    {
        $this->setPageType('form');
        $fields = array();
        if ($this->_context[0] == 'edit') {
            if (!($page_id = $this->_context[1])) {
                redirect(URL . '/symphony/blueprints/pages/');
            }
            if (!($existing = $this->_Parent->Database->fetchRow(0, "SELECT * FROM `tbl_pages` WHERE `id` = '{$page_id}' LIMIT 1"))) {
                $this->_Parent->customError(E_USER_ERROR, __('Page not found'), __('The page you requested to edit does not exist.'), false, true, 'error', array('header' => 'HTTP/1.0 404 Not Found'));
            }
        }
        if (isset($this->_context[2])) {
            switch ($this->_context[2]) {
                case 'saved':
                    $this->pageAlert(__('Page updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Pages</a>', array(DateTimeObj::get(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/pages/new/', URL . '/symphony/blueprints/pages/')), Alert::SUCCESS);
                    break;
                case 'created':
                    $this->pageAlert(__('Page created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Pages</a>', array(DateTimeObj::get(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/pages/new/', URL . '/symphony/blueprints/pages/')), Alert::SUCCESS);
                    break;
            }
        }
        if (isset($_POST['fields'])) {
            $fields = $_POST['fields'];
        } elseif ($this->_context[0] == 'edit') {
            $fields = $existing;
            $types = $this->_Parent->Database->fetchCol('type', "SELECT `type` FROM `tbl_pages_types` WHERE page_id = '{$page_id}' ORDER BY `type` ASC");
            $fields['type'] = @implode(', ', $types);
            $fields['data_sources'] = preg_split('/,/i', $fields['data_sources'], -1, PREG_SPLIT_NO_EMPTY);
            $fields['events'] = preg_split('/,/i', $fields['events'], -1, PREG_SPLIT_NO_EMPTY);
            $fields['body'] = @file_get_contents(PAGES . '/' . trim(str_replace('/', '_', $fields['path'] . '_' . $fields['handle']), '_') . ".xsl");
        } else {
            $fields['body'] = '<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml"
	doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
	doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
	omit-xml-declaration="yes"
	encoding="UTF-8"
	indent="yes" />

<xsl:template match="/">
	
</xsl:template>
	
</xsl:stylesheet>';
        }
        $title = $this->_context[0] == 'edit' ? $fields['title'] : NULL;
        if (trim($title) == '') {
            $title = $existing['title'];
        }
        $this->setTitle(__($title ? '%1$s &ndash; %2$s &ndash; %3$s' : '%1$s &ndash; %2$s', array(__('Symphony'), __('Pages'), $title)));
        $this->appendSubheading($title ? $title : __('Untitled'));
        $div = new XMLElement('div');
        $div->setAttribute('id', 'configure');
        $div->appendChild(new XMLElement('h3', __('URL Settings')));
        $group = new XMLElement('div');
        $group->setAttribute('class', 'triple group');
        $pages = $this->_Parent->Database->fetch("SELECT * FROM `tbl_pages` " . ($this->_context[0] == 'edit' ? "WHERE `id` != '{$page_id}' " : '') . "ORDER BY `title` ASC");
        $label = Widget::Label(__('Parent Page'));
        $options = array(array('', false, '/'));
        if (is_array($pages) and !empty($pages)) {
            if (!function_exists('__compare_pages')) {
                function __compare_pages($a, $b)
                {
                    return strnatcasecmp($a[2], $b[2]);
                }
            }
            foreach ($pages as $page) {
                $options[] = array($page['id'], $fields['parent'] == $page['id'], '/' . $this->_Parent->resolvePagePath($page['id']));
            }
            usort($options, '__compare_pages');
        }
        $label->appendChild(Widget::Select('fields[parent]', $options));
        $group->appendChild($label);
        $label = Widget::Label(__('URL Handle'));
        $label->appendChild(Widget::Input('fields[handle]', $fields['handle']));
        $group->appendChild(isset($this->_errors['handle']) ? $this->wrapFormElementWithError($label, $this->_errors['handle']) : $label);
        $label = Widget::Label(__('URL Parameters'));
        $label->appendChild(Widget::Input('fields[params]', $fields['params']));
        $group->appendChild($label);
        $div->appendChild($group);
        $div->appendChild(new XMLElement('h3', __('Page Metadata')));
        $group = new XMLElement('div');
        $group->setAttribute('class', 'triple group');
        $label = Widget::Label(__('Events'));
        $EventManager = new EventManager($this->_Parent);
        $events = $EventManager->listAll();
        $options = array();
        if (is_array($events) && !empty($events)) {
            foreach ($events as $name => $about) {
                $options[] = array($name, @in_array($name, $fields['events']), $about['name']);
            }
        }
        $label->appendChild(Widget::Select('fields[events][]', $options, array('multiple' => 'multiple')));
        $group->appendChild($label);
        $label = Widget::Label(__('Data Sources'));
        $DSManager = new DatasourceManager($this->_Parent);
        $datasources = $DSManager->listAll();
        $options = array();
        if (is_array($datasources) && !empty($datasources)) {
            foreach ($datasources as $name => $about) {
                $options[] = array($name, @in_array($name, $fields['data_sources']), $about['name']);
            }
        }
        $label->appendChild(Widget::Select('fields[data_sources][]', $options, array('multiple' => 'multiple')));
        $group->appendChild($label);
        $div3 = new XMLElement('div');
        $label = Widget::Label(__('Page Type'));
        $label->appendChild(Widget::Input('fields[type]', $fields['type']));
        $div3->appendChild(isset($this->_errors['type']) ? $this->wrapFormElementWithError($label, $this->_errors['type']) : $label);
        $ul = new XMLElement('ul');
        $ul->setAttribute('class', 'tags');
        if ($types = $this->__fetchAvailablePageTypes()) {
            foreach ($types as $type) {
                $ul->appendChild(new XMLElement('li', $type));
            }
        }
        $div3->appendChild($ul);
        $group->appendChild($div3);
        $div->appendChild($group);
        $this->Form->appendChild($div);
        $fieldset = new XMLElement('fieldset');
        $fieldset->setAttribute('class', 'primary');
        $label = Widget::Label(__('Title'));
        $label->appendChild(Widget::Input('fields[title]', General::sanitize($fields['title'])));
        $fieldset->appendChild(isset($this->_errors['title']) ? $this->wrapFormElementWithError($label, $this->_errors['title']) : $label);
        $label = Widget::Label(__('Body'));
        $label->appendChild(Widget::Textarea('fields[body]', '25', '50', General::sanitize($fields['body']), array('class' => 'code')));
        $fieldset->appendChild(isset($this->_errors['body']) ? $this->wrapFormElementWithError($label, $this->_errors['body']) : $label);
        $this->Form->appendChild($fieldset);
        $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
        $utilities = $utilities['filelist'];
        if (is_array($utilities) && !empty($utilities)) {
            $div = new XMLElement('div');
            $div->setAttribute('class', 'secondary');
            $h3 = new XMLElement('h3', __('Utilities'));
            $h3->setAttribute('class', 'label');
            $div->appendChild($h3);
            $ul = new XMLElement('ul');
            $ul->setAttribute('id', 'utilities');
            foreach ($utilities as $util) {
                $li = new XMLElement('li');
                $li->appendChild(Widget::Anchor($util, URL . '/symphony/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL));
                $ul->appendChild($li);
            }
            $div->appendChild($ul);
            $this->Form->appendChild($div);
        }
        $div = new XMLElement('div');
        $div->setAttribute('class', 'actions');
        $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Page'), 'submit', array('accesskey' => 's')));
        if ($this->_context[0] == 'edit') {
            $button = new XMLElement('button', __('Delete'));
            $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this page')));
            $div->appendChild($button);
        }
        $this->Form->appendChild($div);
    }
 public static function cleanup()
 {
     $sections = Symphony::Database()->fetchCol('handle', "SELECT * FROM `tbl_sections`");
     $files = General::listStructure(WORKSPACE . '/sections', array(), false);
     $exclude = array();
     if (is_array($files['filelist']) && !empty($files['filelist'])) {
         foreach ($files['filelist'] as $filename) {
             $section = str_replace('.xml', '', $filename);
             if (!in_array($section, $sections)) {
                 $exclude[] = $section;
             }
         }
     }
     if (!empty($exclude)) {
         foreach ($exclude as $filename) {
             General::deleteFile(WORKSPACE . "/sections/{$filename}.xml");
         }
     }
 }
 /**
  * Finds all available Events by searching the events folder in the workspace
  * and in all installed extension folders. Returns an associative array of Events.
  *
  * @see toolkit.Manager#about()
  * @return array
  *  Associative array of Events with the key being the handle of the Event
  *  and the value being the Event's `about()` information.
  */
 public static function listAll()
 {
     $result = array();
     $structure = General::listStructure(EVENTS, '/event.[\\w-]+.php/', false, 'ASC', EVENTS);
     if (is_array($structure['filelist']) && !empty($structure['filelist'])) {
         foreach ($structure['filelist'] as $f) {
             $f = self::__getHandleFromFilename($f);
             if ($about = self::about($f)) {
                 $classname = self::__getClassName($f);
                 $can_parse = false;
                 $source = null;
                 $env = array();
                 $class = new $classname($env);
                 try {
                     $method = new ReflectionMethod($classname, 'allowEditorToParse');
                     $can_parse = $method->invoke($class);
                 } catch (ReflectionException $e) {
                 }
                 try {
                     $method = new ReflectionMethod($classname, 'getSource');
                     $source = $method->invoke($class);
                 } catch (ReflectionException $e) {
                 }
                 $about['can_parse'] = $can_parse;
                 $about['source'] = $source;
                 $result[$f] = $about;
             }
         }
     }
     $extensions = Symphony::ExtensionManager()->listInstalledHandles();
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $e) {
             if (!is_dir(EXTENSIONS . "/{$e}/events")) {
                 continue;
             }
             $tmp = General::listStructure(EXTENSIONS . "/{$e}/events", '/event.[\\w-]+.php/', false, 'ASC', EXTENSIONS . "/{$e}/events");
             if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                 foreach ($tmp['filelist'] as $f) {
                     $f = self::__getHandleFromFilename($f);
                     if ($about = self::about($f)) {
                         $about['can_parse'] = false;
                         $result[$f] = $about;
                     }
                 }
             }
         }
     }
     ksort($result);
     return $result;
 }
 /**
  * Finds all available Datasources by searching the data-sources folder in
  * the workspace and in all installed extension folders. Returns an
  * associative array of data-sources.
  *
  * @see toolkit.Manager#about()
  * @return array
  *  Associative array of Datasources with the key being the handle of the
  *  Datasource and the value being the Datasource's `about()` information.
  */
 public function listAll()
 {
     $result = array();
     $structure = General::listStructure(DATASOURCES, '/data.[\\w-]+.php/', false, 'ASC', DATASOURCES);
     if (is_array($structure['filelist']) && !empty($structure['filelist'])) {
         foreach ($structure['filelist'] as $f) {
             $f = self::__getHandleFromFilename($f);
             if ($about = $this->about($f)) {
                 $classname = $this->__getClassName($f);
                 $path = $this->__getDriverPath($f);
                 $can_parse = false;
                 $type = null;
                 if (method_exists($classname, 'allowEditorToParse')) {
                     $can_parse = call_user_func(array($classname, 'allowEditorToParse'));
                 }
                 if (method_exists($classname, 'getSource')) {
                     $type = call_user_func(array($classname, 'getSource'));
                 }
                 $about['can_parse'] = $can_parse;
                 $about['type'] = $type;
                 $result[$f] = $about;
             }
         }
     }
     $extensions = Symphony::ExtensionManager()->listInstalledHandles();
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $e) {
             if (!is_dir(EXTENSIONS . "/{$e}/data-sources")) {
                 continue;
             }
             $tmp = General::listStructure(EXTENSIONS . "/{$e}/data-sources", '/data.[\\w-]+.php/', false, 'ASC', EXTENSIONS . "/{$e}/data-sources");
             if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                 foreach ($tmp['filelist'] as $f) {
                     $f = self::__getHandleFromFilename($f);
                     if ($about = $this->about($f)) {
                         $about['can_parse'] = false;
                         $about['type'] = null;
                         $result[$f] = $about;
                     }
                 }
             }
         }
     }
     ksort($result);
     return $result;
 }
Пример #26
0
 /**
  * Returns an array of all available field handles discovered in the
  * `TOOLKIT . /fields` or `EXTENSIONS . /{}/fields`.
  *
  * @return array
  *  A single dimensional array of field handles.
  */
 public function fetchTypes()
 {
     $structure = General::listStructure(TOOLKIT . '/fields', '/field.[a-z0-9_-]+.php/i', false, 'asc', TOOLKIT . '/fields');
     $extensions = Symphony::ExtensionManager()->listInstalledHandles();
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $handle) {
             if (is_dir(EXTENSIONS . '/' . $handle . '/fields')) {
                 $tmp = General::listStructure(EXTENSIONS . '/' . $handle . '/fields', '/field.[a-z0-9_-]+.php/i', false, 'asc', EXTENSIONS . '/' . $handle . '/fields');
                 if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                     $structure['filelist'] = array_merge($structure['filelist'], $tmp['filelist']);
                 }
             }
         }
         $structure['filelist'] = General::array_remove_duplicates($structure['filelist']);
     }
     $types = array();
     foreach ($structure['filelist'] as $filename) {
         $types[] = FieldManager::__getHandleFromFilename($filename);
     }
     return $types;
 }
 public function getFiles($folder, $strings)
 {
     // Get files
     $files = General::listStructure(preg_replace('{/$}', '', $folder), array('php', 'tpl', 'js'), false, 'asc', false);
     if (empty($files['filelist'])) {
         return $strings;
     }
     // Find strings
     foreach ($files['filelist'] as $file) {
         if (pathinfo($file, PATHINFO_EXTENSION) == 'js') {
             $strings = array_merge($strings, $this->__findJavaScriptStrings($file));
         } else {
             $strings = array_merge($strings, $this->__findStrings($file));
         }
     }
     return $strings;
 }
 public function __viewTemplate()
 {
     $this->setPageType('form');
     $this->Form->setAttribute('action', SYMPHONY_URL . '/blueprints/pages/template/' . $this->_context[1] . '/');
     $filename = $this->_context[1] . '.xsl';
     $file_abs = PAGES . '/' . $filename;
     $is_child = strrpos($this->_context[1], '_');
     $pagename = $is_child != false ? substr($this->_context[1], $is_child + 1) : $this->_context[1];
     $pagedata = Symphony::Database()->fetchRow(0, "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tp.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`tbl_pages` AS p\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tp.handle = '{$pagename}'\n\t\t\t\t\tLIMIT 1\n\t\t\t\t");
     if (!is_file($file_abs)) {
         redirect(SYMPHONY_URL . '/blueprints/pages/');
     }
     $fields['body'] = @file_get_contents($file_abs);
     $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
     if ($formHasErrors) {
         $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR);
     }
     // Status message:
     if (isset($this->_context[2])) {
         $this->pageAlert(__('Page updated at %1$s. <a href="%2$s" accesskey="c">Create another?</a> <a href="%3$s" accesskey="a">View all Pages</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), SYMPHONY_URL . '/blueprints/pages/new/' . $link_suffix, SYMPHONY_URL . '/blueprints/pages/' . $link_suffix)), Alert::SUCCESS);
     }
     $this->setTitle(__($filename ? '%1$s &ndash; %2$s &ndash; %3$s' : '%1$s &ndash; %2$s', array(__('Symphony'), __('Pages'), $filename)));
     $this->appendSubheading(__($filename ? $filename : __('Untitled')), Widget::Anchor(__('Edit Configuration'), SYMPHONY_URL . '/blueprints/pages/edit/' . $pagedata['id'], __('Edit Page Confguration'), 'button', NULL, array('accesskey' => 't')));
     if (!empty($_POST)) {
         $fields = $_POST['fields'];
     }
     $fields['body'] = General::sanitize($fields['body']);
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'primary');
     $label = Widget::Label(__('Body'));
     $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code')));
     if (isset($this->_errors['body'])) {
         $label = $this->wrapFormElementWithError($label, $this->_errors['body']);
     }
     $fieldset->appendChild($label);
     $this->Form->appendChild($fieldset);
     $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
     $utilities = $utilities['filelist'];
     if (is_array($utilities) && !empty($utilities)) {
         $div = new XMLElement('div');
         $div->setAttribute('class', 'secondary');
         $p = new XMLElement('p', __('Utilities'));
         $p->setAttribute('class', 'label');
         $div->appendChild($p);
         $ul = new XMLElement('ul');
         $ul->setAttribute('id', 'utilities');
         foreach ($utilities as $index => $util) {
             $li = new XMLElement('li');
             if ($index % 2 != 1) {
                 $li->setAttribute('class', 'odd');
             }
             $li->appendChild(Widget::Anchor($util, SYMPHONY_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL));
             $ul->appendChild($li);
         }
         $div->appendChild($ul);
         $this->Form->appendChild($div);
     }
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's')));
     $this->Form->appendChild($div);
 }
 function listAll()
 {
     $extensions = array();
     $result = array();
     $structure = General::listStructure(EXTENSIONS, array(), false, 'asc', EXTENSIONS);
     $extensions = $structure['dirlist'];
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $e) {
             if ($about = $this->about($e)) {
                 $result[$e] = $about;
             }
         }
     }
     return $result;
 }
 public function __viewTemplate()
 {
     $this->setPageType('form');
     $handle = isset($this->_context[1]) ? $this->_context[1] : null;
     $this->Form->setAttribute('action', SYMPHONY_URL . '/blueprints/pages/template/' . $handle . '/');
     $this->Form->setAttribute('class', 'columns');
     $filename = $handle . '.xsl';
     $file_abs = PAGES . '/' . $filename;
     $is_child = strrpos($handle, '_');
     $pagename = $is_child != false ? substr($handle, $is_child + 1) : $handle;
     $pagedata = PageManager::fetch(false, array('id'), array("p.handle = '{$pagename}'"));
     $pagedata = array_pop($pagedata);
     if (!is_file($file_abs)) {
         redirect(SYMPHONY_URL . '/blueprints/pages/');
     }
     $fields['body'] = @file_get_contents($file_abs);
     $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
     if ($formHasErrors) {
         $this->pageAlert(__('An error occurred while processing this form. See below for details.'), Alert::ERROR);
     } else {
         if (isset($this->_context[2])) {
             $this->pageAlert(__('Page updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/pages/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/pages/" accesskey="a">' . __('View all Pages') . '</a>', Alert::SUCCESS);
         }
     }
     $this->setTitle(__($filename ? '%1$s &ndash; %2$s &ndash; %3$s' : '%2$s &ndash; %3$s', array($filename, __('Pages'), __('Symphony'))));
     $this->appendSubheading(__($filename ? $filename : __('Untitled')), Widget::Anchor(__('Edit Page'), SYMPHONY_URL . '/blueprints/pages/edit/' . $pagedata['id'] . '/', __('Edit Page Configuration'), 'button', NULL, array('accesskey' => 't')));
     $this->insertBreadcrumbsUsingPageIdentifier($pagedata['id']);
     if (!empty($_POST)) {
         $fields = $_POST['fields'];
     }
     $fields['body'] = htmlentities($fields['body'], ENT_COMPAT, 'UTF-8');
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'primary column');
     $label = Widget::Label(__('Body'));
     $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code')));
     if (isset($this->_errors['body'])) {
         $label = Widget::Error($label, $this->_errors['body']);
     }
     $fieldset->appendChild($label);
     $this->Form->appendChild($fieldset);
     $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
     $utilities = $utilities['filelist'];
     if (is_array($utilities) && !empty($utilities)) {
         $this->Form->setAttribute('class', 'two columns');
         $div = new XMLElement('div');
         $div->setAttribute('class', 'secondary column');
         $p = new XMLElement('p', __('Utilities'));
         $p->setAttribute('class', 'label');
         $div->appendChild($p);
         $frame = new XMLElement('div', null, array('class' => 'frame'));
         $ul = new XMLElement('ul');
         $ul->setAttribute('id', 'utilities');
         foreach ($utilities as $util) {
             $li = new XMLElement('li');
             $li->appendChild(Widget::Anchor($util, SYMPHONY_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL));
             $ul->appendChild($li);
         }
         $frame->appendChild($ul);
         $div->appendChild($frame);
         $this->Form->appendChild($div);
     }
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's')));
     $this->Form->appendChild($div);
 }