*/ public function index() { $view = new Admin_View("admin.html"); $view->page_title = t("Gallery 3 :: Manage Module Updates"); $view->content = new View("admin_moduleupdates.html"); $all_modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); foreach (module::available() as $this_module_name => $module_info) { list ($remote_version, $remote_server) = $this->get_remote_module_version($this_module_name); $font_color = "black"; if ($remote_version == "DNE") { $font_color = "blue"; } else if ($remote_version < $module_info->code_version) { $font_color = "green"; } 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, "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 = $all_modules; print $view; } /** * 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 * @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) { $version = 'DNE'; $server = ''; $file = null; try { $file = fopen ("http://github.com/gallery/gallery3/raw/master/modules/".$module_name."/module.info", "r"); $server = '(G3)'; } catch (Exception $e) { //echo 'Message: ' .$e->getMessage() . '
'; } if ($file == null) { try { $file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/modules/".$module_name."/module.info", "r"); $server = '(G3CC)'; } catch (Exception $e) { //echo 'Message: ' .$e->getMessage() . '
'; } } if ($file != null) { while (!feof ($file)) { $line = fgets ($file, 1024); //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); } return array ($version, $server); } }