X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FApp.php;h=2330bc118586026f119e80c0c3a5596d171a58f4;hb=27d94023eef0263a3ce9750f79a73ac941a25304;hp=ae914ba6050fdaa2de553f9ed14a0b12226b7a28;hpb=ad88b6e3af2489bf8da8f423142418b9c57d58ac;p=friendica.git diff --git a/src/App.php b/src/App.php index ae914ba605..2330bc1185 100644 --- a/src/App.php +++ b/src/App.php @@ -1,9 +1,12 @@ performance['start'] = microtime(true); $this->performance['database'] = 0; $this->performance['database_write'] = 0; + $this->performance['cache'] = 0; + $this->performance['cache_write'] = 0; $this->performance['network'] = 0; $this->performance['file'] = 0; $this->performance['rendering'] = 0; @@ -154,6 +159,8 @@ class App $this->callstack['database'] = []; $this->callstack['database_write'] = []; + $this->callstack['cache'] = []; + $this->callstack['cache_write'] = []; $this->callstack['network'] = []; $this->callstack['file'] = []; $this->callstack['rendering'] = []; @@ -285,12 +292,7 @@ class App $this->is_friendica_app = ($_SERVER['HTTP_USER_AGENT'] == 'Apache-HttpClient/UNAVAILABLE (java 1.4)'); // Register template engines - $dc = get_declared_classes(); - foreach ($dc as $k) { - if (in_array('Friendica\Render\ITemplateEngine', class_implements($k))) { - $this->register_template_engine($k); - } - } + $this->register_template_engine('Friendica\Render\FriendicaSmartyEngine'); self::$a = $this; } @@ -512,9 +514,9 @@ class App '$baseurl' => $this->get_baseurl(), '$local_user' => local_user(), '$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION, - '$delitem' => t('Delete this item?'), - '$showmore' => t('show more'), - '$showfewer' => t('show fewer'), + '$delitem' => L10n::t('Delete this item?'), + '$showmore' => L10n::t('show more'), + '$showfewer' => L10n::t('show fewer'), '$update_interval' => $interval, '$shortcut_icon' => $shortcut_icon, '$touch_icon' => $touch_icon, @@ -599,7 +601,7 @@ class App $this->template_engines[$name] = $class; } else { echo "template engine $class cannot be registered without a name.\n"; - killme(); + die(); } } @@ -942,4 +944,116 @@ class App return true; } + + /** + * @param string $cat Config category + * @param string $k Config key + * @param mixed $default Default value if it isn't set + */ + public function getConfigValue($cat, $k, $default = null) + { + $return = $default; + + if ($cat === 'config') { + if (isset($this->config[$k])) { + $return = $this->config[$k]; + } + } else { + if (isset($this->config[$cat][$k])) { + $return = $this->config[$cat][$k]; + } + } + + return $return; + } + + /** + * Sets a value in the config cache. Accepts raw output from the config table + * + * @param string $cat Config category + * @param string $k Config key + * @param mixed $v Value to set + */ + public function setConfigValue($cat, $k, $v) + { + // Only arrays are serialized in database, so we have to unserialize sparingly + $value = is_string($v) && preg_match("|^a:[0-9]+:{.*}$|s", $v) ? unserialize($v) : $v; + + if ($cat === 'config') { + $this->config[$k] = $value; + } else { + $this->config[$cat][$k] = $value; + } + } + + /** + * Deletes a value from the config cache + * + * @param string $cat Config category + * @param string $k Config key + */ + public function deleteConfigValue($cat, $k) + { + if ($cat === 'config') { + if (isset($this->config[$k])) { + unset($this->config[$k]); + } + } else { + if (isset($this->config[$cat][$k])) { + unset($this->config[$cat][$k]); + } + } + } + + + /** + * Retrieves a value from the user config cache + * + * @param int $uid User Id + * @param string $cat Config category + * @param string $k Config key + * @param mixed $default Default value if key isn't set + */ + public function getPConfigValue($uid, $cat, $k, $default = null) + { + $return = $default; + + if (isset($this->config[$uid][$cat][$k])) { + $return = $this->config[$uid][$cat][$k]; + } + + return $return; + } + + /** + * Sets a value in the user config cache + * + * Accepts raw output from the pconfig table + * + * @param int $uid User Id + * @param string $cat Config category + * @param string $k Config key + * @param mixed $v Value to set + */ + public function setPConfigValue($uid, $cat, $k, $v) + { + // Only arrays are serialized in database, so we have to unserialize sparingly + $value = is_string($v) && preg_match("|^a:[0-9]+:{.*}$|s", $v) ? unserialize($v) : $v; + + $this->config[$uid][$cat][$k] = $value; + } + + /** + * Deletes a value from the user config cache + * + * @param int $uid User Id + * @param string $cat Config category + * @param string $k Config key + */ + public function deletePConfigValue($uid, $cat, $k) + { + if (isset($this->config[$uid][$cat][$k])) { + unset($this->config[$uid][$cat][$k]); + } + } }