コード例 #1
0
ファイル: participants-database.php プロジェクト: raj-rk/Raj
 /**
  * prepares a field for display 
  * 
  * displays an array as a series of comma-separated strings
  * 
  * @param string $string
  * @return string the prepared string
  */
 public static function prepare_value($string)
 {
     $value = self::unserialize_array($string);
     if (is_array($value) && PDb_FormElement::is_assoc($value)) {
         /*
          * here, we create a string representation of an associative array, using 
          * :: to denote a name=>value pair
          */
         $temp = array();
         foreach ($value as $k => $v) {
             if (is_int($k)) {
                 $temp[] = $v;
             } else {
                 $temp[] = $k . '::' . $v;
             }
         }
         return implode(', ', $temp);
     }
     return is_array($value) ? implode(', ', $value) : stripslashes($value);
 }
コード例 #2
0
 /**
  * builds a dropdown setting element
  * 
  * @param array $values array of setting values
  * 
  * @return string HTML
  */
 protected function _build_dropdown($values)
 {
     $selectstring = $this->set_selectstring($values[1]);
     $html = '';
     $pattern = "\n" . '<option %9$s value="%4$s" ><span>%5$s</span></option>';
     $html .= "\n" . '<div class="dropdown-group ' . $values[1] . ' ' . $values[4] . '" ><select name="' . $this->settings_name() . '[' . $values[0] . ']" >';
     if (PDb_FormElement::is_assoc($values[7])) {
         foreach ($values[7] as $name => $title) {
             $values[8] = $name == $values[2] ? $selectstring : '';
             $values[3] = $name;
             $values[4] = $title;
             $html .= vsprintf($pattern, $values);
         }
     } else {
         foreach ($values[7] as $value) {
             $values[8] = $value == $values[2] ? $selectstring : '';
             $values[3] = $value;
             $values[4] = $value;
             $html .= vsprintf($pattern, $values);
         }
     }
     $html .= "\n" . '</select></div>';
     if (!empty($values[6])) {
         $html .= "\n" . '<p class="description">' . $values[6] . '</p>';
     }
     return $html;
 }