load() public static method

public static load ( $path )
Exemplo n.º 1
0
 /**
  * Function: __construct
  * See Also:
  *     <Model::grab>
  */
 public function __construct($version_id, $options = array())
 {
     if (!isset($version_id) and empty($options)) {
         return;
     }
     $options["left_join"][] = array("table" => "notes", "where" => "version_id = versions.id");
     $options["select"][] = "versions.*";
     $options["select"][] = "COUNT(notes.id) AS note_count";
     $options["select"][] = "MAX(notes.created_at) AS last_note";
     $options["group"][] = "id";
     parent::grab($this, $version_id, $options);
     if ($this->no_results) {
         return false;
     }
     $this->compatible = array_map(array("Version", "numberfy"), (array) YAML::load($this->compatible));
     $this->tags = !empty($this->tags) ? YAML::load($this->tags) : array();
     $this->linked_tags = self::link_tags($this->tags);
     $this->filtered = !isset($options["filter"]) or $options["filter"];
     $trigger = Trigger::current();
     if ($this->filtered) {
         $this->description_unfiltered = $this->description;
         if (!$this->extension->user->group->can("code_in_extensions")) {
             $this->description = fix($this->description);
         }
         $trigger->filter($this->description, array("markup_text", "markup_version_text"), $this);
     }
     $trigger->filter($this, "version");
 }
Exemplo n.º 2
0
Arquivo: Theme.php Projeto: 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;
 }
Exemplo n.º 3
0
 /**
  * Function: remove
  * Removes a configuration setting.
  *
  * Parameters:
  *     $setting - The name of the setting to remove.
  */
 public function remove($setting)
 {
     if (isset($this->file) and file_exists($this->file)) {
         $contents = str_replace("<?php header(\"Status: 403\"); exit(\"Access denied.\"); ?>\n", "", file_get_contents($this->file));
         $this->yaml = YAML::load($contents);
     }
     # Add the setting
     unset($this->yaml[$setting]);
     # Add the PHP protection!
     $contents = "<?php header(\"Status: 403\"); exit(\"Access denied.\"); ?>\n";
     # Generate the new YAML settings
     $contents .= YAML::dump($this->yaml);
     file_put_contents(INCLUDES_DIR . "/config.yaml.php", $contents);
 }
Exemplo n.º 4
0
 public static function load($config_dir)
 {
     $config_file = $config_dir . '/elib.yml';
     if (!file_exists($config_file)) {
         die('Config error: ' . $config_file . ' does not exist');
     }
     $config = YAML::load($config_file);
     foreach ($config as $index => $item) {
         if (!is_array($item)) {
             $index = 'ELIB_' . $index;
             define(strtoupper($index), $item);
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Function: __construct
  * See Also:
  *     <Model::grab>
  */
 public function __construct($revision_id, $options = array())
 {
     if (!isset($revision_id) and empty($options)) {
         return;
     }
     parent::grab($this, $revision_id, $options);
     $options["order"] = "created_at ASC, id ASC";
     if ($this->no_results) {
         return false;
     }
     $this->changes = YAML::load($this->changes);
     $this->filtered = !isset($options["filter"]) or $options["filter"];
     $trigger = Trigger::current();
     if ($this->filtered) {
         if (!$this->user->group->can("code_in_revisions")) {
             $this->body = fix($this->body);
         }
         $trigger->filter($this->body, array("markup_text", "markup_revision_text"), $this);
     }
     $trigger->filter($this, "revision");
 }
Exemplo n.º 6
0
Arquivo: Admin.php Projeto: eadz/chyrp
 /**
  * Function: subnav_context
  * Generates the context variables for the subnav.
  */
 public function subnav_context($action)
 {
     $trigger = Trigger::current();
     $visitor = Visitor::current();
     $this->context["subnav"] = array();
     $subnav =& $this->context["subnav"];
     $subnav["write"] = array();
     $pages = array("manage" => array());
     foreach (Config::current()->enabled_feathers as $index => $feather) {
         $info = YAML::load(FEATHERS_DIR . "/" . $feather . "/info.yaml");
         $subnav["write"]["write_post&feather=" . $feather] = array("title" => __($info["name"], $feather), "show" => $visitor->group->can("add_draft", "add_post"), "attributes" => ' id="list_feathers[' . $feather . ']"', "selected" => isset($_GET['feather']) and $_GET['feather'] == $feather or !isset($_GET['feather']) and $action == "write_post" and !$index);
     }
     # Write navs
     $subnav["write"]["write_page"] = array("title" => __("Page"), "show" => $visitor->group->can("add_page"));
     $trigger->filter($subnav["write"], array("admin_write_nav", "write_nav"));
     $pages["write"] = array_merge(array("write_post"), array_keys($subnav["write"]));
     # Manage navs
     $subnav["manage"] = array("manage_posts" => array("title" => __("Posts"), "show" => Post::any_editable() or Post::any_deletable(), "selected" => array("edit_post", "delete_post")), "manage_pages" => array("title" => __("Pages"), "show" => $visitor->group->can("edit_page", "delete_page"), "selected" => array("edit_page", "delete_page")), "manage_users" => array("title" => __("Users"), "show" => $visitor->group->can("add_user", "edit_user", "delete_user"), "selected" => array("edit_user", "delete_user", "new_user")), "manage_groups" => array("title" => __("Groups"), "show" => $visitor->group->can("add_group", "edit_group", "delete_group"), "selected" => array("edit_group", "delete_group", "new_group")));
     $trigger->filter($subnav["manage"], "manage_nav");
     $subnav["manage"]["import"] = array("title" => __("Import"), "show" => $visitor->group->can("add_post"));
     $subnav["manage"]["export"] = array("title" => __("Export"), "show" => $visitor->group->can("add_post"));
     $pages["manage"][] = "new_user";
     $pages["manage"][] = "new_group";
     foreach (array_keys($subnav["manage"]) as $manage) {
         $pages["manage"] = array_merge($pages["manage"], array($manage, preg_replace("/manage_(.+)/e", "'edit_'.depluralize('\\1')", $manage), preg_replace("/manage_(.+)/e", "'delete_'.depluralize('\\1')", $manage)));
     }
     # Settings navs
     $subnav["settings"] = array("general_settings" => array("title" => __("General"), "show" => $visitor->group->can("change_settings")), "content_settings" => array("title" => __("Content"), "show" => $visitor->group->can("change_settings")), "user_settings" => array("title" => __("Users"), "show" => $visitor->group->can("change_settings")), "route_settings" => array("title" => __("Routes"), "show" => $visitor->group->can("change_settings")));
     $trigger->filter($subnav["settings"], "settings_nav");
     $pages["settings"] = array_keys($subnav["settings"]);
     # Extend navs
     $subnav["extend"] = array("modules" => array("title" => __("Modules"), "show" => $visitor->group->can("toggle_extensions")), "feathers" => array("title" => __("Feathers"), "show" => $visitor->group->can("toggle_extensions")), "themes" => array("title" => __("Themes"), "show" => $visitor->group->can("toggle_extensions")));
     $trigger->filter($subnav["extend"], "extend_nav");
     $pages["extend"] = array_keys($subnav["extend"]);
     foreach (array_keys($subnav) as $main_nav) {
         foreach ($trigger->filter($pages[$main_nav], $main_nav . "_nav_pages") as $extend) {
             $subnav[$extend] =& $subnav[$main_nav];
         }
     }
     foreach ($subnav as $main_nav => &$sub_nav) {
         foreach ($sub_nav as &$nav) {
             $nav["show"] = (!isset($nav["show"]) or $nav["show"]);
         }
     }
     $trigger->filter($subnav, "admin_subnav");
 }
Exemplo n.º 7
0
/**
 * 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();
        }
    }
}
Exemplo n.º 8
0
 public function ajax_tag_post()
 {
     if (empty($_POST['name']) or empty($_POST['post'])) {
         exit("{}");
     }
     $sql = SQL::current();
     $post = new Post($_POST['post']);
     $tag = $_POST['name'];
     if (!$post->editable()) {
         exit("{}");
     }
     $tags = $sql->select("post_attributes", "value", array("name" => "tags", "post_id" => $post->id));
     if ($tags and $value = $tags->fetchColumn()) {
         $tags = YAML::load($value);
     } else {
         $tags = array();
     }
     $tags[$tag] = sanitize($tag);
     $sql->replace("post_attributes", array("post_id", "name"), array("name" => "tags", "value" => YAML::dump($tags), "post_id" => $post->id));
     exit("{ url: \"" . url("tag/" . $tags[$tag], MainController::current()) . "\", tag: \"" . $_POST['name'] . "\" }");
 }
Exemplo n.º 9
0
 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));
     }
 }
 $class_name = camelize($_POST["extension"]);
 if ($type == "module" and !is_subclass_of($class_name, "Modules")) {
Exemplo n.º 10
0
 private function getCommandsInDirectory($path, $relativePath)
 {
     $commands = array();
     if (false !== ($d = opendir($path))) {
         while (false !== ($f = readdir($d))) {
             $new_path = $path . '/' . $f;
             $new_relative_path = $relativePath . '/' . $f;
             if ('.amCommand' == substr($f, -10) || is_dir($new_path) && 0 != strncmp('.', $f, 1)) {
                 if (is_dir($new_path) && file_exists($new_path . '/group.amGroup')) {
                     $yaml = YAML::load($new_path . '/group.amGroup');
                     $yaml['filename'] = $f;
                     $yaml['is_collection'] = '1';
                     $yaml['path'] = $relativePath;
                     $commands[] = $yaml;
                     $commands = array_merge($commands, $this->getCommandsInDirectory($new_path, $new_relative_path));
                     continue;
                 }
                 $def_file = $new_path . 'Def';
                 if (!file_exists($def_file)) {
                     throw new Exception('Missing command definition file `' . $def_file . '`.');
                 }
                 $yaml = YAML::load($new_path);
                 $yaml['code'] = file_get_contents($def_file);
                 $yaml['filename'] = substr($f, 0, -10);
                 $yaml['path'] = $relativePath;
                 $commands[] = $yaml;
             }
         }
         closedir($d);
     }
     return $commands;
 }
Exemplo n.º 11
0
}
class NginxConfig extends BracketConfig
{
}
class NginxScope extends BracketScope
{
}
$confScope = new NginxScope();
$nginx['sites']['listen'] = new NginxConfig('listen %(port)s %(options)s', 'server', 1);
$nginx['sites']['domain'] = new NginxConfig('server_name %(domain)s', 'server', 1);
$nginx['pid'] = new NginxConfig('pid %(pid)s');
$config = YAML::load('defaults.yml');
setAll(&$config['nginx'], &$nginx);
addAllStems(&$nginx, &$confScope);
if (isset($argv[1])) {
    $config = YAML::load($argv[1]);
    foreach ($config['nginx']['sites'] as $key => $site) {
        $siteScope[$key] = new NginxScope();
        setAll($site, $nginx['sites']);
        addAllStems(&$nginx['sites'], $siteScope[$key]);
    }
}
foreach ($siteScope as $scope) {
    $confScope->addStem(array('scope' => 'http', 'output' => $scope->returnScopes(), 'level' => 1));
}
echo $confScope->returnScopes();
function setAll($data, array $appconfs)
{
    foreach ($appconfs as $setting) {
        //this is dirty, fix me (so many copies of the yaml array!)
        if (is_object($setting)) {
Exemplo n.º 12
0
/**
 * Function: group_permissions_to_db
 * Migrates the group permissions from a YAML column to the "permissions" table.
 *
 * Versions: 2.0rc1 => 2.0rc2
 */
function group_permissions_to_db()
{
    $sql = SQL::current();
    if (!$sql->select("groups", "permissions")) {
        return;
    }
    echo __("Backing up groups...") . test($groups = $sql->select("groups"));
    if (!$groups) {
        return;
    }
    $backup = $groups->fetchAll();
    $names = array();
    foreach ($backup as $group) {
        $names[$group["id"]] = $group["name"];
        $permissions[$group["id"]] = empty($group["permissions"]) ? array() : YAML::load($group["permissions"]);
    }
    echo __("Dropping `groups` table...") . test($sql->query("DROP TABLE __groups"));
    echo __("Creating `groups` table...") . test($sql->query("CREATE TABLE __groups (\n                                   id INTEGER PRIMARY KEY AUTO_INCREMENT,\n                                   name VARCHAR(100) DEFAULT '',\n                                   UNIQUE (name)\n                               ) DEFAULT CHARSET=utf8"));
    foreach ($names as $id => $name) {
        echo _f("Restoring group `%s`...", array($name)) . test($sql->insert("groups", array("id" => $id, "name" => $name)));
    }
    foreach ($permissions as $id => $permissions) {
        foreach ($permissions as $permission) {
            echo _f("Restoring permission `%s` on group `%s`...", array($permission, $names[$id])) . test($sql->insert("permissions", array("id" => $permission, "name" => $sql->select("permissions", "name", array("id" => $permission))->fetchColumn(), "group_id" => $id)));
        }
    }
}
Exemplo n.º 13
0
 public function on_list_bundles($pars)
 {
     $bundle_dir_path = $this->configuration['support-path'] . '/bundles/';
     if (!is_dir($bundle_dir_path)) {
         throw new Exception('There is no bundles directory available.');
     }
     $bundles = array();
     if (false !== ($d = opendir($bundle_dir_path))) {
         while (false !== ($f = readdir($d))) {
             if (0 == strncmp('.', $f, 1) || !is_dir($bundle_dir_path . $f)) {
                 continue;
             }
             $yaml = YAML::load($bundle_dir_path . $f . '/info.amBundle');
             $yaml['id'] = $f;
             // getting list of bundle templates
             $templates_path = $bundle_dir_path . $f . '/templates/';
             $templates = array();
             if (is_dir($templates_path)) {
                 if (false !== ($d_templates = opendir($templates_path))) {
                     while (false !== ($ff = readdir($d_templates))) {
                         if (0 == strncmp('.', $ff, 1)) {
                             continue;
                         }
                         $content = explode("\n", @file_get_contents($templates_path . $ff));
                         $templates[] = $content[0];
                     }
                     closedir($d_templates);
                 }
             }
             $yaml['templates'] = $templates;
             $bundles[] = $yaml;
         }
         closedir($d);
     }
     self::setResult($bundles);
 }
Exemplo n.º 14
0
 public function ParseFromYAMLs(array $files)
 {
     $this->SetAutomatedValues();
     //Stems::LoadDefinitions('nginx');
     $last = false;
     $total = count($files) - 1;
     $sites_defaults = array();
     foreach ($files as $i => $file) {
         if ($total == $i) {
             $last = true;
         }
         LogCLI::Message('Loading file: ' . LogCLI::BLUE . $file . LogCLI::RESET, 1);
         if (file_exists($file)) {
             LogCLI::Result(LogCLI::OK);
             LogCLI::Message('Parsing file: ' . LogCLI::BLUE . $file . LogCLI::RESET, 1);
             try {
                 $config = YAML::load($file);
                 LogCLI::Result(LogCLI::OK);
             } catch (Exception $e) {
                 LogCLI::Result(LogCLI::FAIL);
                 LogCLI::Fail($e->getMessage());
             }
             if (isset($config['nginx'])) {
                 // adding to main DB
                 $this->settingsDB = System::MergeArrays($this->settingsDB, $config);
                 foreach ($this->usableScopes as $arrayPath) {
                     //LogCLI::MessageResult($arrayPath);
                     //var_dump(self::getArrayElementByPath($config['nginx'], $arrayPath, 1));
                     /*
                     foreach(self::accessArrayElementByPath($config['nginx'], $arrayPath) as $scope => $scopeConfig)
                     {
                         echo("skope ".$scope.":\n");
                     }
                     */
                     //LogCLI::MessageResult('Path: '.LogCLI::BLUE.$arrayPath.LogCLI::RESET, 6, LogCLI::INFO);
                     foreach (self::getArrayElementByPath($config['nginx'], $arrayPath, true) as $scope => $scopeConfig) {
                         if ($scopeConfig !== false) {
                             //echo("skope ".$scope.":\n");
                             //var_dump($scopeConfig);
                             if (is_array($scopeConfig) && $scope != 'sites') {
                                 //LogCLI::MessageResult("Number of dimentions in scope [$scope]: ".self::array_dimen_count($scopeConfig), 3);
                                 //self::array_dimen_count($scopeConfig);
                                 //var_dump($scopeConfig);
                                 //LogCLI::MessageResult($scope);
                                 NginxConfig::setAll(self::accessArrayElementByPath($config['nginx'], $arrayPath), self::accessArrayElementByPath($this->nginx, $arrayPath));
                                 if ($last) {
                                     //LogCLI::MessageResult($scope);
                                     LogCLI::Message("Generating scope: [{$arrayPath}]", 3);
                                     NginxScope::addAllStems(self::accessArrayElementByPath($this->nginx, $arrayPath), $this->confScope);
                                     LogCLI::Result(LogCLI::INFO);
                                 }
                             }
                         }
                     }
                 }
                 // sites scopes
                 if (isset($config['nginx']['sites']['_defaults'])) {
                     $config['nginx']['sites']['_defaults'] = self::ConformizeConfigSite($config['nginx']['sites']['_defaults']);
                     $sites_defaults = System::MergeArrays($sites_defaults, $config['nginx']['sites']['_defaults']);
                 }
                 if (isset($config['nginx']['sites'])) {
                     foreach ($config['nginx']['sites'] as $key => $site) {
                         if ($key != '_defaults') {
                             $site = self::ConformizeConfigSite($site);
                             $siteScope[$key] = new NginxScope();
                             LogCLI::Message("Pushing defaults for subscope [server]: {$key}", 3);
                             NginxConfig::resetAll($this->nginx['sites']);
                             if (isset($sites_defaults)) {
                                 NginxConfig::setAll($sites_defaults, $this->nginx['sites']);
                             }
                             LogCLI::Result(LogCLI::INFO);
                             LogCLI::Message("Setting in subscope [server]: {$key}", 3);
                             //$siteScope[$key] = new NginxScope;
                             NginxConfig::setAll($site, $this->nginx['sites']);
                             LogCLI::Result(LogCLI::INFO);
                             LogCLI::Message("Adding subscope [server]: {$key}", 3);
                             NginxScope::addAllStems($this->nginx['sites'], $siteScope[$key]);
                             LogCLI::Result(LogCLI::INFO);
                         }
                     }
                 }
                 if (isset($siteScope)) {
                     foreach ($siteScope as $scope) {
                         LogCLI::Message("Adding scope: [server]", 3);
                         $this->confScope->addStem(array('scope' => 'http', 'output' => $scope->returnScopes(), 'level' => 1));
                         LogCLI::Result(LogCLI::INFO);
                     }
                 }
                 $this->confScope->orderScopes(array('_ROOT', 'events', 'http'));
             }
         } else {
             LogCLI::Result(LogCLI::FAIL);
             LogCLI::Fatal("No such file: {$file}");
         }
     }
     //return false;
 }
Exemplo n.º 15
0
<?php 
include $__dn . 'client/fry/chap/ac.chap.js';
include $__dn . 'client/fry/chap/ac.chap.view.js';
include $__dn . 'client/fry/chap/ac.chap.settings.js';
function strip_file_name($name)
{
    return str_replace('..', '', str_replace('/', '', $name));
}
// BEGIN: embedding Theme definition script
echo "\n// Generated from theme definition file.\n";
$theme_name = strip_file_name($_REQUEST['theme'] . '.amTheme');
$themes_path = $_AMY_CONF['support-path'] . '/themes/';
if (!file_exists($themes_path . $theme_name)) {
    $theme_name = 'default.amTheme';
}
$theme = YAML::load($themes_path . $theme_name);
echo '$class(\'ac.chap.theme.EAmy < ac.chap.Theme\');

	ac.chap.theme.EAmy.prototype.initDefinition = function()
	{
		$call(this, \'ac.chap.Theme.initDefinition\');';
foreach ($theme['definition'] as $key => $value) {
    if ('T' == $key[0] || 'C' == $key[0]) {
        $key = 'colorScheme[ac.chap.' . $key . ']';
    }
    echo 'this.' . $key . ' = ' . "'{$value}';\n";
}
echo '}' . "\n\n";
// END: embedding Theme definition script
echo "\n// Generated from bundle keymap definition file.\n";
// BEGIN: embedding bundle
Exemplo n.º 16
0
            toFile($config, $filename);
            break;
        case 'generateAll':
            //  $result = process_dir($args[1],TRUE);
            $yamls = getAllYaml($args[1]);
            // Output each opened file and then close
            /*  foreach ($result as $file) {
                if (is_resource($file['handle'])) {
                    echo "\n\nFILE (" . $file['dirpath'].'/'.$file['filename'] . "):\n\n" . fread($file['handle'], filesize($file['dirpath'].'/'.$file['filename']));
                    fclose($file['handle']);
                }
              }*/
            //var_dump($yamls);
            foreach ($yamls as $yaml) {
                echo "\nGenerating from {$yaml}:\n";
                $config = YAML::load($yaml);
                foreach ($config['nginx.sites'] as $siteName => $siteData) {
                    echo "site {$siteName} domain is: " . $siteData['domain'] . "\n";
                }
            }
    }
}
function toFile($array, $file = "tmp.yml")
{
    $dumper = new Dumper();
    $yaml = $dumper->dump($array, 3);
    file_put_contents(__DIR__ . '/' . $file, $yaml);
}
function getAllYaml($path = '.')
{
    $Directory = new RecursiveDirectoryIterator($path);
Exemplo n.º 17
0
function fix_quotes()
{
    $sql = SQL::current();
    if (!($tags = $sql->select("post_attributes", array("post_id", "value"), array("name" => "tags")))) {
        return;
    }
    foreach ($tags->fetchAll() as $attr) {
        $sql->replace("post_attributes", array("post_id" => $attr["post_id"], "name" => "tags", "value" => YAML::dump(YAML::load($attr["value"]))));
    }
}
Exemplo n.º 18
0
 public function admin_edit_aggregate($admin)
 {
     if (empty($_GET['id'])) {
         error(__("No ID Specified"), __("An ID is required to delete an aggregate.", "aggregator"));
     }
     if (!Visitor::current()->group->can("edit_aggregate")) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to delete this aggregate.", "aggregator"));
     }
     $admin->context["users"] = User::find();
     $config = Config::current();
     $aggregate = $config->aggregates[$_GET['id']];
     if (empty($_POST)) {
         return $admin->display("edit_aggregate", array("users" => User::find(), "aggregate" => array("name" => $_GET['id'], "url" => $aggregate["url"], "feather" => $aggregate["feather"], "author" => $aggregate["author"], "data" => preg_replace("/---\n/", "", YAML::dump($aggregate["data"])))));
     }
     if (!isset($_POST['hash']) or $_POST['hash'] != Config::current()->secure_hashkey) {
         show_403(__("Access Denied"), __("Invalid security key."));
     }
     $aggregate = array("url" => $_POST['url'], "last_updated" => 0, "feather" => $_POST['feather'], "author" => $_POST['author'], "data" => YAML::load($_POST['data']));
     unset($config->aggregates[$_GET['id']]);
     $config->aggregates[$_POST['name']] = $aggregate;
     $config->set("aggregates", $config->aggregates);
     $config->set("last_aggregation", 0);
     // to force a refresh
     Flash::notice(__("Aggregate updated.", "aggregator"), "/admin/?action=manage_aggregates");
 }