Ejemplo n.º 1
0
 /**
  * Returns a formatted string of the given timestamp
  *
  * @param integer $tstamp the timestamp to format
  * @param integer $format[optional] the format
  */
 public function formatTime($tstamp, $format = 0)
 {
     switch ($format) {
         case 1:
             $tstring = strftime($this->getDateTimeFormat(1), $tstamp);
             break;
         case 2:
             $tstring = strftime($this->getDateTimeFormat(2), $tstamp);
             break;
         case 3:
             $tstring = strftime($this->getDateTimeFormat(3), $tstamp);
             break;
         case 4:
             $tstring = strftime($this->getDateTimeFormat(4), $tstamp);
             break;
         case 5:
             $tstring = strftime($this->getDateTimeFormat(5), $tstamp);
             break;
         case 6:
             $tstring = strftime($this->getDateTimeFormat(6), $tstamp);
             break;
         case 7:
             $tstring = strftime($this->getDateTimeFormat(7), $tstamp);
             break;
         case 8:
             $tstring = strftime($this->getDateTimeFormat(8), $tstamp);
             break;
         case 9:
             $tstring = strftime($this->getDateTimeFormat(9), $tstamp);
             break;
         case 10:
             $tstring = strftime($this->getDateTimeFormat(10), $tstamp);
             break;
         case 11:
             $tstring = strftime($this->getDateTimeFormat(9), $tstamp);
             break;
         case 12:
             $tstring = '';
             if (date('dmY', $tstamp) == date('dmY')) {
                 $tstring .= __('Today') . ', ';
             } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) {
                 $tstring .= __('Yesterday') . ', ';
             } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) {
                 $tstring .= __('Tomorrow') . ', ';
             } else {
                 $tstring .= strftime($this->getDateTimeFormat(12) . ', ', $tstamp);
             }
             $tstring .= strftime($this->getDateTimeFormat(14), $tstamp);
             break;
         case 13:
             $tstring = '';
             if (date('dmY', $tstamp) == date('dmY')) {
                 //$tstring .= __('Today') . ', ';
             } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) {
                 $tstring .= __('Yesterday') . ', ';
             } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) {
                 $tstring .= __('Tomorrow') . ', ';
             } else {
                 $tstring .= strftime($this->getDateTimeFormat(12) . ', ', $tstamp);
             }
             $tstring .= strftime($this->getDateTimeFormat(14), $tstamp);
             break;
         case 14:
             $tstring = '';
             if (date('dmY', $tstamp) == date('dmY')) {
                 $tstring .= __('Today');
             } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) {
                 $tstring .= __('Yesterday');
             } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) {
                 $tstring .= __('Tomorrow');
             } else {
                 $tstring .= strftime($this->getDateTimeFormat(12), $tstamp);
             }
             break;
         case 15:
             $tstring = strftime($this->getDateTimeFormat(11), $tstamp);
             break;
         case 16:
             $tstring = strftime($this->getDateTimeFormat(12), $tstamp);
             break;
         case 17:
             $tstring = strftime($this->getDateTimeFormat(13), $tstamp);
             break;
         case 18:
             $tstring = strftime($this->getDateTimeFormat(16), $tstamp);
             break;
         case 19:
             $tstring = strftime($this->getDateTimeFormat(14), $tstamp);
             break;
         case 20:
             $tstring = '';
             if (date('dmY', $tstamp) == date('dmY')) {
                 $tstring .= __('Today') . ' (' . strftime('%H:%M', $tstamp) . ')';
             } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) {
                 $tstring .= __('Yesterday') . ' (' . strftime('%H:%M', $tstamp) . ')';
             } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) {
                 $tstring .= __('Tomorrow') . ' (' . strftime('%H:%M', $tstamp) . ')';
             } else {
                 $tstring .= strftime($this->getDateTimeFormat(15), $tstamp);
             }
             break;
         case 21:
             $tstring = TBGContext::isCLI() ? strftime('%a, %d %b %Y %H:%M:%S GMT', $tstamp) : strftime($this->getDateTimeFormat(17), $tstamp);
             if (\caspar\core\Caspar::getUser()->getTimezone() > 0) {
                 $tstring .= '+';
             }
             if (\caspar\core\Caspar::getUser()->getTimezone() < 0) {
                 $tstring .= '-';
             }
             if (\caspar\core\Caspar::getUser()->getTimezone() != 0) {
                 $tstring .= \caspar\core\Caspar::getUser()->getTimezone();
             }
             break;
         case 22:
             $tstring = strftime($this->getDateTimeFormat(15), $tstamp);
             break;
         case 23:
             $tstring = '';
             if (date('dmY', $tstamp) == date('dmY')) {
                 $tstring .= __('Today');
             } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') - 1))) {
                 $tstring .= __('Yesterday');
             } elseif (date('dmY', $tstamp) == date('dmY', mktime(0, 0, 0, date('m'), date('d') + 1))) {
                 $tstring .= __('Tomorrow');
             } else {
                 $tstring .= strftime($this->getDateTimeFormat(15), $tstamp);
             }
             break;
         default:
             return $tstamp;
     }
     return htmlentities($tstring, ENT_COMPAT, $this->getCharset());
 }
Ejemplo n.º 2
0
 public function ajaxResponseText($code, $error)
 {
     $ob_status = ob_get_status();
     if (!empty($ob_status) && (isset($ob_status['status']) && $ob_status['status'] != PHP_OUTPUT_HANDLER_END || isset($ob_status['flags']) && !($ob_status['flags'] & PHP_OUTPUT_HANDLER_END))) {
         ob_end_clean();
     }
     $this->setContentType('application/json');
     $this->setHttpStatus($code);
     $this->renderHeaders();
     if (\caspar\core\Caspar::isDebugMode()) {
         $json_data = array('error' => $error);
         \caspar\core\Caspar::getDebugger()->setJsonOutput($json_data);
         $json_data['csp-debugger'] = \caspar\core\Caspar::getDebugger()->returnCurrentPageRow();
         echo json_encode($json_data);
         die;
     }
     echo json_encode(array('error' => $error));
     die;
 }
Ejemplo n.º 3
0
<?php

\caspar\core\Caspar::getI18n()->setCharset('utf-8');
setlocale(LC_ALL, array('en_US@euro', 'en_US', 'en'));
Ejemplo n.º 4
0
 /**
  * Shortcut to see if request is AJAX
  *
  * @return boolean
  */
 public function isAjaxRequest()
 {
     return \caspar\core\Caspar::getRequest()->isAjaxCall();
 }
Ejemplo n.º 5
0
 /**
  * Renders JSON output, also takes care of setting the correct headers
  * 
  * @param array $content The array to render
  *  
  * @return boolean
  */
 public function renderJSON($text = array())
 {
     $this->getResponse()->setContentType('application/json');
     $this->getResponse()->setDecoration(Response::DECORATE_NONE);
     if (false && \caspar\core\Caspar::isDebugMode()) {
         $json_data = $text;
         \caspar\core\Caspar::getDebugger()->setJsonOutput($json_data);
         $json_data['csp-debugger'] = \caspar\core\Caspar::getDebugger()->returnCurrentPageRow();
         echo json_encode($json_data);
         return true;
     }
     echo json_encode($text);
     return true;
 }
Ejemplo n.º 6
0
/**
 * Generate a url based on a route
 * 
 * @param string	$name 	The route key
 * @param array 	$params	key => value pairs of route parameters
 * 
 * @return string
 */
function make_url($name, $params = array(), $relative = true)
{
    return \caspar\core\Caspar::getRouting()->generate($name, $params, $relative);
}
Ejemplo n.º 7
0
/**
 * Run the I18n translation function
 *
 * @param string $text the text to translate
 * @param array $replacements[optional] replacements
 *
 * @return string
 */
function __($text, $replacements = array(), $html_decode = false)
{
    $i18n = \caspar\core\Caspar::getI18n();
    return $i18n instanceof \caspar\core\I18n ? $i18n->__($text, $replacements, $html_decode) : $text;
}
Ejemplo n.º 8
0
.rounded_box {background: transparent; margin:0px; border-radius: 5px; border: 1px solid #CCC; box-shadow: 0 0 3px rgba(0, 0, 0, 0.3); padding: 0; }
.rounded_box h4 { margin-bottom: 0px; margin-top: 7px; font-size: 14px; }
.error_content { padding: 10px; }
.description { padding: 3px 3px 3px 0;}
pre { overflow: scroll; padding: 5px; }
</style>
<!--[if IE]>
<style>
body { background-color: #DFDFDF; font-family: sans-serif; font-size: 13px; }
</style>
<![endif]-->
</head>
<body>
	<div class="rounded_box" style="margin: 30px auto 30px auto; width: 700px;">
		<?php 
if (!Caspar::isDebugMode()) {
    ?>
			<h1>Woops! An error occured</h1>
			<div style="padding: 10px;">
				Go back to the <a href="http://www.thebuggenie.com">frontpage</a>?
			</div>
		<?php 
} else {
    ?>
			<h1>An error occured in Caspar</h1>
			<div class="error_content">
				<h2><?php 
    echo isset($exception) ? $exception->getMessage() : $error;
    ?>
</h2>
				<?php