本文整理匯總了PHP中General::listStructure方法的典型用法代碼示例。如果您正苦於以下問題:PHP General::listStructure方法的具體用法?PHP General::listStructure怎麽用?PHP General::listStructure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類General
的用法示例。
在下文中一共展示了General::listStructure方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: listTypes
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;
}
示例2: loadDrivers
/**
*
* 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);
}
}
}
}
示例3: listAll
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;
}
示例4: listAll
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;
}
示例5: updateSections
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();
}
}
}
}
}
示例6: listAll
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;
}
示例7: getLatestVersion
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: addJavaScriptAndCSS
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);
}
示例9: listAll
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: fetchTypes
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;
}
示例11: listAll
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;
}
示例12: fetch
/**
* 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'];
}
}
}
}
}
示例13: view
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 – %2$s' : '%1$s – %2$s – %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);
}
示例14: displaySettingsPanel
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: __actionDo
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 {
//.........這裏部分代碼省略.........