Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/template.php')
-rw-r--r--lib/template.php99
1 files changed, 50 insertions, 49 deletions
diff --git a/lib/template.php b/lib/template.php
index a10ddcd5c33..8c872a2059b 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -25,12 +25,13 @@
* @brief make OC_Helper::linkTo available as a simple function
* @param $app app
* @param $file file
+ * @param $args array with param=>value, will be appended to the returned url
* @returns link to the file
*
* For further information have a look at OC_Helper::linkTo
*/
-function link_to( $app, $file ){
- return OC_Helper::linkTo( $app, $file );
+function link_to( $app, $file, $args = array() ) {
+ return OC_Helper::linkTo( $app, $file, $args );
}
/**
@@ -41,7 +42,7 @@ function link_to( $app, $file ){
*
* For further information have a look at OC_Helper::imagePath
*/
-function image_path( $app, $image ){
+function image_path( $app, $image ) {
return OC_Helper::imagePath( $app, $image );
}
@@ -52,7 +53,7 @@ function image_path( $app, $image ){
*
* For further information have a look at OC_Helper::mimetypeIcon
*/
-function mimetype_icon( $mimetype ){
+function mimetype_icon( $mimetype ) {
return OC_Helper::mimetypeIcon( $mimetype );
}
@@ -63,7 +64,7 @@ function mimetype_icon( $mimetype ){
*
* For further information have a look at OC_Helper::humanFileSize
*/
-function human_file_size( $bytes ){
+function human_file_size( $bytes ) {
return OC_Helper::humanFileSize( $bytes );
}
@@ -76,7 +77,7 @@ function simple_file_size($bytes) {
}
function relative_modified_date($timestamp) {
- $l=OC_L10N::get('template');
+ $l=OC_L10N::get('lib');
$timediff = time() - $timestamp;
$diffminutes = round($timediff/60);
$diffhours = round($diffminutes/60);
@@ -98,25 +99,25 @@ function relative_modified_date($timestamp) {
}
function html_select_options($options, $selected, $params=array()) {
- if (!is_array($selected)){
+ if (!is_array($selected)) {
$selected=array($selected);
}
- if (isset($params['combine']) && $params['combine']){
+ if (isset($params['combine']) && $params['combine']) {
$options = array_combine($options, $options);
}
$value_name = $label_name = false;
- if (isset($params['value'])){
+ if (isset($params['value'])) {
$value_name = $params['value'];
}
- if (isset($params['label'])){
+ if (isset($params['label'])) {
$label_name = $params['label'];
}
$html = '';
- foreach($options as $value => $label){
- if ($value_name && is_array($label)){
+ foreach($options as $value => $label) {
+ if ($value_name && is_array($label)) {
$value = $label[$value_name];
}
- if ($label_name && is_array($label)){
+ if ($label_name && is_array($label)) {
$label = $label[$label_name];
}
$select = in_array($value, $selected) ? ' selected="selected"' : '';
@@ -149,7 +150,7 @@ class OC_Template{
* according layout. For now, renderas can be set to "guest", "user" or
* "admin".
*/
- public function __construct( $app, $name, $renderas = "" ){
+ public function __construct( $app, $name, $renderas = "" ) {
// Set the private data
$this->renderas = $renderas;
$this->application = $app;
@@ -161,7 +162,7 @@ class OC_Template{
header('X-Frame-Options: Sameorigin');
header('X-XSS-Protection: 1; mode=block');
header('X-Content-Type-Options: nosniff');
-
+
$this->findTemplate($name);
}
@@ -171,17 +172,17 @@ class OC_Template{
* mobile -> interface for smartphones
* tablet -> interface for tablets
* standalone -> the default interface but without header, footer and
- * sidebar, just the application. Useful to use just a specific
- * app on the desktop in a standalone window.
+ * sidebar, just the application. Useful to use just a specific
+ * app on the desktop in a standalone window.
*/
- public static function detectFormfactor(){
+ public static function detectFormfactor() {
// please add more useragent strings for other devices
- if(isset($_SERVER['HTTP_USER_AGENT'])){
+ if(isset($_SERVER['HTTP_USER_AGENT'])) {
if(stripos($_SERVER['HTTP_USER_AGENT'],'ipad')>0) {
$mode='tablet';
- }elseif(stripos($_SERVER['HTTP_USER_AGENT'],'iphone')>0){
+ }elseif(stripos($_SERVER['HTTP_USER_AGENT'],'iphone')>0) {
$mode='mobile';
- }elseif((stripos($_SERVER['HTTP_USER_AGENT'],'N9')>0) and (stripos($_SERVER['HTTP_USER_AGENT'],'nokia')>0)){
+ }elseif((stripos($_SERVER['HTTP_USER_AGENT'],'N9')>0) and (stripos($_SERVER['HTTP_USER_AGENT'],'nokia')>0)) {
$mode='mobile';
}else{
$mode='default';
@@ -200,21 +201,21 @@ class OC_Template{
// if the formfactor is not yet autodetected do the
// autodetection now. For possible formfactors check the
// detectFormfactor documentation
- if(!isset($_SESSION['formfactor'])){
+ if(!isset($_SESSION['formfactor'])) {
$_SESSION['formfactor'] = self::detectFormfactor();
}
// allow manual override via GET parameter
- if(isset($_GET['formfactor'])){
+ if(isset($_GET['formfactor'])) {
$_SESSION['formfactor']=$_GET['formfactor'];
}
$formfactor=$_SESSION['formfactor'];
- if($formfactor=='default') {
+ if($formfactor=='default') {
$fext='';
- }elseif($formfactor=='mobile') {
+ }elseif($formfactor=='mobile') {
$fext='.mobile';
- }elseif($formfactor=='tablet') {
+ }elseif($formfactor=='tablet') {
$fext='.tablet';
- }elseif($formfactor=='standalone') {
+ }elseif($formfactor=='standalone') {
$fext='.standalone';
}else{
$fext='';
@@ -239,9 +240,9 @@ class OC_Template{
$app = $this->application;
// Check if it is a app template or not.
- if( $app != "" ){
+ if( $app != "" ) {
// Check if the app is in the app folder or in the root
- if( file_exists(OC_App::getAppPath($app)."/templates/" )){
+ if( file_exists(OC_App::getAppPath($app)."/templates/" )) {
// Check if the template is overwritten by the selected theme
if ($this->checkPathForTemplate(OC::$SERVERROOT."/themes/$theme/apps/$app/templates/", $name, $fext)) {
}elseif ($this->checkPathForTemplate(OC_App::getAppPath($app)."/templates/", $name, $fext)) {
@@ -281,9 +282,9 @@ class OC_Template{
{
if ($name =='') return false;
$template = null;
- if( is_file( $path.$name.$fext.'.php' )){
+ if( is_file( $path.$name.$fext.'.php' )) {
$template = $path.$name.$fext.'.php';
- }elseif( is_file( $path.$name.'.php' )){
+ }elseif( is_file( $path.$name.'.php' )) {
$template = $path.$name.'.php';
}
if ($template) {
@@ -306,7 +307,7 @@ class OC_Template{
*
* If the key existed before, it will be overwritten
*/
- public function assign( $key, $value, $sanitizeHTML=true ){
+ public function assign( $key, $value, $sanitizeHTML=true ) {
if($sanitizeHTML == true) $value=OC_Util::sanitizeHTML($value);
$this->vars[$key] = $value;
return true;
@@ -322,8 +323,8 @@ class OC_Template{
* exists, the value will be appended. It can be accessed via
* $_[$key][$position] in the template.
*/
- public function append( $key, $value ){
- if( array_key_exists( $key, $this->vars )){
+ public function append( $key, $value ) {
+ if( array_key_exists( $key, $this->vars )) {
$this->vars[$key][] = $value;
}
else{
@@ -337,7 +338,7 @@ class OC_Template{
* @param array $attributes array of attrobutes for the element
* @param string $text the text content for the element
*/
- public function addHeader( $tag, $attributes, $text=''){
+ public function addHeader( $tag, $attributes, $text='') {
$this->headers[]=array('tag'=>$tag,'attributes'=>$attributes,'text'=>$text);
}
@@ -347,9 +348,9 @@ class OC_Template{
*
* This function proceeds the template and prints its output.
*/
- public function printPage(){
+ public function printPage() {
$data = $this->fetchPage();
- if( $data === false ){
+ if( $data === false ) {
return false;
}
else{
@@ -365,10 +366,10 @@ class OC_Template{
* This function proceeds the template. If $this->renderas is set, it
* will produce a full page.
*/
- public function fetchPage(){
+ public function fetchPage() {
$data = $this->_fetch();
- if( $this->renderas ){
+ if( $this->renderas ) {
$page = new OC_TemplateLayout($this->renderas);
if($this->renderas == 'user') {
$page->assign('requesttoken', $this->vars['requesttoken']);
@@ -376,7 +377,7 @@ class OC_Template{
// Add custom headers
$page->assign('headers',$this->headers, false);
- foreach(OC_Util::$headers as $header){
+ foreach(OC_Util::$headers as $header) {
$page->append('headers',$header);
}
@@ -394,7 +395,7 @@ class OC_Template{
*
* Includes the template file, fetches its output
*/
- private function _fetch(){
+ private function _fetch() {
// Register the variables
$_ = $this->vars;
$l = $this->l10n;
@@ -416,12 +417,12 @@ class OC_Template{
* Includes another template. use <?php echo $this->inc('template'); ?> to
* do this.
*/
- public function inc( $file, $additionalparams = null ){
+ public function inc( $file, $additionalparams = null ) {
// $_ erstellen
$_ = $this->vars;
$l = $this->l10n;
- if( !is_null($additionalparams)){
+ if( !is_null($additionalparams)) {
$_ = array_merge( $additionalparams, $this->vars );
}
@@ -442,9 +443,9 @@ class OC_Template{
* @param $parameters Parameters for the template
* @returns true/false
*/
- public static function printUserPage( $application, $name, $parameters = array() ){
+ public static function printUserPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "user" );
- foreach( $parameters as $key => $value ){
+ foreach( $parameters as $key => $value ) {
$content->assign( $key, $value, false );
}
print $content->printPage();
@@ -457,9 +458,9 @@ class OC_Template{
* @param $parameters Parameters for the template
* @returns true/false
*/
- public static function printAdminPage( $application, $name, $parameters = array() ){
+ public static function printAdminPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "admin" );
- foreach( $parameters as $key => $value ){
+ foreach( $parameters as $key => $value ) {
$content->assign( $key, $value, false );
}
return $content->printPage();
@@ -472,9 +473,9 @@ class OC_Template{
* @param $parameters Parameters for the template
* @returns true/false
*/
- public static function printGuestPage( $application, $name, $parameters = array() ){
+ public static function printGuestPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "guest" );
- foreach( $parameters as $key => $value ){
+ foreach( $parameters as $key => $value ) {
$content->assign( $key, $value, false );
}
return $content->printPage();