Пример #1
0
 function render()
 {
     $loc = LocaleHandler::getInstance();
     $res = '<table summary="" border="1">';
     for ($i = 1; $i <= $this->days_in_month; $i++) {
         $ts = mktime(0, 0, 0, date('m', $this->date), $i, date('Y', $this->date));
         $weekday = date('w', $ts);
         $focus = false;
         if ($i == date('j') && date('m', $this->date) == date('m') && date('Y', $this->date) == date('Y')) {
             $res .= '<tr style="background-color:#77ee77">';
             $focus = true;
         } else {
             if ($weekday == 0 || $weekday == 6) {
                 // weekend (sat, sun)
                 $res .= '<tr style="background-color:#aaa">';
             } else {
                 $res .= '<tr>';
             }
         }
         $res .= '<td valign="top" align="right">' . ($focus ? '<a id="cal_current_day"></a>' : '') . $i . '</td>' . '<td valign="top">' . $loc->getWeekdayLong($weekday) . '</td>' . '<td>';
         foreach ($this->events as $e) {
             if ($e->getDate() == $ts) {
                 $res .= $e->getTitle() . '<br/>';
             }
         }
         $res .= '</td>' . '</tr>';
     }
     $res .= '</table>';
     return $res;
 }
Пример #2
0
 function render()
 {
     if (!$this->name) {
         throw new \Exception('must set a name');
     }
     $header = XhtmlHeader::getInstance();
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/calendar/assets/skins/sam/calendar.css');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/calendar/calendar-min.js');
     $locale = LocaleHandler::getInstance();
     $div_holder = 'yui_date_hold' . mt_rand();
     $res = 'YAHOO.namespace("example.calendar");' . 'YAHOO.example.calendar.init = function() {' . 'var inTxt = YAHOO.util.Dom.get("' . $this->name . '");' . ($this->selected_date ? 'inTxt.value  = "' . sql_date($this->selected_date) . '";' : '') . 'var cal = YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar("' . $div_holder . '");' . ($this->selected_date ? 'cal.cfg.setProperty("selected", "' . js_date($this->selected_date) . '");' . 'cal.cfg.setProperty("pagedate", "' . date('n/Y', $this->selected_date) . '");' : '') . 'cal.cfg.setProperty("start_weekday",' . $this->start_weekday . ');' . 'cal.cfg.setProperty("MONTHS_SHORT",' . Json::encode($locale->handle->month_short, false) . ');' . 'cal.cfg.setProperty("MONTHS_LONG",' . Json::encode($locale->handle->month_long, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_1CHAR",' . Json::encode($locale->handle->weekday_1char, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_SHORT",' . Json::encode($locale->handle->weekday_short, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_MEDIUM",' . Json::encode($locale->handle->weekday_medium, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_LONG",' . Json::encode($locale->handle->weekday_long, false) . ');' . 'cal.selectEvent.subscribe(function() {' . 'var dates = this.getSelectedDates();' . 'var inDate = dates[0];' . 'inTxt.value = inDate.getFullYear() + "-" + (inDate.getMonth() + 1) + "-" + inDate.getDate();' . '}, cal, true);' . 'cal.render();' . '}' . "\n" . 'YAHOO.util.Event.onDOMReady(YAHOO.example.calendar.init);';
     return '<div id="' . $div_holder . '"></div>' . '<div style="clear:both"></div>' . xhtmlInput($this->name) . '<br/>' . js_embed($res);
 }
Пример #3
0
 function render()
 {
     if (!$this->name) {
         throw new \Exception('name must be configured');
     }
     $header = XhtmlHeader::getInstance();
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/calendar/assets/skins/sam/calendar.css');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/calendar/calendar-min.js');
     $res = '(function()' . '{' . 'function IntervalCalendar(container, cfg)' . '{' . 'this._iState = 0;' . 'cfg = cfg || {};' . 'cfg.multi_select = true;' . 'IntervalCalendar.superclass.constructor.call(this, container, cfg);' . 'this.beforeSelectEvent.subscribe(this._intervalOnBeforeSelect, this, true);' . 'this.selectEvent.subscribe(this._intervalOnSelect, this, true);' . 'this.beforeDeselectEvent.subscribe(this._intervalOnBeforeDeselect, this, true);' . 'this.deselectEvent.subscribe(this._intervalOnDeselect, this, true);' . '}' . 'IntervalCalendar._DEFAULT_CONFIG = YAHOO.widget.CalendarGroup._DEFAULT_CONFIG;' . 'YAHOO.lang.extend(IntervalCalendar, YAHOO.widget.CalendarGroup,' . '{' . '_dateString : function(d) {' . 'var a = [];' . 'a[this.cfg.getProperty(IntervalCalendar._DEFAULT_CONFIG.MDY_MONTH_POSITION.key)-1] = (d.getMonth() + 1);' . 'a[this.cfg.getProperty(IntervalCalendar._DEFAULT_CONFIG.MDY_DAY_POSITION.key)-1] = d.getDate();' . 'a[this.cfg.getProperty(IntervalCalendar._DEFAULT_CONFIG.MDY_YEAR_POSITION.key)-1] = d.getFullYear();' . 'var s = this.cfg.getProperty(IntervalCalendar._DEFAULT_CONFIG.DATE_FIELD_DELIMITER.key);' . 'return a.join(s);' . '},' . '_dateIntervalString : function(l, u) {' . 'var s = this.cfg.getProperty(IntervalCalendar._DEFAULT_CONFIG.DATE_RANGE_DELIMITER.key);' . 'return (this._dateString(l) + s + this._dateString(u));' . '},' . 'getInterval : function() {' . 'var dates = this.getSelectedDates();' . 'if(dates.length > 0) {' . 'var l = dates[0];' . 'var u = dates[dates.length - 1];' . 'return [l, u];' . '} else {' . 'return [];' . '}' . '},' . 'setInterval : function(d1, d2) {' . 'var b = (d1 <= d2);' . 'var l = b ? d1 : d2;' . 'var u = b ? d2 : d1;' . 'this.cfg.setProperty("selected", this._dateIntervalString(l, u), false);' . 'this._iState = 2;' . '},' . 'resetInterval : function() {' . 'this.cfg.setProperty("selected", [], false);' . 'this._iState = 0;' . '},' . '_intervalOnBeforeSelect : function(t,a,o) {' . 'this._iState = (this._iState + 1) % 3;' . 'if(this._iState == 0) {' . 'this.deselectAll();' . 'this._iState++;' . '}' . '},' . '_intervalOnSelect : function(t,a,o) {' . 'var dates = this.getSelectedDates();' . 'if(dates.length > 1) {' . 'var l = dates[0];' . 'var u = dates[dates.length - 1];' . 'this.cfg.setProperty("selected", this._dateIntervalString(l, u), false);' . '}' . 'this.render();' . '},' . '_intervalOnBeforeDeselect : function(t,a,o) {' . 'if(this._iState != 0) {' . 'return false;' . '}' . '},' . '_intervalOnDeselect : function(t,a,o) {' . 'if(this._iState != 0) {' . 'this._iState = 0;' . 'this.deselectAll();' . 'var d = a[0];' . 'var date = YAHOO.widget.DateMath.getDate(d[0], d[1] - 1, d[2]);' . 'var page = this.getCalendarPage(date);' . 'if(page) {' . 'page.beforeSelectEvent.fire();' . 'this.cfg.setProperty("selected", this._dateString(date), false);' . 'page.selectEvent.fire([d]);' . '}' . 'return false;' . '}' . '}' . '});' . 'YAHOO.namespace("example.calendar");' . 'YAHOO.example.calendar.IntervalCalendar = IntervalCalendar;' . '})();';
     $locale = LocaleHandler::getInstance();
     $div_holder = 'yui_di_hold' . mt_rand();
     $res .= 'YAHOO.util.Event.onDOMReady(function()' . '{' . 'var inTxt  = YAHOO.util.Dom.get("' . $this->name . '_from");' . 'var outTxt = YAHOO.util.Dom.get("' . $this->name . '_to");' . 'var inDate, outDate, interval;' . ($this->select_from ? 'inTxt.value  = "' . sql_date($this->select_from) . '";' : '') . ($this->select_to ? 'outTxt.value = "' . sql_date($this->select_to) . '";' : '') . 'var myConfigs =' . '{' . 'pages:2,' . ($this->select_from && $this->select_to ? 'selected:"' . js_date($this->select_from) . '-' . js_date($this->select_to) . '",' . 'pagedate:"' . date('n/Y', $this->select_from) . '",' : '') . 'start_weekday:' . $this->start_weekday . ',' . 'MONTHS_SHORT:' . Json::encode($locale->handle->month_short, false) . ',' . 'MONTHS_LONG:' . Json::encode($locale->handle->month_long, false) . ',' . 'WEEKDAYS_1CHAR:' . Json::encode($locale->handle->weekday_1char, false) . ',' . 'WEEKDAYS_SHORT:' . Json::encode($locale->handle->weekday_short, false) . ',' . 'WEEKDAYS_MEDIUM:' . Json::encode($locale->handle->weekday_medium, false) . ',' . 'WEEKDAYS_LONG:' . Json::encode($locale->handle->weekday_long, false) . ',' . '};' . 'var cal = new YAHOO.example.calendar.IntervalCalendar("' . $div_holder . '",myConfigs);' . 'cal.selectEvent.subscribe(function()' . '{' . 'interval = this.getInterval();' . 'if (interval.length == 2) {' . 'inDate = interval[0];' . 'inTxt.value =  inDate.getFullYear() + "-" + (inDate.getMonth() + 1) + "-" + inDate.getDate();' . 'if (interval[0].getTime() != interval[1].getTime()) {' . 'outDate = interval[1];' . 'outTxt.value = outDate.getFullYear() + "-" + (outDate.getMonth() + 1) + "-" + outDate.getDate();' . '} else {' . 'outTxt.value = "";' . '}' . '}' . '}, cal, true);' . 'cal.render();' . '});';
     return '<div id="' . $div_holder . '"></div>' . '<div style="clear:both"></div>' . js_embed($res) . xhtmlInput($this->name . '_from') . ' - ' . xhtmlInput($this->name . '_to');
 }
Пример #4
0
 function render()
 {
     if (!$this->name) {
         throw new \Exception('must set a name');
     }
     $header = XhtmlHeader::getInstance();
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/fonts/fonts-min.css');
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/button/assets/skins/sam/button.css');
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/container/assets/skins/sam/container.css');
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/calendar/assets/skins/sam/calendar.css');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/dragdrop/dragdrop-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/element/element-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/button/button-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/container/container-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/calendar/calendar-min.js');
     $header->embedCss('#container .bd form {' . 'clear:left;' . '}' . '#container .bd {' . 'padding:0;' . '}' . '#container .hd {' . 'text-align:left;' . '}' . '#container .ft .button-group {' . 'text-align:center;' . '}' . '#container_c.yui-overlay-hidden table {' . '*display:none;' . '}' . '#cal {' . 'border:none;' . 'padding:1em;' . '}');
     $locale = LocaleHandler::getInstance();
     $button_name = 'yui_dp_show_' . mt_rand();
     $res = 'YAHOO.util.Event.onDOMReady(function(){' . 'var Event = YAHOO.util.Event,' . 'Dom = YAHOO.util.Dom,' . 'dialog,' . 'calendar;' . 'var showBtn = Dom.get("' . $button_name . '");' . 'Event.on(showBtn, "click", function() {' . 'if (!dialog) {' . 'Event.on(document, "click", function(e) {' . 'var el = Event.getTarget(e);' . 'var dialogEl = dialog.element;' . 'if (el != dialogEl && !Dom.isAncestor(dialogEl, el) && el != showBtn && !Dom.isAncestor(showBtn, el)) {' . 'dialog.hide();' . '}' . '});' . 'function resetHandler() {' . 'var selDates = calendar.getSelectedDates();' . 'var resetDate;' . 'if (selDates.length > 0) {' . 'resetDate = selDates[0];' . '} else {' . 'resetDate = calendar.today;' . '}' . 'calendar.cfg.setProperty("pagedate", resetDate);' . 'calendar.render();' . '}' . 'function closeHandler() {' . 'dialog.hide();' . '}' . 'dialog = new YAHOO.widget.Dialog("container", {' . 'visible:false,' . 'context:["' . $button_name . '", "tl", "bl"],' . 'buttons:[ {text:"Reset", handler: resetHandler, isDefault:true}, {text:"Close", handler: closeHandler}],' . 'draggable:false,' . 'close:true' . '});' . 'dialog.setHeader("Pick A Date");' . 'dialog.setBody(\'<div id="cal"></div>\');' . 'dialog.render(document.body);' . 'dialog.showEvent.subscribe(function() {' . 'if (YAHOO.env.ua.ie) {' . 'dialog.fireEvent("changeContent");' . '}' . '});' . '}' . 'if (!calendar) {' . 'calendar = new YAHOO.widget.Calendar("cal", {' . 'iframe:false,' . 'hide_blank_weeks:true,' . ($this->selected_date ? 'selected:"' . js_date($this->selected_date) . '",' . 'pagedate:"' . date('n/Y', $this->selected_date) . '",' : '') . 'start_weekday:' . $this->start_weekday . ',' . 'MONTHS_SHORT:' . Json::encode($locale->handle->month_short, false) . ',' . 'MONTHS_LONG:' . Json::encode($locale->handle->month_long, false) . ',' . 'WEEKDAYS_1CHAR:' . Json::encode($locale->handle->weekday_1char, false) . ',' . 'WEEKDAYS_SHORT:' . Json::encode($locale->handle->weekday_short, false) . ',' . 'WEEKDAYS_MEDIUM:' . Json::encode($locale->handle->weekday_medium, false) . ',' . 'WEEKDAYS_LONG:' . Json::encode($locale->handle->weekday_long, false) . ',' . '});' . 'calendar.render();' . 'calendar.selectEvent.subscribe(function() {' . 'if (calendar.getSelectedDates().length > 0) {' . 'var selDate = calendar.getSelectedDates()[0];' . 'Dom.get("' . $this->name . '").value = selDate.getFullYear() + "-" + (selDate.getMonth() + 1) + "-" + selDate.getDate();' . '} else {' . 'Dom.get("' . $this->name . '").value = "";' . '}' . 'dialog.hide();' . '});' . 'calendar.renderEvent.subscribe(function() {' . 'dialog.fireEvent("changeContent");' . '});' . '}' . 'var seldate = calendar.getSelectedDates();' . 'if (seldate.length > 0) {' . 'calendar.cfg.setProperty("pagedate", seldate[0]);' . 'calendar.render();' . '}' . 'dialog.show();' . '});' . '});';
     return xhtmlInput($this->name, sql_date($this->selected_date), 8) . ' ' . '<button type="button" id="' . $button_name . '" title="Pick a date">' . '<img src="' . relurl('core_dev/gfx/icon_date-picker.png') . '" alt="Pick a date"/>' . '</button>' . js_embed($res);
 }
Пример #5
0
 public function render()
 {
     //available variables in the scope of the view
     if (class_exists('\\cd\\ErrorHandler')) {
         $error = ErrorHandler::getInstance();
     }
     if (class_exists('\\cd\\SessionHandler')) {
         $session = SessionHandler::getInstance();
     }
     if (class_exists('\\cd\\SqlHandler')) {
         $db = SqlHandler::getInstance();
     }
     if (class_exists('\\cd\\XhtmlHeader')) {
         $header = XhtmlHeader::getInstance();
     }
     if (class_exists('\\cd\\XmlDocumentHandler')) {
         $page = XmlDocumentHandler::getInstance();
     }
     if (class_exists('\\cd\\LocaleHandler')) {
         $locale = LocaleHandler::getInstance();
     }
     if (class_exists('\\cd\\TempStore')) {
         $temp = TempStore::getInstance();
     }
     // make reference to calling object available in the namespace of the view
     $caller = $this->caller;
     $file = $page->getCoreDevPath() . $this->template;
     if (!file_exists($file)) {
         // if not built in view, look in app dir
         $file = $this->template;
         if (!file_exists($file)) {
             throw new \Exception('cannot find ' . $this->template);
         }
     }
     ob_start();
     require $file;
     return ob_get_clean();
 }
Пример #6
0
 function render()
 {
     $header = XhtmlHeader::getInstance();
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/treeview/assets/skins/sam/treeview.css');
     // XXX disable this css to get windows-style treeview object
     // $header->includeCss('http://developer.yahoo.com/yui/build/treeview/assets/treeview-menu.css');
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/calendar/assets/skins/sam/calendar.css');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/animation/animation-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/calendar/calendar-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/json/json-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/connection/connection-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/treeview/treeview-min.js');
     $locale = LocaleHandler::getInstance();
     $div_holder = 'yui_tree_hold' . mt_rand();
     if ($this->allow_expand_all) {
         $node_type = 'TextNode';
     } else {
         $node_type = 'MenuNode';
     }
     $res = 'function loadNodeData(node, fnLoadComplete)' . '{' . 'var sUrl = "' . $this->xhr_url . '" + encodeURI(node.data.id);' . 'var callback = {' . 'success: function(oResponse) {' . 'var oResults = YAHOO.lang.JSON.parse(oResponse.responseText);' . 'if (oResults.records && oResults.records.length) {' . 'for (var i=0; i<oResults.records.length; i++) {' . 'var newNode = new YAHOO.widget.' . $node_type . '({label:oResults.records[i].name,id:oResults.records[i].id}, node, false);' . '}' . '}' . 'oResponse.argument.fnLoadComplete();' . '},' . 'failure: function(oResponse) {' . 'YAHOO.log("Failed to process XHR transaction.", "info", "example");' . 'oResponse.argument.fnLoadComplete();' . '},' . 'argument: {' . '"node": node,' . '"fnLoadComplete": fnLoadComplete' . '},' . 'timeout:' . $this->ms_timeout . '};' . 'YAHOO.util.Connect.asyncRequest("GET", sUrl, callback);' . '}' . 'var tree = new YAHOO.widget.TreeView("' . $div_holder . '");' . ($this->xhr_url ? 'tree.setDynamicLoad(loadNodeData,' . ($this->leaf_mode ? '1' : '0') . ');' : '') . 'var root = tree.getRoot();' . ($this->root_nodes ? 'var aChilds = ' . JSON::encode($this->root_nodes) . ';' . 'for (var i=0, j=aChilds.length; i<j; i++) {' . 'var tempNode = new YAHOO.widget.' . $node_type . '({label:aChilds[i].name,id:aChilds[i].id}, root, false);' . '}' : '') . ($this->js_click ? 'tree.subscribe("clickEvent",function(oArgs){' . $this->js_click . '});' : '') . ($this->js_dblclick ? 'tree.subscribe("dblClickEvent",function(oArgs){' . $this->js_dblclick . '});' : '') . 'tree.render();';
     return '<div id="' . $div_holder . '"></div>' . js_embed($res);
 }
Пример #7
0
 /**
  * @param place, city or Yahoo WOEID of location
  */
 function getWeather($place, $country = '')
 {
     if (self::isWoeid($place)) {
         $woeid = $place;
     } else {
         $x = YahooQueryClient::geocode($place, $country);
         if (!$x->woeid) {
             throw new \Exception('location not found');
         }
         $woeid = $x->woeid;
     }
     $temp = TempStore::getInstance();
     $key = 'WeatherClient//' . $woeid;
     $data = $temp->get($key);
     if ($data) {
         return unserialize($data);
     }
     $url = 'http://weather.yahooapis.com/forecastrss' . '?w=' . $woeid . '&u=c';
     // unit = celcius
     $this->parse($url);
     $items = $this->getItems();
     if (count($items) != 1) {
         throw new \Exception('unexpected number of results');
     }
     if (!$this->city) {
         return false;
     }
     $res = new WeatherResult();
     $res->city = $this->city;
     $res->region = $this->region;
     $res->country = $this->country;
     //XXXX what is the unit types?
     $res->wind_chill = $this->wind_chill;
     $res->wind_direction = $this->wind_direction;
     $res->wind_speed = $this->wind_speed;
     $res->coord_lat = $this->coord_lat;
     $res->coord_long = $this->coord_long;
     $res->time = $this->time;
     $res->visibility = $this->visibility;
     $res->celcius = $this->celcius;
     $locale = LocaleHandler::getInstance();
     $res->skycond = $locale->getSkycondition($this->skycond);
     $temp->set($key, serialize($res), '1h');
     return $res;
 }
Пример #8
0
 /**
  * Embeds a recaptcha on your website
  *
  * @param $ssl use SSL to connect to recaptcha.net
  * @return HTML code to display recaptcha
  */
 public function render($ssl = true)
 {
     $conf = RecaptchaConfig::getInstance();
     if (!$conf->getPublicKey() || !$conf->getPrivateKey()) {
         die('ERROR - You need a Recaptcha API key');
     }
     $server = $ssl ? $this->api_url_ssl : $this->api_url;
     $locale = LocaleHandler::getInstance();
     switch ($locale->get()) {
         case 'swe':
             // translation was submitted to recaptcha google group: http://groups.google.com/group/recaptcha/browse_thread/thread/78a677ea59626024
             $opts = 'custom_translations : {' . 'instructions_visual : "Skriv in de två orden:",' . 'instructions_audio : "Skriv in vad du hör:",' . 'play_again : "Spela ljudet igen",' . 'cant_hear_this : "Ladda ner ljudfil som MP3",' . 'visual_challenge : "Se en visuell captcha",' . 'audio_challenge : "Lyssna på en ljud-captcha",' . 'refresh_btn : "Ladda en ny captcha",' . 'help_btn : "Hjälp",' . 'incorrect_try_again : "Fel svar. Försök igen.",' . '},';
             break;
             // http://code.google.com/intl/sv-SE/apis/recaptcha/docs/customization.html    some languages is supported already
         // http://code.google.com/intl/sv-SE/apis/recaptcha/docs/customization.html    some languages is supported already
         case 'eng':
             $opts = 'lang : "en", ';
             break;
         default:
             throw new \Exception('recaptcha translation missing');
     }
     return js_embed('var RecaptchaOptions = { ' . $opts . ' };') . '<script type="text/javascript" src="' . $server . '/challenge?k=' . $conf->getPublicKey() . '"></script>' . '<noscript>' . '<iframe src="' . $server . '/noscript?k=' . $conf->getPublicKey() . '" height="300" width="500" frameborder="0"></iframe><br/>' . '<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>' . '<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>' . '</noscript>';
 }
Пример #9
0
 /**
  * Renders a duration in human-readable text
  *
  * @return "2 days, 4 hours and 30 seconds"
  */
 function renderRelative()
 {
     if (is_float($this->value)) {
         $secs = ceil($this->value);
     } else {
         $secs = $this->value;
     }
     $ret = '';
     $locale = LocaleHandler::getInstance();
     //years
     $a = date('Y', $secs) - 1970;
     if ($a == 1) {
         $ret = $a . ' ' . $locale->translateDuration('year') . ', ';
     } else {
         if ($a > 0) {
             $ret = $a . ' ' . $locale->translateDuration('years') . ', ';
         }
     }
     $secs -= $a * 60 * 60 * 24 * 30 * 365;
     //months
     $a = date('n', $secs) - 1;
     if ($a == 1) {
         $ret .= $a . ' ' . $locale->translateDuration('month') . ', ';
     } else {
         if ($a > 0) {
             $ret .= $a . ' ' . $locale->translateDuration('months') . ', ';
         }
     }
     $secs -= $a * 60 * 60 * 24 * 30;
     //weeks
     $a = date('W', $secs) - 1;
     if ($a == 1) {
         $ret .= $a . ' ' . $locale->translateDuration('week') . ', ';
     } else {
         if ($a > 0) {
             $ret .= $a . ' ' . $locale->translateDuration('weeks') . ', ';
         }
     }
     $secs -= $a * 60 * 60 * 24 * 7;
     //days
     $a = date('j', $secs) - 1;
     if ($a == 1) {
         $ret .= $a . ' ' . $locale->translateDuration('day') . ', ';
     } else {
         if ($a > 0) {
             $ret .= $a . ' ' . $locale->translateDuration('days') . ', ';
         }
     }
     $secs -= $a * 60 * 60 * 24;
     //hours
     $a = date('H', $secs) - 1;
     if ($a == 1) {
         $ret .= $a . ' ' . $locale->translateDuration('hour') . ', ';
     } else {
         if ($a > 0) {
             $ret .= $a . ' ' . $locale->translateDuration('hours') . ', ';
         }
     }
     $secs -= $a * 60 * 60;
     //minutes
     $a = date('i', $secs) - 0;
     if ($a == 1) {
         $ret .= $a . ' ' . $locale->translateDuration('minute') . ', ';
     } else {
         if ($a > 0) {
             $ret .= $a . ' ' . $locale->translateDuration('minutes') . ', ';
         }
     }
     $secs -= $a * 60;
     //seconds
     $a = date('s', $secs) - 0;
     if ($a > 0) {
         $ret .= $a . ' ' . $locale->translateDuration('seconds');
     }
     if (substr($ret, -2) == ', ') {
         $ret = substr($ret, 0, -2);
     }
     if ($ret == '') {
         $ret = '0s';
     }
     return $ret;
 }
Пример #10
0
require_once 'TaskQueue.php';
//XXX move to core_dev when matured
$page = XmlDocumentHandler::getInstance();
$page->designHead(dirname(__FILE__) . '/design_head.php');
$page->designFoot(dirname(__FILE__) . '/design_foot.php');
$page->setUrl('http://processtest.x/');
$page->setCoreDevInclude($coredev_inc);
///XXX peka på "/path/to/core_dev/core/" katalogen, hör egentligen inte till page handlern men den hör inte till något bra objekt... separat core-dev handler????
$page->setApplicationPath();
$db = SqlFactory::factory('mysql', true);
// enable profiler
SqlHandler::addInstance($db);
//registers the created database connection as the one to use by SqlHandler
//$db->setConfig( array('host' => 'process1.x:44000', 'database' => 'dbProcess', 'username' => 'ml', 'password' => 'xx') );
$db->setConfig(array('host' => 'localhost:44308', 'database' => 'dbProcess2', 'username' => 'root', 'password' => 'xx'));
$page->enableProfiler();
$locale = LocaleHandler::getInstance();
$locale->set('swe');
$session = SessionHandler::getInstance();
$session->setName('savakID');
$session->setTimeout(60 * 60 * 24 * 2);
//keep logged in for 2 days!
$session->setEncryptKey('sdcu7cw897cwhwihwiuh#zaixx7wsxh3hdzsddFDF4ex1g');
$session->allowLogins(true);
$session->allowRegistrations(false);
$page->setUploadPath('/devel/projects/process/uploads/');
$header = XhtmlHeader::getInstance();
//$header->setFavicon('favicon.png');
$header->setTitle('process server');
$header->includeCss('css/site.css');
//$header->includeCss('core_dev/css/core.css');