本文整理汇总了PHP中ET::upgradeModel方法的典型用法代码示例。如果您正苦于以下问题:PHP ET::upgradeModel方法的具体用法?PHP ET::upgradeModel怎么用?PHP ET::upgradeModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ET
的用法示例。
在下文中一共展示了ET::upgradeModel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: news
/**
* Get a list of the most recent posts on the esoTalk blog. Also check for updates to the esoTalk software
* and return the update notification area.
*
* @return void
*/
public function news()
{
// Check for updates and add the update notification view to the response.
ET::upgradeModel()->checkForUpdates();
$this->json("updateNotification", $this->getViewContents("admin/updateNotification"));
// Now fetch the latest posts from the esoTalk blog.
// Thanks to Brian for this code.
// (http://stackoverflow.com/questions/250679/best-way-to-parse-rss-atom-feeds-with-php/251102#251102)
$xmlSource = file_get_contents("http://esotalk.org/blog/index.php/feed/");
$x = simplexml_load_string($xmlSource);
$posts = array();
// Go through each item in the RSS channel...
foreach ($x->channel->item as $item) {
$post = array("date" => (string) $item->pubDate, "ts" => strtotime($item->pubDate), "link" => (string) $item->link, "title" => (string) $item->title, "text" => (string) $item->description);
// Create summary as a shortened body and remove all tags.
$summary = strip_tags($post["text"]);
$maxLen = 200;
if (strlen($summary) > $maxLen) {
$summary = substr($summary, 0, $maxLen) . "...";
}
$post["summary"] = $summary;
$posts[] = $post;
}
// Render the news view.
$this->data("posts", $posts);
$this->render("admin/news");
}
示例2: action_index
/**
* Perform the upgrade process.
*
* @return void
*/
public function action_index()
{
try {
// Run the upgrade process.
ET::upgradeModel()->upgrade(C("esoTalk.version"));
// Update the version and serial in the config file.
ET::writeConfig(array("esoTalk.version" => ESOTALK_VERSION));
// Show a success message and redirect.
$this->message(T("message.upgradeSuccessful"), "success");
$this->redirect(URL(""));
} catch (Exception $e) {
$this->fatalError($e->getMessage());
}
}
示例3: init
/**
* Common initialization for all controllers, called on every page load. This will add basic user links to
* the "user" menu, and add core JS files and language definitions.
*
* If this is overridden, parent::init() should be called to maintain consistency between controllers.
*
* @return void
*/
public function init()
{
// Check for updates to the esoTalk software, but only if we're the root admin and we haven't checked in
// a while.
if (ET::$session->userId == C("esoTalk.rootAdmin") and C("esoTalk.admin.lastUpdateCheckTime") + C("esoTalk.updateCheckInterval") < time()) {
ET::upgradeModel()->checkForUpdates();
}
if ($this->responseType === RESPONSE_TYPE_DEFAULT) {
// If the user IS NOT logged in, add the 'login' and 'sign up' links to the bar.
if (!ET::$session->user) {
$this->addToMenu("user", "join", "<a href='" . URL("user/join?return=" . urlencode($this->selfURL)) . "' class='link-join'>" . T("Sign Up") . "</a>");
$this->addToMenu("user", "login", "<a href='" . URL("user/login?return=" . urlencode($this->selfURL)) . "' class='link-login'>" . T("Log In") . "</a>");
} else {
$this->addToMenu("user", "user", "<a href='" . URL("member/me") . "'>" . avatar(ET::$session->user, "thumb") . name(ET::$session->user["username"]) . "</a>");
$this->addToMenu("user", "settings", "<a href='" . URL("settings") . "' class='link-settings'>" . T("Settings") . "</a>");
if (ET::$session->isAdmin()) {
$this->addToMenu("user", "administration", "<a href='" . URL("admin") . "' class='link-administration'>" . T("Administration") . "</a>");
}
$this->addToMenu("user", "logout", "<a href='" . URL("user/logout?token=" . ET::$session->token) . "' class='link-logout'>" . T("Log Out") . "</a>");
}
// Get the number of members currently online and add it as a statistic.
if (C("esoTalk.members.visibleToGuests") or ET::$session->user) {
$online = ET::SQL()->select("COUNT(*)")->from("member")->where("UNIX_TIMESTAMP()-:seconds<lastActionTime")->bind(":seconds", C("esoTalk.userOnlineExpire"))->exec()->result();
$stat = Ts("statistic.online", "statistic.online.plural", number_format($online));
$stat = "<a href='" . URL("members/online") . "' class='link-membersOnline'>{$stat}</a>";
$this->addToMenu("statistics", "statistic-online", $stat);
}
$this->addToMenu("meta", "copyright", "<a href='http://esotalk.org/' target='_blank'>" . T("Powered by") . " esoTalk</a>");
// Set up some default JavaScript files and language definitions.
$this->addJSFile("core/js/lib/jquery.js", true);
$this->addJSFile("core/js/lib/jquery.migrate.js", true);
$this->addJSFile("core/js/lib/jquery.misc.js", true);
$this->addJSFile("core/js/lib/jquery.history.js", true);
$this->addJSFile("core/js/lib/jquery.scrollTo.js", true);
$this->addJSFile("core/js/global.js", true);
$this->addJSLanguage("message.ajaxRequestPending", "message.ajaxDisconnected", "Loading...", "Notifications");
$this->addJSVar("notificationCheckInterval", C("esoTalk.notificationCheckInterval"));
}
$this->trigger("init");
}
示例4: action_install
/**
* Now that all necessary checks have been made and data has been gathered, perform the installation.
*
* @return void
*/
public function action_install()
{
// If we aren't supposed to be here, get out.
if (!($info = ET::$session->get("install"))) {
$this->redirect(URL("install/info"));
}
// Make sure the base URL has a trailing slash.
if (substr($info["baseURL"], -1) != "/") {
$info["baseURL"] .= "/";
}
// Prepare the $config variable with the installation settings.
$config = array("esoTalk.installed" => true, "esoTalk.version" => ESOTALK_VERSION, "esoTalk.forumTitle" => $info["forumTitle"], "esoTalk.baseURL" => $info["baseURL"], "esoTalk.emailFrom" => "do_not_reply@{$_SERVER["HTTP_HOST"]}", "esoTalk.cookie.name" => 'et');
//"esoTalk.cookie.name" => preg_replace(array("/\s+/", "/[^\w]/"), array("_", ""), $info["forumTitle"]),
// Merge these new config settings into our current conifg variable.
ET::$config = array_merge(ET::$config, $config);
// Initialize the database with our MySQL details.
ET::$database->init(C("esoTalk.database.host"), C("esoTalk.database.user"), C("esoTalk.database.password"), C("esoTalk.database.dbName"), C("esoTalk.database.prefix"), C("esoTalk.database.connectionOptions"), C("esoTalk.database.port"));
// Run the upgrade model's install function.
try {
ET::upgradeModel()->install($info);
} catch (Exception $e) {
$this->fatalError($e->getMessage());
}
// Write the $config variable to config.php.
@unlink(PATH_CONFIG . "/config.php");
ET::writeConfig($config);
/*
// Write custom.css and index.html as empty files (if they're not already there.)
if (!file_exists(PATH_CONFIG."/custom.css")) file_put_contents(PATH_CONFIG."/custom.css", "");
file_put_contents(PATH_CONFIG."/index.html", "");
file_put_contents(PATH_UPLOADS."/index.html", "");
file_put_contents(PATH_UPLOADS."/avatars/index.html", "");
// Write a .htaccess file if they are using friendly URLs (and mod_rewrite).
if (C("esoTalk.urls.rewrite")) {
file_put_contents(PATH_ROOT."/.htaccess", "# Generated by esoTalk
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>");
}
*/
/*
// Write a robots.txt file.
file_put_contents(PATH_ROOT."/robots.txt", "User-agent: *
Crawl-delay: 10
Disallow: /conversations/*?search=*
Disallow: /members/
Disallow: /user/
Disallow: /conversation/start/");
*/
// Clear the session of install data.
ET::$session->remove("install");
// Re-initialize the session and log the administrator in.
ET::$session = ETFactory::make("session");
ET::$session->loginWithMemberId(1);
// Redirect them to the administration page.
$this->redirect(URL("admin"));
}
示例5: settings
public function settings($sender)
{
// Set up the settings form.
$form = ETFactory::make("form");
$form->action = URL("admin/plugins/settings/Debug");
// If the form was submitted...
if ($form->validPostBack("upgradeDB")) {
// Run the upgrade process.
ET::upgradeModel()->upgrade();
// Upgrade plugins as well.
foreach (ET::$plugins as $name => $plugin) {
$plugin->setup(C("{$name}.version"));
}
$sender->message(T("message.upgradeSuccessful"), "success");
$sender->redirect(URL("admin/plugins"));
}
$sender->data("debugSettingsForm", $form);
return $this->view("settings");
}
示例6: init
/**
* Common initialization for all controllers, called on every page load. This will add basic user links to
* the "user" menu, and add core JS files and language definitions.
*
* If this is overridden, parent::init() should be called to maintain consistency between controllers.
*
* @return void
*/
public function init()
{
// Check for updates to the esoTalk software, but only if we're the root admin and we haven't checked in
// a while.
if (ET::$session->userId == C("esoTalk.rootAdmin") and C("esoTalk.admin.lastUpdateCheckTime") + C("esoTalk.updateCheckInterval") < time()) {
ET::upgradeModel()->checkForUpdates();
}
if ($this->responseType === RESPONSE_TYPE_DEFAULT) {
// If the user IS NOT logged in, add the 'login' and 'sign up' links to the bar.
if (!ET::$session->user) {
$this->addToMenu("user", "login", "<a href='" . URL("user/login?return=" . urlencode($this->selfURL)) . "' class='link-login'>" . T("Log In") . "</a>");
$this->addToMenu("user", "join", "<a href='" . URL("user/join?return=" . urlencode($this->selfURL)) . "' class='link-join'>" . T("Sign Up") . "</a>");
} else {
$this->addToMenu("user", "user", "<a href='" . URL("member/me") . "'>" . avatar(ET::$session->userId, ET::$session->user["avatarFormat"], "thumb") . name(ET::$session->user["username"]) . "</a>");
// Fetch all unread notifications so we have a count for the notifications button.
$notifications = ET::activityModel()->getNotifications(-1);
$count = count($notifications);
$this->addToMenu("user", "notifications", "<a href='" . URL("settings/notifications") . "' id='notifications' class='popupButton " . ($count ? "new" : "") . "'><span>{$count}</span></a>");
// Show messages with these notifications.
$this->notificationMessages($notifications);
$this->addToMenu("user", "settings", "<a href='" . URL("settings") . "' class='link-settings'>" . T("Settings") . "</a>");
if (ET::$session->isAdmin()) {
$this->addToMenu("user", "administration", "<a href='" . URL("admin") . "' class='link-administration'>" . T("Administration") . "</a>");
}
$this->addToMenu("user", "logout", "<a href='" . URL("user/logout") . "' class='link-logout'>" . T("Log Out") . "</a>");
}
// Get the number of members currently online and add it as a statistic.
$online = ET::SQL()->select("COUNT(*)")->from("member")->where("UNIX_TIMESTAMP()-:seconds<lastActionTime")->bind(":seconds", C("esoTalk.userOnlineExpire"))->exec()->result();
$stat = Ts("statistic.online", "statistic.online.plural", number_format($online));
$stat = "<a href='" . URL("members/online") . "' class='link-membersOnline'>{$stat}</a>";
$this->addToMenu("statistics", "statistic-online", $stat);
$this->addToMenu("meta", "copyright", "<a href='http://esotalk.com/'>Powered by esoTalk" . (ET::$session->isAdmin() ? " " . ESOTALK_VERSION : "") . "</a>");
// Set up some default JavaScript files and language definitions.
$this->addJSFile("js/lib/jquery.js", true);
$this->addJSFile("js/lib/jquery.misc.js", true);
$this->addJSFile("js/lib/jquery.history.js", true);
$this->addJSFile("js/lib/jquery.scrollTo.js", true);
$this->addJSFile("js/global.js", true);
$this->addJSLanguage("message.ajaxRequestPending", "message.ajaxDisconnected", "Loading...", "Notifications");
$this->addJSVar("notificationCheckInterval", C("esoTalk.notificationCheckInterval"));
// If config/custom.css contains something, add it to be included in the page.
if (file_exists($file = PATH_CONFIG . "/custom.css") and filesize($file) > 0) {
$this->addCSSFile("config/custom.css", true);
}
}
$this->trigger("init");
}
示例7: settings
public function settings($sender)
{
// Set up the settings form.
$form = ETFactory::make("form");
$form->action = URL("admin/plugins");
// If the form was submitted...
if ($form->validPostBack("upgradeDB")) {
// Run the upgrade process.
ET::upgradeModel()->upgrade();
$sender->message(T("message.upgradeSuccessful"), "success");
$sender->redirect(URL("admin/plugins"));
}
$sender->data("debugSettingsForm", $form);
return $this->getView("settings");
}