PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Wordpress/warp/systems/wordpress/config/layouts/fields/style.php

https://github.com/dominikkucharski/Warp-Framework
PHP | 49 lines | 24 code | 14 blank | 11 comment | 7 complexity | e9f0ac2c8d9cb8822b105478a393d4a8 MD5 | raw file
  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. printf('<select %s>', $control->attributes(array('class' => 'widget-style', 'name' => $name)));
  9. foreach ($node->children('option') as $option) {
  10. // set attributes
  11. $attributes = array('value' => $option->attr('value'));
  12. // is checked ?
  13. if ($option->attr('value') == $value) {
  14. $attributes = array_merge($attributes, array('selected' => 'selected'));
  15. }
  16. printf('<option %s>%s</option>', $control->attributes($attributes), $option->attr('name'));
  17. // has colors ?
  18. if ($colors = $option->children('color')) {
  19. $selects[] = sprintf('<select class="widget-color %s">', $option->attr('value'));
  20. foreach ($colors as $color) {
  21. // set attributes
  22. $attributes = array('value' => $color->attr('value'));
  23. // is checked ?
  24. if (isset($widget->options['color']) && $color->attr('value') == $widget->options['color']) {
  25. $attributes = array_merge($attributes, array('selected' => 'selected'));
  26. }
  27. $selects[] = sprintf('<option %s>%s</option>', $control->attributes($attributes), $color->attr('name'));
  28. }
  29. $selects[] = '</select>';
  30. }
  31. }
  32. printf('</select>');
  33. if (isset($selects)) {
  34. echo implode("", $selects);
  35. }