diff --git a/developer_manual/templates.rst b/developer_manual/templates.rst index d97c9582c..7388211bc 100644 --- a/developer_manual/templates.rst +++ b/developer_manual/templates.rst @@ -6,6 +6,64 @@ ownCloud uses its own templating system. Template class -------------- +.. php:class:: OC_Template + + This class provides the templates for owncloud. It is used for loading template files, assign variables to it and render the whole template. + + .. php:method:: __construct($app, $name[, $renderas]) + + :param string $app: the name of the app + :param string $file: name of the template file (without suffix) + :param string $renderas: If $renderas is set, OC_Template will try to produce a full page in the according layout. For now, renderas can be set to "guest", "user" or "admin" + :returns: OC_Template object + + + .. php:method:: detectFormfactor() + + :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. + + .. php:method:: getFormFactorExtension() + + :returns: Returns the formfactor extension for current formfactor (like .mobile or .tablet) + + .. php:method:: assign($key, $value[, $sanitizeHTML=true]) + + :param string $key: the key under which the variable can be accessed in the template + :param $value: the value that we want to pass + :param bool $sanitizeHTML: false, if data shouldn't get passed through htmlentities + :returns: bool + + 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:: 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:: 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 + + + .. php:method:: printPage() + + :returns: bool + + This function proceeds the template and prints its output. + + Template syntax --------------- @@ -25,7 +83,7 @@ This is the print statement which prints out XSS escaped values. ownCloud does n
@@ -44,7 +102,7 @@ This function does not escape the content for XSS. This would typically be used Some HTML"; ?>
- print_unescaped($html); ?> +
.. php:function:: link_to($app, $file, [$args]) @@ -67,9 +125,8 @@ This function is used to produce generate clean and absolute links to your files ?> @@ -97,8 +154,8 @@ When you pass an empty string for $app, the following directories will be search .. code-block:: php - " /> @@ -113,8 +170,8 @@ A shortcut for getting a mimetype icon. .. code-block:: php - " /> @@ -130,7 +187,7 @@ Turns bytes into human readable formats, for instance 1024 bytes get turned into 2kB ?> -
  • p($this->human_file_size('2048'); ?>
  • +
  • human_file_size('2048')); ?>
  • .. php:function:: simple_file_size($bytes) @@ -145,7 +202,7 @@ A more simpler function that only turns bytes into megabytes. If its smaller tha < 0.1 ?> -
  • p($this->simple_file_size('2048'); ?>
  • +
  • .. php:function:: relative_modified_date($timestamp) @@ -160,7 +217,7 @@ Instead of displaying a date, it is often better to give a relative date like: " 5 minutes ago ?> - p($this->relative_modified_date('29393992912'); ?> + .. php:function:: html_select_options($options, $selected[, $params])