PodsUI::view PHP Method

view() public method

Since: 2.3.10
public view ( ) : boolean | mixed
return boolean | mixed
    public function view()
    {
        if (false !== $this->callback_action('view')) {
            return null;
        }
        if (empty($this->row)) {
            $this->get_row();
        }
        if (empty($this->row)) {
            return $this->error(sprintf(__('<strong>Error:</strong> %s not found.', 'pods'), $this->item));
        }
        $pod =& $this->pod;
        $obj =& $this;
        $fields = array();
        if (isset($this->fields[$this->action])) {
            $fields = $this->fields[$this->action];
        }
        if (is_object($this->pod)) {
            $object_fields = (array) pods_var_raw('object_fields', $this->pod->pod_data, array(), null, true);
            $object_field_objects = array('post_type', 'taxonomy', 'media', 'user', 'comment');
            if (empty($object_fields) && in_array($this->pod->pod_data['type'], $object_field_objects)) {
                $object_fields = $this->pod->api->get_wp_object_fields($this->pod->pod_data['type'], $this->pod->pod_data);
            }
            if (empty($fields)) {
                // Add core object fields if $fields is empty
                $fields = array_merge($object_fields, $this->pod->fields);
            }
        }
        $view_fields = $fields;
        // Temporary
        $fields = array();
        foreach ($view_fields as $k => $field) {
            $name = $k;
            $defaults = array('name' => $name, 'type' => 'text', 'options' => 'text');
            if (!is_array($field)) {
                $name = $field;
                $field = array('name' => $name);
            }
            $field = array_merge($defaults, $field);
            $field['name'] = trim($field['name']);
            $value = pods_var_raw('default', $field);
            if (empty($field['name'])) {
                $field['name'] = trim($name);
            }
            if (isset($object_fields[$field['name']])) {
                $field = array_merge($field, $object_fields[$field['name']]);
            } elseif (isset($this->pod->fields[$field['name']])) {
                $field = array_merge($this->pod->fields[$field['name']], $field);
            }
            if (pods_v('hidden', $field, false, null, true) || 'hidden' == $field['type']) {
                continue;
            } elseif (!PodsForm::permission($field['type'], $field['name'], $field['options'], $fields, $pod, $pod->id())) {
                continue;
            }
            $fields[$field['name']] = $field;
            if (empty($this->id) && null !== $value) {
                $this->pod->row_override[$field['name']] = $value;
            }
        }
        unset($view_fields);
        // Cleanup
        ?>
		<div class="wrap pods-ui">
			<div id="icon-edit-pages" class="icon32"<?php 
        if (false !== $this->icon) {
            ?>
 style="background-position:0 0;background-size:100%;background-image:url(<?php 
            echo esc_url($this->icon);
            ?>
);"<?php 
        }
        ?>
><br /></div>
			<h2>
				<?php 
        echo $this->do_template($this->header['view']);
        if (!in_array('add', $this->actions_disabled) && !in_array('add', $this->actions_hidden)) {
            $link = pods_query_arg(array('action' . $this->num => 'add', 'id' . $this->num => '', 'do' . ($this->num = '')), self::$allowed, $this->exclusion());
            if (!empty($this->action_links['add'])) {
                $link = $this->action_links['add'];
            }
            ?>
					<a href="<?php 
            echo esc_url($link);
            ?>
" class="add-new-h2"><?php 
            echo $this->heading['add'];
            ?>
</a>
				<?php 
        } elseif (!in_array('manage', $this->actions_disabled) && !in_array('manage', $this->actions_hidden)) {
            $link = pods_query_arg(array('action' . $this->num => 'manage', 'id' . $this->num => ''), self::$allowed, $this->exclusion());
            if (!empty($this->action_links['manage'])) {
                $link = $this->action_links['manage'];
            }
            ?>
					<a href="<?php 
            echo esc_url($link);
            ?>
" class="add-new-h2">&laquo; <?php 
            echo sprintf(__('Back to %s', 'pods'), $this->heading['manage']);
            ?>
</a>
				<?php 
        }
        pods_view(PODS_DIR . 'ui/admin/view.php', compact(array_keys(get_defined_vars())));
        ?>

			</h2>
		</div>
	<?php 
    }