Minor improvements

This commit is contained in:
Jakob Sack 2011-08-08 23:14:47 +02:00
parent ded97de891
commit 4b967a9414
2 changed files with 18 additions and 27 deletions

View File

@ -146,16 +146,11 @@ class OC_L10N{
// If you add something don't forget to add it to $localizations // If you add something don't forget to add it to $localizations
// at the top of the page // at the top of the page
case 'date': case 'date':
if( is_string( $data )) $data = strtotime( $data );
return date( $this->localizations['date'], $data );
break;
case 'datetime': case 'datetime':
if( is_string( $data )) $data = strtotime( $data );
return date( $this->localizations['datetime'], $data );
break;
case 'time': case 'time':
if( is_string( $data )) $data = strtotime( $data ); if( $data instanceof DateTime ) return $data->format($this->localizations[$type]);
return date( $this->localizations['time'], $data ); elseif( is_string( $data )) $data = strtotime( $data );
return date( $this->localizations[$type], $data );
break; break;
default: default:
return false; return false;

View File

@ -202,15 +202,12 @@ class OC_Template{
* *
* This function proceeds the template and prints its output. * This function proceeds the template and prints its output.
*/ */
public function printPage() public function printPage(){
{
$data = $this->fetchPage(); $data = $this->fetchPage();
if( $data === false ) if( $data === false ){
{
return false; return false;
} }
else else{
{
print $data; print $data;
return true; return true;
} }
@ -223,18 +220,15 @@ class OC_Template{
* This function proceeds the template. If $this->renderas is set, it will * This function proceeds the template. If $this->renderas is set, it will
* will produce a full page. * will produce a full page.
*/ */
public function fetchPage() public function fetchPage(){
{
// global Data we need // global Data we need
global $WEBROOT; global $WEBROOT;
global $SERVERROOT; global $SERVERROOT;
$data = $this->_fetch(); $data = $this->_fetch();
if( $this->renderas ) if( $this->renderas ){
{
// Decide which page we show // Decide which page we show
if( $this->renderas == "user" ) if( $this->renderas == "user" ){
{
$page = new OC_Template( "core", "layout.user" ); $page = new OC_Template( "core", "layout.user" );
$search=new OC_Template( 'core', 'part.searchbox'); $search=new OC_Template( 'core', 'part.searchbox');
$search->assign('searchurl',OC_Helper::linkTo( 'search', 'index.php' )); $search->assign('searchurl',OC_Helper::linkTo( 'search', 'index.php' ));
@ -243,8 +237,7 @@ class OC_Template{
// Add navigation entry // Add navigation entry
$page->assign( "navigation", OC_App::getNavigation()); $page->assign( "navigation", OC_App::getNavigation());
} }
elseif( $this->renderas == "admin" ) elseif( $this->renderas == "admin" ){
{
$page = new OC_Template( "core", "layout.admin" ); $page = new OC_Template( "core", "layout.admin" );
$search=new OC_Template( 'core', 'part.searchbox'); $search=new OC_Template( 'core', 'part.searchbox');
$search->assign('searchurl',OC_Helper::linkTo( 'search', 'index.php' )); $search->assign('searchurl',OC_Helper::linkTo( 'search', 'index.php' ));
@ -256,8 +249,7 @@ class OC_Template{
} }
$page->assign( "settingsnavigation", OC_App::getSettingsNavigation()); $page->assign( "settingsnavigation", OC_App::getSettingsNavigation());
} }
else else{
{
$page = new OC_Template( "core", "layout.guest" ); $page = new OC_Template( "core", "layout.guest" );
} }
@ -295,8 +287,7 @@ class OC_Template{
$page->assign( "content", $data ); $page->assign( "content", $data );
return $page->fetchPage(); return $page->fetchPage();
} }
else else{
{
return $data; return $data;
} }
} }
@ -329,9 +320,14 @@ class OC_Template{
* Includes another template. use <?php echo $this->inc('template'); ?> to * Includes another template. use <?php echo $this->inc('template'); ?> to
* do this. * do this.
*/ */
public function inc( $file ){ public function inc( $file, $additionalparams = null ){
// $_ erstellen // $_ erstellen
$_ = $this->vars; $_ = $this->vars;
$l = $this->l10n;
if( !is_null($additionalparams)){
$_ = array_merge( $additionalparams, $this->vars );
}
// Einbinden // Einbinden
ob_start(); ob_start();