Project

General

Profile

1
<?php
2
/**
3
* @package   Warp Theme Framework
4
* @author    YOOtheme http://www.yootheme.com
5
* @copyright Copyright (C) YOOtheme GmbH
6
* @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
7
*/
8

    
9
$style_folder = $this['path']->path('template:styles');
10
$skip_folders = array('.', '..', 'mobile');
11

    
12
// add default option as first option in the list
13
$styles_list  = array("default");
14

    
15
printf('<select %s>', $this['field']->attributes(compact('name')));
16

    
17
if ($style_folder) {
18

    
19
    // fill the list with all styles found in the folder
20
    foreach (scandir($style_folder) as $style) {
21
        
22
        if (in_array($style, $skip_folders) || !is_dir($style_folder.'/'.$style)) {
23
            continue;
24
        }
25

    
26
        $styles_list[] = $style;
27
    }
28
}
29

    
30
// output
31
foreach ($styles_list as $option) {
32
    // set attributes
33
    $attributes = array('value' => $option);
34

    
35
    // // is checked ?
36
    if ($option == $value) {
37
        $attributes = array_merge($attributes, array('selected' => 'selected'));
38
    }
39

    
40
    // make option-text more human-readable (spaces instead of underscores and capital letters after each space)
41
    $text = ucwords(str_replace( '_', ' ', $option ));
42

    
43
    printf('<option %s>%s</option>', $this['field']->attributes($attributes), $text);
44
}
45

    
46
printf('</select>');
(5-5/8)