[pLog-svn] r1147 - in plugins/trunk: . blogtimes blogtimes/class
blogtimes/class/action blogtimes/class/view blogtimes/js
blogtimes/js/colorpicker blogtimes/js/colorpicker/img
blogtimes/locale blogtimes/templates
mark at devel.plogworld.net
mark at devel.plogworld.net
Sun Feb 20 06:41:41 GMT 2005
Author: mark
Date: 2005-02-20 06:41:40 +0000 (Sun, 20 Feb 2005)
New Revision: 1147
Added:
plugins/trunk/blogtimes/
plugins/trunk/blogtimes/class/
plugins/trunk/blogtimes/class/action/
plugins/trunk/blogtimes/class/action/pluginblogtimesconfigaction.class.php
plugins/trunk/blogtimes/class/action/pluginblogtimesupdateconfigaction.class.php
plugins/trunk/blogtimes/class/view/
plugins/trunk/blogtimes/class/view/pluginblogtimesconfigview.class.php
plugins/trunk/blogtimes/js/
plugins/trunk/blogtimes/js/colorpicker/
plugins/trunk/blogtimes/js/colorpicker/img/
plugins/trunk/blogtimes/js/colorpicker/img/logo.gif
plugins/trunk/blogtimes/js/colorpicker/img/pixel.gif
plugins/trunk/blogtimes/js/colorpicker/img/sel.gif
plugins/trunk/blogtimes/js/colorpicker/img/tcolorp.gif
plugins/trunk/blogtimes/js/colorpicker/picker.html
plugins/trunk/blogtimes/js/colorpicker/picker.js
plugins/trunk/blogtimes/locale/
plugins/trunk/blogtimes/locale/locale_en_UK.php
plugins/trunk/blogtimes/locale/locale_zh_TW.php
plugins/trunk/blogtimes/pluginblogtimes.class.php
plugins/trunk/blogtimes/readme.txt
plugins/trunk/blogtimes/templates/
plugins/trunk/blogtimes/templates/blogtimes.template
Log:
Upload blogtimes plugin, only Admin UI ready!
Added: plugins/trunk/blogtimes/class/action/pluginblogtimesconfigaction.class.php
===================================================================
--- plugins/trunk/blogtimes/class/action/pluginblogtimesconfigaction.class.php 2005-02-20 06:38:21 UTC (rev 1146)
+++ plugins/trunk/blogtimes/class/action/pluginblogtimesconfigaction.class.php 2005-02-20 06:41:40 UTC (rev 1147)
@@ -0,0 +1,26 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/blogtimes/class/view/pluginblogtimesconfigview.class.php" );
+
+ /**
+ * shows a form with the current configuration
+ */
+ class PluginBlogTimesConfigAction extends AdminAction
+ {
+
+ function PluginBlogTimesConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ $this->_view = new PluginBlogTimesConfigView( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/blogtimes/class/action/pluginblogtimesupdateconfigaction.class.php
===================================================================
--- plugins/trunk/blogtimes/class/action/pluginblogtimesupdateconfigaction.class.php 2005-02-20 06:38:21 UTC (rev 1146)
+++ plugins/trunk/blogtimes/class/action/pluginblogtimesupdateconfigaction.class.php 2005-02-20 06:41:40 UTC (rev 1147)
@@ -0,0 +1,149 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/blogtimes/class/view/pluginblogtimesconfigview.class.php" );
+
+ /**
+ * updates the plugin configuration
+ */
+ class PluginBlogTimesUpdateConfigAction extends AdminAction
+ {
+ var $_pluginEnabled;
+ var $_backColor;
+ var $_boxColor;
+ var $_textColor;
+ var $_lineColor;
+ var $_borderColor;
+ var $_tickColor;
+ var $_title;
+ var $_lastDays;
+
+ function PluginBlogTimesUpdateConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function validate()
+ {
+ $error = 0;
+
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+
+ $this->_backColor = $this->_request->getValue( "backColor" );
+ if( !$this->isValidColor($this->_backColor) ) $error = 1;
+
+ $this->_boxColor = $this->_request->getValue( "boxColor" );
+ if( !$this->isValidColor($this->_boxColor) ) $error = 1;
+
+ $this->_textColor = $this->_request->getValue( "textColor" );
+ if( !$this->isValidColor($this->_textColor) ) $error = 1;
+
+ $this->_lineColor = $this->_request->getValue( "lineColor" );
+ if( !$this->isValidColor($this->_lineColor) ) $error = 1;
+
+ $this->_borderColor = $this->_request->getValue( "borderColor" );
+ if( !$this->isValidColor($this->_borderColor) ) $error = 1;
+
+ $this->_tickColor = $this->_request->getValue( "tickColor" );
+ if( !$this->isValidColor($this->_tickColor) ) $error = 1;
+
+ if( $error ) {
+ $this->_view = new PluginBlogTimesConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("blogtimes_error_color_code"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ $this->_title = $this->_request->getValue( "title" );
+ if ( $this->_title == "" ) {
+ $this->_view = new PluginBlogTimesConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("blogtimes_error_title"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ $this->_width = $this->_request->getValue( "width" );
+ if ( $this->_width < 240 || !ctype_digit($this->_width) ) {
+ $this->_view = new PluginBlogTimesConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("blogtimes_error_width"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ $this->_height = $this->_request->getValue( "height" );
+ if ( $this->_height < 30 || !ctype_digit($this->_height) ) {
+ $this->_view = new PluginBlogTimesConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("blogtimes_error_height"));
+ $this->setCommonData();
+
+ return false;
+ }
+ $this->_lastDays = $this->_request->getValue( "lastDays" );
+ if ( $this->_lastDays < 0 || !ctype_digit($this->_lastDays) ) {
+ $this->_view = new PluginBlogTimesConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("blogtimes_error_last_days"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ return true;
+ }
+
+ function perform()
+ {
+ // update the plugin configurations to blog setting
+ $blogSettings = $this->_blogInfo->getSettings();
+ $blogSettings->setValue( "plugin_blogtimes_enabled", $this->_pluginEnabled );
+ $blogSettings->setValue( "plugin_blogtimes_backcolor", $this->_backColor );
+ $blogSettings->setValue( "plugin_blogtimes_boxcolor", $this->_boxColor );
+ $blogSettings->setValue( "plugin_blogtimes_textcolor", $this->_textColor );
+ $blogSettings->setValue( "plugin_blogtimes_linecolor", $this->_lineColor );
+ $blogSettings->setValue( "plugin_blogtimes_bordercolor", $this->_borderColor );
+ $blogSettings->setValue( "plugin_blogtimes_tickcolor", $this->_tickColor );
+ $blogSettings->setValue( "plugin_blogtimes_title", $this->_title );
+ $blogSettings->setValue( "plugin_blogtimes_width", $this->_width );
+ $blogSettings->setValue( "plugin_blogtimes_height", $this->_height );
+ $blogSettings->setValue( "plugin_blogtimes_lastdays", $this->_lastDays );
+ $this->_blogInfo->setSettings( $blogSettings );
+
+ // save the blogs settings
+ $blogs = new Blogs();
+ if( !$blogs->updateBlog( $this->_blogInfo->getId(), $this->_blogInfo )) {
+ $this->_view = new PluginBlogTimesConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ // if everything went ok...
+ $this->_blogInfo->setSettings( $blogSettings );
+ $this->_session->setValue( "blogInfo", $this->_blogInfo );
+ $this->saveSession();
+
+ $this->_view = new PluginBlogTimesConfigView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("blogtimes_settings_saved_ok"));
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ return true;
+ }
+
+ function isValidColor($colorCode) {
+ $pattern = "#[a-fA-F0-9]{6}";
+ $length = strlen($colorCode);
+ if (ereg ($pattern, $colorCode) && $length == 7) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/blogtimes/class/view/pluginblogtimesconfigview.class.php
===================================================================
--- plugins/trunk/blogtimes/class/view/pluginblogtimesconfigview.class.php 2005-02-20 06:38:21 UTC (rev 1146)
+++ plugins/trunk/blogtimes/class/view/pluginblogtimesconfigview.class.php 2005-02-20 06:41:40 UTC (rev 1147)
@@ -0,0 +1,57 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ /**
+ * implements the main view of the feed reader plugin
+ */
+ class PluginBlogTimesConfigView extends AdminPluginTemplatedView
+ {
+
+ function PluginBlogTimesConfigView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "blogtimes", "blogtimes" );
+ }
+
+ function render()
+ {
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_blogtimes_enabled" );
+ $backColor = $blogSettings->getValue( "plugin_blogtimes_backcolor" );
+ if ($backColor == "") $backColor = "#FFFFFF";
+ $boxColor = $blogSettings->getValue( "plugin_blogtimes_boxcolor" );
+ if ($boxColor == "") $boxColor = "#666666";
+ $textColor = $blogSettings->getValue( "plugin_blogtimes_textcolor" );
+ if ($textColor == "") $textColor = "#000000";
+ $lineColor = $blogSettings->getValue( "plugin_blogtimes_linecolor" );
+ if ($lineColor == "") $lineColor = "#FFFFFF";
+ $borderColor = $blogSettings->getValue( "plugin_blogtimes_bordercolor" );
+ if ($borderColor == "") $borderColor = "#666666";
+ $tickColor = $blogSettings->getValue( "plugin_blogtimes_tickcolor" );
+ if ($tickColor == "") $tickColor = "#666666";
+ $title = $blogSettings->getValue( "plugin_blogtimes_title" );
+ if ($title == "") $title = "Blog Post Times";
+ $width = $blogSettings->getValue( "plugin_blogtimes_width" );
+ if ($width == "") $width = 480;
+ $height = $blogSettings->getValue( "plugin_blogtimes_height" );
+ if ($height == "") $height = 65;
+ $lastDays = $blogSettings->getValue( "plugin_blogtimes_lastdays" );
+ if ($lastDays == "") $lastDays = "30";
+
+ // create a view and export the settings to the template
+ $this->setValue( "pluginEnabled", $pluginEnabled );
+ $this->setValue( "backColor", $backColor );
+ $this->setValue( "boxColor", $boxColor );
+ $this->setValue( "textColor", $textColor );
+ $this->setValue( "lineColor", $lineColor );
+ $this->setValue( "borderColor", $borderColor );
+ $this->setValue( "tickColor", $tickColor );
+ $this->setValue( "title", $title );
+ $this->setValue( "width", $width );
+ $this->setValue( "height", $height );
+ $this->setValue( "lastDays", $lastDays );
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/blogtimes/js/colorpicker/img/logo.gif
===================================================================
(Binary files differ)
Property changes on: plugins/trunk/blogtimes/js/colorpicker/img/logo.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/trunk/blogtimes/js/colorpicker/img/pixel.gif
===================================================================
(Binary files differ)
Property changes on: plugins/trunk/blogtimes/js/colorpicker/img/pixel.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/trunk/blogtimes/js/colorpicker/img/sel.gif
===================================================================
(Binary files differ)
Property changes on: plugins/trunk/blogtimes/js/colorpicker/img/sel.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/trunk/blogtimes/js/colorpicker/img/tcolorp.gif
===================================================================
(Binary files differ)
Property changes on: plugins/trunk/blogtimes/js/colorpicker/img/tcolorp.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: plugins/trunk/blogtimes/js/colorpicker/picker.html
===================================================================
--- plugins/trunk/blogtimes/js/colorpicker/picker.html 2005-02-20 06:38:21 UTC (rev 1146)
+++ plugins/trunk/blogtimes/js/colorpicker/picker.html 2005-02-20 06:41:40 UTC (rev 1147)
@@ -0,0 +1,41 @@
+<!--
+Title: Tigra Color Picker
+URL: http://www.softcomplex.com/products/tigra_color_picker/
+Version: 1.1
+Date: 06/26/2003 (mm/dd/yyyy)
+Note: Permission given to use this script in ANY kind of applications if
+ header lines are left unchanged.
+Note: Script consists of two files: picker.js and picker.html
+-->
+
+<html>
+<head>
+ <title>Tigra Color Picker</title>
+ <style>
+ .bd { border : 1px inset InactiveBorder; }
+ .s { width:181 }
+ </style>
+</head>
+<body leftmargin="5" topmargin="5" marginheight="5" marginwidth="5" onload="P.C(P.initPalette)">
+<table cellpadding=0 cellspacing=2 border=0 width=184>
+<form>
+<tr><td align="center">
+<select name="type" onchange="P.C(this.selectedIndex)" class="s">
+ <option>Web Safe Palette</option>
+ <option>Windows System Palette</option>
+ <option>Grey Scale Palette</option>
+ <option>Mac OS Palette</option>
+</select>
+</td></tr>
+<tr><td align="center">
+<script language="JavaScript">
+ var P = opener.TCP;
+ onload = "P.show(P.initPalette)";
+ document.forms[0].elements[0].selectedIndex = P.initPalette;
+ P.draw(window, document);
+</script>
+</td></tr>
+</form>
+</table>
+</body>
+</html>
Added: plugins/trunk/blogtimes/js/colorpicker/picker.js
===================================================================
--- plugins/trunk/blogtimes/js/colorpicker/picker.js 2005-02-20 06:38:21 UTC (rev 1146)
+++ plugins/trunk/blogtimes/js/colorpicker/picker.js 2005-02-20 06:41:40 UTC (rev 1147)
@@ -0,0 +1,170 @@
+// Title: Tigra Color Picker
+// URL: http://www.softcomplex.com/products/tigra_color_picker/
+// Version: 1.1
+// Date: 06/26/2003 (mm/dd/yyyy)
+// Note: Permission given to use this script in ANY kind of applications if
+// header lines are left unchanged.
+// Note: Script consists of two files: picker.js and picker.html
+
+var TCP = new TColorPicker();
+var base_url = "plugins/blogtimes/js/colorpicker/";
+
+function TCPopup(field, palette) {
+ this.field = field;
+ this.initPalette = !palette || palette > 3 ? 0 : palette;
+ var w = 194, h = 240,
+ move = screen ?
+ ',left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '',
+ o_colWindow = window.open(base_url + 'picker.html', null, "help=no,status=no,scrollbars=no,resizable=no" + move + ",width=" + w + ",height=" + h + ",dependent=yes", true);
+ o_colWindow.opener = window;
+ o_colWindow.focus();
+}
+
+function TCBuildCell (R, G, B, w, h) {
+ return '<td bgcolor="#' + this.dec2hex((R << 16) + (G << 8) + B) + '"><a href="javascript:P.S(\'' + this.dec2hex((R << 16) + (G << 8) + B) + '\')" onmouseover="P.P(\'' + this.dec2hex((R << 16) + (G << 8) + B) + '\')"><img src="pixel.gif" width="' + w + '" height="' + h + '" border="0"></a></td>';
+}
+
+function TCSelect(c) {
+ this.field.value = '#' + c.toUpperCase();
+ this.win.close();
+}
+
+function TCPaint(c, b_noPref) {
+ c = (b_noPref ? '' : '#') + c.toUpperCase();
+ if (this.o_samp)
+ this.o_samp.innerHTML = '<font face=Tahoma size=2>' + c +' <font color=white>' + c + '</font></font>'
+ if(this.doc.layers)
+ this.sample.bgColor = c;
+ else {
+ if (this.sample.backgroundColor != null) this.sample.backgroundColor = c;
+ else if (this.sample.background != null) this.sample.background = c;
+ }
+}
+
+function TCGenerateSafe() {
+ var s = '';
+ for (j = 0; j < 12; j ++) {
+ s += "<tr>";
+ for (k = 0; k < 3; k ++)
+ for (i = 0; i <= 5; i ++)
+ s += this.bldCell(k * 51 + (j % 2) * 51 * 3, Math.floor(j / 2) * 51, i * 51, 8, 10);
+ s += "</tr>";
+ }
+ return s;
+}
+
+function TCGenerateWind() {
+ var s = '';
+ for (j = 0; j < 12; j ++) {
+ s += "<tr>";
+ for (k = 0; k < 3; k ++)
+ for (i = 0; i <= 5; i++)
+ s += this.bldCell(i * 51, k * 51 + (j % 2) * 51 * 3, Math.floor(j / 2) * 51, 8, 10);
+ s += "</tr>";
+ }
+ return s
+}
+function TCGenerateMac() {
+ var s = '';
+ var c = 0,n = 1;
+ var r,g,b;
+ for (j = 0; j < 15; j ++) {
+ s += "<tr>";
+ for (k = 0; k < 3; k ++)
+ for (i = 0; i <= 5; i++){
+ if(j<12){
+ s += this.bldCell( 255-(Math.floor(j / 2) * 51), 255-(k * 51 + (j % 2) * 51 * 3),255-(i * 51), 8, 10);
+ }else{
+ if(n<=14){
+ r = 255-(n * 17);
+ g=b=0;
+ }else if(n>14 && n<=28){
+ g = 255-((n-14) * 17);
+ r=b=0;
+ }else if(n>28 && n<=42){
+ b = 255-((n-28) * 17);
+ r=g=0;
+ }else{
+ r=g=b=255-((n-42) * 17);
+ }
+ s += this.bldCell( r, g,b, 8, 10);
+ n++;
+ }
+ }
+ s += "</tr>";
+ }
+ return s;
+}
+
+function TCGenerateGray() {
+ var s = '';
+ for (j = 0; j <= 15; j ++) {
+ s += "<tr>";
+ for (k = 0; k <= 15; k ++) {
+ g = Math.floor((k + j * 16) % 256);
+ s += this.bldCell(g, g, g, 9, 7);
+ }
+ s += '</tr>';
+ }
+ return s
+}
+
+function TCDec2Hex(v) {
+ v = v.toString(16);
+ for(; v.length < 6; v = '0' + v);
+ return v;
+}
+
+function TCChgMode(v) {
+ for (var k in this.divs) this.hide(k);
+ this.show(v);
+}
+
+function TColorPicker(field) {
+ this.build0 = TCGenerateSafe;
+ this.build1 = TCGenerateWind;
+ this.build2 = TCGenerateGray;
+ this.build3 = TCGenerateMac;
+ this.show = document.layers ?
+ function (div) { this.divs[div].visibility = 'show' } :
+ function (div) { this.divs[div].visibility = 'visible' };
+ this.hide = document.layers ?
+ function (div) { this.divs[div].visibility = 'hide' } :
+ function (div) { this.divs[div].visibility = 'hidden' };
+ // event handlers
+ this.C = TCChgMode;
+ this.S = TCSelect;
+ this.P = TCPaint;
+ this.popup = TCPopup;
+ this.draw = TCDraw;
+ this.dec2hex = TCDec2Hex;
+ this.bldCell = TCBuildCell;
+ this.divs = [];
+}
+
+function TCDraw(o_win, o_doc) {
+ this.win = o_win;
+ this.doc = o_doc;
+ var
+ s_tag_openT = o_doc.layers ?
+ 'layer visibility=hidden top=54 left=5 width=182' :
+ 'div style=visibility:hidden;position:absolute;left:6px;top:54px;width:182px;height:0',
+ s_tag_openS = o_doc.layers ? 'layer top=32 left=6' : 'div',
+ s_tag_close = o_doc.layers ? 'layer' : 'div'
+
+ this.doc.write('<' + s_tag_openS + ' id=sam name=sam><table cellpadding=0 cellspacing=0 border=1 width=181 align=center class=bd><tr><td align=center height=18><div id="samp"><font face=Tahoma size=2>sample <font color=white>sample</font></font></div></td></tr></table></' + s_tag_close + '>');
+ this.sample = o_doc.layers ? o_doc.layers['sam'] :
+ o_doc.getElementById ? o_doc.getElementById('sam').style : o_doc.all['sam'].style
+
+ for (var k = 0; k < 4; k ++) {
+ this.doc.write('<' + s_tag_openT + ' id="p' + k + '" name="p' + k + '"><table cellpadding=0 cellspacing=0 border=1 align=center>' + this['build' + k]() + '</table></' + s_tag_close + '>');
+ this.divs[k] = o_doc.layers
+ ? o_doc.layers['p' + k] : o_doc.all
+ ? o_doc.all['p' + k].style : o_doc.getElementById('p' + k).style
+ }
+ if (!o_doc.layers && o_doc.body.innerHTML)
+ this.o_samp = o_doc.all
+ ? o_doc.all.samp : o_doc.getElementById('samp');
+ this.C(this.initPalette);
+ if (this.field.value) this.P(this.field.value, true)
+}
\ No newline at end of file
Added: plugins/trunk/blogtimes/locale/locale_en_UK.php
===================================================================
--- plugins/trunk/blogtimes/locale/locale_en_UK.php 2005-02-20 06:38:21 UTC (rev 1146)
+++ plugins/trunk/blogtimes/locale/locale_en_UK.php 2005-02-20 06:41:40 UTC (rev 1147)
@@ -0,0 +1,29 @@
+<?php
+$messages["manageAppearancePlugins"] = "Appearance Management";
+$messages["BlogTimes"] = "Blog Times";
+
+$messages["blogtimes_plugin_enabled"] = "Enable this plugin";
+$messages["blogtimes_plugin"] = "Blog Times Plugin";
+
+$messages["gravatar_settings_saved_ok"] = "Blog Times settings saved successfully!";
+
+$messages["blogtimes_backcolor"] = "Please input your background color (It should be RGB hex color code).";
+$messages["blogtimes_boxcolor"] = "Please input your box color (It should be RGB hex color code).";
+$messages["blogtimes_textcolor"] = "Please input your text color (It should be RGB hex color code).";
+$messages["blogtimes_linecolor"] = "Please input your line color (It should be RGB hex color code).";
+$messages["blogtimes_bordercolor"] = "Please input your border color (It should be RGB hex color code).";
+$messages["blogtimes_tickcolor"] = "Please input your tick color (It should be RGB hex color code).";
+$messages["blogtimes_title"] = "Please input your title. It will show on image, only accept English.";
+$messages["blogtimes_lastdays"] = "Please input the last days of posts you want to show on image.";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+$messages["label_backcolor"] = "Background Color";
+$messages["label_boxcolor"] = "Box Color";
+$messages["label_textcolor"] = "Text Color";
+$messages["label_linecolor"] = "Line Color";
+$messages["label_bordercolor"] = "Border Color";
+$messages["label_tickcolor"] = "Tick Color";
+$messages["label_title"] = "Title";
+$messages["label_lastdays"] = "Last Days";
+?>
\ No newline at end of file
Added: plugins/trunk/blogtimes/locale/locale_zh_TW.php
===================================================================
--- plugins/trunk/blogtimes/locale/locale_zh_TW.php 2005-02-20 06:38:21 UTC (rev 1146)
+++ plugins/trunk/blogtimes/locale/locale_zh_TW.php 2005-02-20 06:41:40 UTC (rev 1147)
@@ -0,0 +1,29 @@
+<?php
+$messages["manageAppearancePlugins"] = "網誌外觀管理";
+$messages["BlogTimes"] = "網誌時間方塊圖設定";
+
+$messages["blogtimes_plugin_enabled"] = "啟動外掛程式";
+$messages["blogtimes_plugin"] = "網誌時間方塊圖外掛程式";
+
+$messages["blogtimes_settings_saved_ok"] = "網誌時間方塊圖設定儲存成功。";
+
+$messages["blogtimes_backcolor"] = "請輸入你的背景顏色代碼(必須是 16 進位的 RGB 顏色代碼)。";
+$messages["blogtimes_boxcolor"] = "請輸入你的方塊圖顏色代碼(必須是 16 進位的 RGB 顏色代碼)。";
+$messages["blogtimes_textcolor"] = "請輸入你的文字顏色代碼(必須是 16 進位的 RGB 顏色代碼)。";
+$messages["blogtimes_linecolor"] = "請輸入你的文章刻線顏色代碼(必須是 16 進位的 RGB 顏色代碼)。";
+$messages["blogtimes_bordercolor"] = "請輸入你的外框顏色代碼(必須是 16 進位的 RGB 顏色代碼)。";
+$messages["blogtimes_tickcolor"] = "請輸入你的時間刻度顏色代碼(必須是 16 進位的 RGB 顏色代碼)。";
+$messages["blogtimes_title"] = "請輸入你的影像文字敘述,此文字會顯示在方塊圖上。必須為英文。";
+$messages["blogtimes_lastdays"] = "請輸入你所要顯示的過去文章天數。";
+
+$messages["label_configuration"] = "設定";
+$messages["label_enable"] = "啟動";
+$messages["label_backcolor"] = "背景顏色";
+$messages["label_boxcolor"] = "方塊圖顏色";
+$messages["label_textcolor"] = "文字顏色";
+$messages["label_linecolor"] = "文章刻線顏色";
+$messages["label_bordercolor"] = "外框顏色";
+$messages["label_tickcolor"] = "時間刻度顏色";
+$messages["label_title"] = "影像文字敘述";
+$messages["label_lastdays"] = "過去文章天數";
+?>
\ No newline at end of file
Added: plugins/trunk/blogtimes/pluginblogtimes.class.php
===================================================================
--- plugins/trunk/blogtimes/pluginblogtimes.class.php 2005-02-20 06:38:21 UTC (rev 1146)
+++ plugins/trunk/blogtimes/pluginblogtimes.class.php 2005-02-20 06:41:40 UTC (rev 1147)
@@ -0,0 +1,215 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+ include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
+ include_once( PLOG_CLASS_PATH."class/net/requestgenerator.class.php" );
+
+ define( "BLOGTIMES_PATH", "/blogtimes/" );
+ define( "BLOGTIMES_FILE", "blogtimes.png" );
+
+ /**
+ * Plugin that offers blogtimes for current blog
+ * Original Author: Matt Mullenweg http://photomatt.net
+ */
+ class PluginBlogTimes extends PluginBase
+ {
+
+ var $pluginEnabled;
+ var $prefix;
+ var $backColor;
+ var $boxColor;
+ var $textColor;
+ var $lineColor;
+ var $borderColor;
+ var $tickColor;
+ var $title;
+ var $lastDays;
+
+ function PluginBlogTimes()
+ {
+ $this->PluginBase();
+
+ $this->id = "blogtimes";
+ $this->author = "Mark Wu";
+ $this->desc = "This plugin offers you to show the blogtimes image in your blog.";
+
+ $this->prefix = Db::getPrefix();
+
+ $this->locales = Array( "en_UK" , "zh_TW" );
+
+ $this->init();
+ }
+
+ function init()
+ {
+ $this->registerAdminAction( "blogtimes", "PluginBlogTimesConfigAction" );
+ $this->registerAdminAction( "updateBlogTimesConfig", "PluginBlogTimesUpdateConfigAction" );
+
+ $menu =& Menu::getMenu();
+ if( !$menu->entryExists( "/menu/controlCenter/manageAppearancePlugins" ))
+ $this->addMenuEntry( "/menu/controlCenter", "manageAppearancePlugins", "", "", true, false );
+ $this->addMenuEntry( "/menu/controlCenter/manageAppearancePlugins", "BlogTimes", "?op=blogtimes", "" );
+ }
+
+ function register()
+ {
+ $blogSettings = $this->blogInfo->getSettings();
+ $this->pluginEnabled = $blogSettings->getValue( "plugin_blogtimes_enabled" );
+ $this->backColor = $blogSettings->getValue( "plugin_blogtimes_backcolor" );
+ $this->boxColor = $blogSettings->getValue( "plugin_blogtimes_boxcolor" );
+ $this->textColor = $blogSettings->getValue( "plugin_blogtimes_textcolor" );
+ $this->lineColor = $blogSettings->getValue( "plugin_blogtimes_linecolor" );
+ $this->borderColor = $blogSettings->getValue( "plugin_blogtimes_bordercolor" );
+ $this->tickColor = $blogSettings->getValue( "plugin_blogtimes_tickcolor" );
+ $this->title = $blogSettings->getValue( "plugin_blogtimes_title" );
+ $this->lastDays = $blogSettings->getValue( "plugin_blogtimes_lastdays" );
+ }
+
+ function isEnabled()
+ {
+ return $this->pluginEnabled;
+ }
+
+ function show($title='Blog Post Times', $last_x_days = 30) {
+ $rg = new RequestGenerator();
+ $this->updateBlogTimePNG($last_x_days, 480, 65, 5, 5, 1, $title);
+ $blogtimesTag = "<div align=\"center\"><img src=\"".$rg->getUrl( BLOGTIMES_PATH.BLOGTIMES_FILE)."\" /></div>";
+ return $blogtimesTag;
+ }
+
+ function updateBlogTimePNG($last_x_days = 30,
+ $width = 480, $height = 65, $horzpadding = 5, $vertpadding = 5,
+ $show_ticks = 1,
+ $title = "Blog Post Times")
+ {
+ if (!$saveFile) $saveFile = PLOG_CLASS_PATH . BLOGTIMES_PATH . BLOGTIMES_FILE;
+ // constants defining image
+ $fontheight = ImageFontHeight(2);
+ $fontwidth = ImageFontWidth(2);
+ $monthtext = "Last $last_x_days days";
+ $unitname = "hour of day";
+ $show_units = 1;
+
+ // create the basic image
+ $im = @ImageCreate ($width, $height)
+ or die ('Cannot create a new GD image.');
+
+ // generate some colors, format: RED, GREEN, BLUE
+ $white = ImageColorAllocate ($im, 255,255,255);
+ $black = ImageColorAllocate ($im, 0,0,0);
+ $beige = ImageColorAllocate ($im, 238,238,238);
+ $blue = ImageColorAllocate ($im, 102,102,102);
+ $silver = ImageColorAllocate ($im, 0xE0,0xE0,0xE0);
+
+ // define what color to use where
+ $back_color = $white; # this is background of entire image (text & all)
+ $box_color = $blue; # this is background of just the posts box
+ $text_color = $black;
+ $line_color = $white; # this is color of lines for each post
+ $border_color = $blue;
+ $tick_color = $blue;
+
+ # query the db and build the list
+ $posttimes = $this->getPostTimes($last_x_days);
+
+ # calculate how many intervals to show
+ $intervals = floor( ($width / 40) );
+ if ($intervals >= 24) $i_mod = 1;
+ else if ($intervals >= 12) $i_mod = 2;
+ else if ($intervals >= 8) $i_mod = 3;
+ else if ($intervals >= 6) $i_mod = 4;
+ else if ($intervals >= 4) $i_mod = 6;
+ else if ($intervals >= 3) $i_mod = 8;
+ else if ($intervals >= 2) $i_mod = 16;
+ else $i_mod = 24;
+
+ # fill the image with the background color
+ ImageFill($im, 0, 0, $back_color);
+
+ # create a filled rectangle with a solid border
+ $left = $horzpadding; $right = $width - $horzpadding;
+ $top = $fontheight + $vertpadding;
+ $bottom = $height - $vertpadding - $fontheight;
+
+ if ($show_units)
+ $bottom -= $fontheight;
+
+ ImageFilledRectangle($im, $left,$top,$right,$bottom, $box_color);
+ ImageRectangle($im, $left,$top,$right,$bottom, $border_color);
+
+ # write title and monthtext
+ ImageString($im, 2, $left, 0, $title,$text_color);
+ $txtwidth = strlen($monthtext) * $fontwidth;
+ ImageString($im, 2, $right - $txtwidth, 0,$monthtext,$text_color);
+
+ # add the legend on the bottom
+ for ($i = 0; $i <= 23; $i=$i+1)
+ {
+ if ($i % $i_mod == 0) {
+ $curX = $left + ($right - $left)/24 * $i;
+
+ if ($i > 9) {$strX = $curX - 5;}
+ else {$strX = $curX - 2;}
+
+ ImageString($im, 2, $strX , $bottom, $i, $text_color);
+ if ($show_ticks)
+ ImageLine($im, $curX, $bottom, $curX, $bottom - 5, $tick_color);
+ }
+ }
+ ImageString($im, 2, $right - 5, $bottom, 0, $text_color);
+ if ($show_units) {
+ $curX = ($right + $left) / 2 - ($fontwidth * strlen($unitname)/2);
+ $curY = $bottom + $fontheight + 2;
+ ImageString($im, 2, $curX, $curY, $unitname, $text_color);
+ }
+
+ # now we draw the lines for each post
+ # the post times should be in terms of # of minutes since midnight
+ $arrcount = count($posttimes);
+ for ($i = 0; $i < $arrcount; $i++)
+ {
+ # make sure postTime is between 0 and 1439
+ $curPostTime = abs($posttimes[$i]) % 1440;
+
+ # calculate the horz pos inside box
+ $curX = $left + ($right - $left)/1440 * $curPostTime; # 1440 minutes per day
+
+ # draw the post line
+ ImageLine($im, $curX, $bottom, $curX, $top, $line_color);
+ }
+
+ # save the file to disk in PNG format
+ ImageColorTransparent($im, $back_color);
+ ImagePNG ($im,$saveFile);
+ }
+
+ # This function will query the db for all the posts in last x days
+ # and build an array of # of minutes since midnight for each post
+ function getPostTimes($last_x_days = 30)
+ {
+ $config = new Config();
+ $prefix = $config->getValue('db_prefix');
+ $blogId = $this->blogInfo->getId();
+
+ $query = "SELECT HOUR(date)*60+MINUTE(date) AS totmins FROM ".$prefix."articles";
+ $query .= " WHERE blog_id = ".$blogId." AND status = 'PUBLISHED'";
+ $query .= " AND (TO_DAYS(CURRENT_DATE) - TO_DAYS(date)) <= '$last_x_days'";
+ $query .= " ORDER BY date ASC";
+
+ $this->connectDb();
+ $result = $this->db->Execute( $query );
+
+ if( !$result )
+ return false;
+
+ $postTimes = Array();
+ while( $row = $result->FetchRow()) {
+ array_push( $postTimes, $row["totmins"]);
+ }
+
+ return $postTimes;
+ }
+
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/blogtimes/readme.txt
===================================================================
--- plugins/trunk/blogtimes/readme.txt 2005-02-20 06:38:21 UTC (rev 1146)
+++ plugins/trunk/blogtimes/readme.txt 2005-02-20 06:41:40 UTC (rev 1147)
@@ -0,0 +1,28 @@
+Plugin: Article Referers
+Author: Mark Wu
+Release Date: 2005/01/23
+Version: 1.0
+
+This plugin offers you to get the referers of the specific article. Usage as followed:
+
+You can use:
+1. $articlereferers->isEnabled() to check the plugin is enabled or not.
+2. $articlereferers->getArticleReferers( $articleId, $maxReferers , $sortByField ) to get the article referers.
+
+Where:
+1. $articleId is the specific ariticle id
+2. $maxReferers is the the max referers you want to show. 0 means show all referers. Default is 10.
+3. $sortByField is the order of referers. 1 means sort by hits, and 2 means order by last visit date. Default is 1
+
+Example:
+Add the following code to postandcomments.template:
+{if $articlereferers->isEnabled()}
+<p>
+<h3>{$locale->tr("referers")}</h3>
+{assign var=postid value=$post->getId()}
+{assign var=referers value=$articlereferers->getArticleReferers($postid)}
+{foreach from=$referers item=referer}
+<li><a href="{$referer->getUrl()}">{$referer->getUrl()|truncate:60:"..."|escape}</a> ({$referer->getCount()})</li>
+{/foreach}
+</p>
+{/if}
\ No newline at end of file
Added: plugins/trunk/blogtimes/templates/blogtimes.template
===================================================================
--- plugins/trunk/blogtimes/templates/blogtimes.template 2005-02-20 06:38:21 UTC (rev 1146)
+++ plugins/trunk/blogtimes/templates/blogtimes.template 2005-02-20 06:41:40 UTC (rev 1147)
@@ -0,0 +1,102 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=BlogTimes title=$locale->tr("blogtimes_plugin")}
+<script type="text/javascript" src="plugins/blogtimes/js/colorpicker/picker.js"></script>
+<form name="blogTimesPluginConfig" method="post">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_configuration")}</legend>
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <div class="field">
+ <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+ <span class="required"></span>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("blogtimes_plugin_enabled")}
+ </div>
+ </div>
+
+ <div class="field">
+ <label for="backColor">{$locale->tr("label_backcolor")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("blogtimes_backcolor")}</div>
+ <input style="width:100px;" class="text" type="text" name="backColor" id="backColor" value="{$backColor}" width="10" />
+ <a href="javascript:TCP.popup(document.forms['blogTimesPluginConfig'].elements['backColor'])"><img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="plugins/blogtimes/js/colorpicker/img/sel.gif"></a>
+ </div>
+
+ <div class="field">
+ <label for="boxColor">{$locale->tr("label_boxcolor")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("blogtimes_boxcolor")}</div>
+ <input style="width:100px;" class="text" type="text" name="boxColor" id="boxColor" value="{$boxColor}" width="10" />
+ <a href="javascript:TCP.popup(document.forms['blogTimesPluginConfig'].elements['boxColor'])"><img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="plugins/blogtimes/js/colorpicker/img/sel.gif"></a>
+ </div>
+
+ <div class="field">
+ <label for="textColor">{$locale->tr("label_textcolor")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("blogtimes_textcolor")}</div>
+ <input style="width:100px;" class="text" type="text" name="textColor" id="textColor" value="{$textColor}" width="10" />
+ <a href="javascript:TCP.popup(document.forms['blogTimesPluginConfig'].elements['textColor'])"><img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="plugins/blogtimes/js/colorpicker/img/sel.gif"></a>
+ </div>
+
+ <div class="field">
+ <label for="lineColor">{$locale->tr("label_linecolor")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("blogtimes_linecolor")}</div>
+ <input style="width:100px;" class="text" type="text" name="lineColor" id="lineColor" value="{$lineColor}" width="10" />
+ <a href="javascript:TCP.popup(document.forms['blogTimesPluginConfig'].elements['lineColor'])"><img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="plugins/blogtimes/js/colorpicker/img/sel.gif"></a>
+ </div>
+
+ <div class="field">
+ <label for="borderColor">{$locale->tr("label_bordercolor")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("blogtimes_bordercolor")}</div>
+ <input style="width:100px;" class="text" type="text" name="borderColor" id="borderColor" value="{$borderColor}" width="10" />
+ <a href="javascript:TCP.popup(document.forms['blogTimesPluginConfig'].elements['borderColor'])"><img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="plugins/blogtimes/js/colorpicker/img/sel.gif"></a>
+ </div>
+
+ <div class="field">
+ <label for="tickColor">{$locale->tr("label_tickcolor")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("blogtimes_tickcolor")}</div>
+ <input style="width:100px;" class="text" type="text" name="tickColor" id="tickColor" value="{$tickColor}" width="10" />
+ <a href="javascript:TCP.popup(document.forms['blogTimesPluginConfig'].elements['tickColor'])"><img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="plugins/blogtimes/js/colorpicker/img/sel.gif"></a>
+ </div>
+
+ <div class="field">
+ <label for="title">{$locale->tr("label_title")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("blogtimes_title")}</div>
+ <input class="text" type="text" name="title" id="title" value="{$title}" width="10" />
+ </div>
+
+ <div class="field">
+ <label for="width">{$locale->tr("label_width")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("blogtimes_width")}</div>
+ <input class="text" type="text" name="width" id="width" value="{$width}" width="10" />
+ </div>
+
+ <div class="field">
+ <label for="height">{$locale->tr("label_height")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("blogtimes_height")}</div>
+ <input class="text" type="text" name="height" id="height" value="{$height}" width="10" />
+ </div>
+
+ <div class="field">
+ <label for="lastDays">{$locale->tr("label_lastdays")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("blogtimes_lastdays")}</div>
+ <input class="text" type="text" name="lastDays" id="lastDays" value="{$lastDays}" width="10" />
+ </div>
+
+ </fieldset>
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="updateBlogTimesConfig" />
+ <input type="reset" name="{$locale->tr("reset")}" />
+ <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}" />
+ </div>
+</form>
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
More information about the pLog-svn
mailing list