public static function field_set_icon_styles($field_sets) { ?> <style type="text/css"> <?php foreach ($field_sets as $field_set) : ?> <?php if ($field_set->icon != "") : ?> span.field-set-<?php echo $field_set->id ?> { background-image: url(<?php echo MPU::field_set_icon_url($field_set->icon) ?>) } <?php endif; ?> <?php endforeach; ?> <?php MPU::mq2x_start(); ?> <?php foreach ($field_sets as $field_set) : ?> <?php if ($field_set->icon != "") : ?> span.field-set-<?php echo $field_set->id ?> { background-image: url(<?php echo MPU::field_set_icon_2x_url($field_set->icon); ?>); background-size: 16px 16px; } <?php endif; ?> <?php endforeach; ?> <?php MPU::mq2x_end(); ?> </style> <?php }
public function form() { $model = MasterPress::$model; $info = MasterPress::$view; $parent = $info->parent; global $wf; $prefix = ""; $default_key = "edit_posts"; $keys = array(); ?> <div class="mpv-field-sets-form"> <?php if (isset(MasterPress::$parent)) : ?> <div class="title-info-panel"> <div class="title-info-panel-lt"> <?php if (get_class($parent) == "MPM_PostType") : ?> <?php $post_type = $parent; $prefix = $post_type->name."_"; $default_key = "edit_".$post_type->capability_type."s"; $keys = array($default_key); ?> <h3 class="post-type"><i class="mp-icon mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>"></i><span class="label"><?php _e("Post Type:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $parent->labels["name"] ?></span></h3> <input id="post_type_name" type="hidden" value="<?php echo $parent->name ?>" /> <?php elseif ($model->template) : ?> <?php $file = MasterPress::$parent; $page_templates = array_flip(get_page_templates()); $template_name = $page_templates[$file]; ?> <input id="templates" name="templates" type="hidden" value="<?php echo $file ?>" /> <h3><i class="template"></i><span class="label"><?php _e("Template:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $template_name ?></span></h3> <?php elseif ($model->role) : ?> <?php $role_name = MasterPress::$parent; $prefix = $role_name."_"; ?> <input id="roles" name="roles" type="hidden" value="<?php echo $role_name ?>" /> <h3><i class="user-role"></i><span class="label"><?php _e("User Role:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $role_name ?></span></h3> <?php elseif ($model->taxonomy) : ?> <?php $taxonomy_id = MasterPress::$parent; $tax = MPM_Taxonomy::find_by_id($taxonomy_id); $prefix = $tax->name."_"; $default_key = $tax->capabilities["edit_terms"]; $keys = array( $tax->capabilities["manage_terms"], $tax->capabilities["edit_terms"], $tax->capabilities["assign_terms"] ); ?> <input id="taxonomies" name="taxonomies" type="hidden" value="<?php echo $tax->name ?>" /> <h3><i class="mp-icon mp-icon-taxonomy mp-icon-taxonomy-<?php echo $tax->name ?>"></i><span class="label"><?php _e("Taxonomy:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $tax->display_label() ?></span></h3> <?php endif; ?> </div> </div> <?php endif; ?> <?php MPV::messages(); ?> <div class="mpv-field-sets-form"> <div class="f"> <label for="name" class="icon"><i class="script-php"></i><?php _e("Name", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <input id="name_original" name="name_original" type="hidden" class="text mono key" maxlength="20" value="<?php echo $model->name ?>" /> <input id="name_last" name="name_last" type="hidden" class="text mono key" maxlength="20" value="<?php echo $model->name ?>" /> <input id="name" name="name" type="text" class="text mono key" maxlength="255" value="<?php echo $model->name ?>" /><em class="required">(required)</em> <p> <?php _e("This is a unique identifier for the field set used in the MasterPress API. Since it can be used as a PHP variable name, it is restricted to being a lowercase string with words separated by underscores.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div id="f-singular_name" class="f"> <label for="singular_name" class="icon" maxlength="255"><i class="script-php"></i><?php _e("<strong>Singular</strong> Name", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <input id="singular_name" name="singular_name" type="text" value="<?php echo $model->singular_name ?>" class="text mono key" /><em class="required">(required)</em> <p> <?php _e("The singular form of <em>Name</em>, following the same naming conventions", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="allow_multiple" class="icon"><i class="add-remove"></i><?php _e("Allow Multiple Items", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="allow_multiple" name="allow_multiple" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->allow_multiple ) ?> class="checkbox" /> <p id="name_warning" class="warning"> <i class="error-circle"></i> <?php _e("For multiple-item field sets, <em>Name</em> should be specified in <strong>plural form</strong>. Please verify that this is correct above.", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> <div class="f clearfix"> <label id="label-icon" for="icon" class="icon"><i class="image-small"></i><?php _e("Title Icon (16 x 16)", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <div id="icon-file-uploader" class="icon-uploader file-uploader { ids: { drop: 'icon_drop_area' }, input: '#icon', inputName: 'icon_ul', base_url: '<?php echo MASTERPRESS_GLOBAL_CONTENT_URL ?>', params: { dir: 'menu-icons/' }, limit: 1, lang: { buttonChoose: '<?php _e("Choose from Computer…", MASTERPRESS_DOMAIN) ?>', buttonReplace: '<?php _e("Replace file…", MASTERPRESS_DOMAIN) ?>' } }"> <div id="icon_drop_area" class="drop-area"><?php _e("Drop file here to upload", MASTERPRESS_DOMAIN) ?></div> <?php $file_name = $model->icon; $file_class = ""; $clear_class = ""; $preview_class = ""; if ($file_name == "") { $file_name = __("( None )", MASTERPRESS_DOMAIN); $file_class = "name-none"; $preview_class = "preview-none"; $style = ""; $clear_class = "hidden"; } else { $style = ' style="background-image: url('.MPU::field_set_icon_url($model->icon).')" '; } ?> <div class="file"> <span class="preview <?php echo $preview_class ?>" <?php echo $style ?>></span><span data-none="<?php echo __("( None )", MASTERPRESS_DOMAIN) ?>" class="name <?php echo $file_class ?>"><?php echo $file_name ?></span> <button type="button" class="<?php echo $clear_class ?> clear ir" title="<?php _e("Clear", MASTERPRESS_DOMAIN) ?>">Clear</button> </div> <input id="icon" name="icon" value="<?php echo $model->icon ?>" type="hidden" /> <div class="uploader-ui"></div> </div> <!-- /.file-uploader --> <?php MPV::icon_select($model->icon, "menu-icon-select", "icon_select", "icon-file-uploader"); ?> </div> </div> <!-- /.f --> <div class="f"> <label for="expanded" class="icon"><i class="expand"></i><?php _e("Expanded", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="expanded" name="expanded" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->expanded ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#expanded' }"> <?php _e("this field set will be expanded (not summarised) by default in the edit post screen, but can still be collapsed. It is recommended that this is <strong>unchecked if <em>Allow Multiple Items</em> is checked.</strong>", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php if (!$model->role) : ?> <div class="f"> <label for="sidebar" class="icon"><i class="sidebar"></i><?php _e("Show in Sidebar", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="sidebar" name="sidebar" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->sidebar ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#sidebar' }"> <?php _e("this field set will be positioned in the sidebar of the edit post screen by default (but may still be dragged across to the main content area by users)", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php endif; ?> <div class="f"> <label for="disabled" class="icon"><i class="slash"></i><?php _e("Disabled", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="disabled" name="disabled" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->disabled ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#disabled' }"> <?php _e("disabling a field set will keep its definition in the database but it will not be available in any post editing screens in WordPress, which may be <strong>preferable to deleting it</strong> completely.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="versions_store" class="icon"><i class="metabox-versions size-20"></i><?php _e("Version Limit", MASTERPRESS_DOMAIN) ?></label> <div class="fw"> <input id="versions" name="versions" type="text" value="<?php echo $model->versions ?>" class="text" /> <p class="note"> <?php _e("Set a <b>maximum number of versions</b> of content based on this field set to retain.<br />Versions can be used to restore previous revisions of content at a later time.<br />Set this value to 0 if you do not wish to retain previous versions.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="fs fs-labels"> <div class="fst"> <div class="fstb"> <h3><i class="label-string"></i><strong><?php _e("Labels", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("displayed in the <em>Edit Post</em> and MasterPress admin screens", MASTERPRESS_DOMAIN) ?></h3> <div class="buttons"> <button id="autofill-labels" class="button button-autofill" type="button"><?php _e('<strong>Auto-Fill</strong> Labels', MASTERPRESS_DOMAIN) ?></button> </div> </div> </div> <div class="fsc fscs"> <div class="fscb"> <div class="scroll"> <div class="f"> <label for="label_name"><?php _e("Set Label", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_name" name="labels[name]" value="<?php echo $model->labels["name"] ?>" type="text" class="text { tmpl: '{{plural_name}}' }" /> <em class="recommended">(recommended)</em> </div> </div> <!-- /.f --> <div class="f"> <label for="label_description"><?php _e("Description", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <textarea id="label_description" name="labels[description]"><?php echo $model->label("description") ?></textarea> <p> <?php _e("Displayed on the Create / Edit Post screen in the info area above the fields in this set.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php if ($model->shared) : ?> <div class="f"> <label for="label_description_user"><?php _e("Description (User)", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <textarea id="label_description_user" name="labels[description_user]"><?php echo $model->label("description_user") ?></textarea> <p> <?php _e("Displayed on the Create / Edit User and Profile screen in the info area above the fields in this set.<br />If not specified, the standard <em>Description</em> label will be used (if available)", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="label_description_term"><?php _e("Description (Term)", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <textarea id="label_description_term" name="labels[description_term]"><?php echo $model->label("description_term") ?></textarea> <p> <?php _e("Displayed on the Edit (Taxonomy) Term in the info area above the fields in this set.<br />If not specified, the standard <em>Description</em> label will be used (if available)", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php endif; ?> <div class="f f-allow-multiple"> <label for="label_singular_name"><?php _e("<em>Singular</em> Name", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_singular_name" name="labels[singular_name]" value="<?php echo $model->label("singular_name") ?>" type="text" class="text { tmpl: '{{singular_name}}' }" /> <em class="recommended">(recommended)</em> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_add"><?php _e("Add", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_add" name="labels[add]" value="<?php echo $model->label("add") ?>" type="text" class="text { tmpl: '<?php _e("Add {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_add_another"><?php _e("Add Another", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_add_another" name="labels[add_another]" value="<?php echo $model->label("add_another") ?>" type="text" class="text { tmpl: '<?php _e("Add Another {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_remove"><?php _e("Remove", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_remove" name="labels[remove]" value="<?php echo $model->label("remove") ?>" type="text" class="text { tmpl: '<?php _e("Remove {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_click_to_add"><?php _e("Click to Add", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_click_to_add" name="labels[click_to_add]" value="<?php echo $model->label("click_to_add") ?>" type="text" class="text { tmpl: '<?php _e("Click to add {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_one_item"><?php _e("1 Item", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_one_item" name="labels[one_item]" value="<?php echo $model->label("one_item") ?>" type="text" class="text { tmpl: '<?php _e("1 {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_n_items"><?php _e("n Items", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_n_items" name="labels[n_items]" value="<?php echo $model->label("n_items") ?>" type="text" class="text { tmpl: '<?php _e("%d {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_no_items"><?php _e("No Items", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_no_items" name="labels[no_items]" value="<?php echo $model->label("no_items") ?>" type="text" class="text { tmpl: '<?php _e("No {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> </div> </div> </div> </div> <!-- /.fs --> <div class="fs fs-capability-keys clearfix"> <div class="fst"> <div class="fstb"> <h3><i class="key"></i><strong><?php _e("Capabilities", MASTERPRESS_DOMAIN) ?></strong> - <?php _e('the keys used to control access to this field set', MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb clearfix"> <div class="f f-capabilities f-capabilities-editable clearfix"> <label for="label-capabilities-editable"><?php _e("Editable", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <?php $val = $model->capability("editable", false); $caps = array_unique(array_merge($keys, array("edit_posts", "edit_pages"))); $caps = array( __("-- None (Always Editable) --", MASTERPRESS_DOMAIN) => "" ) + $caps; if (MPC::is_edit()) { $caps[] = "edit_".$prefix.$model->name; } $custom_val = ""; if (!in_array($val, $caps)) { $custom_val = $val; } echo WOOF_HTML::select( array("id" => "capabilities-editable", "name" => "capabilities[editable]", "class" => "capabilities" ), $caps, $val ); ?> <label for="capabilities-editable-custom" class="capabilities-custom"><?php _e("OR custom value") ?></label> <input id="capabilities-editable-custom" name="capabilities_custom[editable]" value="<?php echo $custom_val ?>" type="text" class="text mono capabilities-custom" /> <p class="note"> <?php _e("All fields in this set will be read-only for users without this capability.<br />Individual fields may override this with their own capabilities.", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> <div class="f f-capabilities f-capabilities-visible clearfix"> <label for="label-capabilities-visible"><?php _e("Visible", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <?php $val = $model->capability("visible", false); $caps = array_unique(array_merge($keys, array("edit_posts", "edit_pages"))); $caps = array( __("-- None (Always Visible) --", MASTERPRESS_DOMAIN) => "" ) + $caps; if (MPC::is_edit()) { $caps[] = "view_".$prefix.$model->name; } $custom_val = ""; if (!in_array($val, $caps)) { $custom_val = $val; } echo WOOF_HTML::select( array("id" => "capabilities-visible", "name" => "capabilities[visible]", "class" => "capabilities" ), $caps, $val ); ?> <label for="capabilities-visible-custom" class="capabilities-custom"><?php _e("OR custom value") ?></label> <input id="capabilities-visible-custom" name="capabilities_custom[visible]" value="<?php echo $custom_val ?>" type="text" class="text mono capabilities-custom" /> <p class="note"> <?php _e("This field set will be invisible for users without this capability", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs --> <?php $args = array(); $args["supports"] = array(); if (is_multisite() && MASTERPRESS_MULTISITE_SHARING) { $args["supports"] = array("multisite"); } if ($model->is_shared()) { $args["supports"][] = "post_types"; } if (!isset($info->is_template_set) && $model->is_shared() ) { $args["supports"][] = "templates"; } if (!isset($info->is_role_set) && $model->is_shared() ) { $args["supports"][] = "roles"; } if (!isset($info->is_taxonomy_set) && $model->is_shared() ) { $args["supports"][] = "taxonomies"; } $args["labels"] = array( "title" => __("control the visibility of this field set within WordPress", MASTERPRESS_DOMAIN), "title_multisite" => __("specify the sites in the multisite network that this field set is available in", MASTERPRESS_DOMAIN), "title_post_types" => __("specify the post types that this field set is available in", MASTERPRESS_DOMAIN), "title_templates" => __("specify the templates that this field set is available in", MASTERPRESS_DOMAIN), "title_roles" => __("specify the roles that users must have for this field set to be available in their profile edit screen", MASTERPRESS_DOMAIN), "multisite_all" => __( "All Sites" ), "post_types_all" => __( "All Post Types" ), "templates_all" => __( "All Templates" ) ); $args["defaults"] = array( "post_types" => "all" ); if ($model->type == "p") { $post_type = $parent; $templates = $post_type->templates(); if (count($templates)) { $args["supports"][] = "templates"; $args["templates"] = array(); $all = array_flip(get_page_templates()); foreach ($templates as $t) { $name = $all[$t->id]; $args["templates"][$name] = $t->id; } } } if (isset($parent) && is_multisite()) { $site_options = array(); foreach ($parent->sites() as $site) { $site_options[$site->full_path()] = $site->id(); } $args["sites"] = $site_options; }; MPV::fs_visibility( $model, $args ); ?> <?php if ($info->is_template_set) : ?> <input id="visibility-templates" name="visibility[templates]" type="hidden" value="<?php echo $file ?>" /> <?php endif; ?> <?php if ($info->is_role_set) : ?> <input id="visibility-roles" name="visibility[roles]" type="hidden" value="<?php echo $role_name ?>" /> <?php endif; ?> <?php if ($info->is_taxonomy_set) : ?> <input id="visibility-taxonomies" name="visibility[taxonomies]" type="hidden" value="<?php echo $tax->name ?>" /> <?php endif; ?> <?php if ($model->is_post_type() && isset($parent)) : ?> <input id="visibility-post-types" name="visibility[post_types]" type="hidden" value="<?php echo $parent->name ?>" /> <?php endif; ?> <div id="f-position" class="f clearfix"> <label for="position" class="icon"><i class="sort"></i><?php _e("Set Position", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <div class="sortable-list sortable-list-fields"> <span class="arrow"></span> <?php // build a field list $field_sets = array(); if ($model->shared) { $field_sets = MPM_SharedFieldSet::find( array( "orderby" => "position ASC" ) ); } else if ($model->template) { $field_sets = MPM_TemplateFieldSet::find_by_template( MasterPress::$parent ); } else if ($model->role) { $field_sets = MPM_RoleFieldSet::find_by_role( MasterPress::$parent ); } else if ($model->taxonomy) { $field_sets = MPM_TaxonomyFieldSet::find_by_taxonomy( $tax ); } else if ($model->site) { $field_sets = MPM_SiteFieldSet::find( array( "orderby" => "position ASC" ) ); } else { $sql = "SELECT * FROM ".MPU::table("field-sets")." WHERE ( type = 'p' ) AND ".MPM::visibility_rlike("post_types", $parent->name)." ORDER BY position"; $field_sets = MPM::get_models("field-set", $sql); } $sort_field_sets = array(); // now build a representable list of field_sets $icon = $model->shared ? MPU::img_url("icon-shared-field-set.png") : MPU::img_url("icon-field-set-small.png"); $icon_class = $model->shared ? "metabox-share" : "metabox"; foreach ($field_sets as $field_set) { $position = $field_set->position; if (isset($_POST["other_position"]) && $_POST["other_position"][$field_set->id]) { $position = $_POST["other_position"][$field_set->id]; } $sort_field_sets[] = array( "position" => $position, "disabled" => $field_set->disabled, "current" => $field_set->id == $model->id, "label" => $field_set->display_label(), "icon_class" => $icon_class, "icon" => $icon, "id" => $field_set->id ); } if (MPC::is_create()) { $label = $model->display_label(); if (!$label || $label == "") { $label = "?"; } $sort_field_sets[] = array( "position" => $model->position, "disabled" => $model->disabled, "current" => true, "label" => $model->display_label(), "icon" => $icon, "icon_class" => $icon_class ); } $count = 0; ?> <ul> <?php foreach ($sort_field_sets as $f) : $count++; $first = $count == 1 ? "first " : ""; $current = $f["current"] ? 'current ' : ''; ?> <?php $disabled = $f["disabled"] ? 'disabled' : ''; $disabled_title = $f["disabled"] ? __("This field set is disabled", MASTERPRESS_DOMAIN) : ''; ?> <li class="<?php echo $first.$current ?> <?php echo $disabled ?>" title="<?php echo $disabled_title ?>"> <i class="<?php echo $icon_class ?>"></i> <?php if ($f["current"]) : ?> <span class="inline fill { src: '#label_name,#label_singular_name'}"><?php echo $f["label"] ?></span> <input id="position" name="position" value="<?php echo $f["position"] ?>" type="hidden" class="text" /> <?php else: ?> <span class="inline"><?php echo $f["label"] ?></span> <input id="other_position" name="other_position[<?php echo $f["id"] ?>]" value="<?php echo $f["position"] ?>" type="hidden" /> <?php endif; ?> </li> <?php endforeach; ?> </ul> </div> <!-- /.sortable-list --> <p> <?php _e("Drag set to the desired <em>default</em> position in the WordPress <em>Create / Edit Post</em> screen.<br />Note: Field sets are displayed in a standard WordPress UI panel (metabox), which can be dragged around by the user to also influence the order.", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> </div> <!-- /.mpv-field-sets-form --> <?php }
public static function get_set($object, $set_items, $args = array("nested" => false)) { global $meow_provider, $wf; $data = array(); $set = $set_items->info; // check for versions $set_args = $args; if (WOOF::is_false_arg($args, "nested")) { $versions = $set_items->versions(); if (count($versions)) { $versions_options = array(); $count = 0; foreach ($versions as $version) { $count++; $prefix = ""; if ($count == 1) { $prefix .= __("Current", MASTERPRESS_DOMAIN); } else { $prefix = WOOF::items_number( $count - 1, __("Current", MASTERPRESS_DOMAIN), __("1 version ago", MASTERPRESS_DOMAIN), __("%d versions ago", MASTERPRESS_DOMAIN) ); } $text = $prefix." — ".$wf->format_date("[date-time-long]", strtotime(get_date_from_gmt($version->date))); if (!is_null($version->user_login)) { $text = $text." — ".$version->user_login; } if ($set->allow_multiple) { $text = $text." ( ".WOOF::items_number($version->field_set_count, __("no items", MASTERPRESS_DOMAIN), __("1 item", MASTERPRESS_DOMAIN), __("%d items", MASTERPRESS_DOMAIN))." )"; } $versions_options[$text] = $version->version_id; } $selected_version = ""; if (count($versions_options) > 1) { $vvals = array_values($versions_options); $selected_version = $vvals[1]; } $data["versions_select_id"] = "versions-".$set->id; if ($set->current_user_can_edit()) { $data["versions_select"] = WOOF_HTML::select( array("id" => $data["versions_select_id"]), $versions_options, $selected_version ); $data["versions_title"] = sprintf( __("Versions of '%s'", MASTERPRESS_DOMAIN), $set->display_label() ); $set_args["versions_select"] = $data["versions_select"]; } } } $set_classes = array(); if ($set->allow_multiple) { $set_classes[] = "multiple"; } else { $set_classes[] = "single"; } $data["allow_remove"] = true; $data["set_allow_add"] = true; $data["copy_paste_title"] = __("Copy / Paste Content", MASTERPRESS_DOMAIN); if (!$set->current_user_can_edit()) { $data["copy_paste_title"] = __("Copy Content", MASTERPRESS_DOMAIN); $data["readonly"] = true; $data["allow_remove"] = false; $data["set_allow_add"] = false; $set_classes[] = "readonly"; } $set_head_classes = array(); $add_item_title = strip_tags($set->label("add_another")); if ($set_items->count() == 0) { $set_head_classes[] = "hidden"; $add_item_title = strip_tags($set->label("click_to_add")); } else { $data["set_foot_controls_style"] = "display: none;"; } $type_key = $meow_provider->type_key($object); $set_description = trim( $set->label("description") ); if ($set_description != "") { $data["set_description"] = trim( $set->label("description") ); } $set_type_description = $set->label("description_".$type_key); if (isset($set_type_description) && trim($set_type_description) != "") { $data["set_description"] = trim($set_type_description); } $data["set_head_classes"] = implode(" ", $set_head_classes); $data["set_classes"] = implode(" ", $set_classes); $data["set_id"] = $set->id; $data["set_name"] = $set->name; if (isset($args["guid"])) { $data["add_item_template"] = "mpft_ui_{$set->name}"."_".$args["guid"]; } $data["set_dirty_name"] = "mp_meta_dirty[{$set->name}]"; $data["set_versions_name"] = "mp_meta_versions[{$set->name}]"; $data["set_versions"] = $set->versions; $data["set_allow_multiple"] = $set->allow_multiple; $data["set_expanded"] = $set->expanded; $data["add_item_title"] = $add_item_title; $data["set_name_sanitized"] = str_replace("_", "-", $wf->sanitize($set->name)); if (!isset($set->icon) && $set->icon != "") { $data["set_icon"] = MPU::field_set_icon_url($set->icon); $data["set_icon_2x"] = MPU::field_set_icon_2x_url($set->icon); } $data["label_add_another"] = esc_js( strip_tags($set->label("add_another")) ); $data["label_one_item"] = esc_js( $set->label("one_item")); $data["label_n_items"] = esc_js($set->label("n_items")); $data["label_no_items"] = esc_js($set->label("no_items")); $data["label_click_to_add"] = esc_js($set->label("click_to_add")); $data["label_remove_confirm"] = strip_tags($set->label("remove")).": ".__("Are you sure?", MASTERPRESS_DOMAIN); $data["set_items_count"] = MPU::__items($set_items->count(), $set->label("one_item"), $set->label("n_items"), $set->label("no_items")); if ($type_key == "post") { $data["save_nag_message"] = sprintf( __('To Save changes you must also <strong>Save Draft</strong> or <strong class="update">Update</strong> this %s', MASTERPRESS_DOMAIN ), $object->post_type()->singular_label() ); } else if ($type_key == "term") { $data["save_nag_message"] = sprintf( __('To Save changes you must also <strong class="update">Update</strong> this %s', MASTERPRESS_DOMAIN ), $object->taxonomy()->singular_label()); } else if ($type_key == "user") { $data["save_nag_message"] = __('To Save changes you must also <strong class="update">Update</strong> this user', MASTERPRESS_DOMAIN); } if (isset($data["save_nag_message"])) { $data["save_nag_tooltip"] = strip_tags($data["save_nag_message"]); } // loop through the fields, and output their model ids, so that the save action picks them up $data["fields"] = array(); $data["field_icons"] = array(); foreach ($set->fields() as $field) : if ($field->current_user_can_see()) { $field_data = array(); $field_data["field_id"] = $field->id; $field_data["field_model_name"] = "mp_meta_model[{$set->name}][{$field->name}]"; if (!is_null($field->icon) && $field->icon != "") { $data["field_icons"][] = array("url_2x" => MPU::field_icon_2x_url($field->icon), "url" => MPU::field_icon_url($field->icon), "field_path" => $set->name."-".$field->name); } $field_data["field_path"] = $set->name."-".$field->name; if (isset($field->labels["tooltip_help"])) { $tooltip_help = stripslashes(trim($field->label("tooltip_help"))); if ($tooltip_help != "") { $field_data["tooltip_help"] = $tooltip_help; } } $data["fields"][] = $field_data; } endforeach; // need to add creator support here! if ($set->creator) { $set_item = new MEOW_FieldSetCreator($set->name, $object, $set); $template_data = self::set_item_template_data($set_item, $set_args); $data["set_items"] = WOOF::render_template( self::set_item_template(), $template_data, false ); } else { if ($set->allow_multiple) { $data["set_items"] = ""; foreach ($set_items as $set_item) { // grab the data for the set template $template_data = self::set_item_template_data($set_item, $set_args); $data["set_items"] .= WOOF::render_template( self::set_item_template(), $template_data, false ); } // update the set_items (if dirty) $set_items->update(); } else { $set_item = new MEOW_FieldSet($set->name, 1, $object, $set, $set_items); // grab the data for the set template $template_data = self::set_item_template_data($set_item, $set_args); $data["set_items"] = WOOF::render_template( self::set_item_template(), $template_data, false ); } } return WOOF::render_template( self::set_template(), $data, false ); }
public function form() { global $wf; $model = MasterPress::$model; $info = MasterPress::$view; $parent = $info->parent; $post_type = null; $post_type = $info->post_type; $prefix = ""; $default_key = ""; $keys = array(); ?> <?php if (is_object($parent)) : ?> <div class="title-info-panel"> <div class="title-info-panel-lt"> <?php if ($parent->type == 's') : ?> <h3><i class="metabox-share"></i><span class="label"><?php _e("Shared Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php elseif ($parent->type == 'w') : ?> <h3><i class="metabox-sitemap-large"></i><span class="label"><?php _e("Site Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php elseif ($parent->type == "p") : ?> <?php $prefix = $post_type->name."_"; $keys = array("edit_".$post_type->capability_type."s"); ?> <h3><i class="mp-icon mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>"></i><span class="label"><?php _e("Post Type", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $post_type->display_label() ?></span></h3> <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php elseif ($parent->type == 't') : ?> <?php $file = $parent->visibility["templates"]; $page_templates = array_flip(get_page_templates()); $template_name = $page_templates[$file]; ?> <input id="templates" name="templates" type="hidden" value="<?php echo $file ?>" /> <h3><i class="template"></i><span class="label"><?php _e("Template:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $template_name ?></span></h3> <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php elseif ($parent->type == 'r') : ?> <?php $role_name = $parent->visibility["roles"]; $prefix = $role_name."_"; ?> <input id="templates" name="templates" type="hidden" value="<?php echo $role_name ?>" /> <h3><i class="user-role"></i><span class="label"><?php _e("User Role:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $role_name ?></span></h3> <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php elseif ($parent->type == 'x') : ?> <?php $taxonomy_name = $parent->visibility["taxonomies"]; $prefix = $taxonomy_name."_"; $tax = MPM_Taxonomy::find_by_name($taxonomy_name); $keys = array( $tax->capabilities["manage_terms"], $tax->capabilities["edit_terms"], $tax->capabilities["assign_terms"] ); ?> <input id="taxonomies" name="taxonomies" type="hidden" value="<?php echo $taxonomy_name ?>" /> <h3><i class="mp-icon mp-icon-taxonomy-<?php echo $taxonomy_name ?>"></i><span class="label"><?php _e("Taxonomy:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $tax->display_label() ?></span></h3> <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php endif; ?> </div> </div> <?php endif; ?> <?php MPV::messages(); ?> <div class="mpv-fields-form"> <div class="f"> <label for="name" class="icon"><i class="script-php"></i><?php _e("Name", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <input id="name_original" name="name_original" type="hidden" class="text mono key" maxlength="20" value="<?php echo $model->name ?>" /> <input id="name_last" name="name_last" type="hidden" class="text mono key" maxlength="20" value="<?php echo $model->name ?>" /> <input id="name" name="name" type="text" class="text mono key" maxlength="255" value="<?php echo $model->name ?>" /><em class="required">(required)</em> <p> <?php _e("This is a unique identifier for the field in the MasterPress API. Since it can be used as a PHP variable name, it is restricted to being a lowercase string with words separated by underscores.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div id="f-type" class="f clearfix"> <label for="type" class="icon"><i class="types"></i><?php _e("Field Type", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <select id="type" name="type" class="with-icons select2-source" data-icon="mp-icon mp-icon-field-type-<?php echo $model->type ?>"> <?php foreach (MPFT::types_by_category() as $category => $types) : ?> <?php if (count($types)) : ?> <optgroup label="<?php echo $category ?>"> <?php foreach ($types as $type) : ?> <?php $type_class = MPFT::type_class($type); ?> <option data-icon="mp-icon mp-icon-field-type-<?php echo $type ?>" <?php echo WOOF_HTML::selected_attr($type == $model->type) ?> data-description="<?php echo addslashes(call_user_func( array($type_class, "__description") ) ) ?>" value="<?php echo $type ?>"><?php echo call_user_func( array($type_class, "__s") ) ?></option> <?php endforeach; ?> </optgroup> <?php endif; ?> <?php endforeach; ?> </select> <p id="field-type-description"></p> </div> </div> <!-- /.f --> <div class="f"> <label for="required" class="icon"><i class="warning-octagon"></i><?php _e("Required", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="required" name="required" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->required ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#required' }"> <?php _e("A field value must be specified by the user, or the content editing form will not submit.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div id="f-disabled" class="f"> <label for="disabled" class="icon"><i class="slash"></i><?php _e("Disabled", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="disabled" name="disabled" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->disabled ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#disabled' }"> <?php _e("disabling a field will hide it from all content editing screens in WordPress, which may be <strong>preferable to deleting it</strong> completely.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php $options_form = ""; $type_options = $model->type_options; if (isset($_POST["type_options"])) { $type_options = $_POST["type_options"]; } if ($type_class = MPFT::type_class($model->type)) { $options_form = call_user_func_array( array($type_class, "options_form"), array(MPM::array_stripslashes($type_options)) ); } ?> <div class="fs fs-field-type-options" <?php echo $options_form == "" ? ' style="display:none;"' : '' ?>> <div class="fst"> <div class="fstb"> <h3><i class="switch"></i><strong><?php _e("Field Type Options", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("defines the user-interface for this field", MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb"> <div id="field-type-loading" class="fs-loading">Please wait…</div> <div id="field-type-options-content"> <?php if ($type_class = MPFT::type_class($model->type)): ?> <div id="mpft-<?php echo $model->type ?>-options" class="mpft-options"> <?php echo $options_form ?> </div> <?php endif; ?> </div> <!-- /#field-type-options-content --> </div> </div> </div> <!-- /.fs --> <div class="fs fs-labels"> <div class="fst"> <div class="fstb"> <h3><i class="label-string"></i><strong><?php _e("Labels", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("displayed throughout the WordPress administration UI", MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb"> <div class="f"> <label for="label_name"><?php _e("Field Label", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_name" name="labels[name]" value="<?php echo stripslashes($model->labels["name"]) ?>" type="text" class="text { tmpl: '{{name}}' }" /> <em class="recommended">(recommended)</em> </div> </div> <!-- /.f --> <div class="f"> <label for="label_description"><?php _e("Description", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <input id="label_description" name="labels[description]" type="text" maxlength="50" value="<?php echo stripslashes($model->label("description")) ?>" class="text" /> <p> <?php _e("Appears adjacent to the label in brackets to provide a little extra information about the field.<br />For more extensive information, use <em>Tooltip Help</em>.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="label_tooltip_help"><?php _e("Tooltip Help", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <textarea id="label_tooltip_help" name="labels[tooltip_help]"><?php echo stripslashes($model->label("tooltip_help")) ?></textarea> <p> <?php _e("Provides more extensive help for this field through a tooltip, revealed by mousing over a question-mark badge adjacent to the field label", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs .fs-labels --> <?php $args = array(); $args["supports"] = array(); // $args["supports"][] = "fields"; COMING SOON $fields = $parent->fields(); $fields_to_use = array(); foreach ($fields as $field) { if ($field->id != $model->id) { $fields_to_use[] = $field; } } $args["fields"] = $fields_to_use; if (is_multisite()) { $args["supports"][] = "multisite"; } if ($parent->is_shared()) { $args["supports"][] = "post_types"; $args["supports"][] = "roles"; $args["supports"][] = "taxonomies"; $args["supports"][] = "templates"; } $args["labels"] = array( "title" => __("control the visibility of this field within WordPress", MASTERPRESS_DOMAIN), "title_multisite" => __("specify the sites in the multisite network that this field is available in", MASTERPRESS_DOMAIN), "title_post_types" => __("specify the post types that this field is available in", MASTERPRESS_DOMAIN), "templates_all" => sprintf( __( "All Templates <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ), "multisite_all" => sprintf( __( "All Sites <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ), "post_types_all" => sprintf( __( "All Post Types <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ), "roles_all" => sprintf( __( "All User Roles <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ), "taxonomies_all" => sprintf( __( "All Taxonomies <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ) ); $args["defaults"] = array( "taxonomies" => "all", "roles" => "all", "post_types" => "all", "multisite" => "all" ); $args["post_types"] = $parent->post_types(); if (isset($parent) && is_multisite()) { $site_options = array(); foreach ($parent->sites() as $site) { $site_options[$site->full_path()] = $site->id(); } $args["sites"] = $site_options; }; // filter the available roles $roles = $parent->vis("roles"); if ($roles != "" && $roles != "*") { $role_names = explode(",", $roles); $rc = array(); foreach ($role_names as $role_name) { $rc[] = $wf->role($role_name); } $args["roles"] = new WOOF_Collection($rc); } MPV::fs_visibility( $model, $args ); ?> <div class="fs fs-capability-keys clearfix"> <div class="fst"> <div class="fstb"> <h3><i class="key"></i><strong><?php _e("Capabilities", MASTERPRESS_DOMAIN) ?></strong> - <?php _e('the keys used to control access to this field', MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb clearfix"> <div class="f f-capabilities f-capabilities-editable clearfix"> <label for="label-capabilities-editable"><?php _e("Editable", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <?php $val = $model->capability("editable", false); $custom_val = ""; $caps = array_unique(array_merge($keys, array("edit_posts", "edit_pages", "edit_".$prefix.$parent->name))); $caps = array( __("-- None (Same as Field Set) --", MASTERPRESS_DOMAIN) => "" ) + $caps; if (MPC::is_edit()) { $caps[] = "edit_".$prefix.$parent->name."_".$model->name; } if (!in_array($val, $caps)) { $custom_val = $val; } echo WOOF_HTML::select( array("id" => "capabilities-editable", "name" => "capabilities[editable]", "class" => "capabilities" ), $caps, $val ); ?> <label for="capabilities-editable-custom" class="capabilities-custom"><?php _e("OR custom value") ?></label> <input id="capabilities-editable-custom" name="capabilities_custom[editable]" value="<?php echo $custom_val ?>" type="text" class="text mono capabilities-custom" /> <p class="note"> <?php _e("This field will be read-only for users without this capability", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> <div class="f f-capabilities f-capabilities-visible clearfix"> <label for="label-capabilities-visible"><?php _e("Visible", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <?php $val = $model->capability("visible", false); $caps = array_unique(array_merge($keys, array("edit_posts", "edit_pages", "view_".$prefix.$parent->name))); $caps = array( __("-- None (Same as Field Set) --", MASTERPRESS_DOMAIN) => "" ) + $caps; if (MPC::is_edit()) { $caps[] = "view_".$prefix.$parent->name."_".$model->name; } $custom_val = ""; if (!in_array($val, $caps)) { $custom_val = $val; } echo WOOF_HTML::select( array("id" => "capabilities-visible", "name" => "capabilities[visible]", "class" => "capabilities" ), $caps, $val ); ?> <label for="capabilities-visible-custom" class="capabilities-custom"><?php _e("OR custom value") ?></label> <input id="capabilities-visible-custom" name="capabilities_custom[visible]" value="<?php echo $custom_val ?>" type="text" class="text mono capabilities-custom" /> <p class="note"> <?php _e("This field will be invisible for users without this capability", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs --> <div class="fs fs-summary-options clearfix"> <div class="fst"> <div class="fstb"> <h3><i class="set-summary"></i><strong><?php _e("Summary Options", MASTERPRESS_DOMAIN) ?></strong> - <?php _e('settings for the collapsed summary display', MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb clearfix"> <div class="f"> <label for="summary_options_emphasise"><?php _e("Emphasise", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="summary_options_emphasise" name="summary_options[emphasise]" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( isset($model->summary_options["emphasise"]) && $model->summary_options["emphasise"] ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#summary_options_emphasise' }"> <?php _e("Show the summary for this field in <strong>bold text</strong>, which may often be appropriate for the first field in a set, or for other important fields in your content.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f f-summary_width"> <label for="summary_options_width"><?php _e("Block Width", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="summary_options_width" name="summary_options[width]" type="text" maxlength="1" value="<?php echo isset($model->summary_options["width"]) ? $model->summary_options["width"] : "" ?>" class="text" /> <p class="note"> <?php _e("Override block width of the summary, when the field's set is collapsed (min value 1, max value 5)<br />Leave this value empty to use the block width recommended by the field type<br />The pixel width of the summary will be the value here x 150.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f clearfix"> <label id="label-icon" for="icon"><?php _e("Icon (16 x 16)", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <div id="icon-file-uploader" class="icon-uploader file-uploader { ids: { drop: 'icon_drop_area' }, input: '#icon', inputName: 'icon_ul', base_url: '<?php echo MASTERPRESS_GLOBAL_CONTENT_URL ?>', params: { dir: 'menu-icons/' }, limit: 1, lang: { buttonChoose: '<?php _e("Choose from Computer…", MASTERPRESS_DOMAIN) ?>', buttonReplace: '<?php _e("Replace file…", MASTERPRESS_DOMAIN) ?>' } }"> <div id="icon_drop_area" class="drop-area"><?php _e("Drop file here to upload", MASTERPRESS_DOMAIN) ?></div> <?php $file_name = $model->icon; $file_class = ""; $preview_class = ""; $clear_class = ""; if ($file_name == "") { $file_name = __("( None )", MASTERPRESS_DOMAIN); $file_class = "name-none"; $preview_class = "preview-none"; $clear_class = "hidden"; $style = ""; } else { $style = ' style="background-image: url('.MPU::field_set_icon_url($model->icon).')" '; } ?> <div class="file"> <span class="preview <?php echo $preview_class ?>" <?php echo $style ?>></span><span data-none="<?php echo __("( None )", MASTERPRESS_DOMAIN) ?>" class="name <?php echo $file_class ?>"><?php echo $file_name ?></span> <button type="button" class="<?php echo $clear_class ?> clear ir" title="<?php _e("Clear", MASTERPRESS_DOMAIN) ?>">Clear</button> </div> <input id="icon" name="icon" value="<?php echo $model->icon ?>" type="hidden" /> <div class="uploader-ui"></div> </div> <!-- /.file-uploader --> <?php MPV::icon_select($model->icon, "menu-icon-select", "icon_select", "icon-file-uploader"); ?> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs --> <?php // build a field list $fields = $parent->fields(); ?> <?php if ( ( MPC::is_edit() && count($fields) > 1) || (MPC::is_create() && count($fields) > 0) ) : ?> <div id="f-position" class="f clearfix"> <p class="label label-icon icon position"><?php _e("Position in set", MASTERPRESS_DOMAIN)?>:</p> <div class="fw"> <div class="sortable-list sortable-list-fields"> <span class="arrow"></span> <?php // build a field list $sort_fields = array(); // now build a representable list of fields foreach ($fields as $field) { $position = $field->position; if (isset($_POST["other_position"]) && isset($_POST["other_position"][$field->id])) { $position = $_POST["other_position"][$field->id]; } if ($ftc = MPFT::type_class($field->type)) { $sort_fields[] = array( "position" => $position, "disabled" => (bool) $field->disabled, "current" => $field->id == $model->id, "label" => $field->display_label(), "type" => $field->type, "id" => $field->id ); } } if (MPC::is_create()) { $label = $model->display_label(); if (!$label || $label == "") { $label = "?"; } $sort_fields[] = array( "position" => $model->position, "disabled" => (bool) $field->disabled, "current" => true, "label" => $model->display_label(), "type" => $model->type ); } $count = 0; ?> <ul> <?php foreach ($sort_fields as $f) : $count++; $first = $count == 1 ? "first " : ""; $current = $f["current"] ? 'current ' : ''; ?> <?php $disabled = $f["disabled"] ? 'disabled' : ''; $disabled_title = $f["disabled"] ? __("This field is disabled", MASTERPRESS_DOMAIN) : ''; ?> <li class="<?php echo $first.$current ?> <?php echo $disabled ?>" title="<?php echo $disabled_title ?>"> <span class="icon mp-icon mp-icon-field-type-<?php echo $f["type"] ?>"></span> <?php if ($f["current"]) : ?> <span class="fill { src: '#label_name'}"><?php echo $f["label"] ?></span> <input id="position" name="position" value="<?php echo $f["position"] ?>" type="hidden" /> <?php else: ?> <span><?php echo $f["label"] ?></span> <input id="other_position_<?php echo $f["id"] ?>" name="other_position[<?php echo $f["id"] ?>]" value="<?php echo $f["position"] ?>" type="hidden" /> <?php endif; ?> </li> <?php endforeach; ?> </ul> </div> <!-- /.sortable-list --> <p> <?php printf(__("Drag field to the desired position in the %s set.<br />Note: changes to the positions of other fields will also be saved.", MASTERPRESS_DOMAIN), '<em>'.$parent->display_label().'</em>') ?> </p> </div> </div> <!-- /.f --> <?php else: ?> <input id="position" name="position" value="1" type="hidden" /> <?php endif; ?> </div> <!-- /.mpv-fields-form --> <?php } // end form()