public function onCCK_FieldPrepareContent(&$field, $value = '', &$config = array()) { if (self::$type != $field->type) { return; } parent::g_onCCK_FieldPrepareContent($field, $config); // Process if ($field->state) { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $postpone = false; if (count($doc->_links)) { foreach ($doc->_links as $k => $link) { if ($link['relation'] == 'canonical') { unset($doc->_links[$k]); } } } if ($field->options2 != '') { $fieldname = ''; $fieldname2 = ''; $options2 = new JRegistry($field->options2); $location = $config['location'] ? $config['location'] : 'joomla_article'; if ($options2->get('content') == '2') { $postpone = true; $fieldname = $options2->get('content_fieldname'); } if ($options2->get('itemid') == '-2') { $fieldname2 = $options2->get('itemid_fieldname'); $itemId = $config['Itemid']; $postpone = true; } else { $itemId = $options2->get('itemid', $config['Itemid']); } if ($postpone !== false) { parent::g_addProcess('beforeRenderContent', self::$type, $config, array('name' => $field->name, 'fieldname' => $fieldname, 'itemId' => $itemId, 'fieldname2' => $fieldname2, 'location' => $location, 'sef' => $options2->get('sef', JCck::getConfig_Param('sef')))); } elseif ($config['pk']) { $uri = JUri::getInstance(); $domain = $uri->toString(array('scheme', 'host', 'port')); $link = JCck::callFunc_Array('plgCCK_Storage_Location' . $location, 'getRoute', array($config['pk'], $options2->get('sef', JCck::getConfig_Param('sef')), $options2->get('itemid', $config['Itemid']), $config)); $doc->addHeadLink($domain . $link, 'canonical'); $app->cck_canonical_url = $link; } } $app->cck_canonical = true; } $field->display = 0; $field->value = ''; }
public function onCCK_FieldPrepareStore(&$field, $value = '', &$config = array(), $inherit = array(), $return = false) { if (self::$type != $field->type) { return; } // Init if (count($inherit)) { $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name; } else { $name = $field->name; } // Validate parent::g_onCCK_FieldPrepareStore_Validation($field, $name, $value, $config); if ($field->state != 'disabled') { parent::g_addProcess('afterStore', self::$type, $config, array('name' => $field->storage_field2 ? $field->storage_field2 : $field->storage_field, 'value' => $value)); } // Set or Return if ($return === true) { return $value; } if ($value > 0) { $field->text = JCckDatabase::loadResult('SELECT title FROM ' . self::$table . ' WHERE id =' . (int) $value); } $field->value = $value; parent::g_onCCK_FieldPrepareStore($field, $name, $value, $config); }
public function onCCK_FieldPrepareStore(&$field, $value = '', &$config = array(), $inherit = array(), $return = false) { if (self::$type != $field->type) { return; } // Init if (count($inherit)) { $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name; } else { $name = $field->name; } $options2 = JCckDev::fromJSON($field->options2); $siteName = JFactory::getConfig()->get('sitename'); $valid = 0; $send = isset($options2['send']) && $field->state != 'disabled' ? $options2['send'] : 0; $send_field = isset($options2['send_field']) && strlen($options2['send_field']) > 0 ? $options2['send_field'] : 0; $isNew = $config['pk'] ? 0 : 1; $sender = 0; switch ($send) { case 0: $sender = 0; break; case 1: if (!$config['pk']) { $sender = 1; } break; case 2: if ($config['pk']) { $sender = 1; } break; case 3: $sender = 1; break; } $subject = isset($options2['subject']) && $options2['subject'] ? $options2['subject'] : $siteName . '::' . JText::_('COM_CCK_EMAIL_GENERIC_SUBJECT'); $message = isset($options2['message']) && $options2['message'] ? htmlspecialchars_decode($options2['message']) : JText::sprintf('COM_CCK_EMAIL_GENERIC_MESSAGE', $siteName); $message = strlen($options2['message']) > 0 ? htmlspecialchars_decode($options2['message']) : JText::sprintf('COM_CCK_EMAIL_GENERIC_MESSAGE', $siteName); $new_message = strlen($options2['message_field']) > 0 ? $options2['message_field'] : ''; $dest = array(); $from = isset($options2['from']) ? $options2['from'] : 0; $from_param = isset($options2['from_param']) ? $options2['from_param'] : ''; $from_name = isset($options2['from_name']) ? $options2['from_name'] : 0; $from_name_param = isset($options2['from_name_param']) ? $options2['from_name_param'] : ''; $cc = isset($options2['cc']) ? $options2['cc'] : 0; $cc_param = isset($options2['cc_param']) ? $options2['cc_param'] : ''; $bcc = isset($options2['bcc']) ? $options2['bcc'] : 0; $bcc_param = isset($options2['bcc_param']) ? $options2['bcc_param'] : ''; $moredest = isset($options2['to_field']) ? $options2['to_field'] : ''; $send_attach = isset($options2['send_attachment_field']) && strlen($options2['send_attachment_field']) > 0 ? $options2['send_attachment_field'] : 1; $moreattach = isset($options2['attachment_field']) && strlen($options2['attachment_field']) > 0 ? $options2['attachment_field'] : ''; // Prepare if ($options2['to'] != '') { $to = self::_split($options2['to']); $dest = array_merge($dest, $to); $valid = 1; } if ($moredest) { $valid = 1; } if ($options2['to_admin'] != '') { $to_admin = count($options2['to_admin']) ? implode(',', $options2['to_admin']) : $options2['to_admin']; if (strpos($to_admin, ',') !== false) { $recips = explode(',', $to_admin); foreach ($recips as $recip) { $recip_mail = JCckDatabase::loadResult('SELECT email FROM #__users WHERE block=0 AND id=' . $recip); if ($recip_mail) { $dest[] = $recip_mail; $valid = 1; } } } else { $recip_mail = JCckDatabase::loadResult('SELECT email FROM #__users WHERE block=0 AND id=' . $to_admin); if ($recip_mail) { $dest[] = $recip_mail; $valid = 1; } } } if ($value) { // if () TODO check multiple $m_value = self::_split($value); $m_value_size = count($m_value); if ($m_value_size > 1) { for ($i = 0; $i < $m_value_size; $i++) { $dest[] = $m_value[$i]; } } else { $dest[] = $value; } $valid = 1; } // Validate parent::g_onCCK_FieldPrepareStore_Validation($field, $name, $value, $config); // Add Process if (($sender || $send_field) && $valid) { parent::g_addProcess('afterStore', self::$type, $config, array('isNew' => $isNew, 'sender' => $sender, 'send_field' => $send_field, 'name' => $name, 'valid' => $valid, 'subject' => $subject, 'message' => $message, 'new_message' => $new_message, 'dest' => $dest, 'from' => $from, 'from_param' => $from_param, 'from_name' => $from_name, 'from_name_param' => $from_name_param, 'cc' => $cc, 'cc_param' => $cc_param, 'bcc' => $bcc, 'bcc_param' => $bcc_param, 'moredest' => $moredest, 'send_attach' => $send_attach, 'moreattach' => $moreattach, 'format' => @(string) $options2['format'])); } // Set or Return if ($return === true) { return $value; } $field->value = $value; parent::g_onCCK_FieldPrepareStore($field, $name, $value, $config); }
public function onCCK_FieldPrepareStore(&$field, $value = '', &$config = array(), $inherit = array(), $return = false) { if (self::$type != $field->type) { return; } // Init $app = JFactory::getApplication(); $options2 = JCckDev::fromJSON($field->options2); if (count($inherit)) { $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name; $xk = isset($inherit['xk']) ? $inherit['xk'] : -1; $xi = isset($inherit['xi']) ? $inherit['xi'] : -1; $parent = isset($inherit['parent']) ? $inherit['parent'] : ''; $array_x = isset($inherit['array_x']) ? $inherit['array_x'] : 0; $itemPath = isset($inherit['post']) ? $inherit['post'][$name . '_hidden'] : @$config['post'][$name . '_hidden']; $deleteBox = isset($inherit['post']) ? @$inherit['post'][$name . '_delete'] : @$config['post'][$name . '_delete']; $imageTitle = isset($inherit['post']) ? @$inherit['post'][$name . '_title'] : @$config['post'][$name . '_title']; $imageDesc = isset($inherit['post']) ? @$inherit['post'][$name . '_description'] : @$config['post'][$name . '_description']; $imageCustomDir = isset($inherit['post']) ? @$inherit['post'][$name . '_path'] : @$config['post'][$name . '_path']; } else { $name = $field->name; $xk = -1; $xi = -1; $parent = ''; $array_x = 0; $itemPath = @$config['post'][$name . '_hidden']; $deleteBox = @$config['post'][$name . '_delete']; $imageTitle = @$config['post'][$name . '_title']; $imageDesc = @$config['post'][$name . '_description']; $imageCustomDir = @$config['post'][$name . '_path']; } // Prepare $legal_ext = isset($options2['media_extensions']) ? $options2['media_extensions'] : 'custom'; if ($legal_ext == 'custom') { $legal_ext = $options2['legal_extensions']; } else { $legal_ext = JCck::getConfig_Param('media_' . $legal_ext . '_extensions'); if (!$legal_ext) { $legal_ext = $options2['legal_extensions']; } } $legal_ext = explode(',', $legal_ext); $userfile = $array_x ? JRequest::getVar($parent, NULL, 'files', 'array') : JRequest::getVar($name, NULL, 'files', 'array'); if (is_array($userfile['name'])) { if ($array_x) { $userfile_name = $userfile['name'][$xk][$name]; $userfile_type = $userfile['type'][$xk][$name]; $userfile_tmp_name = $userfile['tmp_name'][$xk][$name]; $userfile_error = $userfile['error'][$xk][$name]; $userfile_size = $userfile['size'][$xk][$name]; $userfile = null; $userfile = array(); $userfile['name'] = $userfile_name; $userfile['type'] = $userfile_type; $userfile['tmp_name'] = $userfile_tmp_name; $userfile['error'] = $userfile_error; $userfile['size'] = $userfile_size; } else { $userfile_name = $userfile['name'][$xk]; $userfile_type = $userfile['type'][$xk]; $userfile_tmp_name = $userfile['tmp_name'][$xk]; $userfile_error = $userfile['error'][$xk]; $userfile_size = $userfile['size'][$xk]; $userfile = null; $userfile = array(); $userfile['name'] = $userfile_name; $userfile['type'] = $userfile_type; $userfile['tmp_name'] = $userfile_tmp_name; $userfile['error'] = $userfile_error; $userfile['size'] = $userfile_size; if (is_array($itemPath)) { $itemPath = trim($itemPath[$xk]); } if (is_array($imageTitle)) { $imageTitle = trim($imageTitle[$xk]); } if (is_array($imageDesc)) { $imageDesc = trim($imageDesc[$xk]); } if (is_array($imageCustomDir)) { $imageCustomDir = trim($imageCustomDir[$xk]); } if (is_array($deleteBox)) { $deleteBox = $deleteBox[$xk]; } } } if ($deleteBox == 1) { $title = strrpos($itemPath, '/') ? substr($itemPath, strrpos($itemPath, '/') + 1) : $itemPath; if (self::_checkPath($config['pk'], $options2, $itemPath, $legal_ext)) { if ($itemPath != $field->defaultvalue) { if ($options2['path_user']) { $user_folder = substr($itemPath, 0, strrpos($itemPath, '/')); if ($options2['path_content']) { $user_folder = substr($user_folder, 0, strrpos($user_folder, '/')); } $user_folder = substr($user_folder, strrpos($user_folder, '/') + 1) . '/'; } else { $user_folder = ''; } $content_folder = $options2['path_content'] ? $config['pk'] . '/' : ''; for ($i = 1; $i < 11; $i++) { if (JFile::exists(JPATH_SITE . '/' . $options2['path'] . $user_folder . $content_folder . '_thumb' . $i . '/' . $title)) { JFile::delete(JPATH_SITE . '/' . $options2['path'] . $user_folder . $content_folder . '_thumb' . $i . '/' . $title); } } if (JFile::exists(JPATH_SITE . '/' . $options2['path'] . $user_folder . $content_folder . $title)) { JFile::delete(JPATH_SITE . '/' . $options2['path'] . $user_folder . $content_folder . $title); } } $itemPath = ''; } } $file_path = ''; $process = false; switch (@$options2['size_unit']) { case '0': $unit_prod = 1; break; case '1': $unit_prod = 1000; break; case '2': $unit_prod = 1000000; break; default: $unit_prod = 1; break; } $maxsize = floatval($options2['max_size']) * $unit_prod; $filename = JFile::stripExt($userfile['name']); $userfile['name'] = str_replace($filename, JCckDev::toSafeSTRING($filename, JCck::getConfig_Param('media_characters', '-'), JCck::getConfig_Param('media_case', 0)), $userfile['name']); if (!$maxsize || $maxsize && $userfile['size'] < $maxsize) { if ($userfile && $userfile['name'] && $userfile['tmp_name']) { $ImageCustomName = $userfile['name']; $ImageCustomPath = ''; if (@$options2['custom_path']) { if (strrpos($imageCustomDir, '.') === false) { $ImageCustomPath = $imageCustomDir == '' ? substr($itemPath, 0, strrpos($itemPath, '/') + 1) : ($imageCustomDir[strlen($imageCustomDir) - 1] == '/' ? $imageCustomDir : $imageCustomDir . '/'); } else { $ImageCustomPath = substr($itemPath, 0, strrpos($itemPath, '/') + 1); } } if (count($legal_ext)) { $old_legal = strrpos($userfile['name'], '.') ? substr($userfile['name'], strrpos($userfile['name'], '.') + 1) : ''; $legal = $ImageCustomName == $userfile['name'] ? $old_legal : substr($ImageCustomName, strrpos($ImageCustomName, '.') + 1); if ($old_legal && array_search($old_legal, $legal_ext) === false) { JFactory::getApplication()->enqueueMessage($ImageCustomName . ' - ' . JText::_('COM_CCK_ERROR_LEGAL_EXTENSIONS'), 'notice'); $field->error = true; } else { if (trim($legal) != trim($old_legal)) { $ImageCustomName .= '.' . trim($old_legal); } } } $file_path = $ImageCustomPath ? $ImageCustomPath : $options2['path']; $current_user = JFactory::getUser(); $current_user_id = $current_user->id; if (strpos($file_path, '/' . $current_user_id . '/') === false) { $file_path .= $options2['path_user'] && $current_user_id ? $current_user_id . '/' : ''; } if (strpos($file_path, '/' . $config['pk'] . '/') === false) { $file_path .= $options2['path_content'] && $config['pk'] > 0 ? $config['pk'] . '/' : ''; } $value = $file_path . $ImageCustomName; $process = true; } else { if ($deleteBox == 1) { $imageTitle = ''; $imageDesc = ''; } if ($imageCustomDir != '' && strrpos($imageCustomDir, '.') > 0 && JFile::exists(JPATH_SITE . '/' . $imageCustomDir)) { if (count($legal_ext)) { $legal = strrpos($imageCustomDir, '.') ? substr($imageCustomDir, strrpos($imageCustomDir, '.') + 1) : ''; if ($legal && array_search($legal, $legal_ext) === false) { JFactory::getApplication()->enqueueMessage($imageCustomDir . ' - ' . JText::_('COM_CCK_ERROR_LEGAL_EXTENSIONS'), 'notice'); $field->error = true; } } $value = $imageCustomDir; } else { if ($userfile['name']) { JFactory::getApplication()->enqueueMessage(JText::_('COM_CCK_ERROR_INVALID_FILE'), "error"); $field->error = true; } if ($options2['path'] == $itemPath) { $value = ''; } else { if ($xk != -1 && !$array_x) { $value = $itemPath == $options2['path'] ? '' : $itemPath; } else { $value = $itemPath; } } } } } else { JFactory::getApplication()->enqueueMessage($userfile['name'] . ' - ' . JText::_('COM_CCK_ERROR_MAX_SIZE'), 'notice'); $field->error = true; } // Validate parent::g_onCCK_FieldPrepareStore_Validation($field, $name, $value, $config); if (isset($field->error) && $field->error === true) { return; } $imageTitle = $imageTitle ? addcslashes($imageTitle, '"') : ''; $imageDesc = $imageDesc ? addcslashes($imageDesc, '"') : ''; // Add Process if ($process === true) { $content_folder = $options2['path_content'] ? $options2['path_content'] : 0; $process_params = array('field_name' => $name, 'true_name' => $field->name, 'array_x' => $array_x, 'parent_name' => $parent, 'field_type' => $field->type, 'file_path' => $file_path, 'file_name' => $ImageCustomName, 'tmp_name' => $userfile['tmp_name'], 'xi' => $xi, 'content_folder' => $content_folder, 'options2' => $options2, 'storage' => $field->storage, 'storage_field' => $field->storage_field, 'storage_field2' => $field->storage_field2 ? $field->storage_field2 : $field->name, 'storage_table' => $field->storage_table, 'file_title' => $imageTitle, 'file_descr' => $imageDesc); parent::g_addProcess('afterStore', self::$type, $config, $process_params); } $value = !$options2['multivalue_mode'] || $imageTitle == '' && $imageDesc == '' ? $value : '{"image_location":"' . $value . '","image_title":"' . $imageTitle . '","image_description":"' . $imageDesc . '"}'; if ($return === true) { return $value; } $field->value = $value; parent::g_onCCK_FieldPrepareStore($field, $name, $value, $config); }
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 . '/'); $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; } }
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_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="Joomla.submitform(\'' . $task . '\', document.getElementById(\'seblod_form\'));"'; } else { if ($task == 'export') { parent::g_addProcess('beforeRenderForm', self::$type, $config, array('name' => $field->name, 'task' => $task, 'task_id' => $task_id)); } $click = isset($config['submit']) ? ' onclick="' . $pre_task . $config['submit'] . '(\'' . $task . '\');return false;"' : ''; } // $click = isset( $config['formId'] ) ? ' onclick="if (document.'.$config['formId'].'.boxchecked.value==0){alert(\''.addslashes( JText::_( 'JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST' ) ).'\');}else{ Joomla.submitbutton(\''.$task.'\')};return false;"' : ''; $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="Joomla.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'] : ''; $html = '<button class="btn btn-small' . ($field->css ? ' ' . $field->css : '') . '" onclick="' . $pre_task . 'JCck.Core.submit(\'' . $task . '\')" href="#"><i class="' . $icon . '"></i> ' . $value . '</button>'; JToolBar::getInstance('toolbar')->appendButton('Custom', $html, @$options2['icon']); // JToolBar::getInstance( 'toolbar' )->appendButton( 'Standard', $options2['icon'], $value, $task, true ); todo: check } else { parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<' . $tag, ' ', '', $config); } } $field->value = ''; // Return if ($return === true) { return $field; } }