Пример #1
0
 static function input($args, $formdata = false)
 {
     if (false !== $formdata) {
         $form = new scbForm($formdata);
         return $form->input($args);
     }
     if (empty($args['name'])) {
         return trigger_error('Empty name', E_USER_WARNING);
     }
     $args = wp_parse_args($args, array('desc' => '', 'desc_pos' => 'after', 'wrap' => self::TOKEN, 'wrap_each' => self::TOKEN));
     if (isset($args['value']) && is_array($args['value'])) {
         $args['values'] = $args['value'];
         unset($args['value']);
     }
     if (isset($args['extra']) && !is_array($args['extra'])) {
         $args['extra'] = shortcode_parse_atts($args['extra']);
     }
     self::$cur_name = self::get_name($args['name']);
     switch ($args['type']) {
         case 'select':
         case 'radio':
             $input = self::_single_choice($args);
             break;
         case 'checkbox':
             if (isset($args['values'])) {
                 $input = self::_multiple_choice($args);
             } else {
                 $input = self::_checkbox($args);
             }
             break;
         default:
             $input = self::_input($args);
     }
     return str_replace(self::TOKEN, $input, $args['wrap']);
 }
Пример #2
0
	static function input( $args, $formdata = false ) {
		// setle on singular keys
		foreach ( array( 'name', 'value' ) as $key ) {
			$old = $key . 's';

			if ( isset( $args[$old] ) ) {
				$args[$key] = $args[$old];
				unset( $args[$old] );
			}
		}

		if ( !empty( $formdata ) ) {
			$form = new scbForm( $formdata );
			return $form->input( $args );
		}

		if ( empty( $args['name'] ) )
			return trigger_error( 'Empty name', E_USER_WARNING );

		$args = wp_parse_args( $args, array(
			'desc' => '',
			'desc_pos' => '',
		) );

		$val_is_array = isset( $args['value'] ) && is_array( $args['value'] );

		if ( isset( $args['extra'] ) && !is_array( $args['extra'] ) )
			$args['extra'] = shortcode_parse_atts( $args['extra'] );

		self::$cur_name = self::get_name( $args['name'] );

		switch ( $args['type'] ) {
			case 'select':
			case 'radio':
				if ( ! $val_is_array )
					return trigger_error( "'value' argument is expected to be an array", E_USER_WARNING );

				return self::_single_choice( $args );
				break;
			case 'checkbox':
				if ( $val_is_array )
					return self::_multiple_choice( $args );
				else
					return self::_checkbox( $args );
				break;
			default:
				return self::_input( $args );
		}
	}
Пример #3
0
 static function input($args, $formdata = array())
 {
     foreach (array('name', 'value') as $key) {
         $old = $key . 's';
         if (isset($args[$old])) {
             $args[$key] = $args[$old];
             unset($args[$old]);
         }
     }
     if (empty($args['name'])) {
         return trigger_error('Empty name', E_USER_WARNING);
     }
     $args = wp_parse_args($args, array('value' => NULL, 'desc' => '', 'desc_pos' => ''));
     if (isset($args['extra']) && !is_array($args['extra'])) {
         $args['extra'] = shortcode_parse_atts($args['extra']);
     }
     self::$cur_name = self::get_name($args['name']);
     self::$cur_val = self::get_value($args['name'], $formdata);
     switch ($args['type']) {
         case 'select':
         case 'radio':
             if (!is_array($args['value'])) {
                 return trigger_error("'value' argument is expected to be an array", E_USER_WARNING);
             }
             return self::_single_choice($args);
             break;
         case 'checkbox':
             if (is_array($args['value'])) {
                 return self::_multiple_choice($args);
             } else {
                 return self::_checkbox($args);
             }
             break;
         default:
             return self::_input($args);
     }
 }