예제 #1
0
파일: Theme.php 프로젝트: eadz/chyrp
 /**
  * Function: __construct
  * Loads the Twig parser into <Theme>, and sets up the theme l10n domain.
  */
 private function __construct()
 {
     $config = Config::current();
     # Load the theme translator
     if (file_exists(THEME_DIR . "/locale/" . $config->locale . ".mo")) {
         load_translator("theme", THEME_DIR . "/locale/" . $config->locale . ".mo");
     }
     # Load the theme's info into the Theme class.
     foreach (YAML::load(THEME_DIR . "/info.yaml") as $key => $val) {
         $this->{$key} = $val;
     }
     $this->url = THEME_URL;
 }
예제 #2
0
파일: Admin.php 프로젝트: eadz/chyrp
 /**
  * Function: theme
  * Changes the admin theme.
  */
 public function change_admin_theme()
 {
     if (empty($_GET['theme'])) {
         error(__("No Theme Specified"), __("You did not specify a theme to switch to."));
     }
     $config = Config::current();
     $_SESSION['admin_theme'] = $_GET['theme'];
     if (file_exists(ADMIN_THEMES_DIR . "/" . $_GET['theme'] . "/locale/" . $config->locale . ".mo")) {
         load_translator($_GET['theme'], ADMIN_THEMES_DIR . "/" . $_GET['theme'] . "/locale/" . $config->locale . ".mo");
     }
     $info = YAML::load(ADMIN_THEMES_DIR . "/" . $_GET['theme'] . "/info.yaml");
     fallback($info["notifications"], array());
     foreach ($info["notifications"] as &$notification) {
         $notification = __($notification, $_GET['theme']);
     }
     foreach ($info["notifications"] as $message) {
         Flash::message($message);
     }
     # Clear the caches made by the previous theme.
     foreach (glob(INCLUDES_DIR . "/caches/*.cache") as $cache) {
         @unlink($cache);
     }
     Flash::notice(_f("Admin theme changed to &#8220;%s&#8221;.", array($info["name"])), "/admin/?action=themes");
 }
예제 #3
0
파일: common.php 프로젝트: prych/prych
$sql = SQL::current();
# Set the timezone for date(), etc.
set_timezone($config->timezone);
# Initialize connection to SQL server.
$sql->connect();
# Sanitize all input depending on magic_quotes_gpc's enabled status.
sanitize_input($_GET);
sanitize_input($_POST);
sanitize_input($_COOKIE);
sanitize_input($_REQUEST);
# Begin the session.
session();
# Set the locale for gettext.
set_locale($config->locale);
# Load the translation engine.
load_translator("chyrp", INCLUDES_DIR . "/locale/" . $config->locale . ".mo");
# Constant: PREVIEWING
# Is the user previewing a theme?
define('PREVIEWING', !ADMIN and !empty($_SESSION['theme']));
# Constant: THEME_DIR
# Absolute path to /themes/(current/previewed theme)
define('THEME_DIR', MAIN_DIR . "/themes/" . (PREVIEWING ? $_SESSION['theme'] : $config->theme));
# Constant: THEME_URL
# URL to /themes/(current/previewed theme)
define('THEME_URL', $config->chyrp_url . "/themes/" . (PREVIEWING ? $_SESSION['theme'] : $config->theme));
# Initialize the theme.
$theme = Theme::current();
# Load the Visitor.
$visitor = Visitor::current();
# Prepare the notifier.
$flash = Flash::current();
예제 #4
0
파일: helpers.php 프로젝트: homebru/bandb
/**
 * Function: init_extensions
 * Initialize all Modules and Feathers.
 */
function init_extensions()
{
    $config = Config::current();
    # Instantiate all Modules.
    foreach ($config->enabled_modules as $index => $module) {
        if (!file_exists(MODULES_DIR . "/" . $module . "/" . $module . ".php")) {
            unset($config->enabled_modules[$index]);
            continue;
        }
        if (file_exists(MODULES_DIR . "/" . $module . "/locale/" . $config->locale . ".mo")) {
            load_translator($module, MODULES_DIR . "/" . $module . "/locale/" . $config->locale . ".mo");
        }
        require MODULES_DIR . "/" . $module . "/" . $module . ".php";
        $camelized = camelize($module);
        if (!class_exists($camelized)) {
            continue;
        }
        Modules::$instances[$module] = new $camelized();
        Modules::$instances[$module]->safename = $module;
        foreach (YAML::load(MODULES_DIR . "/" . $module . "/info.yaml") as $key => $val) {
            Modules::$instances[$module]->{$key} = is_string($val) ? __($val, $module) : $val;
        }
    }
    # Instantiate all Feathers.
    foreach ($config->enabled_feathers as $index => $feather) {
        if (!file_exists(FEATHERS_DIR . "/" . $feather . "/" . $feather . ".php")) {
            unset($config->enabled_feathers[$index]);
            continue;
        }
        if (file_exists(FEATHERS_DIR . "/" . $feather . "/locale/" . $config->locale . ".mo")) {
            load_translator($feather, FEATHERS_DIR . "/" . $feather . "/locale/" . $config->locale . ".mo");
        }
        require FEATHERS_DIR . "/" . $feather . "/" . $feather . ".php";
        $camelized = camelize($feather);
        if (!class_exists($camelized)) {
            continue;
        }
        Feathers::$instances[$feather] = new $camelized();
        Feathers::$instances[$feather]->safename = $feather;
        foreach (YAML::load(FEATHERS_DIR . "/" . $feather . "/info.yaml") as $key => $val) {
            Feathers::$instances[$feather]->{$key} = is_string($val) ? __($val, $feather) : $val;
        }
    }
    # Initialize all modules.
    foreach (Feathers::$instances as $feather) {
        if (method_exists($feather, "__init")) {
            $feather->__init();
        }
    }
    foreach (Modules::$instances as $module) {
        if (method_exists($module, "__init")) {
            $module->__init();
        }
    }
}
예제 #5
0
파일: ajax.php 프로젝트: vito/chyrp-site
 case "enable_feather":
     $type = $_POST['action'] == "enable_module" ? "module" : "feather";
     if (!$visitor->group->can("change_settings")) {
         if ($type == "module") {
             exit("{ notifications: ['" . __("You do not have sufficient privileges to enable/disable modules.") . "'] }");
         } else {
             exit("{ notifications: ['" . __("You do not have sufficient privileges to enable/disable feathers.") . "'] }");
         }
     }
     if ($type == "module" and module_enabled($_POST['extension']) or $type == "feather" and feather_enabled($_POST['extension'])) {
         exit("{ notifications: [] }");
     }
     $enabled_array = $type == "module" ? "enabled_modules" : "enabled_feathers";
     $folder = $type == "module" ? MODULES_DIR : FEATHERS_DIR;
     if (file_exists($folder . "/" . $_POST["extension"] . "/locale/" . $config->locale . ".mo")) {
         load_translator($_POST["extension"], $folder . "/" . $_POST["extension"] . "/locale/" . $config->locale . ".mo");
     }
     $info = YAML::load($folder . "/" . $_POST["extension"] . "/info.yaml");
     fallback($info["uploader"], false);
     fallback($info["notifications"], array());
     foreach ($info["notifications"] as &$notification) {
         $notification = addslashes(__($notification, $_POST["extension"]));
     }
     require $folder . "/" . $_POST["extension"] . "/" . $_POST["extension"] . ".php";
     if ($info["uploader"]) {
         if (!file_exists(MAIN_DIR . $config->uploads_path)) {
             $info["notifications"][] = _f("Please create the <code>%s</code> directory at your Chyrp install's root and CHMOD it to 777.", array($config->uploads_path));
         } elseif (!is_writable(MAIN_DIR . $config->uploads_path)) {
             $info["notifications"][] = _f("Please CHMOD <code>%s</code> to 777.", array($config->uploads_path));
         }
     }
예제 #6
0
파일: upgrade.php 프로젝트: homebru/bandb
    Config::$yaml["config"] = YAML::load(preg_replace("/<\\?php(.+)\\?>\n?/s", "", file_get_contents(config_file())));
    if (database_file()) {
        Config::$yaml["database"] = YAML::load(preg_replace("/<\\?php(.+)\\?>\n?/s", "", file_get_contents(database_file())));
    } else {
        Config::$yaml["database"] = oneof(@Config::$yaml["config"]["sql"], array());
    }
} else {
    # $config and $sql here are loaded from the eval()'s above.
    foreach ($config as $name => $val) {
        Config::$yaml["config"][$name] = $val;
    }
    foreach ($sql as $name => $val) {
        Config::$yaml["database"][$name] = $val;
    }
}
load_translator("chyrp", INCLUDES_DIR . "/locale/" . Config::get("locale") . ".mo");
/**
 * Function: test
 * Attempts to perform a task, and displays a "success" or "failed" message determined by the outcome.
 *
 * Parameters:
 *     $try - The task to attempt. Should return something that evaluates to true or false.
 *     $message - Message to display for the test.
 */
function test($try, $message = "")
{
    $sql = SQL::current();
    if (!empty($sql->error)) {
        $message .= "\n" . $sql->error . "\n\n";
        $sql->error = "";
    }
예제 #7
0
파일: Admin.php 프로젝트: homebru/bandb
 /**
  * Function: change_theme
  * Changes the theme.
  */
 public function change_theme()
 {
     if (!Visitor::current()->group->can("change_settings")) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to change settings."));
     }
     if (empty($_GET['theme'])) {
         error(__("No Theme Specified"), __("You did not specify a theme to switch to."));
     }
     $config = Config::current();
     $config->set("theme", $_GET['theme']);
     if (file_exists(THEMES_DIR . "/" . $_GET['theme'] . "/locale/" . $config->locale . ".mo")) {
         load_translator($_GET['theme'], THEMES_DIR . "/" . $_GET['theme'] . "/locale/" . $config->locale . ".mo");
     }
     $info = YAML::load(THEMES_DIR . "/" . $_GET['theme'] . "/info.yaml");
     fallback($info["notifications"], array());
     foreach ($info["notifications"] as &$notification) {
         $notification = __($notification, $_GET['theme']);
     }
     foreach ($info["notifications"] as $message) {
         Flash::message($message);
     }
     # Clear the caches made by the previous theme.
     foreach (glob(INCLUDES_DIR . "/caches/*.cache") as $cache) {
         @unlink($cache);
     }
     Flash::notice(_f("Theme changed to &#8220;%s&#8221;.", array($info["name"])), "/admin/?action=themes");
 }