$theme = $a->argv[2];
if (is_file("view/theme/$theme/config.php")) {
- $orig_theme = $a->theme;
+ $orig_theme = Renderer::$theme;
$orig_page = $a->page;
$orig_session_theme = $_SESSION['theme'];
require_once "view/theme/$theme/theme.php";
}
$_SESSION['theme'] = $orig_session_theme;
- $a->theme = $orig_theme;
+ Renderer::$theme = $orig_theme;
$a->page = $orig_page;
}
$admin_form = '';
if (is_file("view/theme/$theme/config.php")) {
- $orig_theme = $a->theme;
+ $orig_theme = Renderer::$theme;
$orig_page = $a->page;
$orig_session_theme = $_SESSION['theme'];
require_once "view/theme/$theme/theme.php";
}
$_SESSION['theme'] = $orig_session_theme;
- $a->theme = $orig_theme;
+ Renderer::$theme = $orig_theme;
$a->page = $orig_page;
}
$this->footerScripts[] = trim($url, '/');
}
- /**
- * @brief An array for all theme-controllable parameters
- *
- * Mostly unimplemented yet. Only options 'template_engine' and
- * beyond are used.
- */
- public $theme = [
- 'sourcename' => '',
- 'videowidth' => 425,
- 'videoheight' => 350,
- 'force_max_items' => 0,
- 'stylesheet' => '',
- 'template_engine' => 'smarty3',
- ];
-
- /**
- * @brief An array of registered template engines ('name'=>'class name')
- */
- public $template_engines = [];
-
- /**
- * @brief An array of instanced template engines ('name'=>'instance')
- */
- public $template_engine_instance = [];
public $process_id;
public $queue;
private $scheme;
$this->isAjax = strtolower(defaults($_SERVER, 'HTTP_X_REQUESTED_WITH', '')) == 'xmlhttprequest';
// Register template engines
- $this->registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine');
+ Core\Renderer::registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine');
}
/**
$this->page['title'] = $this->config['sitename'];
}
- if (!empty($this->theme['stylesheet'])) {
- $stylesheet = $this->theme['stylesheet'];
+ if (!empty(Core\Renderer::$theme['stylesheet'])) {
+ $stylesheet = Core\Renderer::$theme['stylesheet'];
} else {
$stylesheet = $this->getCurrentThemeStylesheetPath();
}
}
}
- /**
- * @brief Register template engine class
- *
- * @param string $class
- */
- private function registerTemplateEngine($class)
- {
- $v = get_class_vars($class);
- if (!empty($v['name'])) {
- $name = $v['name'];
- $this->template_engines[$name] = $class;
- } else {
- echo "template engine <tt>$class</tt> cannot be registered without a name.\n";
- die();
- }
- }
-
- /**
- * @brief Return template engine instance.
- *
- * If $name is not defined, return engine defined by theme,
- * or default
- *
- * @return object Template Engine instance
- */
- public function getTemplateEngine()
- {
- $template_engine = defaults($this->theme, 'template_engine', 'smarty3');
-
- if (isset($this->template_engines[$template_engine])) {
- if (isset($this->template_engine_instance[$template_engine])) {
- return $this->template_engine_instance[$template_engine];
- } else {
- $class = $this->template_engines[$template_engine];
- $obj = new $class;
- $this->template_engine_instance[$template_engine] = $obj;
- return $obj;
- }
- }
-
- echo "template engine <tt>$template_engine</tt> is not registered!\n";
- exit();
- }
-
- /**
- * @brief Returns the active template engine.
- *
- * @return string the active template engine
- */
- public function getActiveTemplateEngine()
- {
- return $this->theme['template_engine'];
- }
-
- /**
- * sets the active template engine
- *
- * @param string $engine the template engine (default is Smarty3)
- */
- public function setActiveTemplateEngine($engine = 'smarty3')
- {
- $this->theme['template_engine'] = $engine;
- }
-
/**
* Saves a timestamp for a value - f.e. a call
* Necessary for profiling Friendica
*/
class Renderer extends BaseObject
{
+ /**
+ * @brief An array of registered template engines ('name'=>'class name')
+ */
+ public static $template_engines = [];
+
+ /**
+ * @brief An array of instanced template engines ('name'=>'instance')
+ */
+ public static $template_engine_instance = [];
+
+ /**
+ * @brief An array for all theme-controllable parameters
+ *
+ * Mostly unimplemented yet. Only options 'template_engine' and
+ * beyond are used.
+ */
+ public static $theme = [
+ 'sourcename' => '',
+ 'videowidth' => 425,
+ 'videoheight' => 350,
+ 'force_max_items' => 0,
+ 'stylesheet' => '',
+ 'template_engine' => 'smarty3',
+ ];
+
private static $ldelim = [
'internal' => '',
'smarty3' => '{{'
// pass $baseurl to all templates
$r['$baseurl'] = System::baseUrl();
- $t = $a->getTemplateEngine();
+ $t = self::getTemplateEngine();
try {
$output = $t->replaceMacros($s, $r);
{
$stamp1 = microtime(true);
$a = self::getApp();
- $t = $a->getTemplateEngine();
+ $t = self::getTemplateEngine();
try {
$template = $t->getTemplateFile($s, $root);
return $template;
}
+ /**
+ * @brief Register template engine class
+ *
+ * @param string $class
+ */
+ public static function registerTemplateEngine($class)
+ {
+ $v = get_class_vars($class);
+
+ if (!empty($v['name']))
+ {
+ $name = $v['name'];
+ self::$template_engines[$name] = $class;
+ } else {
+ echo "template engine <tt>$class</tt> cannot be registered without a name.\n";
+ die();
+ }
+ }
+
+ /**
+ * @brief Return template engine instance.
+ *
+ * If $name is not defined, return engine defined by theme,
+ * or default
+ *
+ * @return object Template Engine instance
+ */
+ public static function getTemplateEngine()
+ {
+ $template_engine = defaults(self::$theme, 'template_engine', 'smarty3');
+
+ if (isset(self::$template_engines[$template_engine])) {
+ if (isset(self::$template_engine_instance[$template_engine])) {
+ return self::$template_engine_instance[$template_engine];
+ } else {
+ $class = self::$template_engines[$template_engine];
+ $obj = new $class;
+ self::$template_engine_instance[$template_engine] = $obj;
+ return $obj;
+ }
+ }
+
+ echo "template engine <tt>$template_engine</tt> is not registered!\n";
+ exit();
+ }
+
+ /**
+ * @brief Returns the active template engine.
+ *
+ * @return string the active template engine
+ */
+ public static function getActiveTemplateEngine()
+ {
+ return self::$theme['template_engine'];
+ }
+
+ /**
+ * sets the active template engine
+ *
+ * @param string $engine the template engine (default is Smarty3)
+ */
+ public static function setActiveTemplateEngine($engine = 'smarty3')
+ {
+ self::$theme['template_engine'] = $engine;
+ }
+
/**
* Gets the right delimiter for a template engine
*
* load/reload current theme info
*/
- $a->setActiveTemplateEngine(); // reset the template engine to the default in case the user's theme doesn't specify one
+ Renderer::setActiveTemplateEngine(); // reset the template engine to the default in case the user's theme doesn't specify one
$theme_info_file = 'view/theme/' . $a->getCurrentTheme() . '/theme.php';
if (file_exists($theme_info_file)) {
// We overwrite current theme css, because during install we may not have a working mod_rewrite
// so we may not have a css at all. Here we set a static css file for the install procedure pages
- $a->theme['stylesheet'] = $a->getBaseURL() . '/view/install/style.css';
+ Renderer::$theme['stylesheet'] = $a->getBaseURL() . '/view/install/style.css';
self::$installer = new Core\Installer();
self::$currentWizardStep = defaults($_POST, 'pass', self::SYSTEM_CHECK);
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
+use Friendica\Core\Renderer;
function duepuntozero_init(App $a) {
-$a->setActiveTemplateEngine('smarty3');
+Renderer::setActiveTemplateEngine('smarty3');
$colorset = PConfig::get( local_user(), 'duepuntozero','colorset');
if (!$colorset)
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\PConfig;
+use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model;
$a->theme_events_in_profile = false;
$a->videowidth = 622;
- $a->setActiveTemplateEngine('smarty3');
+ Renderer::setActiveTemplateEngine('smarty3');
$baseurl = System::baseUrl();
use Friendica\Core\System;
function smoothly_init(App $a) {
- $a->setActiveTemplateEngine('smarty3');
+ Renderer::setActiveTemplateEngine('smarty3');
$cssFile = null;
$ssl_state = null;
{
$a->theme_events_in_profile = false;
- $a->setActiveTemplateEngine('smarty3');
+ Renderer::setActiveTemplateEngine('smarty3');
if (!empty($a->argv[0]) && $a->argv[0] . defaults($a->argv, 1, '') === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
vier_community_info();