ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
functions.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Assetic package, an OpenSky project.
5  *
6  * (c) 2010-2014 OpenSky Project Inc
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
14 
15 if (function_exists('assetic_init')) {
16  return;
17 }
18 
24 function assetic_init(AssetFactory $factory)
25 {
26  global $_assetic;
27 
28  $_assetic = new stdClass();
29  $_assetic->factory = $factory;
30 }
31 
41 function assetic_javascripts($inputs = array(), $filters = array(), array $options = array())
42 {
43  if (!isset($options['output'])) {
44  $options['output'] = 'js/*.js';
45  }
46 
47  return _assetic_urls($inputs, $filters, $options);
48 }
49 
59 function assetic_stylesheets($inputs = array(), $filters = array(), array $options = array())
60 {
61  if (!isset($options['output'])) {
62  $options['output'] = 'css/*.css';
63  }
64 
65  return _assetic_urls($inputs, $filters, $options);
66 }
67 
77 function assetic_image($input, $filters = array(), array $options = array())
78 {
79  if (!isset($options['output'])) {
80  $options['output'] = 'images/*';
81  }
82 
83  $urls = _assetic_urls($input, $filters, $options);
84 
85  return current($urls);
86 }
87 
97 function _assetic_urls($inputs = array(), $filters = array(), array $options = array())
98 {
99  global $_assetic;
100 
101  if (!is_array($inputs)) {
102  $inputs = array_filter(array_map('trim', explode(',', $inputs)));
103  }
104 
105  if (!is_array($filters)) {
106  $filters = array_filter(array_map('trim', explode(',', $filters)));
107  }
108 
109  $coll = $_assetic->factory->createAsset($inputs, $filters, $options);
110 
111  $debug = isset($options['debug']) ? $options['debug'] : $_assetic->factory->isDebug();
112  $combine = isset($options['combine']) ? $options['combine'] : !$debug;
113 
114  $one = $coll->getTargetPath();
115  if ($combine) {
116  $many = array($one);
117  } else {
118  $many = array();
119  foreach ($coll as $leaf) {
120  $many[] = $leaf->getTargetPath();
121  }
122  }
123 
124  return new TraversableString($one, $many);
125 }
if(function_exists('assetic_init')) assetic_init(AssetFactory $factory)
Initializes the global Assetic object.
Definition: functions.php:24
assetic_image($input, $filters=array(), array $options=array())
Returns an image URL.
Definition: functions.php:77
assetic_javascripts($inputs=array(), $filters=array(), array $options=array())
Returns an array of javascript URLs.
Definition: functions.php:41
assetic_stylesheets($inputs=array(), $filters=array(), array $options=array())
Returns an array of stylesheet URLs.
Definition: functions.php:59
An object that can be used as either a string or array.
if(!is_array($argv)) $options
Create styles array
The data for the language used.
The asset factory creates asset objects.
_assetic_urls($inputs=array(), $filters=array(), array $options=array())
Returns an array of asset urls.
Definition: functions.php:97