本文整理汇总了PHP中module::install方法的典型用法代码示例。如果您正苦于以下问题:PHP module::install方法的具体用法?PHP module::install怎么用?PHP module::install使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module
的用法示例。
在下文中一共展示了module::install方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
public function upgrade()
{
if (php_sapi_name() == "cli") {
// @todo this may screw up some module installers, but we don't have a better answer at
// this time.
$_SERVER["HTTP_HOST"] = "example.com";
} else {
if (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) {
access::forbidden();
}
}
// Upgrade gallery and user first
module::install("gallery");
module::install("user");
// Then upgrade the rest
foreach (module::available() as $id => $module) {
if ($id == "gallery") {
continue;
}
if ($module->active && $module->code_version != $module->version) {
module::install($id);
}
}
if (php_sapi_name() == "cli") {
print "Upgrade complete\n";
} else {
url::redirect("upgrader?done=1");
}
}
示例2: save
public function save()
{
access::verify_csrf();
$changes->activate = array();
$changes->deactivate = array();
$activated_names = array();
$deactivated_names = array();
foreach (module::available() as $module_name => $info) {
if ($info->locked) {
continue;
}
$desired = $this->input->post($module_name) == 1;
if ($info->active && !$desired && module::is_active($module_name)) {
$changes->deactivate[] = $module_name;
$deactivated_names[] = $info->name;
module::deactivate($module_name);
} else {
if (!$info->active && $desired && !module::is_active($module_name)) {
$changes->activate[] = $module_name;
$activated_names[] = $info->name;
module::install($module_name);
module::activate($module_name);
}
}
}
module::event("module_change", $changes);
// @todo this type of collation is questionable from a i18n perspective
if ($activated_names) {
message::success(t("Activated: %names", array("names" => join(", ", $activated_names))));
}
if ($deactivated_names) {
message::success(t("Deactivated: %names", array("names" => join(", ", $deactivated_names))));
}
url::redirect("admin/modules");
}
示例3: change
public function change()
{
access::verify_csrf();
$active_provider = module::get_var("gallery", "identity_provider", "user");
$providers = identity::providers();
$new_provider = Input::instance()->post("provider");
if ($new_provider != $active_provider) {
module::deactivate($active_provider);
// Switch authentication
identity::reset();
module::set_var("gallery", "identity_provider", $new_provider);
module::install($new_provider);
module::activate($new_provider);
module::event("identity_provider_changed", $active_provider, $new_provider);
module::uninstall($active_provider);
message::success(t("Changed to %description", array("description" => $providers->{$new_provider})));
try {
Session::instance()->destroy();
} catch (Exception $e) {
// We don't care if there was a problem destroying the session.
}
url::redirect(item::root()->abs_url());
}
message::info(t("The selected provider \"%description\" is already active.", array("description" => $providers->{$new_provider})));
url::redirect("admin/identity");
}
示例4: _reset
private function _reset()
{
$db = Database::instance();
// Drop all tables
foreach ($db->list_tables() as $table) {
$db->query("DROP TABLE IF EXISTS `{$table}`");
}
// Clean out data
dir::unlink(VARPATH . "uploads");
dir::unlink(VARPATH . "albums");
dir::unlink(VARPATH . "resizes");
dir::unlink(VARPATH . "thumbs");
dir::unlink(VARPATH . "modules");
dir::unlink(VARPATH . "tmp");
$db->clear_cache();
module::$modules = array();
module::$active = array();
// Use a known random seed so that subsequent packaging runs will reuse the same random
// numbers, keeping our install.sql file more stable.
srand(0);
gallery_installer::install(true);
module::load_modules();
foreach (array("user", "comment", "organize", "info", "rss", "search", "slideshow", "tag") as $module_name) {
module::install($module_name);
module::activate($module_name);
}
}
示例5: upgrade
static function upgrade()
{
if (module::get_version("register") < 1) {
module::install("register");
}
if (is_null(module::get_var("registration", "admin_notify")) || is_null(module::get_var("registration", "subject_prefix")) || module::get_version("register") < 2) {
module::set_var("registration", "admin_notify", false);
module::set_var("registration", "subject_prefix", "");
$db = Database::instance();
$db->query("ALTER TABLE {pending_users} ADD `locale` varchar(32) default NULL;");
}
module::set_version("register", 2);
}
示例6: install
public function install()
{
if (!parent::install() or !$this->registerHook('actionProductAdd') or !$this->registerHook('actionProductDelete') or !$this->registerHook('actionProductSave') or !$this->registerHook('actionProductUpdate') or !$this->registerHook('displayRightColumnProduct') or !$this->registerHook('displayFooter') or !$this->registerHook('displayBackOfficeHeader')) {
return false;
}
if (!Db::getInstance()->Execute('CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'supramulticurrency_product` (
`id_product` int(11) unsigned NOT NULL,
`id_currency` int(11) NOT NULL,
`product_price` decimal(10,2) NOT NULL,
`product_sale_price` decimal(10,2) NOT NULL,
`product_detail_prices` TEXT NULL,
PRIMARY KEY (`id_product`)) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8')) {
return false;
}
return true;
return true;
}
示例7: save
public function save()
{
foreach (module::available() as $module_name => $info) {
if ($info->locked) {
continue;
}
$desired = $this->input->post($module_name) == 1;
if ($info->installed && !$desired) {
module::uninstall($module_name);
message::success(t("Uninstalled %module_name module", array("module_name" => $info->name)));
} else {
if (!$info->installed && $desired) {
module::install($module_name);
message::success(t("Installed %module_name module", array("module_name" => $info->name)));
}
}
}
url::redirect("admin/modules");
}
示例8: install
/**
* Install
*
* Module installation routine
*
* @access private
*/
function install($data = '')
{
@umask(0);
if (!Is_Dir(ROOT . "./cms/calendar")) {
mkdir(ROOT . "./cms/calendar", 0777);
}
parent::install();
}
示例9: install
/**
* Install
*
* Module installation routine
*
* @access private
*/
function install($data = '')
{
parent::install();
}
示例10: install
/**
* Install
*
* Module installation routine
*
* @access private
*/
function install($parent_name = "")
{
if (!Is_Dir(ROOT . "./settings")) {
mkdir(ROOT . "./settings", 0777);
}
parent::install($parent_name);
}
示例11: Index
function Index()
{
if (!TEST_MODE) {
print Kohana::show_404();
}
// Jump through some hoops to satisfy the way that we check for the site_domain in
// config.php. We structure this such that the code in config will leave us with a
// site_domain of "." (for historical reasons)
// @todo: for tests, we should force the site_domain to something like example.com
$_SERVER["SCRIPT_FILENAME"] = "index.php";
$_SERVER["SCRIPT_NAME"] = "./index.php";
$original_config = DOCROOT . "var/database.php";
$test_config = VARPATH . "database.php";
if (!file_exists($original_config)) {
print "Please copy kohana/config/database.php to {$original_config}.\n";
return;
} else {
copy($original_config, $test_config);
$db_config = Kohana::config('database');
if (empty($db_config['unit_test'])) {
$default = $db_config['default'];
$conn = $default['connection'];
Kohana::config_set('database.unit_test.benchmark', $default['benchmark']);
Kohana::config_set('database.unit_test.persistent', $default['persistent']);
Kohana::config_set('database.unit_test.connection.type', $conn['type']);
Kohana::config_set('database.unit_test.connection.user', $conn['user']);
Kohana::config_set('database.unit_test.connection.pass', $conn['pass']);
Kohana::config_set('database.unit_test.connection.host', $conn['host']);
Kohana::config_set('database.unit_test.connection.port', $conn['port']);
Kohana::config_set('database.unit_test.connection.socket', $conn['socket']);
Kohana::config_set('database.unit_test.connection.database', "{$conn['database']}_test");
Kohana::config_set('database.unit_test.character_set', $default['character_set']);
Kohana::config_set('database.unit_test.table_prefix', $default['table_prefix']);
Kohana::config_set('database.unit_test.object', $default['object']);
Kohana::config_set('database.unit_test.cache', $default['cache']);
Kohana::config_set('database.unit_test.escape', $default['escape']);
$db_config = Kohana::config('database');
}
if ($db_config['default']['connection']['database'] == $db_config['unit_test']['connection']['database']) {
print "Don't use the default database for your unit tests or you'll lose all your data.\n";
return;
}
try {
$db = Database::instance('unit_test');
$db->connect();
// Make this the default database for the rest of this run
Database::$instances = array('default' => $db);
} catch (Exception $e) {
print "{$e->getMessage()}\n";
return;
}
}
try {
// Find all tests, excluding sample tests that come with the unit_test module.
foreach (glob(MODPATH . "*/tests") as $path) {
if ($path != MODPATH . "unit_test/tests") {
$paths[] = $path;
}
}
Kohana::config_set('unit_test.paths', $paths);
// Clean out the database
if ($tables = $db->list_tables()) {
foreach ($db->list_tables() as $table) {
$db->query("DROP TABLE {$table}");
}
}
// Clean out the filesystem
@system("rm -rf test/var");
@mkdir('test/var/logs', 0777, true);
// Reset our caches
module::$modules = array();
module::$active = array();
module::$var_cache = array();
$db->clear_cache();
// Rest the cascading class path
Kohana::config_set("core", Kohana::config_load("core"));
// Install all modules
// Force gallery and user to be installed first to resolve dependencies.
gallery_installer::install(true);
module::load_modules();
module::install("user");
module::activate("user");
$modules = array();
foreach (glob(MODPATH . "*/helpers/*_installer.php") as $file) {
$module_name = basename(dirname(dirname($file)));
if (in_array($module_name, array("gallery", "user"))) {
continue;
}
module::install($module_name);
module::activate($module_name);
}
// Trigger late-binding install actions (defined in gallery_event::user_login)
graphics::choose_default_toolkit();
$filter = count($_SERVER["argv"]) > 2 ? $_SERVER["argv"][2] : null;
print new Unit_Test($modules, $filter);
} catch (Exception $e) {
print "Exception: {$e->getMessage()}\n";
print $e->getTraceAsString() . "\n";
}
}
示例12: index
function index()
{
if (!TEST_MODE) {
throw new Kohana_404_Exception();
}
// Force strict behavior to flush out bugs early
ini_set("display_errors", true);
error_reporting(-1);
// Jump through some hoops to satisfy the way that we check for the site_domain in
// config.php. We structure this such that the code in config will leave us with a
// site_domain of "." (for historical reasons)
// @todo: for tests, we should force the site_domain to something like example.com
$_SERVER["SCRIPT_FILENAME"] = "index.php";
$_SERVER["SCRIPT_NAME"] = "./index.php";
$config = Kohana_Config::instance();
$original_config = DOCROOT . "var/database.php";
$test_config = VARPATH . "database.php";
if (!file_exists($original_config)) {
print "Please copy kohana/config/database.php to {$original_config}.\n";
return;
} else {
copy($original_config, $test_config);
$db_config = Kohana::config('database');
if (empty($db_config['unit_test'])) {
$default = $db_config['default'];
$conn = $default['connection'];
$config->set('database.unit_test.benchmark', $default['benchmark']);
$config->set('database.unit_test.persistent', $default['persistent']);
$config->set('database.unit_test.connection.type', $conn['type']);
$config->set('database.unit_test.connection.user', $conn['user']);
$config->set('database.unit_test.connection.pass', $conn['pass']);
$config->set('database.unit_test.connection.host', $conn['host']);
$config->set('database.unit_test.connection.port', $conn['port']);
$config->set('database.unit_test.connection.socket', $conn['socket']);
$config->set('database.unit_test.connection.database', "{$conn['database']}_test");
$config->set('database.unit_test.character_set', $default['character_set']);
$config->set('database.unit_test.table_prefix', $default['table_prefix']);
$config->set('database.unit_test.object', $default['object']);
$config->set('database.unit_test.cache', $default['cache']);
$config->set('database.unit_test.escape', $default['escape']);
$db_config = Kohana::config('database');
}
if ($db_config['default']['connection']['database'] == $db_config['unit_test']['connection']['database']) {
print "Don't use the default database for your unit tests or you'll lose all your data.\n";
return;
}
try {
$db = Database::instance('unit_test');
$db->connect();
// Make this the default database for the rest of this run
Database::set_default_instance($db);
} catch (Exception $e) {
print "{$e->getMessage()}\n";
return;
}
}
try {
// Clean out the database
if ($tables = $db->list_tables()) {
foreach ($db->list_tables() as $table) {
$db->query("DROP TABLE {{$table}}");
}
}
// Clean out the filesystem. Note that this cleans out test/var/database.php, but that's ok
// because we technically don't need it anymore. If this is confusing, we could always
// arrange to preserve that one file.
@system("rm -rf test/var");
@mkdir('test/var/logs', 0777, true);
$active_modules = module::$active;
// Reset our caches
module::$modules = array();
module::$active = array();
module::$var_cache = array();
$db->clear_cache();
// Rest the cascading class path
$config->set("core", $config->load("core"));
// Install the active modules
// Force gallery and user to be installed first to resolve dependencies.
gallery_installer::install(true);
module::load_modules();
module::install("user");
module::activate("user");
$modules = $paths = array();
foreach (module::available() as $module_name => $unused) {
if (in_array($module_name, array("gallery", "user"))) {
$paths[] = MODPATH . "{$module_name}/tests";
continue;
}
if (file_exists($path = MODPATH . "{$module_name}/tests")) {
$paths[] = $path;
module::install($module_name);
module::activate($module_name);
}
}
$config->set('unit_test.paths', $paths);
// Trigger late-binding install actions (defined in gallery_event::user_login)
graphics::choose_default_toolkit();
$filter = count($_SERVER["argv"]) > 2 ? $_SERVER["argv"][2] : null;
print new Unit_Test($modules, $filter);
} catch (ORM_Validation_Exception $e) {
//.........这里部分代码省略.........
示例13: install
function install($data = '')
{
parent::install();
subscribeToEvent($this->name, 'SAY');
addClass('IRCBots');
addClassProperty('IRCBots', 'message', 5);
addClassProperty('IRCBots', 'pushMessage');
//addClassProperty('IRCBots', 'alive');
addClassProperty('IRCBots', 'updated');
addClassProperty('IRCBots', 'updatedTime');
addClassMethod('IRCBots', 'onNewMessage', '$this->setProperty("updated", time());' . "\n" . '$this->setProperty("updatedTime", date("H:i"));' . "\n" . '$this->setProperty("message", $params["message"]);');
addClassObject('IRCBots', 'IRCBot1');
}
示例14: install
function install()
{
//$className = 'Push';
//$objectName = 'PushBullet';
//$propertis = array('API_KEY1', 'Device1');
$rec = SQLSelectOne("SELECT ID FROM classes WHERE TITLE LIKE '" . DBSafe($className) . "'");
if (!$rec['ID']) {
$rec = array();
$rec['TITLE'] = $className;
//$rec['PARENT_LIST']='0';
$rec['DESCRIPTION'] = 'Push-notes';
$rec['ID'] = SQLInsert('classes', $rec);
}
$obj_rec = SQLSelectOne("SELECT ID FROM objects WHERE CLASS_ID='" . $rec['ID'] . "' AND TITLE LIKE '" . DBSafe($objectName) . "'");
if (!$obj_rec['ID']) {
$obj_rec = array();
$obj_rec['CLASS_ID'] = $rec['ID'];
$obj_rec['TITLE'] = $objectName;
$obj_rec['DESCRIPTION'] = 'Настройки';
$obj_rec['ID'] = SQLInsert('objects', $obj_rec);
}
for ($i = 0; $i < count($propertis); $i++) {
$prop_rec = SQLSelectOne("SELECT ID FROM properties WHERE OBJECT_ID='" . $obj_rec['ID'] . "' AND TITLE LIKE '" . DBSafe($propertis[$i]) . "'");
if (!$prop_rec['ID']) {
$prop_rec = array();
$prop_rec['TITLE'] = $propertis[$i];
$prop_rec['OBJECT_ID'] = $obj_rec['ID'];
$prop_rec['ID'] = SQLInsert('properties', $prop_rec);
}
}
parent::install();
}
示例15: upgrade
static function upgrade()
{
if (is_null(module::get_var("tag_cloud_html5", "options_sidebar")) || is_null(module::get_var("tag_cloud_html5", "options_wholecloud")) || module::get_version("tag_cloud_html5") < 1) {
module::install("tag_cloud_html5");
}
if (module::get_version("tag_cloud_html5") < 2) {
// added wheelZoom, which is not accessible from admin menu
$options = json_decode(module::get_var("tag_cloud_html5", "options_sidebar"), true);
$options["wheelZoom"] = false;
module::set_var("tag_cloud_html5", "options_sidebar", json_encode($options));
$options = json_decode(module::get_var("tag_cloud_html5", "options_wholecloud"), true);
$options["wheelZoom"] = false;
module::set_var("tag_cloud_html5", "options_wholecloud", json_encode($options));
}
if (module::get_version("tag_cloud_html5") < 3) {
// added deadZone, initial, and initialDecel
module::set_var("tag_cloud_html5", "show_add_tag_form", true);
$options = json_decode(module::get_var("tag_cloud_html5", "options_sidebar"), true);
$options["deadZone"] = 0.25;
$options["initial"] = array(0.8, -0.3);
$options["initialDecel"] = true;
module::set_var("tag_cloud_html5", "options_sidebar", json_encode($options));
$options = json_decode(module::get_var("tag_cloud_html5", "options_wholecloud"), true);
$options["deadZone"] = 0.25;
$options["initial"] = array(0.8, -0.3);
$options["initialDecel"] = true;
module::set_var("tag_cloud_html5", "options_wholecloud", json_encode($options));
}
if (module::get_version("tag_cloud_html5") < 4) {
// added height_sidebar, then scaled back zoom and textHeight for consistency
module::set_var("tag_cloud_html5", "height_sidebar", 0.8);
$options = json_decode(module::get_var("tag_cloud_html5", "options_sidebar"), true);
$options["zoom"] = $options["zoom"] / 0.8;
$options["textHeight"] = $options["textHeight"] * 0.8;
module::set_var("tag_cloud_html5", "options_sidebar", json_encode($options));
}
if (module::get_version("tag_cloud_html5") < 5) {
// added lots of options that are on admin menu
// added physModel, lock, and initialDecel as options not on admin menu
// (previously initialDecel was on menu, so reset here)
module::set_var("tag_cloud_html5", "width_sidebar", 1.0);
module::set_var("tag_cloud_html5", "width_wholecloud", 0.95);
module::set_var("tag_cloud_html5", "height_wholecloud", 0.75);
$options = json_decode(module::get_var("tag_cloud_html5", "options_sidebar"), true);
$options["deadZone"] = $options["deadZone"];
$options["shape"] = "sphere";
$options["lock"] = "";
$options["stretchX"] = 1.0;
$options["stretchY"] = 1.0;
$options["decel"] = 0.92;
$options["physModel"] = true;
$options["maxInputZone"] = 0.25;
$options["minSpeed"] = 0.002;
$options["initialDecel"] = true;
module::set_var("tag_cloud_html5", "options_sidebar", json_encode($options));
$options = json_decode(module::get_var("tag_cloud_html5", "options_wholecloud"), true);
$options["deadZone"] = $options["deadZone"];
$options["shape"] = "sphere";
$options["lock"] = "";
$options["stretchX"] = 1.0;
$options["stretchY"] = 1.0;
$options["decel"] = 0.92;
$options["physModel"] = true;
$options["maxInputZone"] = 0.15;
$options["minSpeed"] = 0.002;
$options["initialDecel"] = true;
module::set_var("tag_cloud_html5", "options_wholecloud", json_encode($options));
}
// note: there are no variable changes for v6 and v7 upgrades
module::set_version("tag_cloud_html5", 7);
}