public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false) { if (self::$type != $field->type) { return; } self::$path = parent::g_getPath(self::$type . '/'); parent::g_onCCK_FieldPrepareForm($field, $config); // Init if (count($inherit)) { $id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name; } else { $id = $field->name; } $value = $value != '' ? (int) $value : (int) $field->defaultvalue; $value = $value ? $value - 1 : 0; $group_id = $field->location != '' ? $field->location : 'cck_tabs1'; // Prepare $form = ''; if ($field->state) { parent::g_addProcess('beforeRenderForm', self::$type, $config, array('name' => $field->name, 'group_id' => $group_id, 'id' => $id, 'identifier' => $field->bool3, 'label' => $field->label, 'url_actions' => $field->bool2, 'value' => $value)); } // Set $field->form = $form; // todo: '<div class="tabbable tabs-left">' $field->value = $field->label; $field->label = ''; // Return if ($return === true) { return $field; } }
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false) { if (self::$type != $field->type) { return; } self::$path = parent::g_getPath(self::$type . '/'); parent::g_onCCK_FieldPrepareForm($field, $config); // Init if (count($inherit)) { $id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name; } else { $id = $field->name; } // Prepare $form = ''; if ($field->state) { $group_id = $field->location != '' ? $field->location : 'cck_tabs1'; if ($field->bool == 2) { $form = JCckDevTabs::end(); } elseif ($field->bool == 1) { $form = JCckDevTabs::open($group_id, $id, $field->label); } else { $form = JCckDevTabs::start($group_id, $id, $field->label, array('active' => $id)); } } // Set $field->form = $form; $field->value = $field->label; $field->label = ''; // Return if ($return === true) { return $field; } }
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false) { if (self::$type != $field->type) { return; } self::$path = parent::g_getPath(self::$type . '/'); parent::g_onCCK_FieldPrepareForm($field, $config); // Init if (count($inherit)) { $id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name; } else { $id = $field->name; } $value = $value != '' ? (int) $value : (int) $field->defaultvalue; $value = $value ? $value - 1 : 0; $group_id = $field->location != '' ? $field->location : 'cck_tabs1'; static $groups = array(); if (!isset($groups[$group_id])) { $groups[$group_id] = array('active' => $value, 'current' => 0); } // Prepare $form = ''; if ($field->state) { if ($field->bool == 2) { $form = JCckDevTabs::end(); } elseif ($field->bool == 1) { $form = JCckDevTabs::open($group_id, $id, $field->label); $form = str_replace('class="tab-pane', 'class="tab-pane cck-tab-pane', $form); if ($groups[$group_id]['current'] == $groups[$group_id]['active']) { $js = '(function($){ $(document).ready(function() { $("#' . $group_id . 'Tabs > li,#' . $group_id . 'Content > div").removeClass("active"); $("#' . $group_id . 'Tabs > li:eq(' . (int) $groups[$group_id]['active'] . '),#' . $id . '").addClass("active"); }); })(jQuery);'; JFactory::getDocument()->addScriptDeclaration($js); } } else { $form = JCckDevTabs::start($group_id, $id, $field->label, array('active' => $id)); $form = str_replace('class="nav nav-tabs"', 'class="nav nav-tabs cck-tabs"', $form); $form = str_replace('class="tab-pane', 'class="tab-pane cck-tab-pane', $form); } $groups[$group_id]['current']++; } // Set $field->form = $form; // todo: '<div class="tabbable tabs-left">' $field->value = $field->label; $field->label = ''; // Return if ($return === true) { return $field; } }