protected function _category_details_content() { $editor_args['category_desc'] = array('type' => 'wp_editor', 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), 'class' => 'my_editor_custom', 'wpeditor_args' => array('media_buttons' => FALSE)); $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); $all_terms = get_terms(array('espresso_venue_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); //setup category select for term parents. $category_select_values[] = array('text' => __('No Parent', 'event_espresso'), 'id' => 0); foreach ($all_terms as $term) { $category_select_values[] = array('text' => $term->name, 'id' => $term->term_id); } $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); $template_args = array('category' => $this->_category, 'category_select' => $category_select, 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), 'category_desc_editor' => $_wp_editor['category_desc']['field'], 'disable' => '', 'disabled_message' => FALSE); $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; return EEH_Template::display_template($template, $template_args, TRUE); }
protected function _term_object_details_content($taxonomy = 'espresso_people_categories') { $editor_args['category_desc'] = array('type' => 'wp_editor', 'value' => EEH_Formatter::admin_format_content($this->_term_object->category_desc), 'class' => 'my_editor_custom', 'wpeditor_args' => array('media_buttons' => FALSE)); $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); $all_terms = get_terms(array($taxonomy), array('hide_empty' => 0, 'exclude' => array($this->_term_object->id))); //setup category select for term parents. $category_select_values[] = array('text' => __('No Parent', 'event_espresso'), 'id' => 0); foreach ($all_terms as $term) { $category_select_values[] = array('text' => $term->name, 'id' => $term->term_id); } $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_term_object->parent); $template_args = array('category' => $this->_term_object, 'category_select' => $category_select, 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), 'category_desc_editor' => $_wp_editor['category_desc']['field'], 'disable' => '', 'disabled_message' => FALSE, 'term_name_label' => $taxonomy == 'espresso_people_categories' ? __('Category Name', 'event_espresso') : __('Type Name', 'event_espresso'), 'term_id_description' => $taxonomy == 'espresso_people_categories' ? __('This is a default category so you can edit the label and the description but not the slug', 'event_espresso') : __('This is a default type so you can edit the label and the description but not the slug', 'event_espresso'), 'term_parent_label' => $taxonomy == 'espresso_people_categories' ? __('Category Parent', 'event_espresso') : __('Type Parent', 'event_espresso'), 'term_parent_description' => $taxonomy == 'espresso_people_categories' ? __('Categories are hierarchical. You can change the parent for this category here.', 'event_espresso') : __('People Types are hierarchical. You can change the parent for this type here.', 'event_espresso'), 'term_description_label' => $taxonomy == 'espresso_people_categories' ? __('Category Description', 'event_espresso') : __('Type Description')); $template = EEA_PEOPLE_ADDON_ADMIN_TEMPLATE_PATH . 'people_term_details.template.php'; return EEH_Template::display_template($template, $template_args, TRUE); }
/** * espresso admin page select_input * Turns an array into a select fields * * @static * @access public * @param string $name field name * @param array $values option values, numbered array starting at 0, where each value is an array with a key 'text' (meaning text to display' and 'id' (meaning the internal value) * eg: array(1=>array('text'=>'Monday','id'=>1),2=>array('text'=>'Tuesday','id'=>2)...). or as an array of key-value pairs, where the key is to be used for the * select input's name, and the value will be the text shown to the user. Optionally you can also include an additional key of "class" which will add a specific class to the option for that value. * @param string $default default value * @param string $parameters extra paramaters * @param string $class css class * @param boolean $autosize whether to autosize the select or not * @return string html string for the select input */ public static function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { //if $values was submitted in the wrong format, convert it over if (!empty($values) && (!array_key_exists(0, $values) || !is_array($values[0]))) { $converted_values = array(); foreach ($values as $id => $text) { $converted_values[] = array('id' => $id, 'text' => $text); } $values = $converted_values; } //load formatter helper EE_Registry::instance()->load_helper('Formatter'); //EE_Registry::instance()->load_helper( 'Formatter' ); $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; //Debug //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); if (EEH_Formatter::ee_tep_not_null($parameters)) { $field .= ' ' . $parameters; } if ($autosize) { $size = 'med'; for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { if ($values[$ii]['text']) { if (strlen($values[$ii]['text']) > 5) { $size = 'wide'; } } } } else { $size = ''; } $field .= ' class="' . $class . ' ' . $size . '">'; if (empty($default) && isset($GLOBALS[$name])) { $default = stripslashes($GLOBALS[$name]); } for ($i = 0, $n = sizeof($values); $i < $n; $i++) { $field .= '<option value="' . $values[$i]['id'] . '"'; if ($default == $values[$i]['id']) { $field .= ' selected = "selected"'; } if (isset($values[$i]['class'])) { $field .= ' class="' . $values[$i]['class'] . '"'; } $field .= '>' . $values[$i]['text'] . '</option>'; } $field .= '</select>'; return $field; }