mirror of
https://github.com/nextcloud/documentation.git
synced 2026-01-03 02:09:45 +07:00
ordered functions and methods alphabetically
This commit is contained in:
@@ -18,13 +18,23 @@ Template class
|
||||
:returns: OC_Template object
|
||||
|
||||
|
||||
.. php:method:: detectFormfactor()
|
||||
.. php:method:: addHeader($tag, $attributes[, $text=''])
|
||||
|
||||
:returns: The mode of the client as a string. **default** -> the normal desktop browser interface, **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.
|
||||
:param string $tag: tag name of the element
|
||||
:param array $attributes: array of attrobutes for the element
|
||||
:param string $text: the text content for the element
|
||||
|
||||
Add a custom element to the html <head>
|
||||
|
||||
|
||||
.. php:method:: append($key, $value)
|
||||
|
||||
:param string $key: the key under which the variable can be accessed in the template
|
||||
:param $value: the value that we want to pass
|
||||
:returns: bool
|
||||
|
||||
This function assigns a variable in an array context. If the key already exists, the value will be appended. It can be accessed via $_[$key][$position] in the template.
|
||||
|
||||
.. php:method:: getFormFactorExtension()
|
||||
|
||||
:returns: Returns the formfactor extension for current formfactor (like .mobile or .tablet)
|
||||
|
||||
.. php:method:: assign($key, $value[, $sanitizeHTML=true])
|
||||
|
||||
@@ -36,32 +46,10 @@ Template class
|
||||
This function assigns a variable. It can be accessed via $_[$key] in the template. If the key existed before, it will be overwritten
|
||||
|
||||
|
||||
.. php:method:: getFormFactorExtension()
|
||||
|
||||
:returns: Returns the formfactor extension for current formfactor (like .mobile or .tablet)
|
||||
.. php:method:: detectFormfactor()
|
||||
|
||||
.. php:method:: append($key, $value)
|
||||
:returns: The mode of the client as a string. **default** -> the normal desktop browser interface, **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.
|
||||
|
||||
:param string $key: the key under which the variable can be accessed in the template
|
||||
:param $value: the value that we want to pass
|
||||
:returns: bool
|
||||
|
||||
This function assigns a variable in an array context. If the key already exists, the value will be appended. It can be accessed via $_[$key][$position] in the template.
|
||||
|
||||
.. php:method:: addHeader($tag, $attributes[, $text=''])
|
||||
|
||||
:param string $tag: tag name of the element
|
||||
:param array $attributes: array of attrobutes for the element
|
||||
:param string $text: the text content for the element
|
||||
|
||||
Add a custom element to the html <head>
|
||||
|
||||
|
||||
.. php:method:: printPage()
|
||||
|
||||
:returns: true when there is content to print
|
||||
|
||||
This function proceeds the template and prints its output.
|
||||
|
||||
|
||||
.. php:method:: fetchPage()
|
||||
@@ -71,6 +59,11 @@ Template class
|
||||
This function proceeds the template and but prints no output.
|
||||
|
||||
|
||||
.. php:method:: getFormFactorExtension()
|
||||
|
||||
:returns: Returns the formfactor extension for current formfactor (like .mobile or .tablet)
|
||||
|
||||
|
||||
.. php:method:: inc($file[, $additionalparams])
|
||||
|
||||
:param string $file: the name of the template
|
||||
@@ -80,14 +73,11 @@ Template class
|
||||
Includes another template. use <?php echo $this->inc('template'); ?> to do this.
|
||||
|
||||
|
||||
.. php:method:: printUserPage($application, $name[, $parameters])
|
||||
.. php:method:: printPage()
|
||||
|
||||
:param string $application: The application we render the template for
|
||||
:param string $name: Name of the template
|
||||
:param array $parameters: Parameters for the template
|
||||
:returns: bool
|
||||
:returns: true when there is content to print
|
||||
|
||||
Shortcut to print a simple page for users
|
||||
This function proceeds the template and prints its output.
|
||||
|
||||
|
||||
.. php:method:: printAdminPage($application, $name[, $parameters])
|
||||
@@ -110,8 +100,112 @@ Template class
|
||||
Shortcut to print a simple page for guests
|
||||
|
||||
|
||||
.. php:method:: printUserPage($application, $name[, $parameters])
|
||||
|
||||
:param string $application: The application we render the template for
|
||||
:param string $name: Name of the template
|
||||
:param array $parameters: Parameters for the template
|
||||
:returns: bool
|
||||
|
||||
Shortcut to print a simple page for users
|
||||
|
||||
|
||||
Template syntax
|
||||
---------------
|
||||
.. php:function:: html_select_options($options, $selected[, $params])
|
||||
|
||||
:param array $options: an array of the form value => label
|
||||
:param string/array $selected: an array containing strings or a simple string which sets a value as selected
|
||||
:param array $params: optional parameters that are done in key => value
|
||||
:returns: the html as string of preset <option> tags
|
||||
|
||||
FIXME: explain parameters
|
||||
|
||||
|
||||
.. php:function:: human_file_size($bytes)
|
||||
|
||||
:param int $bytes: the bytes that we want to convert to a more readable format
|
||||
:returns: the human readable size as string
|
||||
|
||||
Turns bytes into human readable formats, for instance 1024 bytes get turned into 1kb, 1024*1024 bytes get turned into 1mb
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
// this would print <li>2kB</li>
|
||||
?>
|
||||
<li><?php p($this->human_file_size('2048')); ?></li>
|
||||
|
||||
|
||||
.. php:function:: image_path($app, $image)
|
||||
|
||||
:param string $app: the name of your app as a string. If the string is empty, ownCloud looks for the image in core
|
||||
:param array $image: the filename of the image
|
||||
:returns: the absolute URL to the image as a string
|
||||
|
||||
This function looks up images in several common directories and returns the full link to it. The following directories are being searched:
|
||||
|
||||
- /themes/$theme/apps/$app/img/$image
|
||||
- /themes/$theme/$app/img/$image
|
||||
- /$app/img/$image
|
||||
|
||||
When you pass an empty string for $app, the following directories will be searched:
|
||||
|
||||
- /themes/$theme/apps/$app/img/$image
|
||||
- /themes/$theme/core/img/$image
|
||||
- /core/img/$image
|
||||
|
||||
**Example:**
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<img src="<?php print_unescaped(
|
||||
image_path('news', 'starred.svg');
|
||||
); ?>" />
|
||||
|
||||
.. php:function:: link_to($app, $file, [$args])
|
||||
|
||||
:param string $app: the name of your app as a string. If the string is empty, ownCloud asumes that the file is in /core/
|
||||
:param string $file: the relative path from your apps root to the file you want to access
|
||||
:param array $args: the GET parameters that you want set in the URL in form key => value. The value will be run through urlencode()
|
||||
:returns: the absolute URL to the file
|
||||
|
||||
|
||||
This function is used to produce generate clean and absolute links to your files or pages.
|
||||
|
||||
**Example:**
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
// this will produce the link:
|
||||
// index.php/news/pages/weather.php?show=berlin
|
||||
?>
|
||||
<ul>
|
||||
<li><a href="<?php
|
||||
print_unescaped(
|
||||
link_to('news', 'pages/weather.php', array("show" => "berlin"));
|
||||
);
|
||||
?>">Show Weather for Berlin</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
.. php:function mimetype_icon($mimetype)
|
||||
|
||||
:param array $mimetype: the mimetype for which we want to look up the icon
|
||||
:returns: the absolute URL to the icon
|
||||
|
||||
A shortcut for getting a mimetype icon.
|
||||
|
||||
**Example:**
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<img src="<?php print_unescaped(
|
||||
mimetype_icon('application/xml');
|
||||
); ?>" />
|
||||
|
||||
|
||||
.. php:function:: p($data)
|
||||
|
||||
@@ -150,104 +244,6 @@ This function does not escape the content for XSS. This would typically be used
|
||||
<?php print_unescaped($html); ?>
|
||||
</div>
|
||||
|
||||
.. php:function:: link_to($app, $file, [$args])
|
||||
|
||||
:param string $app: the name of your app as a string. If the string is empty, ownCloud asumes that the file is in /core/
|
||||
:param string $file: the relative path from your apps root to the file you want to access
|
||||
:param array $args: the GET parameters that you want set in the URL in form key => value. The value will be run through urlencode()
|
||||
:returns: the absolute URL to the file
|
||||
|
||||
|
||||
This function is used to produce generate clean and absolute links to your files or pages.
|
||||
|
||||
**Example:**
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
// this will produce the link:
|
||||
// index.php/news/pages/weather.php?show=berlin
|
||||
?>
|
||||
<ul>
|
||||
<li><a href="<?php
|
||||
print_unescaped(
|
||||
link_to('news', 'pages/weather.php', array("show" => "berlin"));
|
||||
);
|
||||
?>">Show Weather for Berlin</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
.. php:function:: image_path($app, $image)
|
||||
|
||||
:param string $app: the name of your app as a string. If the string is empty, ownCloud looks for the image in core
|
||||
:param array $image: the filename of the image
|
||||
:returns: the absolute URL to the image as a string
|
||||
|
||||
This function looks up images in several common directories and returns the full link to it. The following directories are being searched:
|
||||
|
||||
- /themes/$theme/apps/$app/img/$image
|
||||
- /themes/$theme/$app/img/$image
|
||||
- /$app/img/$image
|
||||
|
||||
When you pass an empty string for $app, the following directories will be searched:
|
||||
|
||||
- /themes/$theme/apps/$app/img/$image
|
||||
- /themes/$theme/core/img/$image
|
||||
- /core/img/$image
|
||||
|
||||
**Example:**
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<img src="<?php print_unescaped(
|
||||
image_path('news', 'starred.svg');
|
||||
); ?>" />
|
||||
|
||||
|
||||
.. php:function mimetype_icon($mimetype)
|
||||
|
||||
:param array $mimetype: the mimetype for which we want to look up the icon
|
||||
:returns: the absolute URL to the icon
|
||||
|
||||
A shortcut for getting a mimetype icon.
|
||||
|
||||
**Example:**
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<img src="<?php print_unescaped(
|
||||
mimetype_icon('application/xml');
|
||||
); ?>" />
|
||||
|
||||
|
||||
.. php:function:: human_file_size($bytes)
|
||||
|
||||
:param int $bytes: the bytes that we want to convert to a more readable format
|
||||
:returns: the human readable size as string
|
||||
|
||||
Turns bytes into human readable formats, for instance 1024 bytes get turned into 1kb, 1024*1024 bytes get turned into 1mb
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
// this would print <li>2kB</li>
|
||||
?>
|
||||
<li><?php p($this->human_file_size('2048')); ?></li>
|
||||
|
||||
|
||||
.. php:function:: simple_file_size($bytes)
|
||||
|
||||
:param int $bytes: the bytes that we want to convert to a more readable format in megabytes
|
||||
:returns: the human readable size as string
|
||||
|
||||
A more simpler function that only turns bytes into megabytes. If its smaller than 0.1 megabytes, < 0.1 is being returned. If its bigger than 1000 megabytes, > 1000 is being returned.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
// this would print <li>< 0.1</li>
|
||||
?>
|
||||
<li><?php p(simple_file_size('2048')); ?></li>
|
||||
|
||||
|
||||
.. php:function:: relative_modified_date($timestamp)
|
||||
@@ -264,15 +260,20 @@ Instead of displaying a date, it is often better to give a relative date like: "
|
||||
?>
|
||||
<span><?php p(relative_modified_date('29393992912')); ?></span>
|
||||
|
||||
.. php:function:: html_select_options($options, $selected[, $params])
|
||||
|
||||
:param array $options: an array of the form value => label
|
||||
:param string/array $selected: an array containing strings or a simple string which sets a value as selected
|
||||
:param array $params: optional parameters that are done in key => value
|
||||
:returns: the html as string of preset <option> tags
|
||||
.. php:function:: simple_file_size($bytes)
|
||||
|
||||
FIXME: explain parameters
|
||||
:param int $bytes: the bytes that we want to convert to a more readable format in megabytes
|
||||
:returns: the human readable size as string
|
||||
|
||||
A more simpler function that only turns bytes into megabytes. If its smaller than 0.1 megabytes, < 0.1 is being returned. If its bigger than 1000 megabytes, > 1000 is being returned.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
// this would print <li>< 0.1</li>
|
||||
?>
|
||||
<li><?php p(simple_file_size('2048')); ?></li>
|
||||
|
||||
Further reading
|
||||
---------------
|
||||
|
||||
Reference in New Issue
Block a user