/** * Array von Javascript-Variablen, welche in Editor-Template genutzt werden * @return array */ public function getJsVars() { $editorStyles = array(array('title' => $this->language->translate('GLOBAL_SELECT'), 'value' => '')); $cache = new \fpcm\classes\cache('tinymce_plugins'); if ($cache->isExpired()) { $path = dirname(\fpcm\classes\loader::libGetFilePath('tinymce4', 'tinymce.min.js')); $path .= '/plugins/*'; $pluginFolders = implode(' ', array_map('basename', glob($path, GLOB_ONLYDIR))); $cache->write($pluginFolders, $this->config->system_cache_timeout); } else { $pluginFolders = $cache->read(); } $params = array('fpcmTinyMceLang' => $this->config->system_lang, 'fpcmTinyMceElements' => '~readmore', 'fpcmTinyMcePlugins' => $pluginFolders, 'fpcmTinyMceToolbar' => 'formatselect fontsizeselect | bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify outdent indent | subscript superscript table toc | bullist numlist | fpcm_readmore hr blockquote | link unlink anchor image media | emoticons charmap insertdatetime template | undo redo removeformat searchreplace fullscreen code restoredraft', 'fpcmTinyMceCssClasses' => array_merge($editorStyles, $this->getEditorStyles()), 'fpcmTinyMceLinkList' => $this->getEditorLinks(), 'fpcmTinyMceImageList' => $this->getFileList(), 'fpcmTinyMceTextpattern' => $this->getTextPatterns(), 'fpcmTinyMceDefaultFontsize' => $this->config->system_editor_fontsize, 'fpcmTinyMceReadmoreBlockHL' => $this->language->translate('EDITOR_HTML_BUTTONS_READMORE'), 'fpcmTinyMceTemplatesList' => $this->getTemplateDrafts(), 'fpcmTinyMceAutosavePrefix' => 'fpcm-editor-as-' . $this->session->getUserId()); return $this->events->runEvent('editorInitTinymce', $params); }
/** * Ersetzt gefundene Wörter/ Zeichenketten durch Ersetzungstext * @param string $text */ public function replaceItems($text) { $itemsCache = new \fpcm\classes\cache('wordbanItems'); $data = array('search' => array(), 'replace' => array()); if ($itemsCache->isExpired() || !is_array($itemsCache->read())) { $items = $this->dbcon->fetch($this->dbcon->select($this->table), true); if (!is_array($items) || !count($items)) { return $text; } foreach ($items as $value) { $data['search'] = $value->searchtext; $data['replace'] = $value->replacementtext; } $itemsCache->write($data); } else { $data = $itemsCache->read(); } return str_replace($data['search'], $data['replace'], $text); }
/** * Gibt installierte Module zurück * @return array */ public function getInstalledModules() { $cache = new \fpcm\classes\cache(__FUNCTION__, 'modules'); if (!$cache->isExpired()) { return $cache->read(); } $modules = $this->dbcon->fetch($this->dbcon->select($this->table, 'modkey'), true); $keys = array(); foreach ($modules as $module) { $keys[] = $module->modkey; } $cache->write($keys, $this->config->system_cache_timeout); return $keys; }
<?php /** * Combined JavaScript Files * @author Stefan Seehafer <*****@*****.**> * @copyright (c) 2011-2016, Stefan Seehafer * @license http://www.gnu.org/licenses/gpl.txt GPLv3 */ require_once dirname(dirname(__DIR__)) . '/inc/common.php'; $data = array('content' => '', 'filesize' => 0); $cache = new \fpcm\classes\cache('cssfiles', 'theme'); if ($cache->isExpired() || \fpcm\classes\baseconfig::installerEnabled() || FPCM_DEBUG) { $cssFiles = array(__DIR__ . '/style.css', __DIR__ . '/responsive.css', __DIR__ . '/icons.css'); foreach ($cssFiles as $cssFile) { $fileContent = '/* ' . \fpcm\model\files\ops::removeBaseDir($cssFile) . ' */' . PHP_EOL . file_get_contents($cssFile) . PHP_EOL . PHP_EOL; if (!$fileContent) { continue; } $data['content'] .= $fileContent; $data['filesize'] += filesize($cssFile); } $cache->write($data, FPCM_LANGCACHE_TIMEOUT); } else { $data = $cache->read(); } header("Content-Type: text/css"); if (!FPCM_NOJSCSSPHP_FILESIZE_HEADER) { header("Content-Length: " . $data['filesize']); } die($data['content']);
/** * Überschreibt systemweite Einstellungen mit Benutzer-Einstellungen * @return void */ public function setUserSettings() { if (!defined('FPCM_USERID') || !FPCM_USERID) { return false; } $cache2 = new \fpcm\classes\cache($this->cacheName . '_user' . FPCM_USERID, 'system'); $userData = $cache2->read(); if ($cache2->isExpired() || !$this->useCache || !is_array($userData)) { $userData = $this->dbcon->fetch($this->dbcon->select(\fpcm\classes\database::tableAuthors, 'id, usrmeta', 'id = ?', array(FPCM_USERID))); $userData = json_decode($userData->usrmeta, true); if (!is_array($userData)) { return false; } $cache2->write($userData, $this->system_cache_timeout); } foreach ($userData as $key => $value) { $this->data[$key] = $value; } if ($this->system_lang != \fpcm\classes\baseconfig::$fpcmLanguage->getLangCode()) { \fpcm\classes\baseconfig::$fpcmLanguage = new \fpcm\classes\language($this->system_lang); } }
/** * CLI: Cache Aktionen durchführen * @return bool */ public function processCache() { if (!isset($this->funcParams[1])) { $this->output('Invalid params detected, missing cache name or param "all"!'); return true; } $cacheName = $this->funcParams[1] === 'all' ? null : $this->funcParams[1]; $cacheModule = !isset($this->funcParams[2]) || $this->funcParams[2] === 'all' ? '' : $this->funcParams[2]; $cache = new \fpcm\classes\cache($cacheName, $cacheModule); if ($this->funcParams[0] === self::FPCMCLI_PARAM_CLEAN) { $cache->cleanup($cacheName === null ? false : $cacheName, $cacheModule); $this->output('Cache was cleared!'); return true; } if ($this->funcParams[0] === self::FPCMCLI_PARAM_INFO) { $this->output('Cache expiration interval: ' . date('Y-m-d H:i:s', $cache->getExpirationTime())); $this->output('Cache is expired: ' . (int) $cache->isExpired()); return true; } if ($this->funcParams[0] === self::FPCMCLI_PARAM_SIZE) { $this->output('Cache total size: ' . \fpcm\classes\tools::calcSize($cache->getSize())); return true; } if ($this->funcParams[0] === self::FPCMCLI_PARAM_LIST) { $this->output('Cache structur: '); $this->output($cache->getCacheComplete()); return true; } }