attr() public method

public attr ( $attr )
Ejemplo n.º 1
0
Archivo: widget.php Proyecto: soska/dte
 /**
  * Creates a wordpress option formated input
  *
  * @param string $name 
  * @param string $options 
  * @param string $prefix 
  * @return void
  * @author Armando Sosa
  */
 function input($name, $options = null, $prefix = true)
 {
     // default options
     $options = array_merge(array('label' => $name, 'inline' => 0, 'type' => 'text', 'description' => '', 'options' => array(), 'multiple' => false, 'attrs' => '', 'show_all_cats' => __('-- All'), 'show_none_cats' => ''), (array) $options);
     // grab value from options table
     if (!isset($options['value'])) {
         $options['value'] = $this->Widget->getOption($name);
     }
     $name = $this->Widget->get_field_name($name);
     // parse tag
     switch ($options['type']) {
         case 'select':
             $input = $this->_select($name, $options);
             break;
         case 'categorySelect':
             $input = $this->_categorySelect($name, $options);
             break;
         default:
             if (is_array($options['attrs']) && !empty($options['attrs'])) {
                 $options['attrs'] = HtmlHelper::attr($options['attrs']);
             }
             $input = sprintf($this->inputTags[$options['type']], $name, $options['value'], $options['attrs']);
             break;
     }
     if ($options['type'] == 'hidden') {
         return $input;
     }
     if ($options['label']) {
         if ($options['inline']) {
             $output = "<label>{$options['label']} {$input} </label>";
         } else {
             $output = "<p><label for='{$name}'>{$options['label']}</label></p>";
             $output .= "<p>{$input}</p>";
         }
     } else {
         $output = $input;
     }
     return $output;
 }
Ejemplo n.º 2
0
 function ajaxUrl()
 {
     if ($this->alreadyPrintedAjaxUrl) {
         return false;
     }
     $attributes = HtmlHelper::attr(array('name' => 'ajax_url', 'type' => 'hidden', 'value' => admin_url('admin-ajax.php')));
     echo HtmlHelper::tag("input/", $attributes, null, null);
     $this->alreadyPrintedAjaxUrl = true;
 }
Ejemplo n.º 3
0
 function import($type = null, $name = null, $charset = "utf-8")
 {
     switch ($type) {
         case 'style':
             $attribs = HtmlHelper::attr(array('rel' => 'stylesheet', 'href' => DUP_CORE_STYLES_URL . "{$name}.css", 'type' => 'text/css', 'media' => 'screen', 'title' => phraseize($name), 'charset' => $charset));
             return HtmlHelper::tag('link/', $attribs);
             break;
         case 'script':
             $attribs = HtmlHelper::attr(array('src' => DUP_CORE_STYLES_URL . "{$name}.css", 'type' => 'text/javascript', 'charset' => $charset));
             return HtmlHelper::tag('script', $attribs, null, null, null) . HtmlHelper::tag('/script', null, null, null);
             break;
     }
 }
Ejemplo n.º 4
0
 /**
  * Image Radio Control
  *
  * Enhanced Javascript Control, that allows an array of images, to act as radio
  *
  * @param string $name 
  * @param string $options 
  * @return void
  * @author Armando Sosa
  */
 function _imageRadio($name, $options)
 {
     $options = set_merge(array('baseDir' => ''), (array) $options);
     $input = HtmlHelper::tag('div.image-radio-group');
     foreach ($options['options'] as $value => $image) {
         $selected = $value == $options['value'] ? '.selected' : '';
         $atts = HtmlHelper::attr(array('title' => $value, 'src' => $options['baseDir'] . $image));
         $input .= HtmlHelper::tag('img.radio' . $selected, $atts);
     }
     $input .= $this->input($name, array('type' => 'hidden', 'value' => $value), false);
     $input .= HtmlHelper::tag('/div.image-radio-group');
     return $input;
 }