function render_single_member_selector(Dimension $dimension, $genid = null, $selected_member_ids = null, $options = array()) { if (is_null($genid)) $genid = gen_id(); $dimension_options = $dimension->getOptions(true); $dim_info = array( 'dimension_id' => $dimension->getId(), 'dimension_code' => $dimension->getCode(), 'dimension_options' => $dimension_options, 'is_manageable' => $dimension->getIsManageable(), 'is_required' => array_var($options, 'is_required'), 'is_multiple' => array_var($options, 'is_multiple'), ); if($dimension_options && isset($dimension_options->useLangs) && $dimension_options->useLangs ) { $dim_info['dimension_name'] = lang($dimension->getCode()); } $dimensions = array($dim_info); if (is_null($selected_member_ids)) $selected_member_ids = array(); // Set view variables $selected_members = count($selected_member_ids) > 0 ? Members::findAll(array('conditions' => 'id IN ('.implode(',', $selected_member_ids).')')) : array(); $selected_members_json = "[".implode(',', $selected_member_ids)."]"; $component_id = "$genid-member-selectors-panel-$content_object_type_id"; $listeners = array_var($options, 'listeners', array()); $allowed_member_type_ids = array_var($options, 'allowedMemberTypes', null); // Render view include get_template_path("components/multiple_dimension_selector", "dimension"); }
function render_single_member_selector(Dimension $dimension, $genid = null, $selected_member_ids = null, $options = array(), $default_view = true) { if (is_null($genid)) { $genid = gen_id(); } $dim_info = array('dimension_id' => $dimension->getId(), 'dimension_code' => $dimension->getCode(), 'dimension_name' => $dimension->getName(), 'is_manageable' => $dimension->getIsManageable(), 'is_required' => array_var($options, 'is_required'), 'is_multiple' => array_var($options, 'is_multiple')); $dimensions = array($dim_info); if (!is_array($selected_member_ids)) { $selected_member_ids = array(); } foreach ($selected_member_ids as $k => &$v) { if (!is_numeric($v)) { unset($selected_member_ids[$k]); } } if (count($selected_member_ids) > 0) { $sql = "SELECT m.id FROM " . TABLE_PREFIX . "members m WHERE m.id IN (" . implode(',', $selected_member_ids) . ") AND m.dimension_id=" . $dimension->getId(); $clean_sel_member_ids = array_flat(DB::executeAll($sql)); $selected_member_ids = $clean_sel_member_ids; } $content_object_type_id = array_var($options, 'content_object_type_id'); $initial_selected_members = $selected_member_ids; if (is_null($selected_member_ids)) { $selected_member_ids = array(); } // Set view variables $selected_members = count($selected_member_ids) > 0 ? Members::findAll(array('conditions' => 'id IN (' . implode(',', $selected_member_ids) . ')')) : array(); $selected_members_json = "[" . implode(',', $selected_member_ids) . "]"; $component_id = "{$genid}-member-selectors-panel-{$content_object_type_id}"; $listeners = array_var($options, 'listeners', array()); $allowed_member_type_ids = array_var($options, 'allowedMemberTypes', null); $hide_label = array_var($options, 'hide_label', false); if (isset($options['label'])) { $label = $options['label']; } // Render view include get_template_path("components/multiple_dimension_selector", "dimension"); }