Esempio n. 1
0
 static function getSpecialSyntaxKeys($string)
 {
     if (preg_match('@^([^\\[]+)((\\[[^\\]]*\\])+)$@', $string, $match)) {
         //match[1] = array name, match[2] = all keys
         //get names of all keys
         preg_match_all('@\\[([^\\]]*)\\]@', $match[2], $matches);
         //add array name to beginning of keys list
         array_unshift($matches[1], $match[1]);
         //clear out empty key items
         Arrays::remove($matches[1], '', true);
         return $matches[1];
     }
 }
Esempio n. 2
0
 static function implode($separator, $array)
 {
     Arrays::remove($array);
     return implode($separator, $array);
 }
Esempio n. 3
0
 function attributes($x, $name = 'default')
 {
     if ($this->additionalParsers) {
         foreach ($this->additionalParsers as $parser) {
             list($x, $name) = call_user_func($parser, $x, $name);
         }
     }
     $classes = \Arrays::remove(explode(' ', $x['class']));
     unset($x['class']);
     if ($classes) {
         $additions[] = 'class="' . implode(' ', $classes) . '"';
     }
     if ($x['extra']) {
         $additions[] = $x['extra'];
     }
     unset($x['extra']);
     $attributeTypes = array('id', 'title', 'alt', 'rows', 'placeholder');
     foreach ($attributeTypes as $attribute) {
         if ($x[$attribute]) {
             $additions[] = $attribute . '="' . $x[$attribute] . '"';
             unset($x[$attribute]);
         }
     }
     if ($x) {
         //add onclick events
         foreach ($x as $k => $v) {
             if (strtolower(substr($k, 0, 2)) == 'on') {
                 $additions[] = $k . '="' . $v . '"';
             } elseif (strtolower(substr($k, 0, 5) == 'data-')) {
                 $additions[] = $k . '="' . htmlspecialchars($v) . '"';
             } elseif ($k[0] == '@') {
                 if ($v !== null) {
                     $additions[] = substr($k, 1) . '="' . htmlspecialchars($v) . '"';
                 } else {
                     $additions[] = substr($k, 1);
                 }
             }
         }
     }
     if ($additions) {
         return ' ' . implode(' ', $additions) . ' ';
     }
 }
Esempio n. 4
0
 /**
 @param	type	indicates whether tag is css, lastCss, js, or lastJs.  Optional prefix with "-" or "+" to temporarilty change the tagAddOrder
 @param args	additional args taken as files.  Each file in the passed parameters has the following special syntax:
 	-starts with http(s): no modding done
 	-starts with "/": no modding done
 	-starts with "inline:": file taken to be inline css or js.  Code is wrapped in tags before output.
 	-starts with none of the above: file put in path /instanceToken/type/file; ex: "/public/css/main.css"
 	-if array, consider first element the tag naming key and the second element the file; Used for ensuring only one tag item of a key, regardless of file, is included.
 @note	if you don't want to have some tag be unique (ie, you want to include the same js multiple times), don't use this function; instead, just set tag variable (like $bottomJs) directly
 */
 protected function addTag($type)
 {
     if (in_array(substr($type, 0, 1), array('-', '+'))) {
         $originalTagAddOrder = $this->tagAddOrder;
         $this->tagAddOrder = substr($type, 0, 1);
         $type = substr($type, 1);
     }
     if (in_array($type, array('css', 'lastCss'))) {
         $uniqueIn = array('css', 'lastCss');
         $folder = 'css';
     } else {
         $uniqueIn = array('topJs', 'bottomJs', 'lastJs');
         $folder = 'js';
     }
     $files = func_get_args();
     array_shift($files);
     if ($files) {
         if ($this->tagAddOrder == '-') {
             krsort($files);
         }
         $typeArray =& $this->{$type};
         foreach ($files as $file) {
             if (is_array($file)) {
                 $key = $file[0];
                 $file = $file[1];
             }
             if (preg_match('@^inline:@', $file)) {
                 $typeArray[] = $file;
             } else {
                 if (substr($file, 0, 1) != '/' && !preg_match('@^http(s)?:@', $file)) {
                     $file = '/' . $_ENV['urlProjectFileToken'] . '/' . $folder . '/' . $file;
                 }
                 foreach ($uniqueIn as $unique) {
                     Arrays::remove($this->{$unique}, $file);
                 }
                 if (!$key) {
                     if ($this->tagAddOrder == '-') {
                         array_unshift($typeArray, $file);
                     } else {
                         $typeArray[] = $file;
                     }
                 } else {
                     $typeArray[$key] = $file;
                     unset($key);
                 }
             }
         }
     }
     if ($originalTagAddOrder) {
         $this->tagAddOrder = $originalTagAddOrder;
     }
 }
Esempio n. 5
0
 static function explode($separator, $string)
 {
     $array = explode($separator, $string);
     Arrays::remove($array);
     return array_values($array);
 }