]> git.andy128k.dev Git - ipf.git/commitdiff
cleanup
authorAndrey Kutejko <aku@anahoret.com>
Wed, 20 Aug 2014 13:39:32 +0000 (16:39 +0300)
committerAndrey Kutejko <aku@anahoret.com>
Wed, 20 Aug 2014 13:39:32 +0000 (16:39 +0300)
ipf/form/field/treemodelchoice.php [deleted file]
ipf/form/widget/treeselectinput.php [deleted file]

diff --git a/ipf/form/field/treemodelchoice.php b/ipf/form/field/treemodelchoice.php
deleted file mode 100644 (file)
index f598af8..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-
-class IPF_Form_Field_TreeModelChoice extends IPF_Form_Field_Choice{
-
-    public $widget = 'IPF_Form_Widget_TreeSelectInput';
-    protected $_models;
-
-    function __construct($params=array()){
-        parent::__construct($params);
-        $this->_models = $params['models'];
-        $choices = array('--------'=>'');
-        $levels = $this->_getLevels();
-        $this->_collectTreeRecursive($choices);
-        $this->setChoices($choices);
-        $this->widget->setLevels($levels);
-    }    
-    
-    protected function _getLevels(){
-        $levels = array();
-        foreach($this->_models as &$m){
-            $m['objects'] = IPF_ORM_Query::create()->from($m['model'])->orderby('ord')->execute();
-            $levels[] = $m['field'];
-        }
-        return $levels;
-    } 
-    
-    protected function _addObject($o, &$choices, $level, $valname, $name=null)
-    {
-        if (!$name)
-            $name = str_repeat("-", $level).$o['name'];
-        
-        $choices[$name.' ('.$valname.$o->id.')'] = $valname.$o->id;
-    }    
-
-    protected function _collectTreeRecursive(&$choices,$level=0,$parent_id=null,$valname=''){
-        foreach($this->_models[$level]['objects'] as $o){
-            if ($parent_id){
-                $foreign = $this->_models[$level]['foreign'];
-                if ($parent_id!=$o->$foreign)
-                    continue;
-            }
-            $this->_addObject($o, $choices, $level, $valname);
-            if ($level<(count($this->_models)-1)){
-                $this->_collectTreeRecursive($choices,$level+1,$o->id,$valname.$o->id.'.');
-            }
-        }
-    }
-
-    function LateClean($data, &$cleaned_data){
-        foreach($this->_models as &$m){
-            $cleaned_data[$m['field']] = $data[$m['field']];
-        }
-    }
-
-
-    /*
-    public function clean($value){
-        parent::clean($value);
-        if (in_array($value, $this->empty_values)) {
-            return null;
-        }
-        $o = $this->_model->getTable()->find($value);
-        return $o;
-    }
-    */
-}
diff --git a/ipf/form/widget/treeselectinput.php b/ipf/form/widget/treeselectinput.php
deleted file mode 100644 (file)
index a04438a..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-class IPF_Form_Widget_TreeSelectInput extends IPF_Form_Widget_SelectInput
-{
-    protected $_levels = null;
-
-    public function setLevels($levels){
-        $this->_levels = $levels;
-    }
-
-    public function valueToFormData($name, $data)
-    {
-        $val = null;
-        foreach($this->_levels as $l){
-            if ( (!isset($data[$l])) || ($data[$l]=='')){
-                return $val;
-            }
-            if ($val==null)
-                $val = '';
-            else
-                $val .= '.';
-            $val .= $data[$l];
-        }
-        return $val;
-    }
-
-    public function valueFromFormData($name, &$data)
-    {
-        if (isset($data[$name])) {
-            $vals = explode(".",(string)$data[$name]);
-            for($i=0; $i<count($this->_levels); $i++){
-                if ( ($i<count($vals)) && ($data[$name]!=''))
-                    $data[$this->_levels[$i]] = $vals[$i];
-                else
-                    $data[$this->_levels[$i]] = null;
-            }
-            return $data[$name];
-        }
-        return null;
-    }
-}
-