本文整理汇总了PHP中PodsForm::ui_options方法的典型用法代码示例。如果您正苦于以下问题:PHP PodsForm::ui_options方法的具体用法?PHP PodsForm::ui_options怎么用?PHP PodsForm::ui_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PodsForm
的用法示例。
在下文中一共展示了PodsForm::ui_options方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: export
/**
* Export a Package
*
* $params['pods'] string|array|bool Pod IDs to export, or set to true to export all
* $params['templates'] string|array|bool Template IDs to export, or set to true to export all
* $params['pages'] string|array|bool Page IDs to export, or set to true to export all
* $params['helpers'] string|array|bool Helper IDs to export, or set to true to export all
*
* @param array $params Array of things to export
*
* @return array|bool
*
* @static
* @since 2.0.5
*/
public static function export($params)
{
$export = array('meta' => array('version' => PODS_VERSION, 'build' => time()));
if (is_object($params)) {
$params = get_object_vars($params);
}
$api = pods_api();
$pod_ids = pods_var_raw('pods', $params);
$template_ids = pods_var_raw('templates', $params);
$page_ids = pods_var_raw('pages', $params);
$helper_ids = pods_var_raw('helpers', $params);
if (!empty($pod_ids)) {
$api_params = array('export' => true);
if (true !== $pod_ids) {
$api_params['ids'] = (array) $pod_ids;
}
$export['pods'] = $api->load_pods($api_params);
$options_ignore = array('pod_id', 'old_name', 'object_type', 'object_name', 'object_hierarchical', 'table', 'meta_table', 'pod_table', 'field_id', 'field_index', 'field_slug', 'field_type', 'field_parent', 'field_parent_select', 'meta_field_id', 'meta_field_index', 'meta_field_value', 'pod_field_id', 'pod_field_index', 'object_fields', 'join', 'where', 'where_default', 'orderby', 'pod', 'recurse', 'table_info', 'attributes', 'group', 'grouped', 'developer_mode', 'dependency', 'depends-on', 'excludes-on');
$field_types = PodsForm::field_types();
$field_type_options = array();
foreach ($field_types as $type => $field_type_data) {
$field_type_options[$type] = PodsForm::ui_options($type);
}
foreach ($export['pods'] as &$pod) {
if (isset($pod['options'])) {
$pod = array_merge($pod, $pod['options']);
unset($pod['options']);
}
foreach ($pod as $option => $option_value) {
if (in_array($option, $options_ignore) || null === $option_value) {
unset($pod[$option]);
}
}
if (!empty($pod['fields'])) {
foreach ($pod['fields'] as &$field) {
if (isset($field['options'])) {
$field = array_merge($field, $field['options']);
unset($field['options']);
}
foreach ($field as $option => $option_value) {
if (in_array($option, $options_ignore) || null === $option_value) {
unset($field[$option]);
}
}
foreach ($field_type_options as $type => $options) {
if ($type == pods_var('type', $field)) {
continue;
}
foreach ($options as $option_data) {
if (isset($option_data['group']) && is_array($option_data['group']) && !empty($option_data['group'])) {
if (isset($field[$option_data['name']])) {
unset($field[$option_data['name']]);
}
foreach ($option_data['group'] as $group_option_data) {
if (isset($field[$group_option_data['name']])) {
unset($field[$group_option_data['name']]);
}
}
} elseif (isset($field[$option_data['name']])) {
unset($field[$option_data['name']]);
}
}
}
}
}
}
}
if (!empty($template_ids)) {
$api_params = array();
if (true !== $template_ids) {
$api_params['ids'] = (array) $template_ids;
}
$export['templates'] = $api->load_templates($api_params);
}
if (!empty($page_ids)) {
$api_params = array();
if (true !== $page_ids) {
$api_params['ids'] = (array) $page_ids;
}
$export['pages'] = $api->load_pages($api_params);
}
if (!empty($helper_ids)) {
$api_params = array();
if (true !== $helper_ids) {
$api_params['ids'] = (array) $helper_ids;
//.........这里部分代码省略.........
示例2: admin_setup_edit_field_options
/**
* Get list of Pod field options
*
* @return array
*/
public function admin_setup_edit_field_options($pod)
{
$options = array();
$options['additional-field'] = array();
$field_types = PodsForm::field_types();
foreach ($field_types as $type => $field_type_data) {
/**
* @var $field_type PodsField
*/
$field_type = PodsForm::field_loader($type, $field_type_data['file']);
$field_type_vars = get_class_vars(get_class($field_type));
if (!isset($field_type_vars['pod_types'])) {
$field_type_vars['pod_types'] = true;
}
$options['additional-field'][$type] = array();
// Only show supported field types
if (true !== $field_type_vars['pod_types']) {
if (empty($field_type_vars['pod_types'])) {
continue;
} elseif (is_array($field_type_vars['pod_types']) && !in_array(pods_var('type', $pod), $field_type_vars['pod_types'])) {
continue;
} elseif (!is_array($field_type_vars['pod_types']) && pods_var('type', $pod) != $field_type_vars['pod_types']) {
continue;
}
}
$options['additional-field'][$type] = PodsForm::ui_options($type);
}
$input_helpers = array('' => '-- Select --');
if (class_exists('Pods_Helpers')) {
$helpers = pods_api()->load_helpers(array('options' => array('helper_type' => 'input')));
foreach ($helpers as $helper) {
$input_helpers[$helper['name']] = $helper['name'];
}
}
$options['advanced'] = array(__('Visual', 'pods') => array('class' => array('name' => 'class', 'label' => __('Additional CSS Classes', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => ''), 'input_helper' => array('name' => 'input_helper', 'label' => __('Input Helper', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => '', 'data' => $input_helpers)), __('Values', 'pods') => array('default_value' => array('name' => 'default_value', 'label' => __('Default Value', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => ''), 'default_value_parameter' => array('name' => 'default_value_parameter', 'label' => __('Set Default Value via Parameter', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '')), __('Visibility', 'pods') => array('restrict_access' => array('name' => 'restrict_access', 'label' => __('Restrict Access', 'pods'), 'group' => array('admin_only' => array('name' => 'admin_only', 'label' => __('Restrict access to Admins?', 'pods'), 'default' => 0, 'type' => 'boolean', 'dependency' => true, 'help' => __('This field will only be able to be edited by users with the ability to manage_options or delete_users, or super admins of a WordPress Multisite network', 'pods')), 'restrict_role' => array('name' => 'restrict_role', 'label' => __('Restrict access by Role?', 'pods'), 'default' => 0, 'type' => 'boolean', 'dependency' => true), 'restrict_capability' => array('name' => 'restrict_capability', 'label' => __('Restrict access by Capability?', 'pods'), 'default' => 0, 'type' => 'boolean', 'dependency' => true), 'hidden' => array('name' => 'hidden', 'label' => __('Hide field from UI', 'pods'), 'default' => 0, 'type' => 'boolean', 'help' => __('This option is overriden by access restrictions. If the user does not have access to edit this field, it will be hidden. If no access restrictions are set, this field will always be hidden.', 'pods')), 'read_only' => array('name' => 'read_only', 'label' => __('Make field "Read Only" in UI', 'pods'), 'default' => 0, 'type' => 'boolean', 'help' => __('This option is overriden by access restrictions. If the user does not have access to edit this field, it will be read only. If no access restrictions are set, this field will always be read only.', 'pods'), 'depends-on' => array('type' => array('boolean', 'color', 'currency', 'date', 'datetime', 'email', 'number', 'paragraph', 'password', 'phone', 'slug', 'text', 'time', 'website'))))), 'roles_allowed' => array('name' => 'roles_allowed', 'label' => __('Role(s) Allowed', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'pick_object' => 'role', 'pick_format_type' => 'multi', 'default' => 'administrator', 'depends-on' => array('restrict_role' => true)), 'capability_allowed' => array('name' => 'capability_allowed', 'label' => __('Capability Allowed', 'pods'), 'help' => __('Comma-separated list of cababilities, for example add_podname_item, please see the Roles and Capabilities component for the complete list and a way to add your own.', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('restrict_capability' => true))));
if (!class_exists('Pods_Helpers')) {
unset($options['advanced-options']['input_helper']);
}
$options = apply_filters('pods_admin_setup_edit_field_options', $options, $pod);
return $options;
}
示例3: export_pod
/**
* @param string $pod_name
*
* @return string
*/
public function export_pod($pod_name)
{
$output = '';
// Attempt to load the pod, don't throw an exception on error
$params = array('name' => $pod_name, 'fields' => true);
$pod = $this->api->load_pod($params, false);
// Exit if the pod wasn't found or is table based (not supported)
if (false === $pod || !isset($pod['storage']) || 'table' == $pod['storage']) {
return '';
}
// Pull out the field list
$fields = $pod['fields'];
$options_ignore = array('id', 'pod_id', 'old_name', 'object_type', 'object_name', 'object_hierarchical', 'table', 'meta_table', 'pod_table', 'field_id', 'field_index', 'field_slug', 'field_type', 'field_parent', 'field_parent_select', 'meta_field_id', 'meta_field_index', 'meta_field_value', 'pod_field_id', 'pod_field_index', 'fields', 'object_fields', 'join', 'where', 'where_default', 'orderby', 'pod', 'recurse', 'table_info', 'attributes', 'group', 'grouped', 'developer_mode', 'dependency', 'depends-on', 'excludes-on');
$empties = array('description', 'alias', 'help', 'class', 'pick_object', 'pick_val', 'sister_id', 'required', 'unique', 'admin_only', 'restrict_role', 'restrict_capability', 'hidden', 'read_only', 'object', 'label_singular');
$field_types = PodsForm::field_types();
$field_type_options = array();
foreach ($field_types as $type => $field_type_data) {
$field_type_options[$type] = PodsForm::ui_options($type);
}
if (isset($pod['options'])) {
$pod = array_merge($pod, $pod['options']);
unset($pod['options']);
}
foreach ($pod as $option => $option_value) {
if (in_array($option, $options_ignore) || null === $option_value) {
unset($pod[$option]);
} elseif (in_array($option, $empties) && (empty($option_value) || '0' == $option_value)) {
if ('restrict_role' == $option && isset($pod['roles_allowed'])) {
unset($pod['roles_allowed']);
} elseif ('restrict_capability' == $option && isset($pod['capabilities_allowed'])) {
unset($pod['capabilities_allowed']);
}
unset($pod[$option]);
}
}
if (!empty($fields)) {
foreach ($fields as &$field) {
if (isset($field['options'])) {
$field = array_merge($field, $field['options']);
unset($field['options']);
}
foreach ($field as $option => $option_value) {
if (in_array($option, $options_ignore) || null === $option_value) {
unset($field[$option]);
} elseif (in_array($option, $empties) && (empty($option_value) || '0' == $option_value)) {
if ('restrict_role' == $option && isset($field['roles_allowed'])) {
unset($field['roles_allowed']);
} elseif ('restrict_capability' == $option && isset($field['capabilities_allowed'])) {
unset($field['capabilities_allowed']);
}
unset($field[$option]);
}
}
foreach ($field_type_options as $type => $options) {
if ($type == pods_var('type', $field)) {
continue;
}
foreach ($options as $option_data) {
if (isset($option_data['group']) && is_array($option_data['group']) && !empty($option_data['group'])) {
if (isset($field[$option_data['name']])) {
unset($field[$option_data['name']]);
}
foreach ($option_data['group'] as $group_option_data) {
if (isset($field[$group_option_data['name']])) {
unset($field[$group_option_data['name']]);
}
}
} elseif (isset($field[$option_data['name']])) {
unset($field[$option_data['name']]);
}
}
}
}
}
// Output the pods_register_type() call
$output .= sprintf("\t\$pod = %s;\n\n", $this->var_export_format($pod, 1));
$output .= "\tpods_register_type( \$pod[ 'type' ], \$pod[ 'name' ], \$pod );\n\n";
// Output a pods_register_field() call for each field
foreach ($fields as $this_field) {
$output .= sprintf("\t\$field = %s;\n\n", preg_replace('/\\d+ => /', '', $this->var_export_format($this_field, 1)));
$output .= "\tpods_register_field( \$pod[ 'name' ], \$field[ 'name' ], \$field );\n\n";
}
return $output;
}