コード例 #1
0
/**
 * estrae gli N atti più rilevanti per determinati argomenti (tag)
 */
function run_a0_get_main_acts_for_tags($task, $args, $options)
{
    static $loaded;
    // load application context
    if (!$loaded) {
        task_loader();
        $loaded = true;
    }
    echo "memory usage: " . memory_get_usage() . "\n";
    $msg = sprintf("start time: %s\n", date('H:i:s'));
    echo $msg;
    $n = 1;
    if (array_key_exists('nrecs', $options)) {
        $n = (int) $options['nrecs'];
    }
    if (!is_int($n) || $n < 1) {
        throw new Exception("il numero di atti deve essere un intero\n");
    }
    if (count($args) > 0) {
        $argomenti = array();
        foreach ($args as $cnt => $arg) {
            $id = TagPeer::getIdFromTagValue($arg);
            $xml_url = sprintf("http://parlamento.openpolis.it/xml/indici/tag/%d.xml", $id);
            $xsl_file = SF_ROOT_DIR . "/web/xml/indici/xslt/tagActsSorter.xslt";
            printf("Argomento %s:\n", $arg, $id);
            getImportantActs($xml_url, $xsl_file, $n);
            print "\n";
        }
    }
    $start_time = time();
    $msg = sprintf("end time: %s\n", date('H:i:s'));
    echo $msg;
    $msg = sprintf("memory usage: %10d\n", memory_get_usage());
    echo pakeColor::colorize($msg, array('fg' => 'red', 'bold' => false));
}
コード例 #2
0
 function render($e)
 {
     $title = '  [' . get_class($e) . ']  ';
     $len = self::strlen($title);
     $lines = array();
     foreach (explode("\n", $e->getMessage()) as $line) {
         $lines[] = '  ' . $line . '  ';
         $len = max(self::strlen($line) + 4, $len);
     }
     $messages = array(str_repeat(' ', $len), $title . str_repeat(' ', $len - self::strlen($title)));
     foreach ($lines as $line) {
         $messages[] = $line . str_repeat(' ', $len - self::strlen($line));
     }
     $messages[] = str_repeat(' ', $len);
     fwrite(STDERR, "\n");
     foreach ($messages as $message) {
         fwrite(STDERR, pakeColor::colorize($message, 'ERROR', STDERR) . "\n");
     }
     fwrite(STDERR, "\n");
     $pake = pakeApp::get_instance();
     if ($pake->get_trace()) {
         fwrite(STDERR, "exception trace:\n");
         $trace = $this->trace($e);
         for ($i = 0, $count = count($trace); $i < $count; $i++) {
             $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
             $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
             $function = $trace[$i]['function'];
             $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
             $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
             fwrite(STDERR, sprintf(" %s%s%s at %s:%s\n", $class, $type, $function, pakeColor::colorize($file, 'INFO', STDERR), pakeColor::colorize($line, 'INFO', STDERR)));
         }
     }
     fwrite(STDERR, "\n");
 }
コード例 #3
0
ファイル: sfPakeMisc.php プロジェクト: kotow/work
function echo_cms_sep()
{
    if (pakeApp::get_instance()->get_verbose()) {
        $width = 9 + strlen(pakeColor::colorize('', 'SEP'));
        echo sprintf(' %-' . $width . 's %s', pakeColor::colorize("", 'SEP'), pakeApp::excerpt("", null)) . "\n";
    }
}
コード例 #4
0
function run_flush_cache($args, $opts)
{
    $rootDir = realpath(__DIR__."/../../../../");
    $app = new Maveriks\WebApplication();
    $app->setRootDir($rootDir);
    $loadConstants = false;
    $workspaces = get_workspaces_from_args($args);

    if (! defined("PATH_C")) {
        die("ERROR: seems processmaker is not properly installed (System constants are missing).".PHP_EOL);
    }

    CLI::logging("Flush ".pakeColor::colorize("system", "INFO")." cache ... ");
    G::rm_dir(PATH_C);
    G::mk_dir(PATH_C, 0777);
    echo "DONE" . PHP_EOL;

    foreach ($workspaces as $workspace) {
        echo "Flush workspace " . pakeColor::colorize($workspace->name, "INFO") . " cache ... ";

        G::rm_dir($workspace->path . "/cache");
        G::mk_dir($workspace->path . "/cache", 0777);
        G::rm_dir($workspace->path . "/cachefiles");
        G::mk_dir($workspace->path . "/cachefiles", 0777);
        echo "DONE" . PHP_EOL;
    }
}
コード例 #5
0
ファイル: cliMafe.php プロジェクト: hpx2206/processmaker-1
function run_create_translation($args, $opts)
{
    G::LoadSystem('inputfilter');
    $filter = new InputFilter();
    $opts = $filter->xssFilterHard($opts);
    $args = $filter->xssFilterHard($args);
    $rootDir = realpath(__DIR__."/../../../../");
    $app = new Maveriks\WebApplication();
    $app->setRootDir($rootDir);
    $loadConstants = false;

    $workspaces = get_workspaces_from_args($args);
    $lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en';

    $translation = new Translation();
    CLI::logging("Updating labels Mafe ...\n");
    foreach ($workspaces as $workspace) {
        try {
            echo "Updating labels for workspace " . pakeColor::colorize($workspace->name, "INFO") . "\n";
            $translation->generateTransaltionMafe($lang);
        } catch (Exception $e) {
            echo "Errors upgrading labels for workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n";
        }
    }

    CLI::logging("Create successful\n");

}
コード例 #6
0
ファイル: pakeTest.php プロジェクト: emildev35/processmaker
function run_test_unit($task, $args)
{
    $environment = isset($arg[1]) ? $arg[1] : G_TEST_ENV;
    printf("start test in %s environment\n", pakeColor::colorize($environment, 'INFO'));
    define('G_ENVIRONMENT', $environment);
    if (isset($args[0])) {
        foreach ($args as $path) {
            $pathUnit = PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP . dirname($path);
            $files = pakeFinder::type('file')->ignore_version_control()->follow_link()->name(basename($path) . 'Test.php')->in($pathUnit);
            foreach ($files as $file) {
                $fName = str_replace(PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP, '', $file);
                printf("\ntesting %s \n", pakeColor::colorize($fName, 'INFO'));
                include $file;
            }
        }
    } else {
        require_once PATH_THIRDPARTY . '/lime/lime.php';
        $h = new lime_harness(new lime_output_color());
        $h->base_dir = $pathUnit = PATH_CORE . 'test' . PATH_SEP . 'unit';
        //    $h->base_dir = $pathUnit = PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP . "processmaker";
        // register unit tests
        $finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php');
        $h->register($finder->in($h->base_dir));
        $h->run();
    }
}
コード例 #7
0
 public function usage($hint_about_help = true)
 {
     echo ' ' . self::$EXEC_NAME . "             - to list commands\n";
     echo ' ' . self::$EXEC_NAME . " command     - to run specific command\n";
     if (true === $hint_about_help) {
         echo \pakeColor::colorize("Try " . self::$EXEC_NAME . " -H for more information", 'INFO') . "\n";
     }
 }
コード例 #8
0
 public static function render($e)
 {
     $isatty = pakeApp::isTTY();
     $title = '  [' . get_class($e) . ']  ';
     $len = self::strlen($title);
     $lines = array();
     foreach (explode("\n", $e->getMessage()) as $line) {
         if ($isatty) {
             $pieces = explode("\n", wordwrap($line, pakeApp::screenWidth() - 4, "\n", true));
         } else {
             $pieces = array($line);
         }
         foreach ($pieces as $piece) {
             $lines[] = '  ' . $piece . '  ';
             $len = max(self::strlen($piece) + 4, $len);
         }
     }
     if ($isatty) {
         $messages = array(str_repeat(' ', $len), $title . str_repeat(' ', $len - self::strlen($title)));
     } else {
         $messages = array('', $title);
     }
     foreach ($lines as $line) {
         if ($isatty) {
             $messages[] = $line . str_repeat(' ', $len - self::strlen($line));
         } else {
             $messages[] = $line;
         }
     }
     if ($isatty) {
         $messages[] = str_repeat(' ', $len);
     } else {
         $messages[] = '';
     }
     fwrite(STDERR, "\n");
     foreach ($messages as $message) {
         fwrite(STDERR, pakeColor::colorize($message, 'ERROR', STDERR) . "\n");
     }
     fwrite(STDERR, "\n");
     $pake = pakeApp::get_instance();
     if ($pake->get_trace()) {
         fwrite(STDERR, "exception trace:\n");
         $trace = self::trace($e);
         for ($i = 0, $count = count($trace); $i < $count; $i++) {
             $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
             $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
             $function = $trace[$i]['function'];
             $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
             $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
             fwrite(STDERR, pake_sprintf(" %s%s%s at %s:%s\n", $class, $type, $function, pakeColor::colorize($file, 'INFO', STDERR), pakeColor::colorize($line, 'INFO', STDERR)));
         }
     }
     fwrite(STDERR, "\n");
 }
コード例 #9
0
/**
* Check and remove news related to non-existing objects
*/
function run_opp_news_clean($task, $args)
{
    static $loaded;
    // load application context
    if (!$loaded) {
        define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
        define('SF_APP', 'fe');
        define('SF_ENVIRONMENT', 'task');
        define('SF_DEBUG', true);
        require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
        sfContext::getInstance();
        sfConfig::set('pake', true);
        error_reporting(E_ALL);
        $loaded = true;
    }
    $start_time = microtime(true);
    $c = new Criteria();
    $c->clearSelectColumns();
    $c->addSelectColumn(NewsPeer::ID);
    $c->addSelectColumn(NewsPeer::RELATED_MONITORABLE_MODEL);
    $c->addSelectColumn(NewsPeer::RELATED_MONITORABLE_ID);
    $n_news = NewsPeer::doCount($c);
    $rs = NewsPeer::doSelectRS($c);
    $k = 0;
    $newsids_to_remove = array();
    $removed_news = 0;
    while ($rs->next()) {
        $news = array();
        $news['id'] = $rs->getInt(1);
        $news['rel_model'] = $rs->getString(2);
        $news['rel_id'] = $rs->getInt(3);
        if (opp_check_single_news($news)) {
            $newsids_to_remove[] = $news['id'];
            $removed_news++;
        }
        $k++;
        if ($k % 100 == 0) {
            print ".";
        }
        if ($k > 0 && $k % 1000 == 0) {
            $rem = count($newsids_to_remove);
            NewsPeer::doDelete($newsids_to_remove);
            print "processed: {$k}/{$n_news} removed: {$rem} ({$removed_news})\n";
            $newsids_to_remove = array();
        }
    }
    $total_time = microtime(true) - $start_time;
    echo pakeColor::colorize('All done! ', array('fg' => 'red', 'bold' => true));
    echo 'Processed ';
    echo pakeColor::colorize(count($n_news), array('fg' => 'cyan'));
    echo ' news in ';
    echo pakeColor::colorize(sprintf("%f", $total_time), array('fg' => 'cyan'));
    echo " seconds\n";
}
コード例 #10
0
ファイル: sfPakePlugins.php プロジェクト: taryono/school
function run_plugin_list($task, $args)
{
    pake_echo('Installed plugins:');
    $config = _pear_init();
    $registry = $config->getRegistry();
    $installed = $registry->packageInfo(null, null, null);
    foreach ($installed as $channel => $packages) {
        foreach ($packages as $package) {
            $pobj = $registry->getPackage(isset($package['package']) ? $package['package'] : $package['name'], $channel);
            pake_echo(sprintf(" %-40s %10s-%-6s %s", pakeColor::colorize($pobj->getPackage(), 'INFO'), $pobj->getVersion(), $pobj->getState() ? $pobj->getState() : null, pakeColor::colorize(sprintf('# %s (%s)', $channel, $registry->getChannel($channel)->getAlias()), 'COMMENT')));
        }
    }
}
コード例 #11
0
/**
 *
 * @param object $task
 * @param array $args
 */
function run_sfassetlibrary_create_root($task, $args)
{
    $app = $args[0];
    $env = empty($args[1]) ? 'dev' : $args[1];
    // define constants
    define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
    define('SF_APP', $app);
    define('SF_ENVIRONMENT', $env);
    define('SF_DEBUG', true);
    require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
    // initialize database manager
    $databaseManager = new sfDatabaseManager();
    $databaseManager->initialize();
    $con = Propel::getConnection();
    if (sfAssetFolderPeer::getRoot()) {
        throw new sfException('The asset library already has a root');
    }
    echo pakeColor::colorize(sprintf("Creating root node at %s...\n", sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media')), 'COMMENT');
    sfAssetFolderPeer::createRoot();
    echo pakeColor::colorize("Root Node Created\n", 'INFO');
}
コード例 #12
0
/**
 *
 * @param object $task
 * @param array $args
 */
function run_sfassetlibrary_synchronize($task, $args, $options)
{
    if (!count($args)) {
        sfAssetsLibraryTools::log('Usage: php symfony sfassetlibrary-synchronize [app] [dirname] --notVerbose --removeOrphanAssets --removeOrphanFolders');
        return;
    }
    $app = $args[0];
    if (!is_dir(sfConfig::get('sf_app_dir') . DIRECTORY_SEPARATOR . $app)) {
        throw new Exception('The app "' . $app . '" does not exist.');
    }
    if (!isset($args[1])) {
        throw new Exception('You must define a sychronization folder');
    }
    $base_folder = $args[1];
    $verbose = array_key_exists('notVerbose', $options) ? false : true;
    $removeOrphanAssets = array_key_exists('removeOrphanAssets', $options) ? true : false;
    $removeOrphanFolders = array_key_exists('removeOrphanFolders', $options) ? true : false;
    // define constants
    define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
    define('SF_APP', $app);
    define('SF_ENVIRONMENT', 'dev');
    define('SF_DEBUG', true);
    // get configuration
    require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
    // initialize database manager
    $databaseManager = new sfDatabaseManager();
    $databaseManager->initialize();
    $con = Propel::getConnection();
    // synchronize
    sfAssetsLibraryTools::log(sprintf("Comparing files from %s with assets stored in the database...", $base_folder), 'green');
    $rootFolder = sfAssetFolderPeer::getRoot();
    try {
        $rootFolder->synchronizeWith($base_folder, $verbose, $removeOrphanAssets, $removeOrphanFolders);
    } catch (sfAssetException $e) {
        throw new sfException(strtr($e->getMessage(), $e->getMessageParams()));
    }
    echo pakeColor::colorize("Synchronization complete\n", 'INFO');
}
コード例 #13
0
        }
        self::$autoload_callables[] = $callable;
    }
}
function __autoload($class)
{
    static $initialized = false;
    if (!$initialized) {
        simpleAutoloader::initialize(sfConfig::get('sf_symfony_lib_dir'));
        $initialized = true;
    }
    return simpleAutoloader::__autoload($class);
}
// trap -V before pake
if (in_array('-V', $argv) || in_array('--version', $argv)) {
    printf("symfony version %s\n", pakeColor::colorize(trim(file_get_contents($sf_symfony_lib_dir . '/VERSION')), 'INFO'));
    exit(0);
}
if (count($argv) <= 1) {
    $argv[] = '-T';
}
require_once $sf_symfony_lib_dir . '/config/sfConfig.class.php';
sfConfig::add(array('sf_root_dir' => getcwd(), 'sf_symfony_lib_dir' => $sf_symfony_lib_dir, 'sf_symfony_data_dir' => $sf_symfony_data_dir));
// directory layout
include $sf_symfony_data_dir . '/config/constants.php';
// include path
set_include_path(sfConfig::get('sf_lib_dir') . PATH_SEPARATOR . sfConfig::get('sf_app_lib_dir') . PATH_SEPARATOR . sfConfig::get('sf_model_dir') . PATH_SEPARATOR . sfConfig::get('sf_symfony_lib_dir') . DIRECTORY_SEPARATOR . 'vendor' . PATH_SEPARATOR . get_include_path());
// register tasks
$dirs = array(sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'tasks' => 'myPake*.php', sfConfig::get('sf_symfony_data_dir') . DIRECTORY_SEPARATOR . 'tasks' => 'sfPake*.php', sfConfig::get('sf_root_dir') . '/plugins/*/data/tasks' => '*.php');
foreach ($dirs as $globDir => $name) {
    if ($dirs = glob($globDir)) {
コード例 #14
0
 public static function excerpt($text, $size = null)
 {
     if (!$size) {
         $size = self::$MAX_LINE_SIZE;
     }
     if (strlen($text) < $size) {
         return $text;
     }
     $subsize = floor(($size - 3) / 2);
     return substr($text, 0, $subsize) . pakeColor::colorize('...', 'INFO') . substr($text, -$subsize);
 }
コード例 #15
0
ファイル: pakeGulliver.php プロジェクト: bqevin/processmaker
function run_check_standard_code($task, $options)
{
    global $aFiles;
    $aFiles = array();
    if (!isset($options[0])) {
        $folder = PATH_TRUNK . 'classes';
    } else {
        $folder = PATH_TRUNK . $options[0];
    }
    if (!isset($options[1])) {
        $bSubFolders = false;
    } else {
        $bSubFolders = strtolower($options[1]) == 'true';
    }
    printf("checking folder %s\n", pakeColor::colorize($folder, 'INFO'));
    checkFolderStandardCode($folder, $bSubFolders);
    sort($aFiles);
    foreach ($aFiles as $key => $val) {
        printf("%s %s %s %s \n", pakeColor::colorize($val['tab'] ? 'tab' : '   ', 'INFO'), pakeColor::colorize($val['utf'] ? 'utf' : '   ', 'INFO'), pakeColor::colorize($val['dos'] ? 'dos' : '   ', 'INFO'), $val['file']);
    }
}
コード例 #16
0
 public function printInfo($fields = null)
 {
     if (!$fields) {
         $fields = $this->getMetadata();
     }
     $wfDsn = $fields['DB_ADAPTER'] . '://' . $fields['DB_USER'] . ':' . $fields['DB_PASS'] . '@' . $fields['DB_HOST'] . '/' . $fields['DB_NAME'];
     $rbDsn = $fields['DB_ADAPTER'] . '://' . $fields['DB_RBAC_USER'] . ':' . $fields['DB_RBAC_PASS'] . '@' . $fields['DB_RBAC_HOST'] . '/' . $fields['DB_RBAC_NAME'];
     $rpDsn = $fields['DB_ADAPTER'] . '://' . $fields['DB_REPORT_USER'] . ':' . $fields['DB_REPORT_PASS'] . '@' . $fields['DB_REPORT_HOST'] . '/' . $fields['DB_REPORT_NAME'];
     $info = array('Workspace Name' => $fields['WORKSPACE_NAME'], 'Workflow Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_USER'], $fields['DB_PASS'], $fields['DB_HOST'], $fields['DB_NAME']), 'RBAC Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_RBAC_USER'], $fields['DB_RBAC_PASS'], $fields['DB_RBAC_HOST'], $fields['DB_RBAC_NAME']), 'Report Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_REPORT_USER'], $fields['DB_REPORT_PASS'], $fields['DB_REPORT_HOST'], $fields['DB_REPORT_NAME']), 'MySql Version' => $fields['DATABASE']);
     foreach ($info as $k => $v) {
         if (is_numeric($k)) {
             $k = "";
         }
         CLI::logging(sprintf("%20s %s\n", $k, pakeColor::colorize($v, 'INFO')));
     }
 }
コード例 #17
0
ファイル: class.cli.php プロジェクト: bqevin/processmaker
 /**
  * Returns an error colorized version of the message.
  *
  * @param string $message the message to colorize
  */
 public static function error($message)
 {
     return pakeColor::colorize($message, "ERROR");
 }
コード例 #18
0
ファイル: sfPakeUpgrade.php プロジェクト: taryono/school
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');
}
コード例 #19
0
ファイル: cli.php プロジェクト: nshong/processmaker
ini_set('error_reporting', $e_all);
ini_set('short_open_tag', 'On');
ini_set('default_charset', "UTF-8");
ini_set('memory_limit', $config['memory_limit']);
ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']);
ini_set('date.timezone', $config['time_zone']);
define('DEBUG_SQL_LOG', $config['debug_sql']);
define('DEBUG_TIME_LOG', $config['debug_time']);
define('DEBUG_CALENDAR_LOG', $config['debug_calendar']);
define('MEMCACHED_ENABLED', $config['memcached']);
define('MEMCACHED_SERVER', $config['memcached_server']);
define('TIME_ZONE', $config['time_zone']);
G::LoadClass("cli");
// trap -V before pake
if (in_array('-v', $argv) || in_array('-V', $argv) || in_array('--version', $argv)) {
    printf("ProcessMaker version %s\n", pakeColor::colorize(trim(file_get_contents(PATH_GULLIVER . 'VERSION')), 'INFO'));
    exit(0);
}
// register tasks
//TODO: include plugins
$directories = array(PATH_HOME . 'engine/bin/tasks');
$pluginsDirectories = glob(PATH_PLUGINS . "*");
foreach ($pluginsDirectories as $dir) {
    if (!is_dir($dir)) {
        continue;
    }
    if (is_dir("{$dir}/bin/tasks")) {
        $directories[] = "{$dir}/bin/tasks";
    }
}
foreach ($directories as $dir) {
コード例 #20
0
/**
 * Genera i files di testo degli atti
 * ATTO_ID_i.txt - i num progressivo del testo
 */
function run_stlab_genera_testi_atti($task, $args, $options)
{
    static $loaded;
    // load application context
    if (!$loaded) {
        _loader();
    }
    $files_path = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . "stlab";
    if (array_key_exists('files_path', $options)) {
        $files_path = strtolower($options['files_path']);
    }
    $verbose = false;
    $offset = null;
    $limit = null;
    $act_types = array();
    if (array_key_exists('verbose', $options)) {
        $verbose = true;
    }
    if (array_key_exists('offset', $options)) {
        $offset = $options['offset'];
    }
    if (array_key_exists('limit', $options)) {
        $limit = $options['limit'];
    }
    if (array_key_exists('types', $options)) {
        $act_types = explode(",", $options['types']);
    }
    echo "memory usage: " . memory_get_usage() . "\n";
    $start_time = time();
    $msg = sprintf("generazione files dei testi degli atti\n");
    echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
    // creazione del file di archivio
    $zip = new ZipArchive();
    $zip_file_name = $files_path . DIRECTORY_SEPARATOR . "testi.zip";
    if (!file_exists($zip_file_name)) {
        $res = $zip->open($zip_file_name, ZIPARCHIVE::CREATE);
    } else {
        $res = $zip->open($zip_file_name);
    }
    if ($res !== TRUE) {
        throw new Exception("Impossibile creare l'archivio testi.zip: " . $res);
    }
    // set dei limiti
    $c = new Criteria();
    if (!is_null($limit)) {
        $c->setLimit($limit);
    }
    if (!is_null($offset)) {
        $c->setOffset($offset);
    }
    // estrazione documenti
    $c->addJoin(OppDocumentoPeer::ATTO_ID, OppAttoPeer::ID);
    if (count($act_types)) {
        $c->add(OppAttoPeer::TIPO_ATTO_ID, $act_types, Criteria::IN);
    }
    $docs = OppDocumentoPeer::doSelect($c);
    $n_docs = count($docs);
    foreach ($docs as $cnt => $doc) {
        printf("%5d/%5d: ", $c->getOffset() + $cnt + 1, $c->getOffset() + $n_docs);
        // definizione nome nell'archivio (attoID_docID)
        $file_name = $doc->getAttoId() . "_" . $doc->getId() . ".txt";
        // aggiunta testo all'archivio
        $zip->addFromString($file_name, $doc->getTesto());
        printf(" %d_%d ok (%d)\n", $doc->getAttoId(), $doc->getId(), memory_get_usage());
    }
    // chiusura archivio e scrittura su file system
    $zip->close();
    $msg = sprintf("%d atti elaborati\n", $cnt);
    echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
    $msg = sprintf(" [%4d sec] [%10d bytes]\n", time() - $start_time, memory_get_usage());
    echo pakeColor::colorize($msg, array('fg' => 'red', 'bold' => false));
}
コード例 #21
0
/**
 * Calcola o ri-calcola la rilevanza degli argomenti, come somma della rilevanza degli atti taggati
 * Si può specificare il una data fino alla quale calcolare la rilevanza
 * Se sono passati degli ID (argomenti), sono interpretati come ID di argomenti e il calcolo è fatto solo per loro
 */
function run_opp_build_cache_tags($task, $args, $options)
{
    static $loaded;
    // load application context
    if (!$loaded) {
        _loader();
    }
    echo "memory usage: " . memory_get_usage() . "\n";
    $data = '';
    $verbose = false;
    $offset = null;
    $limit = null;
    $start_time = time();
    if (array_key_exists('data', $options)) {
        $data = $options['data'];
    }
    if (array_key_exists('verbose', $options)) {
        $verbose = true;
    }
    if (array_key_exists('offset', $options)) {
        $offset = $options['offset'];
    }
    if (array_key_exists('limit', $options)) {
        $limit = $options['limit'];
    }
    if ($data != '') {
        $legislatura_corrente = OppLegislaturaPeer::getCurrent($data);
        $data_lookup = $data;
    } else {
        $legislatura_corrente = OppLegislaturaPeer::getCurrent();
        $data = date('Y-m-d');
        $data_lookup = OppTagHistoryCachePeer::fetchLastData();
    }
    $msg = sprintf("calcolo rilevanza tag - fino a: %10s\n", $data);
    echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
    if (count($args) > 0) {
        $tags_ids = $args;
    } else {
        $tags_ids = TaggingPeer::getActiveTagsIds('OppAtto');
    }
    $n_tags = count($tags_ids);
    echo "memory usage: " . memory_get_usage() . "\n";
    foreach ($tags_ids as $cnt => $tag_id) {
        printf("%5d/%6d) %40s %6d ... ", $cnt + 1, $n_tags, TagPeer::retrieveByPK($tag_id), $tag_id);
        $indice = OppIndiceRilevanzaPeer::calcola_rilevanza_tag($tag_id, $data, $verbose);
        // inserimento o aggiornamento del valore in opp_tag_history_cache
        $cache_record = OppTagHistoryCachePeer::retrieveByDataChiTipoChiId($data_lookup, 'S', $tag_id);
        if (!$cache_record) {
            $cache_record = new OppTagHistoryCache();
        }
        $cache_record->setLegislatura($legislatura_corrente);
        $cache_record->setChiTipo('S');
        $cache_record->setChiId($tag_id);
        $cache_record->setIndice($indice);
        $cache_record->setData($data);
        $cache_record->setUpdatedAt(date('Y-m-d H:i'));
        // forza riscrittura updated_at, per tenere traccia esecuzioni
        $cache_record->save();
        unset($cache_record);
        $msg = sprintf("%7.2f", $indice);
        echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
        $msg = sprintf(" [%4d sec] [%10d bytes]\n", time() - $start_time, memory_get_usage());
        echo pakeColor::colorize($msg, array('fg' => 'red', 'bold' => false));
    }
    $msg = sprintf("%d tag elaborati\n", $cnt + 1);
    echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
}
コード例 #22
0
/**
 * Prepara uno o più atti, specificati dall'id nell'elenco argomenti per un test
 * Vengono rimossi tutti i dati accessori:
 *  firme, assrgnazioni in commissione, documenti, tagging, esiti, interventi
 * Sono resettati il titolo e l'md5
 *
 * Necessario per pulire un oggetto prima di un test di upgrade
 */
function run_opp_prepare_ddl_for_test($task, $args, $options)
{
    static $loaded;
    // load application context
    if (!$loaded) {
        _loader();
    }
    $dry_run = false;
    if (array_key_exists('dry-run', $options)) {
        $dry_run = true;
    }
    $con = Propel::getConnection(OppAttoPeer::DATABASE_NAME);
    echo "memory usage: " . memory_get_usage() . "\n";
    $start_time = time();
    try {
        $atti_rs = OppAttoPeer::getRSFromIDArray($args, $con);
    } catch (Exception $e) {
        throw new Exception("Specificare degli ID validi. \n" . $e);
    }
    $n_atti = $atti_rs->getRecordCount();
    $cnt = 0;
    while ($atti_rs->next()) {
        $a = $atti_rs->getRow();
        $atto_id = $a['id'];
        print "atto: {$atto_id}\n";
        $atto = OppAttoPeer::retrieveByPK($atto_id);
        $atto->setTitolo("");
        $atto->setMd5("");
        $atto->save();
        print "  titolo e md5 annullat1\n";
        # firme
        $items = $atto->getOppCaricaHasAttos(null, $con);
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} firme rimosse\n";
        # assegnazioni
        $items = $atto->getOppAttoHasSedes(null, $con);
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} assegnazioni in commissione rimosse\n";
        # tag (sf_tagging)
        $items = $atto->getTagsAsTaggingObjects(null, $con);
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} tagging dell'atto rimossi\n";
        # documenti
        $items = $atto->getOppDocumentos(null, $con);
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} documenti allegati rimossi\n";
        # iter
        $last_iter = $atto->getLastIter();
        $last_iter->delete();
        # relazioni
        $items = $atto->getRelazioni();
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} relazioni rimosse\n";
        # esito sedute
        $items = $atto->getOppEsitoSedutas();
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} esiti rimossi\n";
        # interventi
        $items = $atto->getOppInterventos();
        $nitems = count($items);
        foreach ($items as $cnt => $item) {
            $item->delete($con);
        }
        print "  {$nitems} interventi rimossi\n";
        print "\n";
    }
    $msg = sprintf("fine task\n");
    echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
    $msg = sprintf(" [%4d sec] [%10d bytes]\n", time() - $start_time, memory_get_usage());
    echo pakeColor::colorize($msg, array('fg' => 'red', 'bold' => false));
}
コード例 #23
0
function database_upgrade($command, $args)
{
    $workspaces = get_workspaces_from_args($args);
    $checkOnly = strcmp($command, "check") == 0;
    foreach ($workspaces as $workspace) {
        if ($checkOnly) {
            print_r("Checking database in " . pakeColor::colorize($workspace->name, "INFO") . "\n");
        } else {
            print_r("Upgrading database in " . pakeColor::colorize($workspace->name, "INFO") . "\n");
        }
        try {
            $changes = $workspace->upgradeDatabase($checkOnly);
            if ($changes != false) {
                if ($checkOnly) {
                    echo "> " . pakeColor::colorize("Run upgrade", "INFO") . "\n";
                    echo "  Tables (add = " . count($changes['tablesToAdd']);
                    echo ", alter = " . count($changes['tablesToAlter']) . ") ";
                    echo "- Indexes (add = " . count($changes['tablesWithNewIndex']) . "";
                    echo ", alter = " . count($changes['tablesToAlterIndex']) . ")\n";
                } else {
                    echo "-> Schema fixed\n";
                }
            } else {
                echo "> OK\n";
            }
        } catch (Exception $e) {
            echo "> Error: " . CLI::error($e->getMessage()) . "\n";
        }
    }
}
コード例 #24
0
ファイル: pakeApp.class.php プロジェクト: piotras/pake
 public function display_tasks_and_comments()
 {
     $width = 0;
     $tasks = pakeTask::get_tasks();
     foreach ($tasks as $name => $task) {
         $w = strlen(pakeTask::get_mini_task_name($name));
         if ($w > $width) {
             $width = $w;
         }
     }
     $width += strlen(pakeColor::colorize(' ', 'INFO'));
     echo "available " . self::$EXEC_NAME . " tasks:\n";
     // display tasks
     $has_alias = false;
     ksort($tasks);
     foreach ($tasks as $name => $task) {
         if ($task->get_alias()) {
             $has_alias = true;
         }
         if (!$task->get_alias() and $task->get_comment()) {
             $mini_name = pakeTask::get_mini_task_name($name);
             printf('  %-' . $width . 's > %s' . "\n", pakeColor::colorize($mini_name, 'INFO'), $task->get_comment() . ($mini_name != $name ? ' [' . $name . ']' : ''));
         }
     }
     if ($has_alias) {
         print "\ntask aliases:\n";
         // display aliases
         foreach ($tasks as $name => $task) {
             if ($task->get_alias()) {
                 $mini_name = pakeTask::get_mini_task_name($name);
                 printf('  %-' . $width . 's = ' . self::$EXEC_NAME . ' %s' . "\n", pakeColor::colorize(pakeTask::get_mini_task_name($name), 'INFO'), $task->get_alias() . ($mini_name != $name ? ' [' . $name . ']' : ''));
             }
         }
     }
 }
コード例 #25
0
    static function colorize($text = '', $parameters = array(), $stream = STDOUT)
    {
        // disable colors if not supported (windows or non tty console)
        if (!pakeApp::isTTY()) {
            return $text;
        }
        static $options = array('bold' => 1, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, 'conceal' => 8);
        static $foreground = array('black' => 30, 'red' => 31, 'green' => 32, 'yellow' => 33, 'blue' => 34, 'magenta' => 35, 'cyan' => 36, 'white' => 37);
        static $background = array('black' => 40, 'red' => 41, 'green' => 42, 'yellow' => 43, 'blue' => 44, 'magenta' => 45, 'cyan' => 46, 'white' => 47);
        if (!is_array($parameters) && isset(self::$styles[$parameters])) {
            $parameters = self::$styles[$parameters];
        }
        $codes = array();
        if (isset($parameters['fg'])) {
            $codes[] = $foreground[$parameters['fg']];
        }
        if (isset($parameters['bg'])) {
            $codes[] = $background[$parameters['bg']];
        }
        foreach ($options as $option => $value) {
            if (isset($parameters[$option]) && $parameters[$option]) {
                $codes[] = $value;
            }
        }
        return "[" . implode(';', $codes) . 'm' . $text . "";
    }
}
pakeColor::style('ERROR', array('bg' => 'red', 'fg' => 'white', 'bold' => true));
pakeColor::style('INFO', array('fg' => 'green', 'bold' => true));
pakeColor::style('COMMENT', array('fg' => 'yellow'));
コード例 #26
0
function run_database_generate_self_service_by_value($args, $opts)

{

    G::LoadSystem('inputfilter');

    $filter = new InputFilter();

    $opts = $filter->xssFilterHard($opts);

    $args = $filter->xssFilterHard($args);

    try {

        $arrayWorkspace = get_workspaces_from_args($args);



        foreach ($arrayWorkspace as $value) {

            $workspace = $value;



            try {

                echo "Generating the table \"self-service by value\" for " . pakeColor::colorize($workspace->name, "INFO") . "\n";

                $workspace->appAssignSelfServiceValueTableGenerateData();

            } catch (Exception $e) {

                echo "Errors generating the table \"self-service by value\" of workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n";

            }



            echo "\n";

        }



        echo "Done!\n";

    } catch (Exception $e) {

        echo CLI::error($e->getMessage()) . "\n";

    }

}
コード例 #27
0
ファイル: pakeFunction.php プロジェクト: taryono/school
function pake_echo_comment($text)
{
    if (pakeApp::get_instance()->get_verbose()) {
        echo sprintf(pakeColor::colorize('   # %s', 'COMMENT'), $text) . "\n";
    }
}
コード例 #28
0
 * 
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd., 
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 * 
 */
if (!defined('PATH_THIRDPARTY')) {
    require_once $_SERVER['PWD'] . '/test/bootstrap/unit.php';
}
require_once PATH_THIRDPARTY . 'lime/lime.php';
define('G_ENVIRONMENT', G_TEST_ENV);
require_once PATH_CORE . 'config' . PATH_SEP . 'environments.php';
global $G_ENVIRONMENTS;
if (isset($G_ENVIRONMENTS)) {
    $dbfile = $G_ENVIRONMENTS[G_TEST_ENV]['dbfile'];
    if (!file_exists($dbfile)) {
        printf("%s \n", pakeColor::colorize("dbfile {$dbfile} doesn't exist for environment " . G_ENVIRONMENT, 'ERROR'));
        exit(200);
    } else {
        include $dbfile;
    }
} else {
    exit(201);
}
G::LoadThirdParty('pear/json', 'class.json');
G::LoadThirdParty('smarty/libs', 'Smarty.class');
G::LoadSystem('xmlform');
G::LoadSystem('xmlDocument');
G::LoadSystem('form');
G::LoadSystem('xmlDocument');
$t = new lime_test(11, new lime_output_color());
$obj = new Xml_Node('name', 'type', 'value');
コード例 #29
0
/**
 * fetch today's news regarding objects monitored by the user
 *
 * @param string $user - OppUser object
 * @return void
 * @author Guglielmo Celata
 */
function opp_sync_politician_image($pol)
{
    $start_time = microtime(true);
    $success = true;
    echo pakeColor::colorize(sprintf('Processing politician %s...', $pol), array('fg' => 'red', 'bold' => true));
    // invoke the remote getPolImage function to grab the images from op_openpolis
    $remote_img_url = sfConfig::get('app_remote_politicians_images_service_url') . '/' . sfConfig::get('app_remote_openpolis_api_key') . '/' . $pol->getId();
    /* debug
      echo pakeColor::colorize(sprintf('Url:  %s...', $remote_img_url), 
                              array('fg' => 'red', 'bold' => true));
      */
    $file = fopen($remote_img_url, "r");
    if (!$file) {
        $err = "unable to open remote file.";
        $success = false;
    }
    $remote_img_str = '';
    while (!feof($file)) {
        $remote_img_str .= fgets($file, 1024);
    }
    fclose($file);
    $images_root = SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'parlamentari' . DIRECTORY_SEPARATOR;
    // resizes images and stores them in the FS
    $picture = new sfImage();
    $picture->setMimeType('image/jpeg');
    $picture->loadString($remote_img_str);
    $picture->resize(91, null);
    $picture->saveAs($images_root . 'picture/' . $pol->getId() . '.jpeg', 'image/jpeg');
    $thumb = new sfImage();
    $thumb->setMimeType('image/jpeg');
    $thumb->loadString($remote_img_str);
    $thumb->resize(40, null);
    $thumb->saveAs($images_root . 'thumb/' . $pol->getId() . '.jpeg', 'image/jpeg');
    $execution_time = microtime(true) - $start_time;
    if ($success) {
        echo " ok (";
    } else {
        echo " {$err} (";
    }
    echo pakeColor::colorize(sprintf("%f", $execution_time), array('fg' => 'cyan'));
    echo ")\n";
}
コード例 #30
0
ファイル: pakeFunction.php プロジェクト: piotras/pake
function pake_echo_error($text)
{
    pake_echo(sprintf(pakeColor::colorize('   ! %s', 'ERROR'), $text));
}