当前位置: 首页>>代码示例>>PHP>>正文


PHP module::upgrade方法代码示例

本文整理汇总了PHP中module::upgrade方法的典型用法代码示例。如果您正苦于以下问题:PHP module::upgrade方法的具体用法?PHP module::upgrade怎么用?PHP module::upgrade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在module的用法示例。


在下文中一共展示了module::upgrade方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 (!identity::active_user()->admin && !Session::instance()->get("can_upgrade", false)) {
             access::forbidden();
         }
     }
     $available = module::available();
     // Upgrade gallery first
     $gallery = $available["gallery"];
     if ($gallery->code_version != $gallery->version) {
         module::upgrade("gallery");
         module::activate("gallery");
     }
     // Then upgrade the rest
     foreach (module::available() as $id => $module) {
         if ($id == "gallery") {
             continue;
         }
         if ($module->active && $module->code_version != $module->version) {
             module::upgrade($id);
         }
     }
     if (php_sapi_name() == "cli") {
         print "Upgrade complete\n";
     } else {
         url::redirect("upgrader");
     }
 }
开发者ID:ChrisRut,项目名称:gallery3,代码行数:33,代码来源:upgrader.php

示例2: 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 (!identity::active_user()->admin && !Session::instance()->get("can_upgrade", false)) {
             access::forbidden();
         }
         try {
             access::verify_csrf();
         } catch (Exception $e) {
             url::redirect("upgrader");
         }
     }
     $available = module::available();
     // Upgrade gallery first
     $gallery = $available["gallery"];
     if ($gallery->code_version != $gallery->version) {
         module::upgrade("gallery");
         module::activate("gallery");
     }
     // Then upgrade the rest
     $failed = array();
     foreach (module::available() as $id => $module) {
         if ($id == "gallery") {
             continue;
         }
         if ($module->active && $module->code_version != $module->version) {
             try {
                 module::upgrade($id);
             } catch (Exception $e) {
                 // @todo assume it's MODULE_FAILED_TO_UPGRADE for now
                 $failed[] = $id;
             }
         }
     }
     // If the upgrade failed, this will get recreated
     site_status::clear("upgrade_now");
     // Clear any upgrade check strings, we are probably up to date.
     site_status::clear("upgrade_checker");
     if (php_sapi_name() == "cli") {
         if ($failed) {
             print "Upgrade completed ** WITH FAILURES **\n";
             print "The following modules were not successfully upgraded:\n";
             print "  " . implode($failed, "\n  ") . "\n";
             print "Try getting newer versions or deactivating those modules\n";
         } else {
             print "Upgrade complete\n";
         }
     } else {
         if ($failed) {
             url::redirect("upgrader?failed=" . join(",", $failed));
         } else {
             url::redirect("upgrader");
         }
     }
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:59,代码来源:upgrader.php

示例3: 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 = Input::instance()->post($module_name) == 1;
         if ($info->active && !$desired && module::is_active($module_name)) {
             $changes->deactivate[] = $module_name;
             $deactivated_names[] = t($info->name);
             module::deactivate($module_name);
         } else {
             if (!$info->active && $desired && !module::is_active($module_name)) {
                 $changes->activate[] = $module_name;
                 $activated_names[] = t($info->name);
                 if (module::is_installed($module_name)) {
                     module::upgrade($module_name);
                 } else {
                     module::install($module_name);
                 }
                 module::activate($module_name);
             }
         }
     }
     module::event("module_change", $changes);
     // @todo this type of collation is questionable from an 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");
 }
开发者ID:viosca,项目名称:gallery3,代码行数:39,代码来源:admin_modules.php

示例4: _do_save

 private function _do_save()
 {
     $changes = new stdClass();
     $changes->activate = array();
     $changes->deactivate = array();
     $activated_names = array();
     $deactivated_names = array();
     foreach (module::available() as $module_name => $info) {
         if ($info->locked) {
             continue;
         }
         try {
             $desired = Input::instance()->post($module_name) == 1;
             if ($info->active && !$desired && module::is_active($module_name)) {
                 module::deactivate($module_name);
                 $changes->deactivate[] = $module_name;
                 $deactivated_names[] = t($info->name);
             } else {
                 if (!$info->active && $desired && !module::is_active($module_name)) {
                     if (module::is_installed($module_name)) {
                         module::upgrade($module_name);
                     } else {
                         module::install($module_name);
                     }
                     module::activate($module_name);
                     $changes->activate[] = $module_name;
                     $activated_names[] = t($info->name);
                 }
             }
         } catch (Exception $e) {
             message::warning(t("An error occurred while installing the <b>%module_name</b> module", array("module_name" => $info->name)));
             Kohana_Log::add("error", (string) $e);
         }
     }
     module::event("module_change", $changes);
     // @todo this type of collation is questionable from an 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))));
     }
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:43,代码来源:admin_modules.php


注:本文中的module::upgrade方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。