本文整理汇总了PHP中General::validateURL方法的典型用法代码示例。如果您正苦于以下问题:PHP General::validateURL方法的具体用法?PHP General::validateURL怎么用?PHP General::validateURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类General
的用法示例。
在下文中一共展示了General::validateURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __viewIndex
public function __viewIndex()
{
$this->setPageType('table');
$this->setTitle('Symphony – Importers');
$tableHead = array(array('Name', 'col'), array('Version', 'col'), array('Author', 'col'));
$tableBody = array();
if (!is_array($this->_importers) or empty($this->_importers)) {
$tableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', null, count($tableHead)))));
} else {
foreach ($this->_importers as $importer) {
$importer = (object) $importer;
$col_name = Widget::TableData(Widget::Anchor($this->_driver->truncateValue($importer->name), $this->_uri . "/importers/edit/{$importer->handle}/"));
$col_name->appendChild(Widget::Input("items[{$importer->id}]", null, 'checkbox'));
$col_version = Widget::TableData($this->_driver->truncateValue($importer->version));
$col_author = Widget::TableData($this->_driver->truncateValue($importer->version));
if (isset($importer->author['website']) and preg_match('/^[^\\s:\\/?#]+:(?:\\/{2,3})?[^\\s.\\/?#]+(?:\\.[^\\s.\\/?#]+)*(?:\\/[^\\s?#]*\\??[^\\s?#]*(#[^\\s#]*)?)?$/', $importer->author['website'])) {
$col_author = Widget::Anchor($importer->author['name'], General::validateURL($importer->author['website']));
} elseif (isset($importer->author['email']) and preg_match('/^\\w(?:\\.?[\\w%+-]+)*@\\w(?:[\\w-]*\\.)+?[a-z]{2,}$/i', $importer->author['email'])) {
$col_author = Widget::Anchor($importer->author['name'], 'mailto:' . $importer->author['email']);
} else {
$col_author = $importer->author['name'];
}
$col_author = Widget::TableData($col_author);
$tableBody[] = Widget::TableRow(array($col_name, $col_version, $col_author));
}
}
$table = Widget::Table(Widget::TableHead($tableHead), null, Widget::TableBody($tableBody));
$this->Form->appendChild($table);
}
示例2: getValuesFromXML
function getValuesFromXML()
{
$xml_location = $this->get('xml_location');
if (General::validateURL($xml_location) != '') {
// is a URL, check cache
$cache_id = md5($xml_location);
$cache = new Cacheable($this->_Parent->_Parent->Database);
$cachedData = $cache->check($cache_id);
$creation = DateTimeObj::get('c');
if (!$cachedData || time() - $cachedData['creation'] > 5 * 60) {
if (Mutex::acquire($cache_id, 6, TMP)) {
$ch = new Gateway();
$ch->init();
$ch->setopt('URL', $xml_location);
$ch->setopt('TIMEOUT', 6);
$xml = $ch->exec();
$writeToCache = true;
Mutex::release($cache_id, TMP);
$xml = trim($xml);
if (empty($xml) && $cachedData) {
$xml = $cachedData['data'];
}
} elseif ($cachedData) {
$xml = $cachedData['data'];
}
} else {
$xml = $cachedData['data'];
}
$xml = simplexml_load_string($xml);
} elseif (substr($xml_location, 0, 1) == '/') {
// relative to DOCROOT
$xml = simplexml_load_file(DOCROOT . $this->get('xml_location'));
} else {
// in extension's /xml folder
$xml = simplexml_load_file(EXTENSIONS . '/xml_selectbox/xml/' . $this->get('xml_location'));
}
if (!$xml) {
return;
}
$items = $xml->xpath($this->get('item_xpath'));
$options = array();
foreach ($items as $item) {
$option = array();
$text_xpath = $item->xpath($this->get('text_xpath'));
$option['text'] = General::sanitize((string) $text_xpath[0]);
if ($this->get('value_xpath') != '') {
$value_xpath = $item->xpath($this->get('value_xpath'));
$option['value'] = General::sanitize((string) $value_xpath[0]);
}
if ((string) $option['value'] == '') {
$option['value'] = $option['text'];
}
$options[] = $option;
}
return $options;
}
示例3: __viewIndex
function __viewIndex()
{
$this->setPageType('table');
$this->setTitle(__('%1$s – %2$s', array(__('Symphony'), __('Extensions'))));
$this->appendSubheading(__('Extensions'));
$this->Form->setAttribute('action', URL . '/symphony/system/extensions/');
$ExtensionManager = $this->_Parent->ExtensionManager;
$extensions = $ExtensionManager->listAll();
## Sort by extensions name:
uasort($extensions, array('ExtensionManager', 'sortByName'));
$aTableHead = array(array(__('Name'), 'col'), array(__('Enabled'), 'col'), array(__('Version'), 'col'), array(__('Author'), 'col'));
$aTableBody = array();
if (!is_array($extensions) || empty($extensions)) {
$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead)))));
} else {
foreach ($extensions as $name => $about) {
## Setup each cell
$td1 = Widget::TableData(!empty($about['table-link']) && $about['status'] == EXTENSION_ENABLED ? Widget::Anchor($about['name'], $this->_Parent->getCurrentPageURL() . 'extension/' . trim($about['table-link'], '/') . '/') : $about['name']);
$td2 = Widget::TableData($about['status'] == EXTENSION_ENABLED ? __('Yes') : __('No'));
$td3 = Widget::TableData($about['version']);
$link = $about['author']['name'];
if (isset($about['author']['website'])) {
$link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website']));
} elseif (isset($about['author']['email'])) {
$link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']);
}
$td4 = Widget::TableData($link);
$td4->appendChild(Widget::Input('items[' . $name . ']', 'on', 'checkbox'));
## Add a row to the body array, assigning each cell to the row
$aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4), $about['status'] == EXTENSION_NOT_INSTALLED ? 'inactive' : NULL);
}
}
$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
$this->Form->appendChild($table);
$tableActions = new XMLElement('div');
$tableActions->setAttribute('class', 'actions');
$options = array(array(NULL, false, __('With Selected...')), array('enable', false, __('Enable')), array('disable', false, __('Disable')), array('uninstall', false, __('Uninstall'), 'confirm'));
$tableActions->appendChild(Widget::Select('with-selected', $options));
$tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
$this->Form->appendChild($tableActions);
}
示例4: buildTable
private function buildTable(array $extensions = NULL, $prefixes = false)
{
$aTableHead = array(array(__('Name'), 'col'), array(__('Version'), 'col'), array(__('Author'), 'col'), array(__('Actions'), 'col', array('class' => 'row-actions')));
$aTableBody = array();
$colspan = count($aTableHead);
if (is_null($extensions)) {
$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), array('class' => 'inactive', 'colspan' => $colspan))), array('class' => 'odd')));
} else {
foreach ($extensions as $handle) {
$about = $this->lists->extensions[$handle]['object']->about();
$fragment = $this->createDocumentFragment();
if (!empty($about->{'table-link'}) && $this->lists->extensions[$handle]['status'] == Extension::STATUS_ENABLED) {
$fragment->appendChild(Widget::Anchor($about->{'name'}, Administration::instance()->getCurrentPageURL() . '/extension/' . trim($about->{'table-link'}, '/')));
} else {
$fragment->appendChild(new DOMText($about->{'name'}));
}
if ($prefixes && isset($about->{'type'})) {
$fragment->appendChild($this->createElement('span', ' · ' . $about->{'type'}[0]));
}
## Setup each cell
$td1 = Widget::TableData($fragment);
$td2 = Widget::TableData($about->{'version'});
$link = $about->author->name;
if (isset($about->author->website)) {
$link = Widget::Anchor($about->author->name, General::validateURL($about->author->website));
} elseif (isset($about->author->email)) {
$link = Widget::Anchor($about->author->name, 'mailto:' . $about->author->email);
}
$td3 = Widget::TableData($link);
$td3->appendChild(Widget::Input('items[' . $handle . ']', 'on', 'checkbox'));
switch ($this->lists->extensions[$handle]['status']) {
case Extension::STATUS_ENABLED:
$td4 = Widget::TableData();
$td4->appendChild(Widget::Input("action[uninstall][{$handle}]", __('Uninstall'), 'submit', array('class' => 'button delete')));
$td4->appendChild(Widget::Input("action[disable][{$handle}]", __('Disable'), 'submit', array('class' => 'button')));
break;
case Extension::STATUS_DISABLED:
$td4 = Widget::TableData(Widget::Input("action[enable][{$handle}]", __('Enable'), 'submit', array('class' => 'button create')));
break;
case Extension::STATUS_NOT_INSTALLED:
$td4 = Widget::TableData(Widget::Input("action[enable][{$handle}]", __('Install'), 'submit', array('class' => 'button create')));
break;
case Extension::STATUS_REQUIRES_UPDATE:
$td4 = Widget::TableData(Widget::Input("action[update][{$handle}]", __('Update'), 'submit', array('class' => 'button create')));
}
## Add a row to the body array, assigning each cell to the row
$aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4), $this->lists->status[$handle] == Extension::STATUS_NOT_INSTALLED ? array('class' => 'inactive') : array());
}
}
$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
return $table;
}
示例5: __viewInfo
public function __viewInfo()
{
$this->setPageType('form');
$datasource = DatasourceManager::create($this->_context[1], array(), false);
$about = $datasource->about();
$this->setTitle(__('%1$s – %2$s – %3$s', array($about['name'], __('Data Source'), __('Symphony'))));
$this->appendSubheading($this->_context[0] == 'info' ? $about['name'] : __('Untitled'));
$this->insertBreadcrumbs(array(Widget::Anchor(__('Data Sources'), SYMPHONY_URL . '/blueprints/datasources/')));
$this->Form->setAttribute('id', 'controller');
$link = $about['author']['name'];
if (isset($about['author']['website'])) {
$link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website']));
} elseif (isset($about['author']['email'])) {
$link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']);
}
foreach ($about as $key => $value) {
$fieldset = null;
switch ($key) {
case 'author':
if ($link) {
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', __('Author')));
$fieldset->appendChild(new XMLElement('p', $link->generate(false)));
}
break;
case 'version':
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', __('Version')));
$release_date = array_key_exists('release-date', $about) ? $about['release-date'] : filemtime(DatasourceManager::__getDriverPath($this->_context[1]));
if (preg_match('/^\\d+(\\.\\d+)*$/', $value)) {
$fieldset->appendChild(new XMLElement('p', __('%1$s released on %2$s', array($value, DateTimeObj::format($release_date, __SYM_DATE_FORMAT__)))));
} else {
$fieldset->appendChild(new XMLElement('p', __('Created by %1$s at %2$s', array($value, DateTimeObj::format($release_date, __SYM_DATE_FORMAT__)))));
}
break;
case 'description':
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', __('Description')));
$fieldset->appendChild(is_object($about['description']) ? $about['description'] : new XMLElement('p', $about['description']));
break;
case 'example':
if (is_callable(array($datasource, 'example'))) {
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', __('Example XML')));
$example = $datasource->example();
if (is_object($example)) {
$fieldset->appendChild($example);
} else {
$p = new XMLElement('p');
$p->appendChild(new XMLElement('pre', '<code>' . str_replace('<', '<', $example) . '</code>'));
$fieldset->appendChild($p);
}
}
break;
}
if ($fieldset) {
$fieldset->setAttribute('class', 'settings');
$this->Form->appendChild($fieldset);
}
}
// Display source
$file = DatasourceManager::__getClassPath($this->_context[1]) . '/data.' . $this->_context[1] . '.php';
if (file_exists($file)) {
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild(new XMLElement('legend', __('Source')));
$source = file_get_contents($file);
$code = new XMLElement('code', htmlspecialchars($source));
$pre = new XMLElement('pre');
$pre->appendChild($code);
$fieldset->appendChild($pre);
$this->Form->appendChild($fieldset);
}
}
示例6: __viewIndex
public function __viewIndex()
{
$this->setPageType('table');
$this->setTitle(__('%1$s – %2$s', array(__('Extensions'), __('Symphony'))));
$this->appendSubheading(__('Extensions'));
$this->Form->setAttribute('action', SYMPHONY_URL . '/system/extensions/');
Sortable::initialize($this, $extensions, $sort, $order);
$columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Version'), 'sortable' => false), array('label' => __('Status'), 'sortable' => false), array('label' => __('Links'), 'sortable' => false, 'handle' => 'links'), array('label' => __('Authors'), 'sortable' => true, 'handle' => 'author'));
$aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&filter=' . $_REQUEST['filter'] : '');
$aTableBody = array();
if (!is_array($extensions) || empty($extensions)) {
$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))), 'odd'));
} else {
foreach ($extensions as $name => $about) {
// Name
$td1 = Widget::TableData($about['name']);
$td1->appendChild(Widget::Label(__('Select %s Extension', array($about['name'])), null, 'accessible', null, array('for' => 'extension-' . $name)));
$td1->appendChild(Widget::Input('items[' . $name . ']', 'on', 'checkbox', array('id' => 'extension-' . $name)));
// Version
$installed_version = Symphony::ExtensionManager()->fetchInstalledVersion($name);
if (in_array(Extension::EXTENSION_NOT_INSTALLED, $about['status'])) {
$td2 = Widget::TableData($about['version']);
} elseif (in_array(Extension::EXTENSION_REQUIRES_UPDATE, $about['status'])) {
$td2 = Widget::TableData($installed_version . '<i> → ' . $about['version'] . '</i>');
} else {
$td2 = Widget::TableData($installed_version);
}
// Status
$trClasses = array();
$trStatus = '';
$tdMessage = __('Status unavailable');
if (in_array(Extension::EXTENSION_NOT_INSTALLED, $about['status'])) {
$tdMessage = __('Not installed');
$trClasses[] = 'inactive';
$trClasses[] = 'extension-can-install';
}
if (in_array(Extension::EXTENSION_DISABLED, $about['status'])) {
$tdMessage = __('Disabled');
$trStatus = 'status-notice';
}
if (in_array(Extension::EXTENSION_ENABLED, $about['status'])) {
$tdMessage = __('Enabled');
}
if (in_array(Extension::EXTENSION_REQUIRES_UPDATE, $about['status'])) {
$tdMessage = __('Update available');
$trClasses[] = 'extension-can-update';
$trStatus = 'status-ok';
}
if (in_array(Extension::EXTENSION_NOT_COMPATIBLE, $about['status'])) {
$tdMessage .= ', ' . __('requires Symphony %s', array($about['required_version']));
$trStatus = 'status-error';
}
$trClasses[] = $trStatus;
$td3 = Widget::TableData($tdMessage);
// Links
$tdLinks = array();
if ($about['github'] != '') {
$tdLinks['github'] = Widget::Anchor(__('GitHub'), General::validateURL($about['github']))->generate();
}
if ($about['discuss'] != '') {
$tdLinks['discuss'] = Widget::Anchor(__('Discuss'), General::validateURL($about['discuss']))->generate();
// Update links to point to our 'new' domain, RE: #1995
$tdLinks['discuss'] = str_replace('symphony-cms.com', 'getsymphony.com', $tdLinks['discuss']);
}
if ($about['homepage'] != '') {
$tdLinks['homepage'] = Widget::Anchor(__('Homepage'), General::validateURL($about['homepage']))->generate();
}
if ($about['wiki'] != '') {
$tdLinks['wiki'] = Widget::Anchor(__('Wiki'), General::validateURL($about['wiki']))->generate();
}
if ($about['issues'] != '') {
$tdLinks['issues'] = Widget::Anchor(__('Issues'), General::validateURL($about['issues']))->generate();
}
$td4 = Widget::TableData($tdLinks);
// Authors
$tdAuthors = array();
if (!is_array($about['author'])) {
$about['author'] = array($about['author']);
}
foreach ($about['author'] as $author) {
if (isset($author['website'])) {
$tdAuthors[] = Widget::Anchor($author['name'], General::validateURL($author['website']))->generate();
} elseif (isset($author['github'])) {
$tdAuthors[] = Widget::Anchor($author['name'], General::validateURL('https://github.com/' . $author['github']))->generate();
} elseif (isset($author['email'])) {
$tdAuthors[] = Widget::Anchor($author['name'], 'mailto:' . $author['email'])->generate();
} else {
$tdAuthors[] = $author['name'];
}
}
$td5 = Widget::TableData($tdAuthors);
// Create the table row
$tr = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5), implode(' ', $trClasses));
// Add some attributes about the extension
$tr->setAttribute('data-handle', $name);
$tr->setAttribute('data-installed-version', $installed_version);
$tr->setAttribute('data-meta-version', $about['version']);
// Add a row to the body array, assigning each cell to the row
$aTableBody[] = $tr;
}
//.........这里部分代码省略.........
示例7: array
* @licence https://github.com/symphonycms/symphony-1.7/blob/master/LICENCE
*
***/
if (array_key_exists("save", $_POST['action'])) {
$fields = $_POST['fields'];
$required = array('author_name', 'body');
for ($i = 0; $i < count($required); $i++) {
if (trim($fields[$required[$i]]) == "") {
$errors[$required[$i]] = true;
}
}
if (is_array($errors)) {
define("__SYM_ENTRY_MISSINGFIELDS__", true);
} else {
$fields['author_name'] = General::sanitize($fields['author_name']);
$fields['author_url'] = General::validateURL($fields['author_url']);
$fields['author_email'] = General::sanitize($fields['author_email']);
$fields['body'] = $fields['body'];
$fields['spam'] = $fields['spam'] ? "yes" : "no";
if ($fields['blacklist'] && $fields['author_ip'] != '') {
$ip = trim($fields['author_ip']);
$current_blacklist = $Admin->getConfigVar("ip-blacklist", "commenting");
$current_blacklist = preg_split('/,/', $current_blacklist, -1, PREG_SPLIT_NO_EMPTY);
$current_blacklist = @array_map("trim", $current_blacklist);
if (!@in_array($ip, $current_blacklist)) {
$current_blacklist[] = $ip;
}
$Admin->setConfigVar("ip-blacklist", @implode(', ', $current_blacklist), "commenting");
$Admin->saveConfig();
$Admin->flush_cache(array("comments", "entries", "authors"));
} elseif (!$fields['blacklist'] && $fields['author_ip'] != '') {
示例8: __viewInfo
function __viewInfo()
{
$this->setPageType('form');
$DSManager = new DatasourceManager($this->_Parent);
$datasource = $DSManager->create($this->_context[1], NULL, false);
$about = $datasource->about();
$this->setTitle(__('%1$s – %2$s – %3$s', array(__('Symphony'), __('Data Source'), $about['name'])));
$this->appendSubheading($about['name']);
$this->Form->setAttribute('id', 'controller');
$link = $about['author']['name'];
if (isset($about['author']['website'])) {
$link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website']));
} elseif (isset($about['author']['email'])) {
$link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']);
}
foreach ($about as $key => $value) {
$fieldset = NULL;
switch ($key) {
case 'author':
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', 'Author'));
$fieldset->appendChild(new XMLElement('p', $link->generate(false)));
break;
case 'version':
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', 'Version'));
$fieldset->appendChild(new XMLElement('p', $value . ', released on ' . DateTimeObj::get(__SYM_DATE_FORMAT__, strtotime($about['release-date']))));
break;
case 'description':
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', 'Description'));
$fieldset->appendChild(is_object($about['description']) ? $about['description'] : new XMLElement('p', $about['description']));
case 'example':
if (is_callable(array($datasource, 'example'))) {
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', 'Example XML'));
$example = $datasource->example();
if (is_object($example)) {
$fieldset->appendChild($example);
} else {
$p = new XMLElement('p');
$p->appendChild(new XMLElement('pre', '<code>' . str_replace('<', '<', $example) . '</code>'));
$fieldset->appendChild($p);
}
}
break;
}
if ($fieldset) {
$fieldset->setAttribute('class', 'settings');
$this->Form->appendChild($fieldset);
}
}
/*
$dl->appendChild(new XMLElement('dt', __('URL Parameters')));
if(!is_array($about['recognised-url-param']) || empty($about['recognised-url-param'])){
$dl->appendChild(new XMLElement('dd', '<code>'.__('None').'</code>'));
}
else{
$dd = new XMLElement('dd');
$ul = new XMLElement('ul');
foreach($about['recognised-url-param'] as $f) $ul->appendChild(new XMLElement('li', '<code>' . $f . '</code>'));
$dd->appendChild($ul);
$dl->appendChild($dd);
}
$fieldset->appendChild($dl);
*/
}
示例9: EventManager
* Symphony web publishing system
*
* Copyright 2004–2006 Twenty One Degrees Pty. Ltd.
*
* @version 1.7
* @licence https://github.com/symphonycms/symphony-1.7/blob/master/LICENCE
*
***/
$EM = new EventManager(array('parent' => &$Admin));
$oEvent =& $EM->create($_REQUEST['file']);
$about = $oEvent->about();
$GLOBALS['pageTitle'] = 'Events > ' . $about['name'];
$date = $Admin->getDateObj();
$link = $about['author']['name'];
if (isset($about['author']['website'])) {
$link = '<a href="' . General::validateURL($about['author']['website']) . '">' . $about['author']['name'] . '</a>';
} elseif (isset($about['author']['email'])) {
$link = '<a href="mailto:' . $about['author']['email'] . '">' . $about['author']['name'] . '</a>';
}
?>
<form id="controller" action="" method="post">
<h2><?php
print $about['name'];
?>
</h2>
<fieldset>
<dl>
<dt>Author</dt>
示例10: __viewInfo
public function __viewInfo()
{
$this->setPageType('form');
$datasource = DatasourceManager::create($this->_context[1], array(), false);
$about = $datasource->about();
$this->setTitle(__('%1$s – %2$s – %3$s', array($about['name'], __('Data Source'), __('Symphony'))));
$this->appendSubheading($about['name']);
$this->Form->setAttribute('id', 'controller');
$link = $about['author']['name'];
if (isset($about['author']['website'])) {
$link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website']));
} elseif (isset($about['author']['email'])) {
$link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']);
}
foreach ($about as $key => $value) {
$fieldset = NULL;
switch ($key) {
case 'author':
if ($link) {
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', __('Author')));
$fieldset->appendChild(new XMLElement('p', $link->generate(false)));
}
break;
case 'version':
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', __('Version')));
if (preg_match('/^\\d+(\\.\\d+)*$/', $value)) {
$fieldset->appendChild(new XMLElement('p', __('%1$s released on %2$s', array($value, DateTimeObj::format($about['release-date'], __SYM_DATE_FORMAT__)))));
} else {
$fieldset->appendChild(new XMLElement('p', __('Created by %1$s at %2$s', array($value, DateTimeObj::format($about['release-date'], __SYM_DATE_FORMAT__)))));
}
break;
case 'description':
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', __('Description')));
$fieldset->appendChild(is_object($about['description']) ? $about['description'] : new XMLElement('p', $about['description']));
case 'example':
if (is_callable(array($datasource, 'example'))) {
$fieldset = new XMLElement('fieldset');
$fieldset->appendChild(new XMLElement('legend', __('Example XML')));
$example = $datasource->example();
if (is_object($example)) {
$fieldset->appendChild($example);
} else {
$p = new XMLElement('p');
$p->appendChild(new XMLElement('pre', '<code>' . str_replace('<', '<', $example) . '</code>'));
$fieldset->appendChild($p);
}
}
break;
}
if ($fieldset) {
$fieldset->setAttribute('class', 'settings');
$this->Form->appendChild($fieldset);
}
}
}
示例11:
<fieldset>
<label>Comment <textarea name="fields[body]" cols="75" rows="15"><?php
echo General::sanitize($fields['body']);
?>
</textarea></label>
<fieldset>
<label>Name <input name="fields[author_name]" <?php
print General::fieldValue("value", $fields["author_name"]);
?>
/></label>
<label>Email Address <input name="fields[author_email]" <?php
print General::fieldValue("value", $fields["author_email"]);
?>
/></label>
<label>Website <input name="fields[author_url]" <?php
print General::fieldValue("value", General::validateURL($fields["author_url"]));
?>
/></label>
<label><acronym title="Internet Protocol">IP</acronym> Address <input name="fields[author_ip]" <?php
print General::fieldValue("value", $fields["author_ip"]);
?>
/></label>
<label><input name="fields[spam]" type="checkbox" <?php
print $fields['spam'] == "yes" ? ' checked="checked"' : "";
?>
/> Flag this comment as spam</label>
<label><input name="fields[blacklist]" type="checkbox" <?php
print $fields['blacklist'] == "yes" ? ' checked="checked"' : "";
?>
/> Blacklist this users <acronym title="Internet Protocol">IP</acronym> Address</label>
</fieldset>
示例12: __viewIndex
/**
* This function contains the minimal amount of logic for generating the
* index table of a given `$resource_type`. The table has name, source, pages
* release date and author columns. The values for these columns are determined
* by the resource's `about()` method.
*
* As Datasources types can be installed using Providers, the Source column
* can be overridden with a Datasource's `getSourceColumn` method (if it exists).
*
* @param integer $resource_type
* Either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE`
*/
public function __viewIndex($resource_type)
{
$manager = ResourceManager::getManagerFromType($resource_type);
$this->setPageType('table');
Sortable::initialize($this, $resources, $sort, $order, array('type' => $resource_type));
$columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Source'), 'sortable' => true, 'handle' => 'source'), array('label' => __('Pages'), 'sortable' => false), array('label' => __('Release Date'), 'sortable' => true, 'handle' => 'release-date'), array('label' => __('Author'), 'sortable' => true, 'handle' => 'author'));
$aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&filter=' . $_REQUEST['filter'] : '');
$aTableBody = array();
if (!is_array($resources) || empty($resources)) {
$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
} else {
foreach ($resources as $r) {
// Resource name
$action = $r['can_parse'] ? 'edit' : 'info';
$name = Widget::TableData(Widget::Anchor($r['name'], SYMPHONY_URL . $_REQUEST['symphony-page'] . $action . '/' . $r['handle'] . '/', $r['handle']));
// Resource type/source
if (isset($r['source']['id'])) {
$section = Widget::TableData(Widget::Anchor($r['source']['name'], SYMPHONY_URL . '/blueprints/sections/edit/' . $r['source']['id'] . '/', $r['source']['handle']));
} else {
if (class_exists($r['source']['name']) && method_exists($r['source']['name'], 'getSourceColumn')) {
$class = call_user_func(array($manager, '__getClassName'), $r['handle']);
$section = Widget::TableData(call_user_func(array($class, 'getSourceColumn'), $r['handle']));
} else {
if (isset($r['source']['name'])) {
$section = Widget::TableData($r['source']['name']);
} else {
$section = Widget::TableData(__('Unknown'), 'inactive');
}
}
}
// Attached pages
$pages = ResourceManager::getAttachedPages($resource_type, $r['handle']);
$pagelinks = array();
$i = 0;
foreach ($pages as $p) {
++$i;
$pagelinks[] = Widget::Anchor($p['title'], SYMPHONY_URL . '/blueprints/pages/edit/' . $p['id'] . '/')->generate() . (count($pages) > $i ? $i % 10 == 0 ? '<br />' : ', ' : '');
}
$pages = implode('', $pagelinks);
if ($pages == '') {
$pagelinks = Widget::TableData(__('None'), 'inactive');
} else {
$pagelinks = Widget::TableData($pages, 'pages');
}
// Release date
$releasedate = Widget::TableData(Lang::localizeDate(DateTimeObj::format($r['release-date'], __SYM_DATETIME_FORMAT__)));
// Authors
$author = $r['author']['name'];
if (isset($r['author']['website'])) {
$author = Widget::Anchor($r['author']['name'], General::validateURL($r['author']['website']));
} else {
if (isset($r['author']['email'])) {
$author = Widget::Anchor($r['author']['name'], 'mailto:' . $r['author']['email']);
}
}
$author = Widget::TableData($author);
$author->appendChild(Widget::Input('items[' . $r['handle'] . ']', null, 'checkbox'));
$aTableBody[] = Widget::TableRow(array($name, $section, $pagelinks, $releasedate, $author));
}
}
$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
$this->Form->appendChild($table);
$tableActions = new XMLElement('div');
$tableActions->setAttribute('class', 'actions');
$options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm'));
$pages = $this->pagesFlatView();
$group_attach = array('label' => __('Attach to Page'), 'options' => array());
$group_detach = array('label' => __('Detach from Page'), 'options' => array());
$group_attach['options'][] = array('attach-all-pages', false, __('All'));
$group_detach['options'][] = array('detach-all-pages', false, __('All'));
foreach ($pages as $p) {
$group_attach['options'][] = array('attach-to-page-' . $p['id'], false, $p['title']);
$group_detach['options'][] = array('detach-from-page-' . $p['id'], false, $p['title']);
}
$options[] = $group_attach;
$options[] = $group_detach;
$tableActions->appendChild(Widget::Apply($options));
$this->Form->appendChild($tableActions);
}
示例13: url2a
function url2a($str, $nofollow = false)
{
preg_match_all("/http:\\/\\/?[^ ][^<]+/i", $str, $lnk);
$size = sizeof($lnk[0]);
$i = 0;
while ($i < $size) {
$len = strlen($lnk[0][$i]);
if ($len > 30) {
$lnk_txt = substr($lnk[0][$i], 0, 30) . "...";
} else {
$lnk_txt = $lnk[0][$i];
}
$url = General::validateURL($lnk[0][$i]);
if (!empty($url)) {
$str = str_replace($url, "<a href=\"{$url}\" " . ($nofollow ? "rel=\"nofollow\"" : "") . ">{$lnk_txt}</a>", $str);
}
$i++;
}
return $str;
}
示例14: array
$required = array('name', 'source');
for ($i = 0; $i < count($required); $i++) {
if (trim($fields[$required[$i]]) == "") {
$errors[$required[$i]] = true;
}
}
if (is_array($errors)) {
define("__SYM_ENTRY_MISSINGFIELDS__", true);
} else {
$defines = array();
$fields['name'] = str_replace(array('\'', '"'), "", $fields['name']);
$handle = General::createFileName($fields['name'], $Admin->getConfigVar('handle_length', 'admin'), '_');
$rootelement = General::createFileName($fields['name'], $Admin->getConfigVar('handle_length', 'admin'), '-');
$classname = ucfirst($handle);
$source = $fields['source'];
$var = array('HANDLE' => $handle, 'ROOT-ELEMENT' => $rootelement, 'CLASS NAME' => $classname, 'NAME' => $fields['name'], 'DESCRIPTION' => "", 'AUTHOR-NAME' => $Admin->getAuthorName(), 'AUTHOR-WEBSITE' => General::validateURL(URL), 'AUTHOR-EMAIL' => $Admin->getAuthorEmail(), 'VERSION' => "1.0", 'RELEASE DATE' => date("Y-m-d H:i:s", $date->get(true, false)));
$xml_elements = array();
if (is_array($fields['xml-elements']) && !empty($fields['xml-elements'])) {
foreach ($fields['xml-elements'] as $f) {
$f = trim($f, '[]');
$bits = preg_split('/\\]\\[/i', $f, -1, PREG_SPLIT_NO_EMPTY);
list($group, $element) = $bits;
$xml_elements[$group][] = $element;
}
}
switch ($source) {
case "authors":
$defines['status'] = $fields['status'];
$defines['username'] = $fields['username'];
break;
case "comments":
示例15: __viewIndex
public function __viewIndex()
{
$this->setPageType('table');
$this->setTitle(__('%1$s – %2$s', array(__('Extensions'), __('Symphony'))));
$this->appendSubheading(__('Extensions'));
$this->Form->setAttribute('action', SYMPHONY_URL . '/system/extensions/');
Sortable::initialize($this, $extensions, $sort, $order);
$columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Installed Version'), 'sortable' => false), array('label' => __('Enabled'), 'sortable' => false), array('label' => __('Authors'), 'sortable' => true, 'handle' => 'author'));
$aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&filter=' . $_REQUEST['filter'] : '');
$aTableBody = array();
if (!is_array($extensions) || empty($extensions)) {
$aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
} else {
foreach ($extensions as $name => $about) {
$td1 = Widget::TableData($about['name']);
$installed_version = Symphony::ExtensionManager()->fetchInstalledVersion($name);
$td2 = Widget::TableData(is_null($installed_version) ? __('Not Installed') : $installed_version);
// If the extension is using the new `extension.meta.xml` format, check the
// compatibility of the extension. This won't prevent a user from installing
// it, but it will let them know that it requires a version of Symphony greater
// then what they have.
if (in_array(EXTENSION_NOT_INSTALLED, $about['status'])) {
$td3 = Widget::TableData(__('Enable to install %s', array($about['version'])));
}
if (in_array(EXTENSION_NOT_COMPATIBLE, $about['status'])) {
$td3 = Widget::TableData(__('Requires Symphony %s', array($about['required_version'])));
}
if (in_array(EXTENSION_ENABLED, $about['status'])) {
$td3 = Widget::TableData(__('Yes'));
}
if (in_array(EXTENSION_REQUIRES_UPDATE, $about['status'])) {
if (in_array(EXTENSION_NOT_COMPATIBLE, $about['status'])) {
$td3 = Widget::TableData(__('New version %1$s, Requires Symphony %2$s', array($about['version'], $about['required_version'])));
} else {
$td3 = Widget::TableData(__('Enable to update to %s', array($about['version'])));
}
}
if (in_array(EXTENSION_DISABLED, $about['status'])) {
$td3 = Widget::TableData(__('Disabled'));
}
$td4 = Widget::TableData(NULL);
if (isset($about['author'][0]) && is_array($about['author'][0])) {
$authors = '';
foreach ($about['author'] as $i => $author) {
if (isset($author['website'])) {
$link = Widget::Anchor($author['name'], General::validateURL($author['website']));
} else {
if (isset($author['email'])) {
$link = Widget::Anchor($author['name'], 'mailto:' . $author['email']);
} else {
$link = $author['name'];
}
}
$authors .= ($link instanceof XMLElement ? $link->generate() : $link) . ($i != count($about['author']) - 1 ? ", " : "");
}
$td4->setValue($authors);
} else {
if (isset($about['author']['website'])) {
$link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website']));
} else {
if (isset($about['author']['email'])) {
$link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']);
} else {
$link = $about['author']['name'];
}
}
$td4->setValue($link instanceof XMLElement ? $link->generate() : $link);
}
$td4->appendChild(Widget::Input('items[' . $name . ']', 'on', 'checkbox'));
// Add a row to the body array, assigning each cell to the row
$aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4), in_array(EXTENSION_NOT_INSTALLED, $about['status']) ? 'inactive' : NULL);
}
}
$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
$this->Form->appendChild($table);
$version = new XMLElement('p', 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), array('id' => 'version'));
$this->Form->appendChild($version);
$tableActions = new XMLElement('div');
$tableActions->setAttribute('class', 'actions');
$options = array(array(NULL, false, __('With Selected...')), array('enable', false, __('Enable/Install')), array('disable', false, __('Disable')), array('uninstall', false, __('Uninstall'), 'confirm', null, array('data-message' => __('Are you sure you want to uninstall the selected extensions?'))));
/**
* Allows an extension to modify the existing options for this page's
* With Selected menu. If the `$options` parameter is an empty array,
* the 'With Selected' menu will not be rendered.
*
* @delegate AddCustomActions
* @since Symphony 2.3.2
* @param string $context
* '/system/extensions/'
* @param array $options
* An array of arrays, where each child array represents an option
* in the With Selected menu. Options should follow the same format
* expected by `Widget::__SelectBuildOption`. Passed by reference.
*/
Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/system/extensions/', array('options' => &$options));
if (!empty($options)) {
$tableActions->appendChild(Widget::Apply($options));
$this->Form->appendChild($tableActions);
}
}