Пример #1
0
function run_disallow_permissions()
{
    $settings = getSettings();
    $root = "..";
    pake_echo_action("permissions", "allow permissions...");
    pake_chmod('', $root, 0755);
}
Пример #2
0
/**
 * safely removes directory via pake
 *
 * @param object $finder
 * @param string $sub_dir
 * @param string $lock_name
 */
function _safe_cache_remove($finder, $sub_dir, $lock_name)
{
    ini_set("memory_limit", "2048M");
    $sf_root_dir = sfConfig::get('sf_root_dir');
    // create a lock file
    pake_touch($sf_root_dir . '/' . $lock_name . '.lck', '');
    // change mode so the web user can remove it if we die
    pake_chmod($lock_name . '.lck', $sf_root_dir, 0777);
    // remove cache files
    pake_remove($finder, $sf_root_dir . '/' . $sub_dir);
    // release lock
    pake_remove($sf_root_dir . '/' . $lock_name . '.lck', '');
}
/**
 * safely removes directory via pake
 *
 * @param object $finder
 * @param string $sub_dir
 * @param string $lock_name
 */
function _safe_cache_remove($finder, $sub_dir, $lock_name)
{
    $sf_root_dir = sfConfig::get('sf_root_dir');
    // create a lock file
    $lock_file = $sf_root_dir . DIRECTORY_SEPARATOR . $lock_name . '-cli.lck';
    pake_touch($lock_file, '');
    // change mode so the web user can remove it if we die
    pake_chmod($lock_file, $sf_root_dir, 0777);
    // remove cache files
    pake_remove($finder, $sf_root_dir . DIRECTORY_SEPARATOR . $sub_dir);
    // release lock
    pake_remove($lock_file, '');
}
Пример #4
0
/**
 * create a single file with all pake classes; usage: pake compact [plugin1 [plugin2 […]]]
 *
 * To be able to include a plugin in pake_runtime.php, you have to use include_once for external dependencies
 * and require_once for internal dependencies (for other included PI or pake classes) because we strip 
 * all require_once statements
 *
 * @return bool
 * @author Alexey Zakhlestin
 */
function run_compact($task, $args)
{
    $_root = dirname(__FILE__);
    $options = pakeYaml::loadFile($_root . '/options.yaml');
    $version = $options['version'];
    pake_replace_tokens('lib/pake/pakeApp.class.php', $_root, 'const VERSION = \'', '\';', array('1.1.DEV' => "const VERSION = '{$version}';"));
    // core-files
    $files = array($_root . '/lib/pake/init.php', $_root . '/lib/pake/pakeFunction.php');
    // adding pake-classes library
    $files = array_merge($files, pakeFinder::type('file')->name('*.class.php')->maxdepth(0)->in($_root . '/lib/pake'));
    // adding sfYaml library
    $files = array_merge($files, pakeFinder::type('file')->name('*.php')->in($_root . '/lib/pake/sfYaml'));
    $plugins = $args;
    foreach ($plugins as $plugin_name) {
        $files[] = $_root . '/lib/pake/tasks/pake' . $plugin_name . 'Task.class.php';
    }
    // starter
    $files[] = $_root . '/bin/pake.php';
    // merge all files
    $content = '';
    foreach ($files as $file) {
        $content .= pake_read_file($file);
    }
    pake_replace_tokens('lib/pake/pakeApp.class.php', $_root, "const VERSION = '", "';", array($version => "const VERSION = '1.1.DEV';"));
    // strip require_once statements
    $content = preg_replace('/^\\s*require(?:_once)?[^$;]+;/m', '', $content);
    // replace windows and mac format with unix format
    $content = str_replace(array("\r\n"), "\n", $content);
    // strip php tags
    $content = preg_replace(array("/<\\?php/", "/<\\?/", "/\\?>/"), '', $content);
    // replace multiple new lines with a single newline
    $content = preg_replace(array("/\n\\s+\n/s", "/\n+/s"), "\n", $content);
    $content = "#!/usr/bin/env php\n<?php\n" . trim($content) . "\n";
    $target_dir = $_root . '/target';
    pake_mkdirs($target_dir);
    $target = $target_dir . '/pake';
    if (!file_put_contents($target, $content)) {
        throw new pakeException('Failed to write to "' . $target . '"');
    }
    pake_echo_action('file+', $target);
    // strip all comments
    pake_strip_php_comments($target);
    pake_chmod('pake', $target_dir, 0755);
}
Пример #5
0
function run_upgrade_1_0($task, $args)
{
    // check we have a project
    if (!file_exists('symfony') && !file_exists('SYMFONY')) {
        throw new Exception('You must be in a symfony project directory');
    }
    // upgrade propel.ini
    _upgrade_1_0_propel_ini();
    // upgrade i18n support
    _upgrade_1_0_i18n();
    // upgrade model classes
    _upgrade_1_0_propel_model();
    // migrate activate to enabled
    _upgrade_1_0_activate();
    // find all applications for this project
    $apps = pakeFinder::type('directory')->name(sfConfig::get('sf_app_module_dir_name'))->mindepth(1)->maxdepth(1)->relative()->in(sfConfig::get('sf_apps_dir_name'));
    // install symfony CLI
    if (file_exists(sfConfig::get('sf_root_dir') . '/SYMFONY')) {
        pake_remove(sfConfig::get('sf_root_dir') . '/SYMFONY', '');
    }
    pake_copy(sfConfig::get('sf_symfony_data_dir') . '/skeleton/project/symfony', sfConfig::get('sf_root_dir') . '/symfony');
    pake_chmod('symfony', sfConfig::get('sf_root_dir'), 0777);
    // update schemas
    _upgrade_1_0_schemas();
    // add bootstrap files for tests
    _add_1_0_test_bootstraps();
    // upgrade main config.php
    _upgrade_1_0_main_config_php();
    // upgrade all applications
    foreach ($apps as $app_module_dir) {
        $app = str_replace(DIRECTORY_SEPARATOR . sfConfig::get('sf_app_module_dir_name'), '', $app_module_dir);
        pake_echo_action('upgrade 1.0', pakeColor::colorize(sprintf('upgrading application "%s"', $app), array('fg' => 'cyan')));
        $app_dir = sfConfig::get('sf_apps_dir_name') . '/' . $app;
        // upgrade config.php
        _upgrade_1_0_config_php($app_dir);
        // upgrade filters.yml
        _upgrade_1_0_filters_yml($app_dir);
        // upgrade all modules
        $dir = $app_dir . '/' . sfConfig::get('sf_app_module_dir_name');
        if ($dir) {
            // template dirs
            $template_dirs = pakeFinder::type('directory')->name('templates')->mindepth(1)->maxdepth(1)->in($dir);
            $template_dirs[] = $app_dir . '/' . sfConfig::get('sf_app_template_dir_name');
            _upgrade_1_0_deprecated_for_templates($template_dirs);
            _upgrade_1_0_date_form_helpers($template_dirs);
            _upgrade_1_0_deprecated_for_generator($app_dir);
            _upgrade_1_0_cache_yml($app_dir);
            // actions dirs
            $action_dirs = pakeFinder::type('directory')->name('actions')->mindepth(1)->maxdepth(1)->in($dir);
            _upgrade_1_0_deprecated_for_actions($action_dirs);
            // view.yml
            _upgrade_1_0_view_yml($app_dir);
            _upgrade_1_0_php_files($app_dir);
        }
    }
    pake_echo_action('upgrade 1.0', 'done');
    pake_mkdirs(sfConfig::get('sf_root_dir') . '/plugins');
    if (is_dir(sfConfig::get('sf_lib_dir') . '/plugins')) {
        pake_echo_comment('WARNING: you must re-install all your plugins');
    }
    pake_echo_comment('Now, you must:');
    pake_echo_comment(' - rebuild your model classes: symfony propel-build-model');
    pake_echo_comment(' - clear the cache: symfony cc');
}