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; }
protected function _init() { parent::_init(); if (is_null($this->_useMobileBreakpoints)) { $this->_useMobileBreakpoints = Kwf_Config::getValue('kwc.mobileBreakpoints'); } }
/** * 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; }
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; }
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'); }
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; } }
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; }
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; } }
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; }
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; }
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); }
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); }
/** * @return Apache_Solr_Service */ private function _getSolrService($subroot) { static $i = array(); if (is_string($subroot) && $subroot) { $subroot = Kwf_Component_Data_Root::getInstance()->getComponentById($subroot, array('ignoreVisible' => true)); } // Create core names from subroot. e.g. root-at => at, root-ro-master => ro_master $subrootIds = array(); while ($subroot) { if (Kwc_Abstract::getFlag($subroot->componentClass, 'subroot')) { $subrootIds[] = $subroot->id; } $subroot = $subroot->parent; } $subrootId = implode('_', array_reverse($subrootIds)); if (!isset($i[$subrootId])) { $solr = Kwf_Config::getValueArray('fulltext.solr'); $path = $solr['path']; $subrootPart = $subrootId; if (!$subrootPart) { $subrootPart = 'root'; } $path = str_replace('%subroot%', $subrootPart, $path); $path = str_replace('%appid%', Kwf_Config::getValue('application.id'), $path); $i[$subrootId] = new Kwf_Util_Fulltext_Solr_Service($solr['host'], $solr['port'], $path); } return $i[$subrootId]; }
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; }
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; }
public function getContentsPacked() { if (!$this->_features) { return null; } $modernizrPath = getcwd() . '/node_modules/modernizr'; $outputFile = tempnam('./temp', 'modernizr'); $configAll = json_decode(file_get_contents($modernizrPath . '/lib/config-all.json'), true); $allFeatureDetects = $configAll['feature-detects']; $options = array(); foreach ($configAll['options'] as $i) { $options[$i] = false; } $options['mq'] = true; $options['setClasses'] = true; $featureDetects = array(); foreach ($this->_features as $f) { if (isset($options[strtolower($f)])) { //for prefixed $options[strtolower($f)] = true; } else { $filter = new Zend_Filter_Word_CamelCaseToSeparator('/'); $fFiltered = strtolower($filter->filter($f)); if (!in_array($fFiltered, $allFeatureDetects)) { throw new Kwf_Exception("Invalid Modernizr Dependency, test doesn't exist: '" . $f . "'"); } $featureDetects[] = $fFiltered; } } foreach ($options as $k => $i) { if (!$i) { unset($options[$k]); } } $options = array_keys($options); $classPrefix = ''; if (Kwf_Config::getValue('application.uniquePrefix')) { $classPrefix = Kwf_Config::getValue('application.uniquePrefix') . '-'; } $config = array('classPrefix' => $classPrefix, 'options' => $options, 'feature-detects' => $featureDetects); $configFile = tempnam('temp/', 'modernizrbuild'); unlink($configFile); $configFile .= '.json'; file_put_contents($configFile, json_encode($config, JSON_PRETTY_PRINT)); $cmd = getcwd() . "/" . VENDOR_PATH . "/bin/node {$modernizrPath}/bin/modernizr --config {$configFile} --uglify --dest " . $outputFile; exec($cmd, $out, $retVar); if ($retVar) { throw new Kwf_Exception("modernizr failed: " . implode("\n", $out)); } $ret = file_get_contents($outputFile); unlink($configFile); unlink($outputFile); //remove comments containing selected tests $ret = preg_replace("#\n/\\*!\n\\{.*?\\}\n!\\*/\n#s", '', $ret); $ret = Kwf_SourceMaps_SourceMap::createEmptyMap($ret); $map = $ret->getMapContentsData(false); $map->{'_x_org_koala-framework_masterFiles'} = array(getcwd() . '/node_modules/modernizr/package.json'); return $ret; }
public function getContents($language) { if (!Kwf_Config::getValue('ravenJs.dsn')) { throw new Kwf_Exception('ravenJS.dsn config setting is required'); } $data = array('dsn' => Kwf_Config::getValue('ravenJs.dsn')); return "Kwf.RavenJsConfig = " . json_encode($data) . ";"; }
protected function _clearCache($options) { if (Kwf_Config::getValue('cacheSimpleNamespace')) { $this->_output("change cacheSimpleNamespace config setting to clear"); } else { Kwf_Cache_Simple::_clear(); } }
public function getMaxTime() { $ret = parent::getMaxTime(); if ($value = Kwf_Config::getValue('maintenanceJobs.pageMetaRebuildMaxTime')) { $ret = $value; } return $ret; }
protected function _clearCache($options) { if (!Kwf_Config::getValue('debug.componentCache.clearOnClearCache')) { $this->_output("skipped: (won't delete, use clear-view-cache to clear)\n"); return; } Kwf_Component_Cache::getInstance()->deleteViewCache(new Kwf_Model_Select()); }
public function setUp() { if (!Kwf_Config::getValue('aws.key') || !Kwf_Config::getValue('aws.secret')) { $this->markTestSkipped(); } Kwf_Registry::get('config')->aws->uploadsBucket = 'kwf-test'; Kwf_Config::deleteValueCache('aws.uploadsBucket'); }
/** * Helper function that returns scaled and croped images for media output * * Used by image components in getMediaOutput. * Tries to avoid scaling if not required (to keep gif animation intact) */ public static function getMediaOutputForDimension($data, $dim, $type) { if (isset($data['url'])) { $file = Kwf_Config::getValue('mediaCacheDir') . '/remotefile_' . md5($data['url']); if (!is_file($file)) { $httpClientConfig = array('timeout' => 20, 'persistent' => false); if (Kwf_Config::getValue('http.proxy.host')) { $httpClientConfig['adapter'] = 'Zend_Http_Client_Adapter_Proxy'; $httpClientConfig['proxy_host'] = Kwf_Config::getValue('http.proxy.host'); $httpClientConfig['proxy_port'] = Kwf_Config::getValue('http.proxy.port'); } $httpClient = new Zend_Http_Client($data['url'], $httpClientConfig); $request = $httpClient->request(); if ($request->getStatus() == 200) { file_put_contents($file, $request->getBody()); if (!getimagesize($file)) { unlink($file); throw new Kwf_Exception('File is no image: ' . $data['url']); } } else { throw new Kwf_Exception('Could not download file: ' . $data['url']); } } $data['file'] = $file; } // calculate output width/height on base of getImageDimensions and given width $width = substr($type, strlen(Kwf_Media::DONT_HASH_TYPE_PREFIX)); $width = substr($width, 0, strpos($width, '-')); if ($width) { $width = Kwf_Media_Image::getResponsiveWidthStep($width, Kwf_Media_Image::getResponsiveWidthSteps($dim, isset($data['image']) ? $data['image'] : $data['file'])); $dim['height'] = $width / $dim['width'] * $dim['height']; $dim['width'] = $width; } $ret = array(); if (isset($data['image'])) { $output = Kwf_Media_Image::scale($data['image'], $dim); $ret['contents'] = $output; } else { $sourceSize = @getimagesize($data['file']); $scalingNeeded = true; $resultingSize = Kwf_Media_Image::calculateScaleDimensions($data['file'], $dim); if ($sourceSize && array($resultingSize['crop']['width'], $resultingSize['crop']['height']) == array($sourceSize[0], $sourceSize[1]) && array($resultingSize['width'], $resultingSize['height']) == array($sourceSize[0], $sourceSize[1])) { $scalingNeeded = false; } if ($scalingNeeded) { //NOTE: don't pass actual size of the resulting image, scale() will calculate that on it's own //else size is calculated twice and we get rounding errors $uploadId = isset($data['uploadId']) ? $data['uploadId'] : null; $output = Kwf_Media_Image::scale($data['file'], $dim, $uploadId); $ret['contents'] = $output; } else { $ret['file'] = $data['file']; } } $ret['mimeType'] = $data['mimeType']; $ret['mtime'] = filemtime($data['file']); return $ret; }
public function jsonRebuildAction() { if (!Kwf_Config::getValue('server.phpCli')) { throw new Kwf_Exception_Client("Not (yet?) supported without phpCli"); } $cmd = Kwf_Config::getValue('server.phpCli') . " bootstrap.php fulltext rebuild --silent"; $procData = Kwf_Util_BackgroundProcess::start($cmd, $this->view); $this->view->assign($procData); }
public static function getInstance() { static $i; if (!isset($i)) { $be = Kwf_Config::getValue('fulltext.backend'); $i = new $be(); } return $i; }
public static function getInstance() { static $i; if (!isset($i)) { $logger = Kwf_Config::getValue('debug.exceptionLogger'); $i = new $logger(); } return $i; }
public function render($ignoreCli = false) { if (!Kwf_Registry::get('config')->setupFinished) { echo "<h1>" . Kwf_Config::getValue('application.name') . "</h1>\n"; echo "<a href=\"" . Kwf_Setup::getBaseUrl() . "/kwf/maintenance/setup\">[start setup]</a>\n"; exit; } parent::render($ignoreCli); }
public function getContentsPacked() { if (!Kwf_Config::getValue('ravenJs.dsn')) { throw new Kwf_Exception('ravenJS.dsn config setting is required'); } $data = array('dsn' => Kwf_Config::getValue('ravenJs.dsn')); $ret = "Kwf.RavenJsConfig = " . json_encode($data) . ";"; return Kwf_SourceMaps_SourceMap::createEmptyMap($ret); }
public static function getMetaTagsForData($data) { $ret = array(); if (Kwf_Config::getValue('application.kwf.name') == 'Koala Framework') { $ret['generator'] = 'Koala Web Framework CMS'; } if ($data->getPage()) { if (Kwc_Abstract::getFlag($data->getPage()->componentClass, 'metaTags')) { foreach ($data->getPage()->getComponent()->getMetaTags() as $name => $content) { if (!isset($ret[$name])) { $ret[$name] = ''; } //TODO: for eg noindex,nofollow other separator $ret[$name] .= ' ' . $content; } } if (Kwc_Abstract::getFlag($data->getPage()->componentClass, 'noIndex')) { if (isset($ret['robots'])) { $ret['robots'] .= ','; } else { $ret['robots'] = ''; } $ret['robots'] .= 'noindex'; } } foreach ($ret as &$i) { $i = trim($i); } unset($i); // verify-v1 if (isset($_SERVER['HTTP_HOST'])) { $host = $_SERVER['HTTP_HOST']; } else { $host = Kwf_Config::getValue('server.domain'); } $hostParts = explode('.', $host); if (count($hostParts) < 2) { $configDomain = $host; } else { $shortParts = array('com', 'co', 'gv', 'or'); if (count($hostParts) > 2 & in_array($hostParts[count($hostParts) - 2], $shortParts)) { $hostParts[count($hostParts) - 2] = $hostParts[count($hostParts) - 3] . $hostParts[count($hostParts) - 2]; } $configDomain = $hostParts[count($hostParts) - 2] . $hostParts[count($hostParts) - 1]; // zB 'com' } $configVerify = Kwf_Config::getValueArray('verifyV1'); if ($configVerify && isset($configVerify[$configDomain])) { $ret['verify-v1'] = $configVerify[$configDomain]; } $configVerify = Kwf_Config::getValueArray('googleSiteVerification'); if ($configVerify && isset($configVerify[$configDomain])) { $ret['google-site-verification'] = $configVerify[$configDomain]; } return $ret; }
protected function _init() { parent::_init(); $this->insertBefore('content', new Kwf_Form_Field_TextField('name', trlKwfStatic('Name')))->setAllowBlank(false)->setWidth(300); $this->insertAfter('name', new Kwf_Form_Field_TextField('email', trlKwfStatic('E-Mail')))->setVtype('email')->setWidth(300); $this->fields['content']->setFieldLabel(trlKwfStatic('Comment')); if (Kwf_Config::getValue('recaptcha.privateKey')) { $this->insertAfter('content', new Kwf_Form_Field_Recaptcha('captcha', trlKwfStatic('Captcha'))); } }
protected function _refreshCache($options) { $cmd = Kwf_Config::getValue('server.phpCli') . ' bootstrap.php process-control restart --silent 2>&1'; exec($cmd, $out, $ret); if ($ret) { throw new Kwf_Exception("restart failed:\n" . implode("\n", $out)); } else { $this->_output(implode("\n", $out)); } }