Cleaned up copy of v1 to conform to coding standards, file spacing, and added extra documentation.
This commit is contained in:
parent
bbee742b64
commit
74bca55d52
@ -1,9 +1,43 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
|
||||
DEFINE("SITEMAP_FILENAME", "sitemap.xml");
|
||||
<?php defined("SYSPATH") or die("No direct script access.");/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
class Admin_Moduleupdates_Controller extends Admin_Controller {
|
||||
|
||||
/**
|
||||
* Builds the backend information for the Module Updates page.
|
||||
*
|
||||
* Builds an array of data containing the needed information about an installed copy of Gallery3
|
||||
* to determine if versions stored in the GitHub are newer.
|
||||
*
|
||||
* List ID: The name of the folder the module resides in (obtained from module::available)
|
||||
* name: The given name of the module (obtained from module::available)
|
||||
* locked: If the module is considered locked by Gallery (obtained from module::available)
|
||||
* code_version: The version of the module in the modules directory (obtained from module::available)
|
||||
* active: If the module is installed and enabled (obtained from module::available)
|
||||
* version: The version installed and running (obtained from module::available)
|
||||
* description: The description of the module (obtained from module::available)
|
||||
* remote_version: The version of the code on GitHub (obtained from get_remote_module_version)
|
||||
* remote_server: The server the remote version is on (obtained from get_remote_module_version)
|
||||
* font_color: The color to display the update in depending on its status
|
||||
*
|
||||
* @author brentil <forums@inner-ninja.com>
|
||||
*/
|
||||
public function index() {
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->page_title = t("Gallery 3 :: Manage Module Updates");
|
||||
@ -11,78 +45,81 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
||||
|
||||
$all_modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
|
||||
|
||||
foreach (module::available() as $this_module_name => $module_info){
|
||||
foreach (module::available() as $this_module_name => $module_info) {
|
||||
|
||||
list($remote_version, $remote_server) = $this->get_remote_module_version($this_module_name);
|
||||
list ($remote_version, $remote_server) = $this->get_remote_module_version($this_module_name);
|
||||
|
||||
$font_color = "black";
|
||||
if($remote_version == "DNE"){
|
||||
if ($remote_version == "DNE") {
|
||||
$font_color = "blue";
|
||||
}else if($remote_version < $module_info->code_version){
|
||||
} else if ($remote_version < $module_info->code_version) {
|
||||
$font_color = "green";
|
||||
}else if($remote_version > $module_info->code_version){
|
||||
} else if ($remote_version > $module_info->code_version) {
|
||||
$font_color = "red";
|
||||
}
|
||||
$all_modules->$this_module_name = array("name" => $module_info->name, "locked" => $module_info->locked, "code_version" => $module_info->code_version, "locked" => $module_info->active, "version" => $module_info->version,"description" => $module_info->description, "remote_version" => $remote_version, "remote_server" => $remote_server, "font_color" => $font_color);
|
||||
//echo $this_module_name."=".$this->get_remote_module_version($this_module_name)."<br>";
|
||||
$all_modules->$this_module_name = array ("name" => $module_info->name, "locked" => $module_info->locked,
|
||||
"code_version" => $module_info->code_version, "active" => $module_info->active,
|
||||
"version" => $module_info->version,"description" => $module_info->description,
|
||||
"remote_version" => $remote_version, "remote_server" => $remote_server, "font_color" => $font_color);
|
||||
}
|
||||
|
||||
//$view->content->vars = module::available();
|
||||
|
||||
$view->content->vars = $all_modules;
|
||||
|
||||
print $view;
|
||||
}
|
||||
|
||||
private function get_remote_module_version($module_name){
|
||||
|
||||
/**
|
||||
* Parses the known GitHub repositories for new versions of modules.
|
||||
*
|
||||
* Searches the remote GitHub repositories for a module with a like filename to that of the ones
|
||||
* installed in the running Gallery isntall. Reads the remote modules module.info file to
|
||||
* gather the version information. Uses the following locations;
|
||||
*
|
||||
* http://github.com/gallery/gallery3
|
||||
* http://github.com/gallery/gallery3-contrib
|
||||
*
|
||||
* @author brentil <forums@inner-ninja.com>
|
||||
* @param String The folder name of the module to search for on the remote GitHub server
|
||||
* @return Array An array with the remote module version and the server it was found on.
|
||||
*/
|
||||
private function get_remote_module_version ($module_name) {
|
||||
|
||||
//http://github.com/gallery/gallery3-contrib/raw/master/modules/**MOD_NAME**/module.info
|
||||
$version = 'DNE';
|
||||
$server = '';
|
||||
$file = null;
|
||||
|
||||
try{
|
||||
try {
|
||||
$file = fopen ("http://github.com/gallery/gallery3/raw/master/modules/".$module_name."/module.info", "r");
|
||||
//$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/modules/google_analytics/module.info", "r");
|
||||
$server = '(G3)';
|
||||
}
|
||||
catch(Exception $e){
|
||||
catch (Exception $e) {
|
||||
//echo 'Message: ' .$e->getMessage() . '<br>';
|
||||
}
|
||||
|
||||
if ($file == null) {
|
||||
try{
|
||||
try {
|
||||
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/modules/".$module_name."/module.info", "r");
|
||||
$server = '(G3CC)';
|
||||
}
|
||||
catch(Exception $e){
|
||||
catch (Exception $e) {
|
||||
//echo 'Message: ' .$e->getMessage() . '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($file == null) {
|
||||
try{
|
||||
$file = fopen ("http://github.com/rWatcher/gallery3-contrib/raw/master/modules/".$module_name."/module.info", "r");
|
||||
$server = '(rW)';
|
||||
}
|
||||
catch(Exception $e){
|
||||
//echo 'Message: ' .$e->getMessage() . '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($file != null) {
|
||||
while (!feof ($file)) {
|
||||
$line = fgets ($file, 1024);
|
||||
/* This only works if the title and its tags are on one line */
|
||||
|
||||
//Regular expression to find & gather the version number in the remote module.info file
|
||||
if (preg_match ("@version = (.*)@i", $line, $out)) {
|
||||
$version = $out[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose($file);
|
||||
}
|
||||
fclose ($file);
|
||||
}
|
||||
|
||||
return array ($version, $server);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,17 +16,11 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
class moduleupdates_event {
|
||||
static function module_change($changes) {
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class moduleupdates_event_Core {
|
||||
|
||||
static function admin_menu($menu, $theme) {
|
||||
|
||||
$menu->get("settings_menu")
|
||||
->append(Menu::factory("link")
|
||||
->id("moduleupdates_menu")
|
||||
|
@ -16,11 +16,13 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
class moduleupdates_installer {
|
||||
|
||||
static function install() {
|
||||
|
||||
$version = module::get_version("moduleupdates");
|
||||
if ($version == 0) {
|
||||
/* @todo Put database creation here */
|
||||
module::set_version("moduleupdates", 1);
|
||||
}
|
||||
}
|
||||
@ -29,7 +31,7 @@ class moduleupdates_installer {
|
||||
}
|
||||
|
||||
static function uninstall() {
|
||||
/* @todo Put database table drops here */
|
||||
|
||||
module::delete("moduleupdates");
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
name = "Module Updates"
|
||||
description = "Compares your installed module version against the ones stored in the GIT Hub."
|
||||
description = "Compares your installed module version against the ones stored in the GitHub."
|
||||
version = 1
|
||||
|
@ -1,31 +1,32 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
|
||||
<div id="g-admin-moduleupdates" class="g-block">
|
||||
<h1> <?= t("Module Updates") ?> </h1>
|
||||
<p>
|
||||
<?= t("Compares your installed module version against the ones stored in the GitHub.<br><br>") ?>
|
||||
<?= t("Compares your installed module version against the ones stored in the GitHub.<br><br>") ?>
|
||||
<?= t("<font color=red>Red = Out of Date</font><br>") ?>
|
||||
<?= t("<font color=green>Green = Your version is newer</font><br>") ?>
|
||||
<?= t("<font color=blue>Blue = Does Not Exist/No information available</font><br>") ?>
|
||||
</p>
|
||||
|
||||
<ul id="g-action-status" class="g-message-block">
|
||||
<li class="g-warning"><?= t("Versions are compared from the official Gallery3 (G3), official Gallery3 Community Contributions (G3CC), & rWatcher (rW). Versions downloaded from the forums will not be shown.") ?></li>
|
||||
<li class="g-warning"><?= t("Versions are compared from the official Gallery3 (G3) and official Gallery3 Community Contributions (G3CC). Versions downloaded from the forums will not be shown.") ?></li>
|
||||
</ul>
|
||||
|
||||
<div class="g-block-content">
|
||||
<table>
|
||||
<tr>
|
||||
<th> <?= t("Module") ?> </th>
|
||||
<th> <?= t("Your Version") ?> </th>
|
||||
<th> <?= t("Your Version") ?> </th>
|
||||
<th> <?= t("Remote Version") ?> </th>
|
||||
<th> <?= t("Description") ?> </th>
|
||||
<th> <?= t("Description") ?> </th>
|
||||
</tr>
|
||||
<? foreach ($vars as $module_name): ?>
|
||||
<tr class="<?= text::alternate("g-odd", "g-even") ?>">
|
||||
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['name'] ?> </font> </td>
|
||||
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['code_version'] ?> </font> </td>
|
||||
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['code_version'] ?> </font> </td>
|
||||
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['remote_version'] ?> <?= $module_name['remote_server'] ?> </font> </td>
|
||||
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['description'] ?> </font> </td>
|
||||
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['description'] ?> </font> </td>
|
||||
</tr>
|
||||
<? endforeach ?>
|
||||
</table>
|
||||
|
Reference in New Issue
Block a user