本文整理汇总了PHP中Kwf_Config类的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Config类的具体用法?PHP Kwf_Config怎么用?PHP Kwf_Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Kwf_Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assets
public function assets(Kwf_Assets_Package $assetsPackage, $language = null)
{
if (!$language) {
$language = Kwf_Trl::getInstance()->getTargetLanguage();
}
$indent = str_repeat(' ', 8);
$ret = '';
foreach ($assetsPackage->getPackageUrls('text/css', $language) as $file) {
$ret .= "{$indent}<link rel=\"stylesheet\" type=\"text/css\" href=\"" . htmlspecialchars($file) . "\" />\n";
}
foreach ($assetsPackage->getPackageUrls('text/css; media=print', $language) as $file) {
$ret .= "{$indent}<link rel=\"stylesheet\" type=\"text/css\" href=\"" . htmlspecialchars($file) . "\" ";
if (!Kwf_Config::getValue('debug.assets.usePrintCssForAllMedia')) {
$ret .= "media=\"print\" ";
}
$ret .= "/>\n";
}
foreach ($assetsPackage->getPackageUrls('text/javascript', $language) as $file) {
$ret .= "{$indent}<script type=\"text/javascript\" src=\"" . htmlspecialchars($file) . "\"></script>\n";
}
foreach ($assetsPackage->getPackageUrls('text/javascript; defer', $language) as $file) {
$ret .= "<script type=\"text/javascript\">\n var se=document.createElement('script');se.type='text/javascript';se.async=true;\n se.src='" . $file . "';\n var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(se,s);\n </script>";
}
return $ret;
}
示例2: open
/**
* opening of the session - mandatory arguments won't be needed
*
* @param string $savePath
* @param string $sessionName
* @return bool
*/
public function open($savePath, $sessionName)
{
if (!isset($this->_lifeTime)) {
$this->_lifeTime = intval(ini_get("session.gc_maxlifetime"));
}
if (!isset($this->_refreshTime)) {
$this->_refreshTime = ceil($this->_lifeTime / 3);
}
$this->_initSessionData = null;
$this->_memcache = new Memcache();
if (Kwf_Config::getValue('aws.simpleCacheCluster')) {
$servers = Kwf_Util_Aws_ElastiCache_CacheClusterEndpoints::getCached(Kwf_Config::getValue('aws.simpleCacheCluster'));
} else {
if (Kwf_Cache_Simple::$memcacheHost) {
$servers = array(array('host' => Kwf_Cache_Simple::$memcacheHost, 'port' => Kwf_Cache_Simple::$memcachePort));
} else {
throw new Kwf_Exception("no memcache configured");
}
}
foreach ($servers as $s) {
if (version_compare(phpversion('memcache'), '2.1.0') == -1 || phpversion('memcache') == '2.2.4') {
// < 2.1.0
$this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1);
} else {
if (version_compare(phpversion('memcache'), '3.0.0') == -1) {
// < 3.0.0
$this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1, true, null, 10000);
} else {
$this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1);
}
}
}
return true;
}
示例3: getSettings
public static function getSettings()
{
$ret = parent::getSettings();
$ret['generators']['child'] = array('class' => 'Kwf_Component_Generator_Static', 'component' => array('linkTag' => 'Kwc_Basic_ImageEnlarge_EnlargeTag_Component'), 'addUrlPart' => false);
$ret['cssClass'] = 'kwcBasicImageEnlarge ' . Kwf_Config::getValue('kwc.imageEnlarge.cssClass');
return $ret;
}
示例4: getContentsPacked
public function getContentsPacked()
{
$contents = file_get_contents($this->getAbsoluteFileName());
$useTrl = strpos($contents, 'trl') !== false && preg_match('#trl(c|p|cp)?(Kwf)?(Static)?\\(#', $contents);
$trlData = array();
if ($useTrl) {
foreach (Kwf_TrlJsParser_UnderscoreTemplateParser::parseContent($contents) as $trlElement) {
$d = Kwf_Assets_Util_Trl::getJsReplacement($trlElement);
$contents = str_replace($d['before'], $d['replace'], $contents);
$trlData[] = $d['trlElement'];
}
}
$contents = str_replace("\n", '\\n', $contents);
$contents = str_replace("'", "\\'", $contents);
$contents = "var _ = require('underscore');\n" . "module.exports = _.template('" . $contents . "');\n";
$replacements = array();
if (strpos($contents, 'kwfUp-') !== false) {
if (Kwf_Config::getValue('application.uniquePrefix')) {
$replacements['kwfUp-'] = Kwf_Config::getValue('application.uniquePrefix') . '-';
} else {
$replacements['kwfUp-'] = '';
}
}
foreach ($replacements as $search => $replace) {
$contents = str_replace($search, $replace, $contents);
}
$map = Kwf_SourceMaps_SourceMap::createEmptyMap($contents);
$data = $map->getMapContentsData();
$data->{'_x_org_koala-framework_masterFiles'} = array($this->getAbsoluteFileName());
if ($trlData) {
$data->{'_x_org_koala-framework_trlData'} = $trlData;
}
return $map;
}
示例5: _processContents
protected function _processContents($ret)
{
$pathType = $this->getType();
if ($pathType == 'ext2') {
//hack um bei ext-css-dateien korrekte pfade für die bilder zu haben
$ret = str_replace('../images/', '/assets/ext2/resources/images/', $ret);
}
//convert relative paths (as in bower dependencies; example: jquery.socialshareprivacy, mediaelement
$fn = $this->getFileNameWithType();
$fnDir = substr($fn, 0, strrpos($fn, '/'));
$ret = preg_replace('#url\\(\\s*([^)]+?)\\s*\\)#', 'url(\\1)', $ret);
//remove spaces inside url()
$ret = preg_replace('#url\\((\'|")(?![a-z]+:)([^/\'"])#', 'url(\\1/assets/' . $fnDir . '/\\2', $ret);
$ret = preg_replace('#url\\((?![a-z]+:)([^/\'"])#', 'url(/assets/' . $fnDir . '/\\1', $ret);
$ret = self::expandAssetVariables($ret);
if (strpos($ret, 'cssClass') !== false && (strpos($ret, '$cssClass') !== false || strpos($ret, '.cssClass') !== false)) {
$cssClass = $this->_getComponentCssClass();
if ($cssClass) {
$ret = str_replace('$cssClass', $cssClass, $ret);
$ret = str_replace('.cssClass', '.' . $cssClass, $ret);
}
}
if (strpos($ret, 'kwfup-') !== false) {
if (Kwf_Config::getValue('application.uniquePrefix')) {
$ret = str_replace('kwfup-', Kwf_Config::getValue('application.uniquePrefix') . '-', $ret);
} else {
$ret = str_replace('kwfup-', '', $ret);
}
}
return $ret;
}
示例6: money
public static function money($context, $amount)
{
$data = null;
if (isset($context['data']) && $context['data'] instanceof Kwf_Component_Data) {
$data = $context['data'];
} else {
if (isset($context['item']) && $context['item'] instanceof Kwf_Component_Data) {
$data = $context['item'];
}
}
if ($data) {
$format = $data->getBaseProperty('money.format');
$decimals = $data->getBaseProperty('money.decimals');
$decimalSeparator = $data->getBaseProperty('money.decimalSeparator');
$thousandSeparator = $data->getBaseProperty('money.thousandSeparator');
if (is_null($decimalSeparator)) {
$decimalSeparator = $data->trlcKwf('decimal separator', ".");
}
if (is_null($thousandSeparator)) {
$thousandSeparator = $data->trlcKwf('thousands separator', ",");
}
} else {
$format = Kwf_Config::getValue('money.format');
$decimals = Kwf_Config::getValue('money.decimals');
$decimalSeparator = trlcKwf('decimal separator', ".");
$thousandSeparator = trlcKwf('thousands separator', ",");
}
$number = number_format($amount, $decimals, $decimalSeparator, $thousandSeparator);
return str_replace('{0}', $number, $format);
}
示例7: getContent
public function getContent($includeMaster)
{
if ($this->_data->getBaseProperty('preLogin')) {
$ignore = false;
foreach (Kwf_Config::getValueArray('preLoginIgnoreIp') as $i) {
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip == $i) {
$ignore = true;
}
if (!$ignore && substr($i, -1) == '*') {
$i = substr($i, 0, -1);
if (substr($ip, 0, strlen($i)) == $i) {
$ignore = true;
}
}
if (!$ignore && substr($i, 0, 1) == '*') {
$i = substr($i, 1);
if (substr($ip, -strlen($i)) == $i) {
$ignore = true;
}
}
}
Kwf_Setup::checkPreLogin($this->_data->getBaseProperty('preLoginUser'), $this->_data->getBaseProperty('preLoginPassword'));
}
$benchmarkEnabled = Kwf_Benchmark::isEnabled();
if ($benchmarkEnabled) {
$startTime = microtime(true);
}
$process = $this->_getProcessInputComponents($includeMaster);
if ($benchmarkEnabled) {
Kwf_Benchmark::subCheckpoint('getProcessInputComponents', microtime(true) - $startTime);
}
self::_callProcessInput($process);
if ($benchmarkEnabled) {
Kwf_Benchmark::checkpoint('processInput');
}
$ret = array();
$hasDynamicParts = false;
$ret['content'] = $this->_render($includeMaster, $hasDynamicParts);
if ($benchmarkEnabled) {
Kwf_Benchmark::checkpoint('render');
}
$ret['mimeType'] = 'text/html; charset=utf-8';
if (!$includeMaster) {
$assetsBox = $this->_data->getChildComponent('-assets');
if ($assetsBox) {
$ret['assets'] = $assetsBox->render(null, false, $hasDynamicParts);
} else {
$ret['assets'] = '';
}
}
if (!$hasDynamicParts) {
$ret['lifetime'] = 60 * 60;
}
self::_callPostProcessInput($process);
if ($benchmarkEnabled) {
Kwf_Benchmark::checkpoint('postProcessInput');
}
return $ret;
}
示例8: getInstance
public static function getInstance()
{
static $i;
if (!isset($i)) {
if (Kwf_Config::getValue('server.aws')) {
throw new Kwf_Exception_NotYetImplemented("using counter on multiple servers is not yet implemented");
}
if (extension_loaded('apc')) {
if (function_exists('apc_inc')) {
//apc >= 3.1.1
$i = new Kwf_Benchmark_Counter_Apc();
} else {
//kein memcache-fallback, da der dann *nur* für den counter verwendet werden würde
$i = new Kwf_Benchmark_Counter_File();
}
} else {
if (class_exists('Memcache')) {
$i = new Kwf_Benchmark_Counter_Memcache();
} else {
$i = new Kwf_Benchmark_Counter_File();
}
}
}
return $i;
}
示例9: indexAction
public function indexAction()
{
$ok = false;
foreach (Kwf_Config::getValueArray('debug.benchmarkCounterAccessIp') as $i) {
if (substr($i, -1) == '*') {
$i = substr($i, 0, -1);
if (substr($_SERVER['REMOTE_ADDR'], 0, strlen($i)) == $i) {
$ok = true;
}
} else {
if ($_SERVER['REMOTE_ADDR'] == $i) {
$ok = true;
}
}
}
if (!$ok) {
throw new Kwf_Exception_AccessDenied();
}
$names = array('content-requests', 'asset-requests', 'media-requests', 'admin-requests', 'fullpage-hit', 'fullpage-miss', 'dbqueries', 'render-hit', 'render-miss', 'render-noviewcache', 'viewcache-mem', 'viewcache-db', 'viewcache-miss', 'viewcache-delete-page', 'viewcache-delete-component', 'viewcache-delete-master', 'viewcache-delete-partial', 'viewcache-delete-componentLink', 'viewcache-delete-fullPage');
$out = array();
$load = @file_get_contents('/proc/loadavg');
$load = explode(' ', $load);
$out['load'] = (double) $load[0];
foreach ($names as $name) {
$out[$name] = Kwf_Benchmark_Counter::getInstance()->getValue($name);
}
echo json_encode($out);
exit;
}
示例10: _getRedirectPage
protected function _getRedirectPage()
{
if (!Kwf_Config::getValue('fbAppData.pageTabUrl')) {
throw new Kwf_Exception('kwc.fbApp.Data.pageTabUrl has to be set in config');
}
return Kwf_Config::getValue('fbAppData.pageTabUrl');
}
示例11: clean
public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
switch ($mode) {
case Zend_Cache::CLEANING_MODE_ALL:
$ret = true;
if (PHP_SAPI == 'cli') {
if (Kwf_Config::getValue('externalClearCacheScript')) {
throw new Kwf_Exception("Dont't delete complete apc-user cache via cli.");
}
$ret = Kwf_Util_Apc::callClearCacheByCli(array('type' => 'user'));
}
if (extension_loaded('apcu')) {
return $ret && apc_clear_cache('user');
} else {
return $ret && apc_clear_cache();
}
break;
case Zend_Cache::CLEANING_MODE_OLD:
$this->_log("Zend_Cache_Backend_Apc::clean() : CLEANING_MODE_OLD is unsupported by the Apc backend");
break;
case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
$this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_APC_BACKEND);
break;
default:
Zend_Cache::throwException('Invalid mode for clean() method');
break;
}
}
示例12: getTemplateVars
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer)
{
$ret = parent::getTemplateVars($renderer);
$ret['settingsRow'] = $this->_getRow();
$ret['tableStyle'] = $this->_getRow()->table_style;
$ret['columnCount'] = $this->getColumnCount();
if (Kwf_Config::getValue('kwc.responsive')) {
$ret['rootElementClass'] .= ' responsive' . ucfirst($this->_getRow()->responsive_style);
}
$dataSelect = new Kwf_Model_Select();
$dataSelect->whereEquals('visible', 1);
$dataSelect->order('pos', 'ASC');
$ret['dataRows'] = array();
$rows = $this->_getRow()->getChildRows('tableData', $dataSelect);
foreach ($rows as $row) {
$rowData = array();
$rowData['cssStyle'] = $row->css_style;
$rowData['data'] = array();
for ($i = 1; $i <= $ret['columnCount']; $i++) {
$rowData['data']['column' . $i] = array('value' => $row->{'column' . $i}, 'cssClass' => '');
}
$ret['dataRows'][] = $rowData;
}
$ret['dataRows'] = Kwc_Basic_Table_Component::addDefaultCssClasses($ret['dataRows'], $this->_getSetting('rowStyles'));
$ret['headerRows'] = array();
if (isset($ret['dataRows'][0]['htmlTag']) && $ret['dataRows'][0]['htmlTag'] == 'th') {
$ret['headerRows'] = array(array_shift($ret['dataRows']));
}
return $ret;
}
示例13: getTemplateVars
public function getTemplateVars($values, $fieldNamePostfix = '', $idPrefix = '')
{
$ret = parent::getTemplateVars($values, $fieldNamePostfix, $idPrefix);
require_once 'vendor/koala-framework/recaptcha-php/recaptchalib.php';
$ret['html'] = "<div data-fieldname=\"" . $this->getFieldName() . $fieldNamePostfix . "\">" . recaptcha_get_html(Kwf_Config::getValue('recaptcha.publicKey')) . "</div>";
return $ret;
}
示例14: _render
protected function _render($includeMaster, &$hasDynamicParts)
{
$lightboxContent = $this->_data->render(null, false, $hasDynamicParts);
$kwfUniquePrefix = Kwf_Config::getValue('application.uniquePrefix');
if ($kwfUniquePrefix) {
$kwfUniquePrefix = $kwfUniquePrefix . '-';
}
if ($includeMaster) {
$parent = $this->_getParent();
$parentContentSender = Kwc_Abstract::getSetting($parent->componentClass, 'contentSender');
$parentContentSender = new $parentContentSender($parent);
$parentContent = $parentContentSender->_render($includeMaster, $hasDynamicParts);
//remove main content to avoid duplicate content for search engines
//content will be loaded using ajax
$startPos = strpos($parentContent, '<main class="' . $kwfUniquePrefix . 'kwfMainContent">');
$endPos = strpos($parentContent, '</main><!--/' . $kwfUniquePrefix . 'kwfMainContent-->');
$parentContent = substr($parentContent, 0, $startPos) . '<main class="' . $kwfUniquePrefix . 'kwfMainContent" data-kwc-component-id="' . $parent->componentId . '">' . substr($parentContent, $endPos);
foreach ($this->_data->getRecursiveChildComponents(array('flag' => 'hasInjectIntoRenderedHtml')) as $component) {
$box = $component;
$isInBox = false;
while (!$isInBox && $box) {
if (isset($box->box)) {
$isInBox = true;
}
$box = $box->parent;
}
if ($isInBox) {
$parentContent = $component->getComponent()->injectIntoRenderedHtml($parentContent);
}
}
//append lightbox after <body> in parent
$options = $this->_getOptions();
$style = '';
if (isset($options['width'])) {
$style .= "width: {$options['width']}px;";
}
if (isset($options['height'])) {
$style .= "height: {$options['height']}px";
}
$class = $kwfUniquePrefix . 'kwfLightbox';
$class .= " " . $kwfUniquePrefix . "kwfLightbox{$options['style']}";
if (isset($options['cssClass'])) {
$class .= " {$options['cssClass']}";
}
if (isset($options['adaptHeight']) && $options['adaptHeight']) {
$class .= " adaptHeight";
}
$options = htmlspecialchars(json_encode($options));
$lightboxContent = "<div class=\"{$class} " . $kwfUniquePrefix . "kwfLightboxOpen\">\n" . " <div class=\"" . $kwfUniquePrefix . "kwfLightboxScrollOuter\">\n" . " <div class=\"" . $kwfUniquePrefix . "kwfLightboxScroll\">\n" . " <div class=\"" . $kwfUniquePrefix . "kwfLightboxBetween\">\n" . " <div class=\"" . $kwfUniquePrefix . "kwfLightboxBetweenInner\">\n" . " <div class=\"" . $kwfUniquePrefix . "kwfLightboxInner\" style=\"{$style}\">\n" . " <input type=\"hidden\" class=\"options\" value=\"{$options}\" />\n" . " <div class=\"" . $kwfUniquePrefix . "kwfLightboxContent\">\n" . " {$lightboxContent}\n" . " </div>\n" . " <a class=\"" . $kwfUniquePrefix . "closeButton\" href=\"{$parent->url}\"><span class=\"" . $kwfUniquePrefix . "innerCloseButton\">" . $this->_data->trlKwf('Close') . "</span></a>\n" . " </div>\n" . " </div>\n" . " </div>\n" . " </div>\n" . " <div class=\"" . $kwfUniquePrefix . "kwfLightboxMask " . $kwfUniquePrefix . "kwfLightboxMaskOpen\"></div>\n" . " </div>\n" . "</div>\n";
$ret = preg_replace('#(<body[^>]*>)#', "\\1\n" . $lightboxContent, $parentContent);
if (preg_match('#<html[^>]* class#', $ret)) {
$ret = preg_replace('#(<html[^>]*?)( class="([^"]*)")#', "\\1 class=\"\\3 " . $kwfUniquePrefix . "kwfLightboxActive\"", $ret);
} else {
$ret = preg_replace('#(<html[^>]*)#', "\\1 class=\"\\3" . $kwfUniquePrefix . "kwfLightboxActive\"", $ret);
}
return $ret;
} else {
return $lightboxContent;
}
}
示例15: money
public function money($amount)
{
$component = null;
if (isset($this->_view) && $this->_view && $this->_view->data && $this->_view->data instanceof Kwf_Component_Data) {
$component = $this->_view->data;
}
if ($component) {
$format = $component->getBaseProperty('money.format');
$decimals = $component->getBaseProperty('money.decimals');
$decimalSeparator = $component->getBaseProperty('money.decimalSeparator');
$thousandSeparator = $component->getBaseProperty('money.thousandSeparator');
if (is_null($decimalSeparator)) {
$decimalSeparator = $component->trlcKwf('decimal separator', ".");
}
if (is_null($thousandSeparator)) {
$thousandSeparator = $component->trlcKwf('thousands separator', ",");
}
} else {
$format = Kwf_Config::getValue('money.format');
$decimals = Kwf_Config::getValue('money.decimals');
$decimalSeparator = trlcKwf('decimal separator', ".");
$thousandSeparator = trlcKwf('thousands separator', ",");
}
$number = number_format($amount, $decimals, $decimalSeparator, $thousandSeparator);
return str_replace('{0}', $number, $format);
}