本文整理汇总了PHP中Symphony::Configuration方法的典型用法代码示例。如果您正苦于以下问题:PHP Symphony::Configuration方法的具体用法?PHP Symphony::Configuration怎么用?PHP Symphony::Configuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symphony
的用法示例。
在下文中一共展示了Symphony::Configuration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action
public function action()
{
##Do not proceed if the config file is read only
if (!is_writable(CONFIG)) {
redirect(URL . '/symphony/system/preferences/');
}
###
# Delegate: CustomActions
# Description: This is where Extensions can hook on to custom actions they may need to provide.
$this->_Parent->ExtensionManager->notifyMembers('CustomActions', '/system/preferences/');
if (isset($_POST['action']['save'])) {
$settings = $_POST['settings'];
###
# Delegate: Save
# Description: Saving of system preferences.
$this->_Parent->ExtensionManager->notifyMembers('Save', '/system/preferences/', array('settings' => &$settings, 'errors' => &$this->_errors));
if (!is_array($this->_errors) || empty($this->_errors)) {
foreach ($settings as $set => $values) {
foreach ($values as $key => $val) {
Symphony::Configuration()->set($key, $val, $set);
}
}
$this->_Parent->saveConfig();
redirect(URL . '/symphony/system/preferences/success/');
}
}
}
示例2: convertToXML
/**
* Given a CSV file, generate a resulting XML tree
*
* @param string $data
* @return string
*/
public static function convertToXML($data)
{
$headers = array();
// Get CSV settings
$settings = array('csv-delimiter' => ',', 'csv-enclosure' => '"', 'csv-escape' => '\\');
$settings = array_merge($settings, (array) Symphony::Configuration()->get('remote_datasource'));
// DOMDocument
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
$root = $doc->createElement('data');
$doc->appendChild($root);
foreach (str_getcsv($data, PHP_EOL) as $i => $row) {
if (empty($row)) {
continue;
}
if ($i == 0) {
foreach (str_getcsv($row, $settings['csv-delimiter'], $settings['csv-enclosure'], $settings['csv-escape']) as $i => $head) {
if (class_exists('Lang')) {
$head = Lang::createHandle($head);
}
$headers[] = $head;
}
} else {
self::addRow($doc, $root, str_getcsv($row, $settings['csv-delimiter'], $settings['csv-enclosure'], $settings['csv-escape']), $headers);
}
}
$output = $doc->saveXML($doc->documentElement);
return trim($output);
}
示例3: upgrade
public static function upgrade()
{
// 2.2.2 Beta 1
if (version_compare(self::$existing_version, '2.2.2 Beta 1', '<=')) {
Symphony::Configuration()->set('version', '2.2.2 Beta 1', 'symphony');
// Rename old variations of the query_caching configuration setting
if (Symphony::Configuration()->get('disable_query_caching', 'database')) {
$value = Symphony::Configuration()->get('disable_query_caching', 'database') == "no" ? "on" : "off";
Symphony::Configuration()->set('query_caching', $value, 'database');
Symphony::Configuration()->remove('disable_query_caching', 'database');
}
// Add Session GC collection as a configuration parameter
Symphony::Configuration()->set('session_gc_divisor', '10', 'symphony');
// Save the manifest changes
Symphony::Configuration()->write();
}
// 2.2.2 Beta 2
if (version_compare(self::$existing_version, '2.2.2 Beta 2', '<=')) {
Symphony::Configuration()->set('version', '2.2.2 Beta 2', 'symphony');
try {
// Change Textareas to be MEDIUMTEXT columns
$textarea_tables = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_textarea`");
foreach ($textarea_tables as $field) {
Symphony::Database()->query(sprintf("ALTER TABLE `tbl_entries_data_%d` CHANGE `value` `value` MEDIUMTEXT, CHANGE `value_formatted` `value_formatted` MEDIUMTEXT", $field));
Symphony::Database()->query(sprintf('OPTIMIZE TABLE `tbl_entries_data_%d`', $field));
}
} catch (Exception $ex) {
}
// Save the manifest changes
Symphony::Configuration()->write();
}
// Update the version information
return parent::upgrade();
}
示例4: lookup
public static function lookup($ip)
{
$ch = curl_init();
// Notice: the request back to the service API includes your domain name
// and the version of Symphony that you're using
$version = Symphony::Configuration()->get('version', 'symphony');
$domain = $_SERVER[SERVER_NAME];
curl_setopt($ch, CURLOPT_URL, "http://api.josephdenne.com/_geoloc/array/?symphony=" . $version . "&domain=" . $domain . "&ip=" . $ip);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$geoinfo = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if ($geoinfo === false || $info['http_code'] != 200) {
return;
} else {
$geoinfo = explode(',', $geoinfo);
}
$result = new XMLElement("geolocation");
$included = array('id', 'lookups', 'country', 'region', 'city', 'lat', 'lon', 'error');
$i = 0;
foreach ($included as $geoloc) {
$result->appendChild(new XMLElement($geoloc, $geoinfo[$i]));
$i++;
}
return $result;
}
示例5: start
/**
* Starts a Session object, only if one doesn't already exist. This function maps
* the Session Handler functions to this classes methods by reading the default
* information from the PHP ini file.
*
* @link http://php.net/manual/en/function.session-set-save-handler.php
* @link http://php.net/manual/en/function.session-set-cookie-params.php
* @param integer $lifetime
* How long a Session is valid for, by default this is 0, which means it
* never expires
* @param string $path
* The path the cookie is valid for on the domain
* @param string $domain
* The domain this cookie is valid for
* @param boolean $httpOnly
* Whether this cookie can be read by Javascript. By default the cookie
* cannot be read by Javascript
* @param boolean $secure
* Whether this cookie should only be sent on secure servers. By default this is
* false, which means the cookie can be sent over HTTP and HTTPS
* @throws Exception
* @return string|boolean
* Returns the Session ID on success, or false on error.
*/
public static function start($lifetime = 0, $path = '/', $domain = null, $httpOnly = true, $secure = false)
{
if (!self::$_initialized) {
if (!is_object(Symphony::Database()) || !Symphony::Database()->isConnected()) {
return false;
}
if (session_id() == '') {
ini_set('session.save_handler', 'user');
ini_set('session.gc_maxlifetime', $lifetime);
ini_set('session.gc_probability', '1');
ini_set('session.gc_divisor', Symphony::Configuration()->get('session_gc_divisor', 'symphony'));
}
session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'gc'));
session_set_cookie_params($lifetime, $path, $domain ? $domain : self::getDomain(), $secure, $httpOnly);
session_cache_limiter('');
if (session_id() == '') {
if (headers_sent()) {
throw new Exception('Headers already sent. Cannot start session.');
}
register_shutdown_function('session_write_close');
session_start();
}
self::$_initialized = true;
}
return session_id();
}
示例6: frontendPrePageResolve
public function frontendPrePageResolve($context)
{
if (!self::$resolved) {
// get languages from configuration
if (self::$languages = Symphony::Configuration()->get('languages', 'multilingual')) {
self::$languages = explode(',', str_replace(' ', '', self::$languages));
// detect language from path
if (preg_match('/^\\/([a-z]{2})\\//', $context['page'], $match)) {
// set language from path
self::$language = $match[1];
} else {
// detect language from browser
self::$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
// check if language is supported
if (!in_array(self::$language, self::$languages)) {
// set to default otherwise
self::$language = self::$languages[0];
}
// redirect root page
if (!$context['page']) {
header('Location: ' . URL . '/' . self::$language . '/');
exit;
}
}
self::$resolved = true;
}
}
示例7: __parseLog
protected function __parseLog($file)
{
$items = array();
$last = null;
if (is_readable($file)) {
header('content-type: text/plain');
if (preg_match('/.gz$/', $file)) {
$handle = gzopen($file, "r");
$data = gzread($handle, Symphony::Configuration()->get('maxsize', 'log'));
gzclose($handle);
} else {
$data = file_get_contents($file);
}
$lines = explode(PHP_EOL, $data);
// Skip log info:
while (count($lines)) {
$line = trim(array_shift($lines));
if ($line == '--------------------------------------------') {
break;
}
}
// Create items:
foreach ($lines as $line) {
preg_match('/^(.*?) > (.*)/', trim($line), $matches);
// New entry:
if (count($matches) == 3) {
$message = htmlentities($matches[2]);
$items[] = (object) array('timestamp' => DateTimeObj::get(__SYM_DATETIME_FORMAT__, strtotime($matches[1])), 'message' => $message);
}
}
// Reverse order:
$items = array_reverse($items);
}
return $items;
}
示例8: save
public static function save(Utility $utility)
{
$file = UTILITIES . "/{$utility->name}";
FileWriter::write($file, $utility->body, Symphony::Configuration()->core()->symphony->{'file-write-mode'});
//General::writeFile($file, $utility->body,Symphony::Configuration()->core()->symphony->{'file-write-mode'});
return file_exists($file);
}
示例9: __construct
protected function __construct()
{
$this->Profiler = new Profiler();
if (get_magic_quotes_gpc()) {
General::cleanArray($_SERVER);
General::cleanArray($_COOKIE);
General::cleanArray($_GET);
General::cleanArray($_POST);
}
include CONFIG;
self::$Configuration = new Configuration(true);
self::$Configuration->setArray($settings);
define_safe('__LANG__', self::$Configuration->get('lang', 'symphony') ? self::$Configuration->get('lang', 'symphony') : 'en');
define_safe('__SYM_DATE_FORMAT__', self::$Configuration->get('date_format', 'region'));
define_safe('__SYM_TIME_FORMAT__', self::$Configuration->get('time_format', 'region'));
define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . ' ' . __SYM_TIME_FORMAT__);
$this->initialiseLog();
GenericExceptionHandler::initialise();
GenericErrorHandler::initialise($this->Log);
$this->initialiseCookie();
try {
Lang::init(LANG . '/lang.%s.php', __LANG__);
} catch (Exception $e) {
trigger_error($e->getMessage(), E_USER_ERROR);
}
$this->initialiseDatabase();
if (!$this->initialiseExtensionManager()) {
throw new SymphonyErrorPage('Error creating Symphony extension manager.');
}
DateTimeObj::setDefaultTimezone(self::$Configuration->get('timezone', 'region'));
}
示例10: savePreferences
/**
* Save the preferences
*
* @param $context
*/
public function savePreferences($context)
{
if (isset($_POST['force_download']['trusted_locations'])) {
Symphony::Configuration()->set('trusted_locations', serialize(explode("\n", str_replace("\r", '', $_POST['force_download']['trusted_locations']))), 'force_download');
Symphony::Configuration()->write();
}
}
示例11: initializeContext
/**
* Initialize contextual XML (formerly params)
*/
public function initializeContext()
{
$this->View->context->register(array('system' => array('site-name' => Symphony::Configuration()->core()->symphony->sitename, 'site-url' => URL, 'admin-url' => URL . '/symphony', 'symphony-version' => Symphony::Configuration()->core()->symphony->version), 'date' => array('today' => DateTimeObj::get('Y-m-d'), 'current-time' => DateTimeObj::get('H:i'), 'this-year' => DateTimeObj::get('Y'), 'this-month' => DateTimeObj::get('m'), 'this-day' => DateTimeObj::get('d'), 'timezone' => date_default_timezone_get())));
if ($this->User) {
$this->View->context->register(array('session' => self::instance()->User->fields()));
}
}
示例12: upgrade
static function upgrade()
{
if (version_compare(self::$existing_version, '2.3.3beta1', '<=')) {
// Update DB for the new author role #1692
Symphony::Database()->query(sprintf("ALTER TABLE `tbl_authors` CHANGE `user_type` `user_type` enum('author', 'manager', 'developer') DEFAULT 'author'", $field));
// Remove directory from the upload fields, #1719
$upload_tables = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_upload`");
if (is_array($upload_tables) && !empty($upload_tables)) {
foreach ($upload_tables as $field) {
Symphony::Database()->query(sprintf("UPDATE tbl_entries_data_%d SET file = substring_index(file, '/', -1)", $field));
}
}
}
if (version_compare(self::$existing_version, '2.3.3beta2', '<=')) {
// Update rows for associations
if (!Symphony::Configuration()->get('association_maximum_rows', 'symphony')) {
Symphony::Configuration()->set('association_maximum_rows', '5', 'symphony');
}
}
// Update the version information
Symphony::Configuration()->set('version', self::getVersion(), 'symphony');
Symphony::Configuration()->set('useragent', 'Symphony/' . self::getVersion(), 'general');
if (Symphony::Configuration()->write() === false) {
throw new Exception('Failed to write configuration file, please check the file permissions.');
} else {
return true;
}
}
示例13: view
public function view()
{
$section_handle = (string) $this->context[0];
$page = isset($this->context[1]) ? (int) $this->context[1] : 1;
if (empty($section_handle)) {
die('Invalid section handle');
}
$config = (object) Symphony::Configuration()->get('elasticsearch');
ElasticSearch::init();
$type = ElasticSearch::getTypeByHandle($section_handle);
if ($page === 1) {
// delete all documents in this index
$query = new Elastica_Query(array('query' => array('match_all' => array())));
$type->type->deleteByQuery($query);
}
// get new entries
$em = new EntryManager(Symphony::Engine());
$entries = $em->fetchByPage($page, $type->section->get('id'), (int) $config->{'reindex-batch-size'}, NULL, NULL, FALSE, FALSE, TRUE);
foreach ($entries['records'] as $entry) {
ElasticSearch::indexEntry($entry, $type->section);
}
$entries['total-entries'] = 0;
// last page, count how many entries in the index
if ($entries['remaining-pages'] == 0) {
// wait a few seconds, allow HTTP requests to complete...
sleep(5);
$entries['total-entries'] = $type->type->count();
}
header('Content-type: application/json');
echo json_encode(array('pagination' => array('total-pages' => (int) $entries['total-pages'], 'total-entries' => (int) $entries['total-entries'], 'remaining-pages' => (int) $entries['remaining-pages'], 'next-page' => $page + 1)));
exit;
}
示例14: __construct
protected function __construct()
{
$this->Profiler = new Profiler();
if (get_magic_quotes_gpc()) {
General::cleanArray($_SERVER);
General::cleanArray($_COOKIE);
General::cleanArray($_GET);
General::cleanArray($_POST);
}
include CONFIG;
self::$Configuration = new Configuration(true);
self::$Configuration->setArray($settings);
DateTimeObj::setDefaultTimezone(self::$Configuration->get('timezone', 'region'));
self::$_lang = self::$Configuration->get('lang', 'symphony') ? self::$Configuration->get('lang', 'symphony') : 'en';
// Legacy support for __LANG__ constant
define_safe('__LANG__', self::lang());
define_safe('__SYM_DATE_FORMAT__', self::$Configuration->get('date_format', 'region'));
define_safe('__SYM_TIME_FORMAT__', self::$Configuration->get('time_format', 'region'));
define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . ' ' . __SYM_TIME_FORMAT__);
$this->initialiseLog();
GenericExceptionHandler::initialise();
GenericErrorHandler::initialise(self::$Log);
$this->initialiseCookie();
$this->initialiseDatabase();
if (!$this->initialiseExtensionManager()) {
throw new SymphonyErrorPage('Error creating Symphony extension manager.');
}
Lang::loadAll($this->ExtensionManager);
}
示例15: view
public function view($call_parent = TRUE)
{
$this->addElementToHead(new XMLElement('script', "Symphony.Context.add('elasticsearch', " . json_encode(Symphony::Configuration()->get('elasticsearch')) . ")", array('type' => 'text/javascript')), 99);
if ($call_parent) {
parent::view();
}
}