コード例 #1
0
	/**
	 * Magic __get method for returning property values
	 * Override the handling of the value property to properly return the setting of the checkbox.
	 *
	 * @param string $name The name of the property
	 * @return mixed The value of the requested property
	 */
	public function __get( $name )
	{
		static $posted = null;
		switch ( $name ) {
			case 'value':
				if ( isset( $_POST[$this->field . '_submitted'] ) ) {
					if(!isset($posted)) {
						$valuesj = $_POST->raw( $this->field . '_submitted');
						$values = json_decode($valuesj);
						$terms = array();
						foreach($this->get_default() as $term) {
							$terms[$term->id] = $term;
						}
						foreach($values as $value) {
							$terms[$value->id]->mptt_left = $value->left;
							$terms[$value->id]->mptt_right = $value->right;
						}
						$terms = new Terms($terms);
						$posted = $terms->tree_sort();
					}
					return $posted;
				}
				else {
					return $this->get_default();
				}
		}
		return parent::__get( $name );
	}
コード例 #2
0
ファイル: formcontroltree.php プロジェクト: habari/system
 public function process()
 {
     $values = json_decode($_POST->raw($this->input_name()));
     $terms = array();
     foreach ($this->value as $term) {
         $terms[$term->id] = $term;
     }
     foreach ($values as $value) {
         $terms[$value->id]->mptt_left = $value->left;
         $terms[$value->id]->mptt_right = $value->right;
     }
     $terms = new Terms($terms);
     $posted = $terms->tree_sort();
     //$this->set_value($_POST[$this->input_name()], false);
     $this->set_value($posted, false);
 }