1
0

Merge branch 'master' of github.com:gallery/gallery3-contrib

This commit is contained in:
Bharat Mediratta 2010-08-28 21:11:14 -07:00
commit 9272744409
12 changed files with 443 additions and 62 deletions

View File

@ -0,0 +1,57 @@
<?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_adsense_Controller extends Admin_Controller {
public function index() {
$view = new Admin_View("admin.html");
$view->page_title = t("Adsense settings");
$view->content = new View("admin_adsense.html");
$view->content->form = $this->_get_admin_form();
print $view;
}
public function save() {
access::verify_csrf();
$form = $this->_get_admin_form();
if ($form->validate()) {
module::set_var("adsense", "code", $form->adsense->code->value);
module::set_var("adsense", "location", $form->adsense->location->value);
message::success(t("Adsense settings updated"));
url::redirect("admin/adsense");
} else {
print $form;
}
}
private function _get_admin_form() {
$form = new Forge("admin/adsense/save", "", "post", array("id" => "g-adsense-admin-form"));
$adsense_settings = $form->group("adsense")->label(t("Adsense settings"));
$adsense_settings->textarea("code")->label(t("Adsense code"))
->value(module::get_var("adsense", "code"));
$adsense_settings->dropdown("location")
->label(t("Where should the ads be displayed?"))
->options(array("header" => t("In the header"),
"sidebar" => t("In the sidebar"),
"footer" => t("In the footer")))
->selected(module::get_var("adsense", "location"));
$adsense_settings->submit("save")->value(t("Save"));
return $form;
}
}

View File

@ -0,0 +1,39 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 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 adsense_block_Core {
static function get_site_list() {
return array("adsense" => t("Adsense"));
}
static function get($block_id, $theme) {
$block = "";
switch ($block_id) {
case "adsense":
if (module::get_var("adsense", "location") == "sidebar") {
$block = new Block();
$block->css_id = "g-adsense";
$block->title = t("Adsense");
$block->content = new View("adsense_block.html");
}
break;
}
return $block;
}
}

View File

@ -0,0 +1,28 @@
<?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 adsense_event_Core {
static function admin_menu($menu, $theme) {
$menu->get("settings_menu")
->append(Menu::factory("link")
->id("adsense_menu")
->label(t("Adsense"))
->url(url::site("admin/adsense")));
}
}

View File

@ -0,0 +1,54 @@
<?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.
*/
//header_bottom or footer
class adsense_theme {
static function header_bottom($theme) {
if(module::get_var("adsense","location") == "header") {
$code = module::get_var("adsense", "code");
if (!$code) {
return;
}
$google_code = '
<script type="text/javascript">' . $code . '</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
return $google_code;
}
}
static function footer($theme) {
if(module::get_var("adsense","location") == "footer") {
$code = module::get_var("adsense", "code");
if (!$code) {
return;
}
$google_code = '
<script type="text/javascript">' . $code . '</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
return $google_code;
}
}
}

View File

@ -0,0 +1,3 @@
name = "Adsense"
description = "Display Google Adsense ads"
version = 1

View File

@ -0,0 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div class="g-block">
<h1> <?= t("Adsense settings") ?> </h1>
<div class="g-block-content">
<?= $form ?>
</div>
</div>

View File

@ -0,0 +1,17 @@
<?php
defined("SYSPATH") or die("No direct script access.");
if(module::get_var("adsense","location") == "sidebar") {
$code = module::get_var("adsense", "code");
if (!$code) {
return;
}
$google_code = '
<script type="text/javascript">' . $code . '</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
echo $google_code;
}
?>

View File

@ -39,40 +39,136 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
* @author brentil <forums@inner-ninja.com>
*/
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);
$devDebug = false;
$refreshCache = false;
$cache = unserialize(Cache::instance()->get("moduleupdates_cache"));
$cache_updates = unserialize(Cache::instance()->get("moduleupdates_cache_updates"));
//---------------------------------------------------------------------------------------------
//echo 'Message 01: ' .$cache_updates . '<br>';
//---------------------------------------------------------------------------------------------
//if someone pressed the button to refresh now
if (request::method() == "post") {
access::verify_csrf();
$cache = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
$cache_updates = array("date" => "", "updates" => 0);
$refreshCache = true;
}else if(count($cache) < 1 or $cache_updates['date'] == ""){
//if there are no items in the cache array or the update date is "" refresh the data
$cache = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
$cache_updates = array("date" => "", "updates" => 0);
$refreshCache = true;
}
//Check the ability to access the Gallery3 GitHub
$GitHub = null;
try {
$GitHub = fopen ("http://github.com", "r");
if ($GitHub != null) {
$GitHub = '<font color=green>Online</font>';
}else{
$GitHub = '<font color=red>Offline</font>';
}
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
//Check the ability to access the Google
$Google = null;
try {
$Google = fopen ("http://google.com", "r");
if ($Google != null) {
$Google = '<font color=green>Online</font>';
}else{
$Google = '<font color=red>Offline</font>';
}
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
foreach (module::available() as $this_module_name => $module_info) {
$remote_version = '';
$remote_server = '';
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 ($module_info->version != '' and $module_info->code_version < $module_info->version) {
$font_color = "pink";
} else if ($module_info->version != '' and $module_info->code_version > $module_info->version) {
$font_color = "orange";
} else if ($remote_version < $module_info->code_version or ($module_info->version != '' and $remote_version < $module_info->version)) {
$font_color = "green";
} else if ($remote_version > $module_info->code_version or ($module_info->version != '' and $remote_version > $module_info->version)) {
$font_color = "red";
}
if($refreshCache == true){
foreach (module::available() as $this_module_name => $module_info) {
//example code for setting cache values
//Cache::instance()->set($key, "$log{$msg}", array("task", "log", "import"), 2592000);
//example delete cache
//Cache::instance()->delete("update_l10n_cache:{$task->id}");
//example for reading cache
//$log = Cache::instance()->get($key);
$remote_version = '';
$remote_server = '';
$update_count = 0;
list ($remote_version, $remote_server) = $this->get_remote_module_version($this_module_name, $devDebug);
$font_color = "black";
//BLUE - DNE: Does Not Exist, this module was not found
if ($remote_version == "DNE") {
$font_color = "blue";
//PINK - Your installed version is newer than file version
} else if ($module_info->version != '' and $module_info->code_version < $module_info->version) {
$font_color = "pink";
//ORANGE - Your file version is newer than the installed version
} else if ($module_info->version != '' and $module_info->code_version > $module_info->version) {
$font_color = "orange";
//GREEN - Your version is newer than the GitHub
} else if ($remote_version < $module_info->code_version or ($module_info->version != ''
and $remote_version < $module_info->version)) {
$font_color = "green";
//RED - Your version is older than the GitHub
} else if ($remote_version > $module_info->code_version or ($module_info->version != ''
and $remote_version > $module_info->version)) {
$font_color = "red";
$update_count++;
/*
if($remote_server == "(G3)"){
$module_info->name = "<a href=\"http://github.com/gallery/gallery3/tree/master/modules/".$this_module_name."\" target=\"_new\">".$module_info->name."</a>";
}else if($remote_server == "(G3CC)"){
$module_info->name = "<a href=\"http://github.com/gallery/gallery3-contrib/tree/master/modules/".$this_module_name."\" target=\"_new\">".$module_info->name."</a>";
}else if($remote_server == "(brentil)"){
$module_info->name = "<a href=\"http://github.com/brentil/gallery3-contrib/tree/master/modules/".$this_module_name."\" target=\"_new\">".$module_info->name."</a>";
}
*/
}
$module_info->name = "<a href=\"http://codex.gallery2.org/Gallery3:Modules:".$this_module_name."\" target=\"_new\">".$module_info->name."</a>";
//populate the list fo modules and their data
$cache->$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);
}
$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);
//Define right now as YYYY.MM.DD HH:MM with the # of updates that are out of date
$cache_updates = array("date" => date("Y.m.d - H:i"), "updates" => $update_count);
//---------------------------------------------------------------------------------------------
//echo 'Message 02: ' .$cache_updates . '<br>';
//---------------------------------------------------------------------------------------------
//Write out the new data to cache with a 30 day expiration & 0 for update data so it's always present
Cache::instance()->set("moduleupdates_cache", serialize($cache), array("ModuleUpdates"), 30*86400);
Cache::instance()->set("moduleupdates_cache_updates", serialize($cache_updates), array("ModuleUpdates"), null);
log::success("moduleupdates", t("Completed checking remote GitHub for modules updates."));
}
$view->content->vars = $cache;
$view->content->update_time = $cache_updates['date'];
$view->content->csrf = access::csrf_token();
$view->content->Google = $Google;
$view->content->GitHub = $GitHub;
$view->content->vars = $all_modules;
print $view;
}
@ -91,22 +187,41 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
* @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) {
private function get_remote_module_version ($module_name, $devDebug) {
$version = 'DNE';
$server = '';
$file = null;
try {
$file = fopen ("http://github.com/gallery/gallery3/raw/master/modules/".$module_name."/module.info", "r");
if ($file != null) {
$server = '(G3)';
}
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
//For development debug only
if ($devDebug == true){
if ($file == null) {
try {
$file = fopen ("http://github.com/brentil/gallery3-contrib/raw/master/modules/".$module_name."/module.info", "r");
if ($file != null) {
$server = '(brentil)';
}
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
}
}
//Check the main Gallery3 GitHub
if ($file == null) {
try {
$file = fopen ("http://github.com/gallery/gallery3/raw/master/modules/".$module_name."/module.info", "r");
if ($file != null) {
$server = '(G3)';
}
}
catch (Exception $e) {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
}
//Check the Gallery3 Community Contributions GitHub
if ($file == null) {
try {
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/modules/".$module_name."/module.info", "r");
@ -118,7 +233,7 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
//echo 'Message: ' .$e->getMessage() . '<br>';
}
}
if ($file != null) {
while (!feof ($file)) {
$line = fgets ($file, 1024);

View File

@ -17,21 +17,35 @@
* 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) {
module::set_version("moduleupdates", 1);
module::set_version("moduleupdates", 2);
//Remove the ModuleUpdates cache entry 'JIC'
Cache::instance()->delete("ModuleUpdates");
//create the blank ModuleUpdates cache entry with an expiration of 0 days
Cache::instance()->set("moduleupdates_cache", "", array("ModuleUpdates"), null);
Cache::instance()->set("moduleupdates_cache_updates", "", array("ModuleUpdates"), null);
}
}
static function upgrade($version) {
module::set_version("moduleupdates", 2);
//Remove the ModuleUpdates cache entry 'JIC'
Cache::instance()->delete("ModuleUpdates");
//Empty the ModuleUpdates cache entry so our new version starts from scratch
Cache::instance()->set("moduleupdates_cache", "", array("ModuleUpdates"), null);
Cache::instance()->set("moduleupdates_cache_updates", "", array("ModuleUpdates"), null);
}
static function uninstall() {
//Remove the ModuleUpdates cache entry as we remove the module
Cache::instance()->delete("ModuleUpdates");
module::delete("moduleupdates");
}
}

View File

@ -1,3 +1,3 @@
name = "Module Updates"
description = "Compares your installed module version against the ones stored in the GitHub."
version = 1
version = 2

View File

@ -1,21 +1,33 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="g-admin-moduleupdates" class="g-block">
<h1> <?= t("Module Updates v1.2") ?> </h1>
<p>
<?= t("Compares your installed module version against the ones stored in the GitHub.<br><br>") ?>
<?= t("<font color=red>Red = Your version is older than the GitHub</font><br>") ?>
<?= t("<font color=green>Green = Your version is newer than the GitHub</font><br>") ?>
<?= t("<font color=orange>Orange = Your file version is newer than the installed version</font><br>") ?>
<?= t("<font color=pink>Pink = Your installed version is newer than file version</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) and official Gallery3 Community Contributions (G3CC). Versions downloaded from the forums will not be shown.") ?></li>
</ul>
<h1> <?= t("Module Updates v2.0") ?> </h1>
<?= t("Compares your installed module version against the ones stored in the GitHub.") ?>
<div class="g-block-content">
<form method="post" action="<?= url::site("admin/moduleupdates") ?>" id="g-configure-moduleupdates-form">
<input type="hidden" name="csrf" value="<? echo $csrf; ?>" />
<fieldset>
<legend>ModuleUpdates Information</legend>
<ul>
<li><?= t("<font color=red>Red = Your version is older than the GitHub</font><br>") ?></li>
<li><?= t("<font color=green>Green = Your version is newer than the GitHub</font><br>") ?></li>
<li><?= t("<font color=orange>Orange = Your file version is newer than the installed version</font><br>") ?></li>
<li><?= t("<font color=pink>Pink = Your installed version is newer than file version</font><br>") ?></li>
<li><?= t("<font color=blue>Blue = Does Not Exist/No information available</font><br>") ?></li>
<li><?= t("Outbound Status: " . $Google . " - GitHub Status: " . $GitHub . "<br>") ?></li>
<li><input type="submit" value="<?= t("Check Modules for Updates")?>" class="submit" /> <? if($update_time == ""){ echo "&nbsp;- Last Scan: Unknown";}else{ echo "&nbsp;- Last Scan: ".$update_time;} ?></li>
</ul>
</fieldset>
</form>
<br>
<ul id="g-action-status" class="g-message-block">
<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>
<table>
<tr>
<th> <?= t("Module") ?> </th>
@ -25,14 +37,12 @@
</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'].">"; ?> <?= t($module_name['name']) ?> </font> </td>
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['code_version'] ?><? if ($module_name['version'] != '') echo "/".$module_name['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'].">"; ?> <?= t($module_name['description']) ?> </font> </td>
</tr>
<? endforeach ?>
</table>
</div>
</div>
<pre>
</pre>
</div>

View File

@ -26,11 +26,38 @@
//
?>
<?
// @mamouneyya
// in order to add 'first' & 'last' navigation buttons for item pages. code inspired from GreyDragon Wind theme
if ($page_type == "item"): {
if ($item):
$parent = $item->parent();
endif;
$current_page = $position;
$total_pages = $total;
$siblings = $item->parent()->children();
for ($i = 1; $i <= $total; $i++):
$_pagelist[$i] = $siblings[$i-1]->url();
endfor;
}
endif;
?>
<ul class="g-paginator ui-helper-clearfix">
<li class="g-first">
<? if ($page_type == "collection"): ?>
<? if (isset($first_page_url)): ?>
<a href="<?= $first_page_url ?>" class="g-button ui-icon-left ui-state-default ui-corner-all">
<a href="<?= $first_page_url ?>" class="g-button ui-icon-left ui-state-default ui-corner-all" id="g-navi-first">
<span class="ui-icon ui-icon-seek-first"></span><?= t("First") ?></a>
<? else: ?>
<a class="g-button ui-icon-left ui-state-disabled ui-corner-all">
<span class="ui-icon ui-icon-seek-first"></span><?= t("First") ?></a>
<? endif ?>
<? endif ?>
<? if ($page_type == "item"): ?>
<? if ($current_page > 1): ?>
<a href="<?= $_pagelist[1] ?>" class="g-button ui-icon-left ui-state-default ui-corner-all" id="g-navi-first">
<span class="ui-icon ui-icon-seek-first"></span><?= t("First") ?></a>
<? else: ?>
<a class="g-button ui-icon-left ui-state-disabled ui-corner-all">
@ -39,7 +66,7 @@
<? endif ?>
<? if (isset($previous_page_url)): ?>
<a href="<?= $previous_page_url ?>" class="g-button ui-icon-left ui-state-default ui-corner-all">
<a href="<?= $previous_page_url ?>" class="g-button ui-icon-left ui-state-default ui-corner-all" id="g-navi-prev">
<span class="ui-icon ui-icon-seek-prev"></span><?= t("Previous") ?></a>
<? else: ?>
<a class="g-button ui-icon-left ui-state-disabled ui-corner-all">
@ -67,7 +94,7 @@
<li class="g-text-right">
<? if (isset($next_page_url)): ?>
<a href="<?= $next_page_url ?>" class="g-button ui-icon-right ui-state-default ui-corner-all">
<a href="<?= $next_page_url ?>" class="g-button ui-icon-right ui-state-default ui-corner-all" id="g-navi-next">
<span class="ui-icon ui-icon-seek-next"></span><?= t("Next") ?></a>
<? else: ?>
<a class="g-button ui-state-disabled ui-icon-right ui-corner-all">
@ -76,7 +103,17 @@
<? if ($page_type == "collection"): ?>
<? if (isset($last_page_url)): ?>
<a href="<?= $last_page_url ?>" class="g-button ui-icon-right ui-state-default ui-corner-all">
<a href="<?= $last_page_url ?>" class="g-button ui-icon-right ui-state-default ui-corner-all" id="g-navi-last">
<span class="ui-icon ui-icon-seek-end"></span><?= t("Last") ?></a>
<? else: ?>
<a class="g-button ui-state-disabled ui-icon-right ui-corner-all">
<span class="ui-icon ui-icon-seek-end"></span><?= t("Last") ?></a>
<? endif ?>
<? endif ?>
<? if ($page_type == "item"): ?>
<? if ($current_page < $total_pages): ?>
<a href="<?= $_pagelist[$total_pages] ?>" class="g-button ui-icon-right ui-state-default ui-corner-all" id="g-navi-last">
<span class="ui-icon ui-icon-seek-end"></span><?= t("Last") ?></a>
<? else: ?>
<a class="g-button ui-state-disabled ui-icon-right ui-corner-all">