/** * * @param array $options */ public function setInstallInfo($options) { $this->installInfo = array(); // Base info $module_name = $options['module']; $module_dir = conf::pathModules() . "/{$module_name}"; // ini file info $ini_file = $module_dir . "/{$module_name}.ini"; $ini_file_dist = $module_dir . "/{$module_name}.ini-dist"; // If profile is set. Then use profile's module ini dist settings if (isset($options['profile'])) { $ini_file_dist = conf::pathBase() . "/profiles/{$options['profile']}/{$module_name}.ini-dist"; } // If module_dir already exists, then try to load ini settings of the module if (file_exists($module_dir)) { // Generate an ini file $this->generateInifile($ini_file, $ini_file_dist); // Merge in locale.ini settings if found $this->loadLocaleIniSettings($module_dir); // load install.inc if found $install_file = "{$module_dir}/install.inc"; $this->loadInstallFile($module_name, $install_file); } else { $status = "No module dir: {$module_dir}"; common::echoStatus('NOTICE', 'y', $status); return false; } }
/** * will update all translation files in specified language * @param array $options */ function translate_path($options) { if (!isset($options['path'])) { common::abort('Add a path'); } $path = conf::pathBase() . "/{$options['path']}"; if (!file_exists($path) or !is_dir($path)) { common::abort('Specify a dir as path'); } $e = new extractor(); if (!empty($options['language'])) { $e->defaultLanguage = $options['language']; } $e->setSingleDir($options['path']); $e->updateLang(); common::echoStatus('OK', 'g', 'Extraction done'); }
function db_to_sqlite($options = array()) { $check = "which sequel"; if (common::execCommand($check)) { common::echoMessage('You need sequel. Install it like this, e.g.:'); common::echoMessage('sudo aptitude install ruby-sequel libsqlite3-ruby libmysql-ruby'); common::abort(); } else { common::echoStatus('OK', 'g', 'Sequel is installed'); } $ok = false; $info = admin::getDbInfo(); if (!$info) { return db_no_url(); } if ($info['scheme'] == 'mysql') { $ok = true; } if ($info['scheme'] == 'mysqli') { $ok = true; } if (!$ok) { common::echoStatus('ERROR', 'r', 'Driver needs to be mysql or mysqli'); } $fs = new Filesystem(); $fs->remove('sqlite/database.sql'); $username = conf::getMainIni('username'); $password = conf::getMainIni('password'); $command = "sequel "; $command .= "{$info['scheme']}://{$username}:{$password}@{$info['host']}/{$info['dbname']} "; $command .= "-C "; $command .= "sqlite://sqlite/database.sql"; $ret = common::systemCommand($command); $base = conf::pathBase(); if (!$ret) { $fs->chmod('sqlite/database.sql', 0777, 00, true); common::echoMessage('Sqlite database created. Edit config.ini and add:'); common::echoMessage("sqlite:/{$base}/sqlite/database.sql"); } }
function miau_test($options) { echo common::colorOutput('These are the options given to function miau_test()', 'Cyan'); echo PHP_EOL; // Print the arguments print_r($options); // echo a string with a newline echo common::echoMessage('Draw a cat!'); // echo a colored string. You will need to add newlines echo common::colorOutput('Miau', 'y') . PHP_EOL; // Read a line from the user $str = common::readSingleline('What does a cat say? (Enter input) '); // Echo a formatted status echo common::echoStatus('OK', 'y', $str); // confirm with a yes or a no $res = common::readlineConfirm('Please confirm that you are sure ' . $str); // readlineConfirm return 1 on 'y' and 0 on 'n' if (!$res) { echo common::colorOutput('Ok - you made a mistake!', 'r') . PHP_EOL; } else { echo common::colorOutput('OK. You are sure. ', 'b') . PHP_EOL; } }
/** * Try to set a public clone URL in a module array * @param string $module_name name of the module * @return string $val clone url */ public static function getCloneUrlModule($module_name) { $path = conf::pathModules() . "/{$module_name}"; if (!file_exists($path)) { echo $path . " NOT" . PHP_EOL; common::echoStatus('NOTICE', 'y', "module {$module_name} has no module source"); return false; } return self::getCloneUrlFromPath($path); }
/** * passthru wrapper which print command being passthru'ed * @param string $command * @return int $res result from passthrou */ function multi_passthru($command) { common::echoStatus('NOTICE', 'g', "Executing command: {$command}"); passthru($command, $ret); return $ret; }
/** * function for upgrading a module, template or profile according to latest tag * or master * * @param array with module options * @param string tag with wersion or 'master' * @param string module, templatee or profile. */ function cos_git_commit($val, $type = 'module') { $repo_path = cos_get_repo_path($val['module_name'], $type); if (!cos_git_is_repo($repo_path)) { common::echoMessage("{$repo_path} is not a git repo"); return; } if (empty($val['private_clone_url'])) { common::echoMessage("No private clone url is set in install.inc of {$val['module_name']}"); return; } if (!common::readlineConfirm("You are about to commit module: {$val['module_name']}. Continue?")) { return; } common::echoStatus('COMMIT', 'g', "Module: '{$val['module_name']}'"); $git_add = "cd {$repo_path} && git add . "; common::execCommand($git_add); $git_command = "cd {$repo_path} && git commit "; proc_close(proc_open($git_command, array(0 => STDIN, 1 => STDOUT, 2 => STDERR), $pipes)); $git_push = "cd {$repo_path} && git push {$val['private_clone_url']}"; //passthru($git_command); common::execCommand($git_push); echo PHP_EOL; }
/** * Try to set a public clone URL in a module array * @param array $val module info * @return array $val module info with a public clone URL. If a public clone URL exists */ public static function getCloneUrl($module_name) { $module_path = conf::pathModules() . "/{$module_name}"; if (!file_exists($module_path)) { common::echoStatus('NOTICE', 'y', "module {$module_name} has no module source"); return false; } $command = "cd {$module_path} && git config --get remote.origin.url"; $ret = common::execCommand($command, array('silence' => 1), 0); if ($ret == 0) { $git_url = shell_exec($command); return trim($git_url); } return false; }