PodsUI::__construct PHP Method

__construct() public method

Generate UI for Data Management
Since: 2.0
public __construct ( mixed $options, boolean $deprecated = false ) : PodsUI
$options mixed Object, Array, or String containing Pod or Options to be used
$deprecated boolean Set to true to support old options array from Pods UI plugin
return PodsUI
    public function __construct($options, $deprecated = false)
    {
        $this->_nonce = pods_v('_wpnonce', 'request');
        $object = null;
        if (is_object($options)) {
            $object = $options;
            $options = array();
            if (isset($object->ui)) {
                $options = (array) $object->ui;
                unset($object->ui);
            }
            if (is_object($object) && ('Pods' == get_class($object) || 'Pod' == get_class($object))) {
                $this->pod =& $object;
            }
        }
        if (!is_array($options)) {
            // @todo need to come back to this and allow for multi-dimensional strings
            // like: option=value&option2=value2&option3=key[val],key2[val2]&option4=this,that,another
            if (false !== strpos($options, '=') || false !== strpos($options, '&')) {
                parse_str($options, $options);
            } else {
                $options = array('pod' => $options);
            }
        }
        if (!is_object($object) && isset($options['pod'])) {
            if (is_object($options['pod'])) {
                $this->pod = $options['pod'];
            } elseif (isset($options['id'])) {
                $this->pod = pods($options['pod'], $options['id']);
            } else {
                $this->pod = pods($options['pod']);
            }
            unset($options['pod']);
        } elseif (is_object($object)) {
            $this->pod = $object;
        }
        if (false !== $deprecated || is_object($this->pod) && 'Pod' == get_class($this->pod)) {
            $options = $this->setup_deprecated($options);
        }
        if (is_object($this->pod) && 'Pod' == get_class($this->pod) && is_object($this->pod->_data)) {
            $this->pods_data =& $this->pod->_data;
        } elseif (is_object($this->pod) && 'Pods' == get_class($this->pod) && is_object($this->pod->data)) {
            $this->pods_data =& $this->pod->data;
        } elseif (is_object($this->pod)) {
            $this->pods_data = pods_data($this->pod->pod);
        } elseif (!is_object($this->pod)) {
            $this->pods_data = pods_data($this->pod);
        }
        $options = $this->do_hook('pre_init', $options);
        $this->setup($options);
        if (is_object($this->pods_data) && is_object($this->pod) && 0 < $this->id) {
            if ($this->id != $this->pods_data->id) {
                $this->row = $this->pods_data->fetch($this->id);
            } else {
                $this->row = $this->pods_data->row;
            }
        }
        if ((!is_object($this->pod) || 'Pods' != get_class($this->pod)) && false === $this->sql['table'] && false === $this->data) {
            echo $this->error(__('<strong>Error:</strong> Pods UI needs a Pods object or a Table definition to run from, see the User Guide for more information.', 'pods'));
            return false;
        }
        $this->go();
    }