本文整理汇总了PHP中Settings::getSetting方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::getSetting方法的具体用法?PHP Settings::getSetting怎么用?PHP Settings::getSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings
的用法示例。
在下文中一共展示了Settings::getSetting方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSetting
/**
* Get settings
*
* @param string $name
* @param mixed $default
* @return mixed
*/
public function getSetting($name, $default = null)
{
if (!$this->settings) {
return null;
}
return $this->settings->getSetting($name, $default);
}
示例2: triggerWebtreesAdminTasks
public function triggerWebtreesAdminTasks()
{
$settings = new Settings();
$this->logger = \Piwik\Container\StaticContainer::get('Psr\\Log\\LoggerInterface');
$this->logger->info('Webtrees Admin Task triggered');
$rooturl = $settings->getSetting('webtreesRootUrl');
if (!$rooturl || strlen($rooturl->getValue()) === 0) {
return;
}
$token = $settings->getSetting('webtreesToken');
if (!$token || strlen($token->getValue()) === 0) {
return;
}
$taskname = $settings->getSetting('webtreesTaskName');
if (!$taskname || strlen($taskname->getValue()) === 0) {
return;
}
$url = sprintf('%1$s/module.php?mod=perso_admintasks&mod_action=trigger&force=%2$s&task=%3$s', $rooturl->getValue(), $token->getValue(), $taskname->getValue());
$this->logger->info('webtrees url : {url}', array('url' => $url));
try {
\Piwik\Http::sendHttpRequest($url, Webtrees::SOCKET_TIMEOUT);
} catch (Exception $e) {
$this->logger->warning('an error occured', array('exception' => $e));
}
}
示例3: initialize
/**
* initialize()
* check configuration and existence of base webdav directory
*/
private function initialize()
{
$this->sWebdavBaseDirPath = Settings::getSetting('webdav', 'base_dir', null);
if ($this->sWebdavBaseDirPath === null) {
$this->iError = self::ERROR_BASE_DIR_CONFIG;
} else {
$this->sWebdavBaseDirPath = MAIN_DIR . "/{$this->sWebdavBaseDirPath}";
if (file_exists($this->sWebdavBaseDirPath) && !@is_dir($this->sWebdavBaseDirPath)) {
$this->iError = self::ERROR_BASE_DIR_PATH;
}
if (!file_exists($this->sWebdavBaseDirPath)) {
if (!@mkdir($this->sWebdavBaseDirPath)) {
$this->iError = self::ERROR_BASE_DIR_PERMISSION;
}
} elseif (is_writable($this->sWebdavBaseDirPath) === false) {
$this->iError = self::ERROR_BASE_DIR_PERMISSION;
}
}
if ($this->iError) {
$this->sErrorLocation = __CLASS__ . "->" . __METHOD__;
}
if ($this->iError === null) {
$this->sWebdavBaseDirPath = realpath($this->sWebdavBaseDirPath);
$this->aFiles = array_keys(ResourceFinder::getFolderContents($this->sWebdavBaseDirPath));
}
}
示例4: getConsolidatedKeywords
public function getConsolidatedKeywords($sLanguageId = null, $bReturnArray = false)
{
if ($sLanguageId == null) {
$sLanguageId = Session::language();
}
$aKeywords = array();
$aKeywords[] = TranslationPeer::getString('meta.keywords', null, '');
$aTags = TagPeer::tagInstancesForObject($this);
foreach ($aTags as $iKey => $oTag) {
$aTags[$iKey] = $oTag->getTag()->getName();
}
$aKeywords[] = $aTags;
$aKeywords[] = Settings::getSetting('frontend', 'keywords', '');
$aKeywords[] = $this->getActivePageString()->getMetaKeywords();
$aResult = array();
foreach ($aKeywords as $iKey => $mKeywords) {
if (!is_array($mKeywords)) {
$mKeywords = explode(',', $mKeywords);
}
foreach ($mKeywords as $sKeyword) {
$sKeyword = trim($sKeyword);
if (!isset($aResult[$sKeyword]) && $sKeyword !== '') {
$aResult[$sKeyword] = true;
}
}
}
if ($bReturnArray) {
return array_keys($aResult);
}
return implode(', ', array_keys($aResult));
}
示例5: deleteRow
public function deleteRow($aRowData, $oCriteria)
{
$oLanguage = LanguagePeer::doSelectOne($oCriteria);
if ($oLanguage->getIsDefault()) {
throw new LocalizedException('wns.language.delete_default.denied');
}
if ($oLanguage->getIsDefaultEdit()) {
throw new LocalizedException('wns.language.delete_default.denied');
}
if (LanguagePeer::doCount(new Criteria()) < 2) {
throw new LocalizedException('wns.language.delete_last.denied');
}
$sLanguageId = $oLanguage->getId();
foreach (LanguageObjectQuery::create()->filterByLanguageId($sLanguageId)->find() as $oLanguageObject) {
$oHistory = $oLanguageObject->newHistory();
$oHistory->save();
$oLanguageObject->delete();
}
$iResult = $oLanguage->delete();
$oReplacementLanguage = LanguageQuery::create()->findOne();
if (AdminManager::getContentLanguage() === $sLanguageId) {
AdminManager::setContentLanguage(Settings::getSetting("session_default", AdminManager::CONTENT_LANGUAGE_SESSION_KEY, $oReplacementLanguage->getId()));
}
if (Session::language() === $sLanguageId) {
Session::getSession()->setLanguage(Settings::getSetting("session_default", Session::SESSION_LANGUAGE_KEY, $oReplacementLanguage->getId()));
}
}
示例6: getJsForFrontend
public function getJsForFrontend()
{
if (Settings::getSetting("frontend", "protect_email_addresses", false)) {
ResourceIncluder::defaultIncluder()->addResource('e-mail-defuscate.js');
}
return null;
}
示例7: getCountryPlugins
/**
* This returns all those countries in the database that have country-specific data, namely:
* region info (province / state / county), postal code info AND a list of cities. These countries
* have special functionality within the UI.
*
* TODO this pretty poor. It actually instantiates the country plugins
*
* @param boolean $installedOnly this determines
* @return array
*/
public static function getCountryPlugins($installedOnly = true)
{
$allowedCountries = array();
if ($installedOnly) {
$installedCountries = Settings::getSetting("installedCountries");
$allowedCountries = explode(",", $installedCountries);
}
$countryPluginsFolder = realpath(__DIR__ . "/../../plugins/countries");
$countryPlugins = array();
if ($handle = opendir($countryPluginsFolder)) {
while (false !== ($item = readdir($handle))) {
if ($item == "." || $item == ".." || $item == ".svn") {
continue;
}
if (!empty($allowedCountries) && !in_array($item, $allowedCountries)) {
continue;
}
if (is_dir("{$countryPluginsFolder}/{$item}")) {
$obj = self::instantiateCountryPlugin($countryPluginsFolder, $item);
if ($obj != null) {
$obj->path = $countryPluginsFolder;
$obj->folder = $item;
$countryPlugins[] = $obj;
}
}
}
closedir($handle);
}
return $countryPlugins;
}
示例8: onAnyError
public function onAnyError($aOptions, $bNeverPrint = false, $bNeverNotifyDeveloper = false)
{
if ($bNeverNotifyDeveloper) {
return;
}
$aProwlConfig = Settings::getSetting('prowl', 'users', array());
$aKeys = array();
foreach ($aProwlConfig as $aConfig) {
if (in_array(ErrorHandler::getEnvironment(), $aConfig['environments'])) {
$aKeys[] = $aConfig['key'];
}
}
if (count($aKeys) == 0) {
return;
}
$aError =& $aOptions[0];
$aProwlParams = array();
$aProwlParams['apikey'] = implode(',', $aKeys);
$aProwlParams['application'] = "Rapila on " . $aError['host'];
$aProwlParams['event'] = "Error on in " . $aError['path'];
$aProwlParams['url'] = 'http://' . $aError['host'] . $aError['path'];
$aProwlParams['description'] = StringUtil::truncate($aError['message'], 800);
$sParams = http_build_query($aProwlParams);
$rCurl = curl_init('https://api.prowlapp.com/publicapi/add');
curl_setopt($rCurl, CURLOPT_POSTFIELDS, $sParams);
curl_setopt($rCurl, CURLOPT_POST, 1);
curl_exec($rCurl);
}
示例9: renderFile
public function renderFile()
{
//Send Content-Type
$sCharset = Settings::getSetting('encoding', 'browser', 'utf-8');
if ($this->sType === ResourceIncluder::RESOURCE_TYPE_CSS) {
header("Content-Type: text/css;charset={$sCharset}");
} else {
if ($this->sType === ResourceIncluder::RESOURCE_TYPE_JS) {
header("Content-Type: text/javascript;charset={$sCharset}");
}
}
//Find consolidated resources
$aKeys = array();
while (Manager::hasNextPathItem()) {
$aKeys[] = Manager::usePath();
}
$sKey = 'consolidated-output-' . $this->sType . '-' . implode('|', $aKeys);
$oCachingStrategy = clone CachingStrategy::fromConfig('file');
$oCache = new Cache($sKey, 'resource', $oCachingStrategy);
$oItemCachingStrategy = clone $oCachingStrategy;
$oItemCachingStrategy->init(array('key_encode' => null));
$oCache->sendCacheControlHeaders();
if (!$oCache->entryExists(false)) {
foreach ($aKeys as $sItemKey) {
$oItemCache = new Cache($sItemKey, DIRNAME_PRELOAD, $oItemCachingStrategy);
if (!$oItemCache->entryExists(false)) {
throw new Exception("Consolidated resource {$sItemKey} does not exist.");
}
$oCache->setContents($oItemCache->getContentsAsString() . "\n", false, true);
}
}
$oCache->sendCacheControlHeaders();
$oCache->passContents(true);
}
示例10: checkAuth
public function checkAuth($sType, $sUserName, $sPassword)
{
$bIsLoggedIn = Session::getSession()->isAuthenticated();
if (!$bIsLoggedIn) {
$iLogin = Session::getSession()->loginUsingDigest();
$bIsLoggedIn = ($iLogin & Session::USER_IS_VALID) === Session::USER_IS_VALID;
}
if ($bIsLoggedIn) {
if (!Session::getSession()->getUser()->getIsAdmin()) {
foreach (Session::getSession()->getUser()->getGroups() as $oGroup) {
if ($oGroup->getName() === Settings::getSetting('webdav', 'privileged_group', 'webdav.*')) {
$this->aWebdavPermissions = true;
break;
} else {
foreach ($oGroup->getDirectoryPermissions() as $oWebdavPermission) {
if (!isset($this->aWebdavPermissions[$oWebdavPermission->getFilename()])) {
$this->aWebdavPermissions[$oWebdavPermission->getFilename()] = true;
}
}
}
}
} else {
$this->aWebdavPermissions = true;
}
} else {
Session::startDigest();
exit;
}
return $bIsLoggedIn;
}
示例11: getExportTypePlugins
/**
* Returns an array of available, instantiated Export Type objects.
*/
public static function getExportTypePlugins($runtimeContext, $installedOnly = true)
{
$allowedExportTypes = array();
if ($installedOnly) {
$exportTypes = Settings::getSetting("installedExportTypes");
$allowedExportTypes = explode(",", $exportTypes);
}
$exportTypesFolder = realpath(__DIR__ . "/../../plugins/exportTypes");
$exportTypes = array();
if ($handle = opendir($exportTypesFolder)) {
while (false !== ($item = readdir($handle))) {
if ($item == "." || $item == ".." || $item == ".svn") {
continue;
}
if (!empty($allowedExportTypes) && !in_array($item, $allowedExportTypes)) {
continue;
}
if (is_dir("{$exportTypesFolder}/{$item}")) {
$obj = self::instantiateExportType($runtimeContext, $exportTypesFolder, $item);
if ($obj != null) {
$folders = explode(DIRECTORY_SEPARATOR, $exportTypesFolder . DIRECTORY_SEPARATOR . $item);
$folders = array_reverse($folders);
// interesting, this. This is extremely simple and makes access to these values really easy
// ($class->path), but they're public so they can be overridden (bad!). But I still think
// it's better than some verbose getter function like $obj->getPath();
$obj->path = "{$folders[2]}/{$folders[1]}/{$folders[0]}";
$obj->folder = $folders[0];
$exportTypes[] = $obj;
}
}
}
closedir($handle);
}
return $exportTypes;
}
示例12: __construct
public function __construct($sSetting = null, $bPrintDoctype = true, $sClassName = null, $sLanguage = null)
{
$this->sContentType = "text/html";
if ($sLanguage === null) {
$sLanguage = Session::language();
}
$this->sLanguage = $sLanguage;
$this->sCharset = Settings::getSetting("encoding", "browser", "utf-8");
$this->sSetting = $sSetting;
$this->bPrintDoctype = $bPrintDoctype;
$this->sClassName = $sClassName;
if ($this->sSetting === null) {
$this->sSetting = Settings::getSetting('frontend', 'doctype', 'none');
}
if ($this->sSetting === self::SETTING_NONE || $this->sSetting === self::SETTING_HTML_4_STRICT || $this->sSetting === self::SETTING_HTML_4_TRANSITIONAL || $this->sSetting === self::SETTING_HTML_5) {
return;
}
if (@stristr(@$_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) {
if (preg_match("/application\\/xhtml\\+xml;q=([01]|0\\.\\d{1,3}|1\\.0)/i", $_SERVER["HTTP_ACCEPT"], $matches)) {
$xhtml_q = $matches[1];
if (preg_match("/text\\/html;q=([01]|0\\.\\d{1,3}|1\\.0)/i", $_SERVER["HTTP_ACCEPT"], $matches)) {
$html_q = $matches[1];
if ((double) $xhtml_q >= (double) $html_q) {
$this->sContentType = "application/xhtml+xml";
}
}
} else {
$this->sContentType = "application/xhtml+xml";
}
}
}
示例13: __construct
public function __construct($sSessionKey = null, $sModuleContents = null, $mModuleSettings = null)
{
parent::__construct($sSessionKey);
$this->sModuleContents = $sModuleContents;
if ($mModuleSettings === null || is_string($mModuleSettings)) {
$this->aModuleSettings = Settings::getSetting('text_module', null, array());
if ($mModuleSettings !== null) {
$this->aModuleSettings = array_merge($this->aModuleSettings, Settings::getSetting($mModuleSettings, 'text_module', array()));
}
} else {
$this->aModuleSettings = $mModuleSettings;
}
$this->cleanupCss();
$this->cleanupStyles();
$this->cleanupFormatTags();
$this->cleanupInsertableParts();
$this->cleanupToolbar();
foreach ($this->aModuleSettings as $sKey => $mSetting) {
$this->setSetting($sKey, $mSetting);
}
// let CKEDITOR find plugins
$aPlugins = array();
foreach (ResourceFinder::create()->addPath(DIRNAME_WEB, ResourceIncluder::RESOURCE_TYPE_JS, 'widget', 'ckeditor-plugins')->addDirPath()->addRecursion()->addPath('plugin.js')->returnObjects()->find() as $oPluginPath) {
$oPluginPath = $oPluginPath->parent();
$aPlugins[$oPluginPath->getFileName()] = $oPluginPath->getFrontendPath() . '/';
}
if (count($aPlugins) === 0) {
$aPlugins = null;
}
$this->setSetting('additional_plugin_paths', $aPlugins);
$this->setSetting('language', Session::language());
}
示例14: getBaseUrl
/**
* Formats and returns the base URL for the application.
* @return String The base URL for the application.
*/
public static function getBaseUrl()
{
if (UrlFormatter::$baseUrl == NULL) {
UrlFormatter::$baseUrl = Settings::getSetting('APPLICATION_URL') . 'index.php';
}
return UrlFormatter::$baseUrl;
}
示例15: getCriteria
public function getCriteria()
{
$oQuery = DocumentCategoryQuery::create();
if (!Session::getSession()->getUser()->getIsAdmin() || Settings::getSetting('admin', 'hide_externally_managed_document_categories', true)) {
return $oQuery->filterByIsExternallyManaged('false');
}
return $oQuery;
}