1) ? $theme[1] : ''); $opts = ((App::$profile_uid) ? '?f=&puid=' . App::$profile_uid : ''); $schema_str = ((x(App::$layout, 'schema')) ? '&schema=' . App::$layout['schema'] : ''); if (($s) && (!$schema_str)) { $schema_str = '&schema=' . $s; } $opts .= $schema_str; if (file_exists('view/theme/' . $t . '/php/style.php')) { return ('/view/theme/' . $t . '/php/style.pcss' . $opts); } return ('/view/theme/' . $t . '/css/style.css'); } public static function include($file, $root = '') { // Make sure $root ends with a slash / if it's not blank if ($root) { $root = rtrim($root,'/') . '/'; } $theme_info = App::$theme_info; if (array_key_exists('extends', $theme_info)) { $parent = $theme_info['extends']; } else { $parent = 'NOPATH'; } $theme = self::current(); $thname = $theme[0]; $ext = substr($file, strrpos($file, '.') + 1); $paths = [ "{$root}view/theme/$thname/$ext/$file", "{$root}view/theme/$parent/$ext/$file", "{$root}view/site/$ext/$file", "{$root}view/$ext/$file", ]; foreach ($paths as $p) { if (str_contains($p, 'NOPATH')) { continue; } if (file_exists($p)) { return $p; } } return ''; } public static function get_info($theme) { $info = null; $has_yaml = true; if (is_file("view/theme/$theme.yml")) { $info = Infocon::from_file("view/theme/$theme.yml"); } elseif (is_file("view/theme/$theme/php/theme.php")) { $has_yaml = false; $info = Infocon::from_c_comment("view/theme/$theme/php/theme.php"); } if ($info && ! $has_yaml) { try { file_put_contents("view/theme/$theme.yml",Yaml::encode($info)); } catch (Exception $e) { } } return $info ?: [ 'name' => $theme ] ; } public static function get_email_template($s, $root = '') { $testroot = ($root=='') ? $testroot = "ROOT" : $root; $t = App::template_engine(); if (isset(App::$override_intltext_templates[$testroot][$s]["content"])) { return App::$override_intltext_templates[$testroot][$s]["content"]; } else { if (isset(App::$override_intltext_templates[$testroot][$s]["root"]) && isset(App::$override_intltext_templates[$testroot][$s]["file"])) { $s = App::$override_intltext_templates[$testroot][$s]["file"]; $root = App::$override_intltext_templates[$testroot][$s]["root"]; } elseif (App::$override_templateroot) { $newroot = App::$override_templateroot.$root; if ($newroot != '' && !str_ends_with($newroot, '/')) { $newroot .= '/'; } $template = $t->get_email_template($s, $newroot); } $template = $t->get_email_template($s, $root); return $template; } } public static function get_template($s, $root = '') { $testroot = ($root=='') ? $testroot = "ROOT" : $root; $t = App::template_engine(); if (isset(App::$override_markup_templates[$testroot][$s]["content"])) { return App::$override_markup_templates[$testroot][$s]["content"]; } else { if (isset(App::$override_markup_templates[$testroot][$s]["root"]) && isset(App::$override_markup_templates[$testroot][$s]["file"])) { $s = App::$override_markup_templates[$testroot][$s]["file"]; $root = App::$override_markup_templates[$testroot][$s]["root"]; } elseif (App::$override_templateroot) { $newroot = App::$override_templateroot.$root; if ($newroot != '' && !str_ends_with($newroot, '/')) { $newroot .= '/'; } $template = $t->get_template($s, $newroot); } $template = $t->get_template($s, $root); return $template; } } /** * @brief Returns the theme's screenshot. * * The screenshot is expected as view/theme/$theme/img/screenshot.[png|jpg]. * * @param string $theme The name of the theme * @return string */ public static function get_screenshot($theme) { $exts = ['.png', '.jpg']; foreach ($exts as $ext) { if (file_exists('view/theme/' . $theme . '/img/screenshot' . $ext)) { return(z_root() . '/view/theme/' . $theme . '/img/screenshot' . $ext); } } return(z_root() . '/images/blank.png'); } public static function debug() { logger('system_theme: ' . self::$system_theme); logger('session_theme: ' . self::$session_theme); } }