Changeset 2072
- Timestamp:
- 02/12/10 22:45:31 (13 years ago)
- Location:
- plugins/countdown
- Files:
-
- 32 added
- 2 deleted
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
plugins/countdown/_define.php
r693 r2072 2 2 # ***** BEGIN LICENSE BLOCK ***** 3 3 # 4 # This file is part of CountDown .5 # Copyright 2007 Moe (http://gniark.net/)4 # This file is part of CountDown, a plugin for Dotclear 2 5 # Copyright 2007,2010 Moe (http://gniark.net/) 6 6 # 7 # CountDown is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 3 of the License, or 10 # (at your option) any later version. 7 # CountDown is free software; you can redistribute it and/or 8 # modify it under the terms of the GNU General Public License v2.0 9 # as published by the Free Software Foundation. 11 10 # 12 11 # CountDown is distributed in the hope that it will be useful, 13 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 14 # GNU General Public License for more details. 16 15 # 17 # You should have received a copy of the GNU General Public License 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 16 # You should have received a copy of the GNU General Public 17 # License along with this program. If not, see 18 # <http://www.gnu.org/licenses/>. 19 19 # 20 20 # ***** END LICENSE BLOCK ***** … … 24 24 $this->registerModule( 25 25 /* Name */ "CountDown", 26 /* Description*/ "Count down widget",26 /* Description*/ "CountDown widget", 27 27 /* Author */ "Moe (http://gniark.net/)", 28 /* Version */ '1. 1',28 /* Version */ '1.2-alpha2', 29 29 /* Permissions */ 'admin' 30 30 ); -
plugins/countdown/_widget.php
r693 r2072 2 2 # ***** BEGIN LICENSE BLOCK ***** 3 3 # 4 # This file is part of CountDown. 5 # Copyright 2007 Moe (http://gniark.net/) 6 # 7 # CountDown is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 3 of the License, or 10 # (at your option) any later version. 4 # This file is part of CountDown, a plugin for Dotclear 2 5 # Copyright 2007,2010 Moe (http://gniark.net/) 6 # 7 # CountDown is free software; you can redistribute it and/or 8 # modify it under the terms of the GNU General Public License v2.0 9 # as published by the Free Software Foundation. 11 10 # 12 11 # CountDown is distributed in the hope that it will be useful, 13 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 14 # GNU General Public License for more details. 16 15 # 17 # You should have received a copy of the GNU General Public License 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 16 # You should have received a copy of the GNU General Public 17 # License along with this program. If not, see 18 # <http://www.gnu.org/licenses/>. 19 19 # 20 20 # ***** END LICENSE BLOCK ***** … … 22 22 if (!defined('DC_RC_PATH')) {return;} 23 23 24 class publicCountDown 24 $core->addBehavior('initWidgets', 25 array('CountDownBehaviors','initWidgets')); 26 27 class CountDownBehaviors 25 28 { 26 public static function Show(&$w)29 public static function initWidgets($w) 27 30 { 28 31 # set timezone 29 32 global $core; 33 $tz = $core->blog->settings->blog_timezone; 34 35 $w->create('CountDown',__('CountDown'), 36 array('CountDownBehaviors','Show')); 37 38 $w->CountDown->setting('title',__('Title:'),__('CountDown'),'text'); 39 40 $w->CountDown->setting('text_before', 41 __('Text displayed if the date is in the future:'),__('In'),'text'); 42 43 $w->CountDown->setting('text_after', 44 __('Text displayed if the date is in the past:'),__('For'),'text'); 45 46 # create arrays for year, month, day, hour, minute and second 47 $array_year = $array_month = $array_day = $array_hour = array(); 48 $array_minute = $array_number_of_times = array(); 49 for ($i = 1902;$i <= 2037;$i++) 50 { 51 $array_year[$i] = $i; 52 } 53 for ($i = 1;$i <= 12;$i++) 54 { 55 $i = str_repeat('0',(2-strlen($i))).$i; 56 $array_month[ucfirst(__(strftime('%B', mktime(0, 0, 0, $i, 1, 1970)))).' ('.$i.')'] = $i; 57 } 58 for ($i = 1;$i <= 31;$i++) 59 { 60 $i = str_repeat('0',(2-strlen($i))).$i; 61 $array_day[$i] = $i; 62 } 63 for ($i = 0;$i <= 23;$i++) 64 { 65 $i = str_repeat('0',(2-strlen($i))).$i; 66 $array_hour[$i] = $i; 67 } 68 for ($i = 0;$i <= 60;$i++) 69 { 70 $i = str_repeat('0',(2-strlen($i))).$i; 71 $array_minute[$i] = $i; 72 } 73 for ($i = 1;$i <= 5;$i++) 74 { 75 $array_number_of_times[$i] = $i; 76 } 77 $array_number_of_times['6 ('.__('all').')'] = 6; 78 # /create arrays 79 80 $w->CountDown->setting('year',ucfirst(__('year')).':', 81 dt::str('%Y',null,$tz),'combo',$array_year); 82 $w->CountDown->setting('month',ucfirst(__('month')).':', 83 dt::str('%m',null,$tz),'combo',$array_month); 84 $w->CountDown->setting('day',ucfirst(__('day')).':', 85 dt::str('%d',null,$tz),'combo',$array_day); 86 $w->CountDown->setting('hour',ucfirst(__('hour')).':', 87 dt::str('%H',null,$tz),'combo',$array_hour); 88 $w->CountDown->setting('minute',ucfirst(__('minute')).':', 89 dt::str('%M',null,$tz),'combo',$array_minute); 90 $w->CountDown->setting('second',ucfirst(__('second')).':', 91 dt::str('%S',null,$tz),'combo',$array_minute); 92 93 $w->CountDown->setting('number_of_times', 94 __('Number of values to be displayed:'),'6','combo', 95 $array_number_of_times); 96 97 $w->CountDown->setting('zeros', 98 __('Show zeros before hours, minutes and seconds'),false,'check'); 99 100 $w->CountDown->setting('dynamic', 101 __('Enable dynamic display'),false,'check'); 102 103 $jquery_countdown_ref = 'http://keith-wood.name/countdownRef.html'; 104 105 $w->CountDown->setting('dynamic_format', 106 sprintf(__('Dynamic display format (see <a href="%1$s" %2$s>jQuery Countdown reference</a>):'), 107 $jquery_countdown_ref, 108 'onclick="return window.confirm(\''. 109 __('Are you sure you want to leave this page?').'\')"'), 110 __('yowdHMS'),'text'); 111 112 $w->CountDown->setting('dynamic_layout_before', 113 sprintf(__('Dynamic display layout if the date is in the future (see <a href="%1$s" %2$s>jQuery Countdown reference</a>):'), 114 $jquery_countdown_ref, 115 'onclick="return window.confirm(\''. 116 __('Are you sure you want to leave this page?').'\')"'), 117 __('In {y<}{yn} {yl}, {y>}{o<}{on} {ol}, {o>}{d<}{dn} {dl}, {d>}{hn} {hl}, {mn} {ml} and {sn} {sl}'), 118 'textarea'); 119 120 $w->CountDown->setting('dynamic_layout_after', 121 sprintf(__('Dynamic display layout if the date is in the past (see <a href="%1$s" %2$s>jQuery Countdown reference</a>):'), 122 $jquery_countdown_ref, 123 'onclick="return window.confirm(\''. 124 __('Are you sure you want to leave this page?').'\')"'), 125 __('For {y<}{yn} {yl}, {y>}{o<}{on} {ol}, {o>}{d<}{dn} {dl}, {d>}{hn} {hl}, {mn} {ml} and {sn} {sl}'), 126 'textarea'); 127 128 $w->CountDown->setting('homeonly', 129 __('Home page only'),false,'check'); 130 } 131 132 # escape quotes but not XHTML tags 133 # inspired by html::escapeJS() 134 public static function escapeQuotes($str) 135 { 136 $str = str_replace("'","\'",$str); 137 $str = str_replace('"','\"',$str); 138 return $str; 139 } 140 141 public static function Show($w) 142 { 143 # set timezone 144 global $core; 30 145 31 146 if ($w->homeonly && $core->url->type != 'default') { … … 36 151 $local_time = dt::addTimeZone($core->blog->settings->blog_timezone); 37 152 38 $ts = mktime($w->hour,$w->minute,$w->second,$w->month,$w->day,$w->year); 153 $ts = mktime($w->hour,$w->minute,$w->second,$w->month,$w->day, 154 $w->year); 39 155 # get difference 40 156 (int)$diff = ($local_time - $ts); 41 157 $after = ($diff > 0) ? true : false; 42 158 $diff = abs($diff); 43 159 44 160 $times = array(); 45 161 46 162 $intervals = array 47 163 ( 48 (3600*24*365.24) => array('one'=>__('year'),'more'=>__('years'),'zeros'=>false), 49 (3600*24*30.4) => array('one'=>__('month'),'more'=>__('months'),'zeros'=>false), 50 (3600*24) => array('one'=>__('day'),'more'=>__('days'),'zeros'=>false), 51 (3600) => array('one'=>__('hour'),'more'=>__('hours'),'zeros'=>true), 52 (60) => array('one'=>__('minute'),'more'=>__('minutes'),'zeros'=>true), 53 (1) => array('one'=>__('second'),'more'=>__('seconds'),'zeros'=>true), 164 (3600*24*365.24) => array('one'=>__('year'),'more'=>__('years'), 165 'zeros'=>false), 166 (3600*24*30.4) => array('one'=>__('month'),'more'=>__('months'), 167 'zeros'=>false), 168 (3600*24) => array('one'=>__('day'),'more'=>__('days'), 169 'zeros'=>false), 170 (3600) => array('one'=>__('hour'),'more'=>__('hours'), 171 'zeros'=>true), 172 (60) => array('one'=>__('minute'),'more'=>__('minutes'), 173 'zeros'=>true), 174 (1) => array('one'=>__('second'),'more'=>__('seconds'), 175 'zeros'=>true), 54 176 ); 55 177 56 178 foreach ($intervals as $k => $v) 57 179 { … … 59 181 { 60 182 $time = floor($diff/$k); 61 $times[] = (($w->zeros AND $v['zeros']) ? sprintf('%02d',$time) : $time).' '.(($time <= 1) ? $v['one'] : $v['more']); 183 $times[] = (($w->zeros AND $v['zeros']) 184 ? sprintf('%02d',$time) : $time).' '.(($time <= 1) ? $v['one'] 185 : $v['more']); 62 186 $diff = $diff%$k; 63 187 } 64 188 } 65 189 66 190 # output 67 $header = (strlen($w->title) > 0) ? '<h2>'.html::escapeHTML($w->title).'</h2>' : null; 191 $header = (strlen($w->title) > 0) 192 ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''; 68 193 $text = ($after) ? $w->text_after : $w->text_before; 69 194 if (strlen($text) > 0) {$text .= ' ';} 70 195 71 196 # get times and make a string 72 197 $times = array_slice($times,0,$w->number_of_times); … … 77 202 } 78 203 else {$str = implode('',$times);} 79 80 return '<div class="countdown">'.$header.'<p class="text">'.$text.$str.'</p></div>'; 204 205 if (!$w->dynamic) 206 { 207 return '<div class="countdown">'.$header. 208 '<p class="text">'.$text.'<span>'.$str.'</span></p>'. 209 '</div>'; 210 } 211 else 212 { 213 # dynamic display with Countdown for jQuery 214 if (!is_numeric($GLOBALS['_ctx']->countdown)) 215 { 216 $GLOBALS['_ctx']->countdown = 0; 217 } 218 $id = $GLOBALS['_ctx']->countdown; 219 $GLOBALS['_ctx']->countdown += 1; 220 221 $script = ''; 222 223 if (!defined('COUNTDOWN_SCRIPT')) 224 { 225 $script = 226 '<script type="text/javascript" src="'. 227 $core->blog->getQmarkURL(). 228 'pf=countdown/js/jquery.countdown.min.js"></script>'."\n"; 229 230 $l10n_file = 231 'jquery.countdown-'.$core->blog->settings->lang.'.js'; 232 if (file_exists(dirname(__FILE__).'/js/'.$l10n_file)) 233 { 234 $script .= 235 '<script type="text/javascript" src="'.$core->blog->getQmarkURL(). 236 'pf=countdown/js/'.$l10n_file.'"></script>'."\n"; 237 } 238 239 define('COUNTDOWN_SCRIPT',(bool)true); 240 } 241 242 if ($after) 243 { 244 $to = 'since'; 245 $layout = $w->dynamic_layout_after; 246 } 247 else 248 { 249 $to = 'until'; 250 $layout = $w->dynamic_layout_before; 251 } 252 253 return $script.'<div class="countdown">'.$header. 254 '<p class="text" id="countdown-'.$id.'">'.$text.$str.'</p>'. 255 '<script type="text/javascript">'."\n". 256 '//<![CDATA['."\n". 257 '$().ready(function() {'. 258 "$('#countdown-".$id."').countdown({". 259 # In Javascript, 0 = January, 11 = December 260 $to.": new Date(".(int)$w->year.",".(int)$w->month."-1,". 261 (int)$w->day.",".(int)$w->hour.",".(int)$w->minute.",". 262 (int)$w->second."), 263 description: '".html::escapeJS($text)."', 264 format: '".$w->dynamic_format."', 265 layout: '".$layout."', 266 expiryText: '".html::escapeJS($w->text_after)."', 267 });". 268 '});'."\n". 269 '//]]>'. 270 '</script>'."\n". 271 '</div>'; 272 } 81 273 } 82 274 } -
plugins/countdown/locales/fr/main.po
r1638 r2072 1 # French translation of CountDown, a plugin for dotclear 2 # This file is generated by LangOmatic, a plugin for Dotclear 1 # Language: français 2 # Module: countdown - 1.2-alpha2 3 # Date: 2010-02-12 18:31:01 4 # Translated with dcTranslater - 1.2 5 3 6 msgid "" 4 msgstr "" 5 "Content-Type: text/plain; charset=UTF-8\n" 6 "Project-Id-Version: \n" 7 "POT-Creation-Date: \n" 8 "PO-Revision-Date: \n" 9 "Last-Translator: Kozlika <kozlika@free.fr>\n" 10 "Language-Team: \n" 11 "MIME-Version: 1.0\n" 12 "Content-Transfer-Encoding: 8bit\n" 7 msgstr "Content-Type: text/plain; charset=UTF-8\n" 13 8 14 #: _admin.php:12 15 #: _admin.php:14 9 #: _admin.php:38 16 10 msgid "CountDown" 17 11 msgstr "Chronomètre" 18 12 19 #: _admin.php: 1613 #: _admin.php:41 20 14 msgid "Text displayed if the date is in the future:" 21 15 msgstr "Texte affiché si la date est dans le futur :" 22 16 23 #: _admin.php: 1617 #: _admin.php:41 24 18 msgid "In" 25 19 msgstr "Dans" 26 20 27 #: _admin.php: 1821 #: _admin.php:44 28 22 msgid "Text displayed if the date is in the past:" 29 23 msgstr "Texte affiché si la date est passée :" 30 24 31 #: _admin.php: 1825 #: _admin.php:44 32 26 msgid "For" 33 27 msgstr "Depuis" 34 28 35 #: _admin.php: 5029 #: _admin.php:77 36 30 msgid "all" 37 31 msgstr "tous" 38 32 39 #: _admin.php:53 40 #: _public.php:30 33 #: _public.php:58 41 34 msgid "year" 42 35 msgstr "année" 43 36 44 #: _admin.php:54 45 #: _public.php:36 37 #: _public.php:60 46 38 msgid "month" 47 39 msgstr "mois" 48 40 49 #: _admin.php:55 50 #: _public.php:42 41 #: _public.php:62 51 42 msgid "day" 52 43 msgstr "jour" 53 44 54 #: _admin.php:56 55 #: _public.php:48 45 #: _public.php:64 56 46 msgid "hour" 57 47 msgstr "heure" 58 48 59 #: _admin.php:57 60 #: _public.php:54 49 #: _public.php:66 61 50 msgid "minute" 62 51 msgstr "minute" 63 52 64 #: _admin.php:58 65 #: _public.php:60 53 #: _public.php:68 66 54 msgid "second" 67 55 msgstr "seconde" 68 56 69 #: _admin.php: 6057 #: _admin.php:94 70 58 msgid "Number of values to be displayed:" 71 59 msgstr "Nombre de valeurs à afficher :" 72 60 73 #: _admin.php: 6261 #: _admin.php:98 74 62 msgid "Show zeros before hours, minutes and seconds" 75 63 msgstr "Afficher des zéros devant les heures, les minutes et les secondes" 76 64 77 #: _public.php:30 65 #: _admin.php:101 66 msgid "Enable dynamic display" 67 msgstr "Activer l'affichage dynamique" 68 69 #: _admin.php:106 70 msgid "Dynamic display format (see <a href="%1$s" %2$s>jQuery Countdown reference</a>):" 71 msgstr "Format de l'affichage dynamique (voir <a href=\"%1$s\" %2$s>jQuery Countdown reference</a>) :" 72 73 #: _admin.php:113 74 msgid "Dynamic display layout if the date is in the future (see <a href="%1$s" %2$s>jQuery Countdown reference</a>):" 75 msgstr "Mise en page de l'affichage dynamique si la date est dans le futur (voir <a href=\"%1$s\" %2$s>jQuery Countdown reference</a>) :" 76 77 #: _admin.php:117 78 msgid "In {y<}{yn} {yl}, {y>}{o<}{on} {ol}, {o>}{d<}{dn} {dl}, {d>}{hn} {hl}, {mn} {ml} and {sn} {sl}" 79 msgstr "Dans {y<}{yn} {yl}, {y>}{o<}{on} {ol}, {o>}{d<}{dn} {dl}, {d>}{hn} {hl}, {mn} {ml} et {sn} {sl}" 80 81 #: _admin.php:121 82 msgid "Dynamic display layout if the date is in the past (see <a href="%1$s" %2$s>jQuery Countdown reference</a>):" 83 msgstr "Mise en page de l'affichage dynamique si la date est passée (voir <a href=\"%1$s\" %2$s>jQuery Countdown reference</a>) :" 84 85 #: _admin.php:125 86 msgid "For {y<}{yn} {yl}, {y>}{o<}{on} {ol}, {o>}{d<}{dn} {dl}, {d>}{hn} {hl}, {mn} {ml} and {sn} {sl}" 87 msgstr "Depuis {y<}{yn} {yl}, {y>}{o<}{on} {ol}, {o>}{d<}{dn} {dl}, {d>}{hn} {hl}, {mn} {ml} et {sn} {sl}" 88 89 #: _public.php:58 78 90 msgid "years" 79 91 msgstr "années" 80 92 81 #: _public.php: 3693 #: _public.php:60 82 94 msgid "months" 83 95 msgstr "mois" 84 96 85 #: _public.php: 4297 #: _public.php:62 86 98 msgid "days" 87 99 msgstr "jours" 88 100 89 #: _public.php: 48101 #: _public.php:64 90 102 msgid "hours" 91 103 msgstr "heures" 92 104 93 #: _public.php: 54105 #: _public.php:66 94 106 msgid "minutes" 95 107 msgstr "minutes" 96 108 97 #: _public.php:6 0109 #: _public.php:68 98 110 msgid "seconds" 99 111 msgstr "secondes" 100 112 101 #: _public.php: 74113 #: _public.php:95 102 114 msgid "and" 103 115 msgstr "et"
Note: See TracChangeset
for help on using the changeset viewer.