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; $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name; } else { $id = $field->name; $name = $field->name; } $value = $field->defaultvalue; // Prepare $value = JCckDevHelper::replaceLive($value); if ($field->bool8) { $field->bool8 = $config['doTranslation']; } if ($field->bool8) { $value = trim(preg_replace('/[^A-Za-z0-9_ ]/', '', strip_tags($value))); if ($value) { $value = JText::_('COM_CCK_' . str_replace(' ', '_', $value)); } } $form = htmlspecialchars_decode($value); // Set if (!$field->variation) { $field->form = $form; if ($field->script) { parent::g_addScriptDeclaration($field->script); } } else { parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '', '', '', $config); } $field->value = $value; // Return if ($return === true) { return $field; } }
protected function prepareDisplay($preconfig) { $app = JFactory::getApplication(); $config = JFactory::getConfig(); $this->option = $app->input->get('option', ''); $this->state = $this->get('State'); $option = $this->option; $params = $app->getParams(); $view = $this->getName(); $limitstart = $this->state->get('limitstart'); $live = urldecode($params->get('live')); $variation = $params->get('variation'); if ($params->get('show_list', '') != '') { $preconfig['show_list'] = (int) $params->get('show_list'); } $preconfig['search2'] = $params->get('search2'); $preconfig['show_form'] = $params->get('show_form', ''); $preconfig['auto_redirect'] = $params->get('auto_redirect', ''); $preconfig['auto_redirect_vars'] = $params->get('auto_redirect_vars', ''); $preconfig['limit2'] = $params->get('limit2', 0); $preconfig['limitend'] = $params->get('pagination2', ''); $preconfig['ordering'] = $params->get('ordering', ''); $preconfig['ordering2'] = $params->get('ordering2', ''); // Page $menus = $app->getMenu(); $menu = $menus->getActive(); $home = isset($menu->home) && $menu->home ? true : false; if (is_object($menu)) { $menu_params = new JRegistry(); $menu_params->loadString($menu->params); if (!$menu_params->get('page_title')) { $params->set('page_title', $menu->title); } } else { $params->set('page_title', 'List'); } $title = $params->get('page_title'); if (empty($title)) { $title = $config->get('sitename'); } elseif ($config->get('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $config->get('sitename'), $title); } elseif ($config->get('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $config->get('sitename')); } $config = NULL; $this->document->setTitle($title); if ($params->get('menu-meta_description')) { $this->document->setDescription($params->get('menu-meta_description')); } if ($params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $params->get('menu-meta_keywords')); } if ($params->get('robots')) { $this->document->setMetadata('robots', $params->get('robots')); } $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->raw_rendering = $params->get('raw_rendering', 0); // Pagination $pagination = $params->get('show_pagination'); // Prepare jimport('cck.base.list.list'); include JPATH_LIBRARIES_CCK . '/base/list/list_inc.php'; $pagination = $this->getModel()->_getPagination($total_items); // Set if (!is_object(@$options)) { $options = new JRegistry(); } $this->show_form = $preconfig['show_form']; $this->show_list_title = $params->get('show_list_title'); if ($this->show_list_title == '') { $this->show_list_title = $options->get('show_list_title', '1'); $this->tag_list_title = $options->get('tag_list_title', 'h2'); $this->class_list_title = $options->get('class_list_title'); } elseif ($this->show_list_title) { $this->tag_list_title = $params->get('tag_list_title', 'h2'); $this->class_list_title = $params->get('class_list_title'); } if ($params->get('display_list_title', '') == '1') { $this->title = $params->get('title_list_title', ''); } elseif ($params->get('display_list_title', '') == '0') { $this->title = $menu->title; } else { $this->title = @$search->title; } $this->show_list_desc = $params->get('show_list_desc'); if ($this->show_list_desc == '') { $this->show_list_desc = $options->get('show_list_desc', '1'); $this->description = @$search->description; } elseif ($this->show_list_desc) { $this->description = $params->get('list_desc', @$search->description); } else { $this->description = ''; } if (!$total_items && !$options->get('show_list_desc_no_result', '1')) { $this->show_list_desc = 0; $this->description = ''; } if ($this->description != '') { $this->description = str_replace('[title]', $menu->title, $this->description); $this->description = str_replace('[note]', $menu->note, $this->description); $this->description = str_replace('$cck->get', '$cck->get', $this->description); $this->description = JCckDevHelper::replaceLive($this->description); if (strpos($this->description, '$cck->get') !== false) { $matches = ''; $regex = '#\\$cck\\-\\>get([a-zA-Z0-9_]*)\\( ?\'([a-zA-Z0-9_]*)\' ?\\)(;)?#'; preg_match_all($regex, $this->description, $matches); if (count($matches[1])) { foreach ($matches[1] as $k => $v) { $fieldname = $matches[2][$k]; $target = strtolower($v); if (count(@$doc->list)) { $this->description = str_replace($matches[0][$k], current($doc->list)->fields[$fieldname]->{$target}, $this->description); } else { $this->description = str_replace($matches[0][$k], '', $this->description); } } } } } $this->show_items_number = $params->get('show_items_number'); if ($this->show_items_number == '') { $this->show_items_number = $options->get('show_items_number', 0); $this->label_items_number = $options->get('label_items_number', 'Results'); $this->class_items_number = $options->get('class_items_number', 'total'); } elseif ($this->show_items_number) { $this->label_items_number = $params->get('show_items_number_label', 'Results'); $this->class_items_number = $params->get('class_items_number', 'total'); } $this->show_pages_number = $params->get('show_pages_number', $options->get('show_pages_number', 1)); $this->show_pagination = $params->get('show_pagination'); $this->class_pagination = $params->get('class_pagination', 'pagination'); if ($this->show_pagination == '') { $this->show_pagination = $options->get('show_pagination', 0); $this->class_pagination = $options->get('class_pagination', 'pagination'); $this->callback_pagination = $options->get('callback_pagination', ''); } else { $this->callback_pagination = ''; } if ($app->input->get('tmpl') == 'raw') { $params->set('show_page_heading', 0); } $this->config =& $config; $this->data =& $data; $this->form =& $form; $this->home =& $home; $this->items =& $items; $this->limitend = $config['limitend']; $this->pagination =& $pagination; $this->params =& $params; $this->search =& $search; $this->total =& $total_items; }
protected static function _getOptionsList($options2, $free_sql, $lang_code, $static = false) { $options = ''; if ($free_sql == 0) { $opt_table = isset($options2['table']) ? ' FROM ' . $options2['table'] : ''; $opt_name = isset($options2['name']) ? $options2['name'] : ''; $opt_value = isset($options2['value']) ? $options2['value'] : ''; $opt_where = @$options2['where'] != '' ? ' WHERE ' . $options2['where'] : ''; $opt_orderby = @$options2['orderby'] != '' ? ' ORDER BY ' . $options2['orderby'] . ' ' . (@$options2['orderby_direction'] != '' ? $options2['orderby_direction'] : 'ASC') : ''; // Language Detection $opt_value = str_replace('[lang]', $lang_code, $opt_value); $opt_name = str_replace('[lang]', $lang_code, $opt_name); $opt_where = str_replace('[lang]', $lang_code, $opt_where); $opt_orderby = str_replace('[lang]', $lang_code, $opt_orderby); if ($opt_name && $opt_table) { $query = 'SELECT ' . $opt_name . ',' . $opt_value . $opt_table . $opt_where . $opt_orderby; $query = JCckDevHelper::replaceLive($query); $lists = $static ? JCckDatabaseCache::loadObjectList($query) : JCckDatabase::loadObjectList($query); if (count($lists)) { foreach ($lists as $list) { $options .= $list->{$opt_name} . '=' . $list->{$opt_value} . '||'; } } } } else { $opt_query = isset($options2['query']) ? $options2['query'] : ''; // Language Detection $opt_query = str_replace('[lang]', $lang_code, $opt_query); $opt_query = JCckDevHelper::replaceLive($opt_query); $lists = $static ? JCckDatabaseCache::loadObjectList($opt_query) : JCckDatabase::loadObjectList($opt_query); if (count($lists)) { foreach ($lists as $list) { $options .= @$list->text . '=' . @$list->value . '||'; } } } return $options; }
} } } } } $show_more = $params->get('show_more', 1); $show_link_more = $params->get('show_link_more', 0); $show_more_class = $params->get('link_more_class', ''); $show_more_class = $show_more_class ? ' class="' . $show_more_class . '"' : ''; $show_more_text = $params->get('link_more_text', ''); if ($show_more_text == '') { $show_more_text = JText::_('MOD_CCK_LIST_VIEW_ALL'); } elseif (JCck::getConfig_Param('language_jtext', 0)) { $show_more_text = JText::_('COM_CCK_' . str_replace(' ', '_', trim($show_more_text))); } $show_more_link = ''; if (($show_more == 1 || $show_more == 2 && $total || $show_more == 3 && $total_items > $preconfig['limit2']) && $show_link_more) { $show_more_link = 'index.php?Itemid=' . $show_link_more; $show_more_link = JRoute::_($show_more_link); $show_more_vars = $params->get('link_more_variables', ''); if ($show_more_vars) { $show_more_vars = JCckDevHelper::replaceLive($show_more_vars); if ($show_more_vars != '') { $show_more_link .= strpos($show_more_link, '?') !== false ? '&' . $show_more_vars : '?' . $show_more_vars; } } } $raw_rendering = $params->get('raw_rendering', 0); $moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx')); $class_sfx = $params->get('force_moduleclass_sfx', 0) == 1 ? $moduleclass_sfx : ''; require JModuleHelper::getLayoutPath('mod_cck_list', $params->get('layout', 'default'));
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 . '/'); $field->label2 = trim(@$field->label2); parent::g_onCCK_FieldPrepareForm($field, $config); // Init if (count($inherit)) { $id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name; $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name; } else { $id = $field->name; $name = $field->name; } $value = $field->label; $field->label = ''; // Prepare $pre_task = ''; $options2 = JCckDev::fromJSON($field->options2); $task = isset($options2['task']) && $options2['task'] ? $options2['task'] : 'save'; $task_auto = isset($options2['task_auto']) && $options2['task_auto'] == '0' ? 0 : 1; $task_id = isset($options2['task_id']) && $options2['task_id'] ? $options2['task_id'] : 0; if (JFactory::getApplication()->isAdmin()) { $task = $config['client'] == 'admin' ? 'form.' . $task : 'list.' . $task; } if ($task_id) { $pre_task = htmlspecialchars('jQuery("#' . $config['formId'] . '").append(\'<input type="hidden" name="tid" value="' . $task_id . '">\');'); } $class = 'button btn' . ($field->css ? ' ' . $field->css : ''); if ($task == 'cancel') { $click = ' onclick="JCck.Core.submitForm(\'' . $task . '\', document.getElementById(\'seblod_form\'));"'; } else { if ($task == 'export' || $task == 'process' || $task == 'list.export' || $task == 'list.process') { $click = $pre_task . $config['submit'] . '(\'' . $task . '\');return false;'; if ($field->variation != 'toolbar_button') { parent::g_addProcess('beforeRenderForm', self::$type, $config, array('name' => $field->name, 'task' => $task, 'task_auto' => $task_auto, 'task_id' => $task_id)); } if (!$task_auto) { $click = 'if (document.' . $config['formId'] . '.boxchecked.value==0){alert(\'' . JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST') . '\');}else{' . $click . '}'; } $click = isset($config['submit']) ? ' onclick="' . $click . '"' : ''; } elseif ($task == 'save2redirect') { $custom = ''; if (isset($options2['custom']) && $options2['custom']) { $custom = JCckDevHelper::replaceLive($options2['custom']); $custom = $custom ? '&' . $custom : ''; } if ($config['client'] == 'search') { $pre_task = htmlspecialchars('jQuery("#' . $config['formId'] . '").attr(\'action\', \'' . JRoute::_('index.php?Itemid=' . $options2['itemid'] . $custom) . '\');'); } else { $pre_task = htmlspecialchars('jQuery("#' . $config['formId'] . ' input[name=\'config[url]\']").val(\'' . JRoute::_('index.php?Itemid=' . $options2['itemid'] . $custom) . '\');'); } $click = isset($config['submit']) ? ' onclick="' . $pre_task . $config['submit'] . '(\'' . $task . '\');return false;"' : ''; } else { $click = isset($config['submit']) ? ' onclick="' . $pre_task . $config['submit'] . '(\'' . $task . '\');return false;"' : ''; } } if ($field->attributes && strpos($field->attributes, 'onclick="') !== false) { $matches = array(); $search = '#onclick\\=\\"([a-zA-Z0-9_\\(\\)\\\'\\;\\.]*)"#'; preg_match($search, $field->attributes, $matches); if (count($matches) && $matches[0]) { if ($matches[0] == $field->attributes) { $field->attributes = substr(trim($field->attributes), 0, -1); $click = ' ' . $field->attributes . '"'; $field->attributes = ''; } else { $click = ' onclick="' . $matches[1] . '"'; $field->attributes = trim(str_replace($matches[0], '', $field->attributes)); } } } $attr = 'class="' . $class . '"' . $click . ($field->attributes ? ' ' . $field->attributes : ''); if ($field->bool) { $label = $value; if (JCck::on()) { if ($field->bool6 == 3) { $label = '<span class="icon-' . $options2['icon'] . '"></span>'; $attr .= ' title="' . $value . '"'; } elseif ($field->bool6 == 2) { $label = $value . "\n" . '<span class="icon-' . $options2['icon'] . '"></span>'; } elseif ($field->bool6 == 1) { $label = '<span class="icon-' . $options2['icon'] . '"></span>' . "\n" . $value; } } $type = $field->bool7 == 1 ? 'submit' : 'button'; $form = '<button type="' . $type . '" id="' . $id . '" name="' . $name . '" ' . $attr . '>' . $label . '</button>'; $tag = 'button'; } else { $form = '<input type="submit" id="' . $id . '" name="' . $name . '" value="' . $value . '" ' . $attr . ' />'; $tag = 'input'; } if ($field->bool2 == 1) { $alt = $field->bool3 ? ' ' . JText::_('COM_CCK_OR') . ' ' : "\n"; if ($config['client'] == 'search') { $onclick = 'onclick="jQuery(\'#' . $config['formId'] . '\').clearForm();"'; $form .= $alt . '<a href="javascript: void(0);" ' . $onclick . ' title="' . JText::_('COM_CCK_RESET') . '">' . JText::_('COM_CCK_RESET') . '</a>'; } else { $onclick = 'onclick="JCck.Core.submitForm(\'cancel\', document.getElementById(\'seblod_form\'));"'; $form .= $alt . '<a href="javascript: void(0);" ' . $onclick . ' title="' . JText::_('COM_CCK_CANCEL') . '">' . JText::_('COM_CCK_CANCEL') . '</a>'; } } elseif ($field->bool2 == 2) { $alt = $field->bool3 ? ' ' . JText::_('COM_CCK_OR') . ' ' : "\n"; $field2 = (object) array('link' => $options2['alt_link'], 'link_options' => $options2['alt_link_options'], 'id' => $id, 'name' => $name, 'text' => htmlspecialchars($options2['alt_link_text']), 'value' => ''); JCckPluginLink::g_setLink($field2, $config); JCckPluginLink::g_setHtml($field2, 'text'); $form .= $alt . $field2->html; } // Set if (!$field->variation) { $field->form = $form; if ($field->script) { parent::g_addScriptDeclaration($field->script); } } else { if ($field->variation == 'toolbar_button') { $field->form = ''; $icon = isset($options2['icon']) && $options2['icon'] ? 'icon-' . $options2['icon'] : ''; $onclick = $pre_task . 'JCck.Core.submit(\'' . $task . '\')'; if (!$task_auto) { $onclick = 'if (document.' . $config['formId'] . '.boxchecked.value==0){alert(\'' . JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST') . '\');}else{' . $onclick . '}'; } $html = '<button class="btn btn-small' . ($field->css ? ' ' . $field->css : '') . '" onclick="' . $onclick . '" href="#"><i class="' . $icon . '"></i> ' . $value . '</button>'; parent::g_addProcess('beforeRenderForm', self::$type, $config, array('name' => $field->name, 'button' => array('html' => $html, 'icon' => @$options2['icon']), 'pre_task' => $pre_task, 'task' => $task, 'task_auto' => $task_auto, 'task_id' => $task_id)); } else { parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<' . $tag, ' ', '', $config); } } $field->value = ''; // Return if ($return === true) { return $field; } }