/**
  * 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);
 }
Example #2
0
 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));
     }
 }
 /**
  * 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));
     }
 }
Example #4
0
 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));
 }
 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()));
     }
 }
Example #6
0
 public function getJsForFrontend()
 {
     if (Settings::getSetting("frontend", "protect_email_addresses", false)) {
         ResourceIncluder::defaultIncluder()->addResource('e-mail-defuscate.js');
     }
     return null;
 }
 /**
  * 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;
 }
 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);
 }
 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);
 }
Example #10
0
 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;
 }
 /**
  * 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;
 }
Example #12
0
 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";
         }
     }
 }
Example #13
0
 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());
 }
 /**
  * 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;
 }
Example #15
0
 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;
 }
Example #16
0
 public static function checkPasswordValidity($sPassword, $oFlash)
 {
     if (mb_strlen($sPassword) < Settings::getSetting('login', 'password_min_length', 4)) {
         $oFlash->addMessage('password_length');
         return false;
     }
     return true;
 }
Example #17
0
 public function addSubscriberGroupMembershipBySubscriberGroupId($iSubscriberGroupId)
 {
     $oSubscriberGroupMembership = new SubscriberGroupMembership();
     $oSubscriberGroupMembership->setSubscriberGroupId($iSubscriberGroupId);
     if (Settings::getSetting('newsletter', 'optin_confirmation_required', true)) {
         $oSubscriberGroupMembership->setOptInHash($this->getOptInChecksum($iSubscriberGroupId));
     }
     return $this->addSubscriberGroupMembership($oSubscriberGroupMembership);
 }
 public static function getAdminLanguages($bDisplayOriginalLanguage = false)
 {
     // display registered languages instead of found and possibly incomplete ones
     $aLanguages = array();
     $aRegisteredLanguages = Settings::getSetting('admin', 'registered_user_languages', array());
     foreach ($aRegisteredLanguages as $sLanguageId) {
         $aLanguages[$sLanguageId] = self::getLanguageName($sLanguageId, $bDisplayOriginalLanguage ? $sLanguageId : null);
     }
     return $aLanguages;
 }
 /**
  * This function returns a reference to the database connection. If none exists, it will establish
  * the connection to the database.
  * @return A reference to the database connection.
  * @throws PDOException If an error occurred during the process of establishing the database connection.
  */
 public static function getDbConnection()
 {
     // if the single DB connection has not yet been initialized, initialize it
     if (DbConnectionUtil::$dbConnection == NULL) {
         $dbConnectionString = 'mysql:host=' . Settings::getSetting('DB_URL');
         $dbConnectionString .= ';dbname=' . Settings::getSetting('DB_SCHEMA');
         DbConnectionUtil::$dbConnection = new PDO($dbConnectionString, Settings::getSetting('DB_USERNAME'), Settings::getSetting('DB_PASSWORD'));
         DbConnectionUtil::$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     }
     return DbConnectionUtil::$dbConnection;
 }
 public static function getTagOptions()
 {
     $aResult = TagQuery::create()->filterByTagged('Document')->select(array('Id', 'Name'))->find()->toKeyValue('Id', 'Name');
     if (count($aResult) > 0 && !Settings::getSetting('admin', 'list_allows_multiple_categories', true)) {
         $aResult = array('' => ' ---- ') + $aResult;
     }
     if (count($aResult) === 0) {
         $aResult = array('' => TranslationPeer::getString('wns.document_list.no_tags_available'));
     }
     return $aResult;
 }
Example #21
0
 public function verifySessionContentEditLanguage()
 {
     $sSessionDefaultLanguage = Settings::getSetting("session_default", AdminManager::CONTENT_LANGUAGE_SESSION_KEY, null);
     if (LanguageQuery::create()->filterById($sSessionDefaultLanguage)->count() < 1) {
         $oLanguage = new Language();
         $oLanguage->setId($sSessionDefaultLanguage);
         $oLanguage->setPathPrefix($sSessionDefaultLanguage);
         $oLanguage->setIsActive(true);
         $oLanguage->save();
     }
 }
 public function listCategories()
 {
     $oQuery = LinkCategoryQuery::create()->orderByName();
     if (Settings::getSetting('admin', 'hide_externally_managed_link_categories', true)) {
         $oQuery->filterByIsExternallyManaged(false);
     }
     $aResult = array();
     foreach ($oQuery->select(array('Id', 'Name'))->find() as $aData) {
         $aResult[] = array('key' => $aData['Id'], 'value' => $aData['Name']);
     }
     return $aResult;
 }
Example #23
0
 public static function dumpAll()
 {
     $aArgs = func_get_args();
     @ob_clean();
     if (!function_exists('xdebug_break')) {
         @header("Content-Type: text/plain;charset=" . Settings::getSetting('encoding', 'browser', 'utf-8'));
     } else {
         @header("Content-Type: text/html;charset=" . Settings::getSetting('encoding', 'browser', 'utf-8'));
     }
     call_user_func_array('var_dump', $aArgs);
     exit;
 }
Example #24
0
 public function render()
 {
     $sDirectory = MAIN_DIR . "/" . Settings::getSetting('webdav', 'base_dir', '.');
     $sRealPathDir = realpath($sDirectory);
     if ($sRealPathDir === false) {
         throw new Exception("Error in WedavManager:: directory {$sDirectory} does not exist");
     }
     $oServer = new WebDAVServer($sRealPathDir);
     // ob_start(array($this, 'log'), 512);
     $oServer->ServeRequest();
     // ob_end_flush();
 }
 public static function processCSSContent($sContent, $oFile)
 {
     $oCache = new Cache('preview_css' . $oFile->getInternalPath(), DIRNAME_TEMPLATES);
     header("Content-Type: text/css;charset=" . Settings::getSetting('encoding', 'browser', 'utf-8'));
     if ($oCache->entryExists() && !$oCache->isOutdated($oFile->getFullPath())) {
         $oCache->sendCacheControlHeaders();
         $oCache->passContents();
         exit;
     }
     $oParser = new Sabberworm\CSS\Parser($sContent, Sabberworm\CSS\Settings::create()->withDefaultCharset(Settings::getSetting('encoding', 'browser', 'utf-8')));
     $oCssContents = $oParser->parse();
     //Make all rules important
     // foreach($oCssContents->getAllRuleSets() as $oCssRuleSet) {
     //	foreach($oCssRuleSet->getRules() as $oRule) {
     //		$oRule->setIsImportant(true);
     //	}
     // }
     //Multiply all rules and prepend specific strings
     $aPrependages = array('#rapila_admin_menu', '.filled-container.editing', '.ui-dialog', '.cke_dialog_contents', '#widget-notifications', '.cke_reset', 'body > .cke_reset_all', '.tag_panel');
     foreach ($oCssContents->getAllDeclarationBlocks() as $oBlock) {
         $aNewSelector = array();
         foreach ($oBlock->getSelectors() as $iKey => $oSelector) {
             $sSelector = $oSelector->getSelector();
             if (StringUtil::startsWith($sSelector, "body ") || StringUtil::startsWith($sSelector, "html ")) {
                 $aNewSelector[] = $sSelector;
             } else {
                 foreach ($aPrependages as $sPrependage) {
                     if (StringUtil::startsWith($sSelector, "{$sPrependage} ") || StringUtil::startsWith($sSelector, "{$sPrependage}.") || $sSelector === $sPrependage) {
                         $aNewSelector[] = $sSelector;
                     } else {
                         $aNewSelector[] = "{$sPrependage} {$sSelector}";
                     }
                 }
             }
         }
         $oBlock->setSelector($aNewSelector);
     }
     //Absolutize all URLs
     foreach ($oCssContents->getAllValues() as $oValue) {
         if ($oValue instanceof Sabberworm\CSS\Value\URL) {
             $sURL = $oValue->getURL()->getString();
             if (!StringUtil::startsWith($sURL, '/') && !preg_match('/^\\w+:/', $sURL)) {
                 $sURL = $oFile->getFrontendDirectoryPath() . DIRECTORY_SEPARATOR . $sURL;
             }
             $oValue->setURL(new Sabberworm\CSS\Value\CSSString($sURL));
         }
     }
     $sContents = $oCssContents->render(Sabberworm\CSS\OutputFormat::createCompact());
     $oCache->setContents($sContents);
     $oCache->sendCacheControlHeaders();
     print $sContents;
 }
 public function renderFile()
 {
     $oTemplate = new Template("{$this->sModuleName}.{$this->sModuleType}.{$this->sResourceType}", array(DIRNAME_MODULES, $this->sModuleType, $this->sModuleName, DIRNAME_TEMPLATES));
     $sContents = $oTemplate->render();
     $sModuleClass = Module::getClassNameByTypeAndName($this->sModuleType, $this->sModuleName);
     if ($this->sResourceType === ResourceIncluder::RESOURCE_TYPE_CSS && $sModuleClass::USE_NAMESPACED_CSS) {
         $oFile = ResourceFinder::findResourceObject(array(DIRNAME_MODULES, $this->sModuleType, $this->sModuleName, DIRNAME_TEMPLATES, "{$this->sModuleName}.{$this->sModuleType}.{$this->sResourceType}.tmpl"));
         NamespacedPreviewCssFileModule::processCSSContent($sContents, $oFile);
     } else {
         header("Content-Type: text/css;charset=" . Settings::getSetting('encoding', 'browser', 'utf-8'));
         print $sContents;
     }
 }
 /**
  * @param optional int / string $iPageSize
  * configure page_size per site or list-widget
  * – by configuring global value or local overwrite value in config.yml
  * admin:
  *   page_size: number [0, none]
  *   example_list_page_size:  number [0, none]
  */
 public function addPaging($iPageSize = 'default')
 {
     $sConfigKey = 'page_size';
     if ($iPageSize === 'default') {
         $iPageSize = Settings::getSetting('admin', $this->getModuleName() . "_{$sConfigKey}", 'default');
     }
     if ($iPageSize === 'default') {
         $iPageSize = Settings::getSetting('admin', $sConfigKey, 25);
     }
     if (is_numeric($iPageSize) && $iPageSize > 0) {
         $this->oListWidget->setSetting('page_size', $iPageSize);
     }
 }
 /**
  * Used to generate the main index and install pages.
  * @param string $template the path from the GD root to the template
  * @param array $pageVars
  * @param string $action "display" displays the result (default) or "return" to return the value
  * @return mixed
  */
 public static function displayPage($template, $pageVars = array(), $action = "display")
 {
     // check the compile directory has the write permissions
     if (!is_writable(Core::$smarty->compile_dir) && is_readable(Core::$smarty->compile_dir)) {
         Templates::displaySeriousError("The <b>/cache</b> folder isn't writable. This folder is used by Smarty to generate temporary files for speedy page loads. You'll need to update that folder's permissions to allow read and write permissions (777 on unix/mac).");
         exit;
     }
     // check that the user is running a recent enough version of PHP. This is needed for json_encode,
     // json_decode and for Smarty 3
     $minimumPHPVersion = Core::getMinimumPHPVersion();
     $currentVersion = PHP_VERSION;
     if (version_compare($currentVersion, $minimumPHPVersion) < 0) {
         Templates::displaySeriousError("Sorry, you need to be running PHP <b>{$minimumPHPVersion}</b> or later. You're currently running <b>{$currentVersion}</b>.");
         exit;
     }
     // check the environment has mysqli
     if (!function_exists("mysqli_connect")) {
         Templates::displaySeriousError("Sorry, you must have the <b>mysqli</b> PHP extension installed in order to use this script.");
         exit;
     }
     Core::$smarty->assign("L", Core::$language->getCurrentLanguageStrings());
     Core::$smarty->assign("currLang", Core::$language->getCurrentLanguageFile());
     Core::$smarty->assign("queryString", $_SERVER["QUERY_STRING"]);
     // this sucks. Needs to cache the DB value
     $theme = isset($pageVars["theme"]) ? $pageVars["theme"] : Settings::getSetting("theme");
     Core::$smarty->assign("theme", $theme);
     Core::$smarty->assign("inDemoMode", Core::checkDemoMode());
     Core::$smarty->assign("allowThemes", Core::$allowThemes);
     // now add the custom variables for this template, as defined in $page_vars
     foreach ($pageVars as $key => $value) {
         Core::$smarty->assign($key, $value);
     }
     // "success" and "message" are special
     if (!isset($pageVars["success"])) {
         Core::$smarty->assign("success", null);
     }
     if (!isset($pageVars["message"])) {
         Core::$smarty->assign("message", null);
     }
     try {
         $templatePath = realpath(__DIR__ . "/../../{$template}");
         if ($action == "display") {
             Core::$smarty->display($templatePath);
         } else {
             return Core::$smarty->fetch($templatePath);
         }
     } catch (Exception $e) {
         Templates::displaySeriousError("Smarty encountered a problem writing to the /cache folder. The (probably indecipherable) error message returned is:", $e);
         exit;
     }
 }
Example #29
0
 /**
  * Flushes any registered headers to the output buffer.
  */
 public static function flushHeaders()
 {
     foreach (self::$headers as $name => $content) {
         // We can't set headers when unit testing.
         if (!Settings::getSetting("Context", "UnitTesting", false)) {
             if ($content === false) {
                 header($name);
             } else {
                 header($name . ": " . $content);
             }
         }
     }
     self::$flushed = true;
 }
 public static function providerInstance($sConfigKey)
 {
     $aMetadata = Settings::getSetting($sConfigKey, null, null, 'documentation');
     if ($aMetadata === null) {
         return null;
     }
     if (!isset($aMetadata['provider'])) {
         $aMetadata['provider'] = 'static';
     }
     if (!isset($aMetadata['priority'])) {
         $aMetadata['priority'] = 0;
     }
     $aMetadata['config_key'] = $sConfigKey;
     return self::getModuleInstance($aMetadata['provider'], $aMetadata);
 }