|
[Php-blog-plugin-cvs]
additional_plugins/serendipity_plugin_imagesidebar
lang_en.inc.php, 1.4, 1.5 menalto_sidebar.php, 1.4,
1.5 serendipity_plugin_imagesidebar.php, 1.9, 1.10
From: Matthew Groeninger <mgroeninger@us...> - 2006-12-13 08:08
|
Update of /cvsroot/php-blog/additional_plugins/serendipity_plugin_imagesidebar
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9971/serendipity_plugin_imagesidebar
Modified Files:
lang_en.inc.php menalto_sidebar.php
serendipity_plugin_imagesidebar.php
Log Message:
Added url options for Menalto Gallery version 2.
Added support for g2_type (not just random) g2_maxSize, g2_linkTarget, and g2_show.
Also added caching option, so that server will not do gallery request on every page request.
Index: lang_en.inc.php
===================================================================
RCS file: /cvsroot/php-blog/additional_plugins/serendipity_plugin_imagesidebar/lang_en.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- lang_en.inc.php 10 Oct 2006 20:51:41 -0000 1.4
+++ lang_en.inc.php 13 Dec 2006 08:08:02 -0000 1.5
@@ -24,9 +24,24 @@
@define('PLUGIN_GALLERYRANDOMBLOCK_NUMREPEAT_DESC', 'Enter the number of random photos to show in this block.');
@define('PLUGIN_GALLERYRANDOMBLOCK_FILE_NAME', 'Filename of the embedded script (Only used for Gallery 1.x versions!)');
@define('PLUGIN_GALLERYRANDOMBLOCK_VERSION', 'Which version of Gallery are you using?');
-@...', 'ERROR: URL could not be opened. Either your PHP does not support URL fopen Wrappers or you specified the wrong inclusion URL; the gallery cannot be embedded here');
-@...', 'Album ID to show');
+@define('PLUGIN_GALLERYRANDOMBLOCK_ERROR_CONNECT', 'ERROR: URL could not be opened. the gallery cannot be embedded here');
+@define('PLUGIN_GALLERYRANDOMBLOCK_ERROR_HTTP', 'ERROR: The HTTP server returned the error or the warning(result:%d).');@define('PLUGIN_GALLERYRANDOMBLOCK_ITEMID', 'Album ID to show');
@define('PLUGIN_GALLERYRANDOMBLOCK_ITEMID_DESC', 'Empty value shows all albums, only applies to Gallery 2.x versions.');
+@define('PLUGIN_GALLERYRANDOMBLOCK_G2DISPLAYTYPE', 'Picture to display.');
+@define('PLUGIN_GALLERYRANDOMBLOCK_G2DISPLAYTYPE_RAND', 'Random');
+@define('PLUGIN_GALLERYRANDOMBLOCK_G2DISPLAYTYPE_RENCENT', 'Recent');
+@define('PLUGIN_GALLERYRANDOMBLOCK_G2DISPLAYTYPE_VIEWED', 'Most Viewed');
+@define('PLUGIN_GALLERYRANDOMBLOCK_G2DISPLAYTYPE_SPECIFIC','Specific');
+@define('PLUGIN_GALLERYRANDOMBLOCK_SINGLE_ITEMID', 'ID of the specific image to display.');
+@define('PLUGIN_GALLERYRANDOMBLOCK_SINGLE_ITEMID_DESC', '');
+@define('PLUGIN_GALLERYRANDOMBLOCK_MAXSIZE','Maximium Width of Image.');
+@define('PLUGIN_GALLERYRANDOMBLOCK_MAXSIZE_DESC','This will set the image to a specific width. Unfortunately, this setting causes the large image to be downloaded and then rescaled to the required size. Leave blank to use the standard Gallery thumbnail.');
+@define('PLUGIN_GALLERYRANDOMBLOCK_LINKTARGET','Link Target');
+@define('PLUGIN_GALLERYRANDOMBLOCK_LINKTARGET_DESC','Sets the links "target" option. Leave blank to leave unset. A good setting might be "_blank".');
+@define('PLUGIN_GALLERYRANDOMBLOCK_SHOWDETAIL','Which details should be displayed.');
+@define('PLUGIN_GALLERYRANDOMBLOCK_SHOWDETAIL_DESC','Tell the plugin which details to display. This must be a comma seperated list of keywords. Available keywords are "title, date, views, owner, heading". To display no information use the keyword "none".');
+
+
@define('PLUGIN_CPGS_NAME', 'Coppermine Thumbnails');
@define('PLUGIN_CPGS_DESC', 'Display thumbnails from a Coppermine gallery in the sidebar');
Index: serendipity_plugin_imagesidebar.php
===================================================================
RCS file: /cvsroot/php-blog/additional_plugins/serendipity_plugin_imagesidebar/serendipity_plugin_imagesidebar.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- serendipity_plugin_imagesidebar.php 1 Dec 2006 09:00:55 -0000 1.9
+++ serendipity_plugin_imagesidebar.php 13 Dec 2006 08:08:03 -0000 1.10
@@ -75,7 +75,7 @@
$propbag->add('description', PLUGIN_SIDEBAR_IMAGESIDEBAR_DESC);
$propbag->add('stackable', true);
$propbag->add('author', 'Andrew Brown (Menalto code), Matthew Groeninger (Unified/Media Lib. Code), Stefan Lange-Hegermann (Zooomr Code), Matthew Maude (Coppermine code)');
- $propbag->add('version', '0.93');
+ $propbag->add('version', '0.95');
$propbag->add('license', 'BSD');
$propbag->add('requirements', array(
'serendipity' => '0.8',
Index: menalto_sidebar.php
===================================================================
RCS file: /cvsroot/php-blog/additional_plugins/serendipity_plugin_imagesidebar/menalto_sidebar.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- menalto_sidebar.php 10 Oct 2006 07:25:32 -0000 1.4
+++ menalto_sidebar.php 13 Dec 2006 08:08:02 -0000 1.5
@@ -4,7 +4,7 @@
function introspect_custom()
{
- return array('menalto_path', 'menalto_file', 'menalto_repeat', 'menalto_gversion');
+ return array('menalto_path', 'menalto_file', 'menalto_repeat', 'menalto_rotate_time', 'menalto_gversion','g2_type','itemId','g2_maxsize','g2_linkTarget','g2_show','menalto_next_update','menalto_cache_output');
}
function introspect_config_item_custom($name, &$propbag)
@@ -20,10 +20,17 @@
break;
case 'itemId':
- $propbag->add('type', 'string');
- $propbag->add('name', PLUGIN_GALLERYRANDOMBLOCK_ITEMID);
- $propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_ITEMID_DESC);
- $propbag->add('default', '');
+ if ($this->get_config('menalto_gversion',1) == 2) {
+ $propbag->add('type', 'string');
+ if ($this->get_config('g2_type',1) == 4) {
+ $propbag->add('name', PLUGIN_GALLERYRANDOMBLOCK_SINGLE_ITEMID);
+ $propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_SINGLE_ITEMID_DESC);
+ } else {
+ $propbag->add('name', PLUGIN_GALLERYRANDOMBLOCK_ITEMID);
+ $propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_ITEMID_DESC);
+ }
+ $propbag->add('default', '');
+ }
break;
case 'menalto_path':
@@ -40,11 +47,12 @@
if ((int)$serendipity['serendipityUserlevel'] < (int)USERLEVEL_ADMIN) {
return false;
}
-
- $propbag->add('type', 'string');
- $propbag->add('name', PLUGIN_GALLERYRANDOMBLOCK_FILE_NAME);
- $propbag->add('description', '');
- $propbag->add('default', 'block-random.php');
+ if ($this->get_config('menalto_gversion',1) == 1) {
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_GALLERYRANDOMBLOCK_FILE_NAME);
+ $propbag->add('description', '');
+ $propbag->add('default', 'block-random.php');
+ }
break;
case 'menalto_repeat':
@@ -53,6 +61,13 @@
$propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_NUMREPEAT_DESC);
$propbag->add('default', '1');
break;
+
+ case 'menalto_rotate_time':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_ROTATETIME_NAME);
+ $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_ROTATETIME_DESC);
+ $propbag->add('default', '60');
+ break;
case 'menalto_gversion':
$propbag->add('type', 'select');
@@ -66,6 +81,48 @@
break;
+ case 'g2_type':
+ if ($this->get_config('menalto_gversion','1') == '2') {
+ $propbag->add('type', 'select');
+ $propbag->add('name', PLUGIN_GALLERYRANDOMBLOCK_G2DISPLAYTYPE);
+ $propbag->add('description', '');
+ $propbag->add('default', 1);
+ $propbag->add('select_values', array(
+ 1 => PLUGIN_GALLERYRANDOMBLOCK_G2DISPLAYTYPE_RAND,
+ 2 => PLUGIN_GALLERYRANDOMBLOCK_G2DISPLAYTYPE_RENCENT,
+ 3 => PLUGIN_GALLERYRANDOMBLOCK_G2DISPLAYTYPE_VIEWED,
+ 4 => PLUGIN_GALLERYRANDOMBLOCK_G2DISPLAYTYPE_SPECIFIC
+ ));
+ }
+ break;
+
+
+ case 'g2_maxsize':
+ if ($this->get_config('menalto_gversion',1) == 2) {
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_GALLERYRANDOMBLOCK_MAXSIZE);
+ $propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_MAXSIZE_DESC);
+ $propbag->add('default', '');
+ }
+ break;
+
+ case 'g2_linkTarget':
+ if ($this->get_config('menalto_gversion',1) == 2) {
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_GALLERYRANDOMBLOCK_LINKTARGET);
+ $propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_LINKTARGET_DESC);
+ $propbag->add('default', '');
+ }
+ break;
+
+ case 'g2_show':
+ if ($this->get_config('menalto_gversion',1) == 2) {
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_GALLERYRANDOMBLOCK_SHOWDETAIL);
+ $propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_SHOWDETAIL_DESC);
+ $propbag->add('default', 'title, date, views, owner, heading');
+ }
+ break;
default:
return false;
}
@@ -75,33 +132,95 @@
function generate_content_custom(&$title) {
global $serendipity;
- $title = $this->get_config('title');
- $path = $this->get_config('menalto_path');
- $file = $this->get_config('menalto_file');
- $repeat = $this->get_config('menalto_repeat');
+ $update = true;
+ $rotate_time = (int)$this->get_config('menalto_rotate_time');
+ $next_update = $this->get_config('menalto_next_update');
- if (!is_numeric($repeat)) {
- $repeat = 1;
+ if (@include_once("Cache/Lite.php")) {
+ $cache_obj = new Cache_Lite( array('cacheDir' => $serendipity['serendipityPath'].'templates_c/','automaticSerialization' => true));
+ $cache_output = $cache_obj->get('menaltosidebar_cache');
+ } else {
+ $cache_output = $this->get_config('menalto_cache_output','');
}
-
- if (substr($path,-1) != '/') {
- $path .= '/';
+ if ($rotate_time !=0 ) {
+ if ($next_update > time()) {
+ $update = false;
+ } else {
+ $next_update = $this->calc_update_time($rotate_time,$next_update);
+ $this->set_config('menalto_next_update',$next_update);
+ }
}
+ $title = $this->get_config('title', $this->title);
+ if ($update || $cache_output == '') {
- if ((int)$this->get_config('menalto_gversion') === 2) {
- $file = 'main.php?g2_view=imageblock:External&g2_blocks=randomImage&g2_itemFrame=none';
- $gid = $this->get_config('itemId');
- if ($gid > 0) {
- $file .='&g2_itemId=' . $gid;
+ $path = $this->get_config('menalto_path');
+ $file = $this->get_config('menalto_file');
+ $repeat = $this->get_config('menalto_repeat');
+
+ if (!is_numeric($repeat)) {
+ $repeat = 1;
}
- }
-
- if (empty($file)) {
- $file = 'block-random.php';
- }
- for ($i=1; $i <= $repeat; $i++) {
+ if (substr($path,-1) != '/') {
+ $path .= '/';
+ }
+
+ if ((int)$this->get_config('menalto_gversion') === 2) {
+ $file = 'main.php?g2_view=imageblock:External&g2_itemFrame=none';
+ $gid = $this->get_config('itemId');
+ if ($gid > 0) {
+ $file .='&g2_itemId=' . $gid;
+ }
+ switch ((int)$this->get_config('g2_type')) {
+ case 4:
+ $file .='&g2_blocks=specificItem';
+ break;
+ case 3:
+ $file .='&g2_blocks=viewedImage';
+ break;
+ case 2:
+ $file .='&g2_blocks=recentImage';
+ break;
+ case 1:
+ default:
+ $file .='&g2_blocks=randomImage';
+ break;
+ }
+
+ $maxsize = (int)$this->get_config('g2_maxsize','');
+ if ($maxsize > 0) {
+ $file .='&g2_maxSize=' . $maxsize;
+ }
+
+ $linktarget = $this->get_config('g2_linkTarget','');
+ if ($linktarget != '') {
+ $file .='&g2_linkTarget=' . $linktarget;
+ }
+
+ $show_detail = $this->get_config('g2_show','');
+ if ($show_detail != '') {
+ $details = explode(',',$show_detail);
+ foreach ($details as $detail) {
+ $details_string = $details_string . trim($detail) . '|';
+ }
+ $details_string = substr($details_string,0,strlen($details_string)-1);
+ $file .='&g2_show=' . $details_string;
+ if ($maxsize > 0) {
+ $file .='|fullSize';
+ }
+ } else {
+ if ($maxsize > 0) {
+ $file .='&g2_show=fullSize';
+ }
+ }
+ }
+
+ if (empty($file)) {
+ $file = 'block-random.php';
+ }
+ $output_str = '';
+ for ($i=1; $i <= $repeat; $i++) {
$options = array();
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
if (function_exists('serendipity_request_start')) {
@@ -110,19 +229,49 @@
$req = new HTTP_Request($path.$file,$options);
$req_result = $req->sendRequest();
if ( PEAR::isError( $req_result)) {
- echo PLUGIN_GALLERYRANDOMBLOCK_ERROR_CONNECT . "<br />\n";
+ $output_str = $output_str. PLUGIN_GALLERYRANDOMBLOCK_ERROR_CONNECT . "<br />\n";
} else {
$res_code = $req->getResponseCode();
if ($res_code != "200") {
- printf( PLUGIN_GALLERYRANDOMBLOCK_ERROR_HTTP . "<br />\n", $res_code);
+ $output_str = $output_str. sprintf( PLUGIN_GALLERYRANDOMBLOCK_ERROR_HTTP . "<br />\n", $res_code);
} else {
- echo $req->getResponseBody();
+ $output_str = $output_str. $req->getResponseBody();
}
}
if ($i < $repeat) {
- echo '<hr />';
+ $output_str = $output_str. '<hr />';
}
+ }
+ if (class_exists('Cache_Lite') && is_object($cache_obj)) {
+ $cache_obj->save($output_str,'menaltosidebar_cache');
+ } else {
+ $this->set_config('menalto_cache_output',$output_str);
+ }
+ } else {
+ $output_str = $cache_output;
+ }
+ echo $output_str;
+ }
+
+ function calc_update_time ($rotate_time,$last_update) {
+ $next_time = mktime(date("H"), date("i"), 0, date("m"), date("d"), date("Y"));
+ if ($last_update == '') {
+ $last_update = mktime(date("H"), 0, 0, date("m"), date("d"), date("Y"));
}
+ if ($rotate_time !=0 ) {
+ if ($rotate_time > 1440) {
+ $rotate_time = 1440;
+ }
+ $day = (int) ($rotate_time / 1440);
+ $hours = (int) (($rotate_time % 1440)/ 60);
+ $minutes = (int) ((($rotate_time % 1440) % 60)/1);
+ while ($next_time < time()) {
+ $next_time = mktime(date("H",$last_update)+$hours, date("i",$last_update)+$minutes, 0, date("m",$last_update), date("d",$last_update)+ $day, date("Y",$last_update));
+ $last_update = $next_time;
+ }
+ }
+ return $next_time;
+
}
}
|
| Thread | Author | Date |
|---|---|---|
| [Php-blog-plugin-cvs] additional_plugins/serendipity_plugin_imagesidebar lang_en.inc.php, 1.4, 1.5 menalto_sidebar.php, 1.4, 1.5 serendipity_plugin_imagesidebar.php, 1.9, 1.10 | Matthew Groeninger <mgroeninger@us...> |