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); // 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 if (count($inherit)) { $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name; $xk = isset($inherit['xk']) ? $inherit['xk'] : -1; $value = isset($inherit['post']) ? $inherit['post'][$name . '_hidden'] : @$config['post'][$name . '_hidden']; } else { $name = $field->name; $xk = -1; $value = @$config['post'][$name . '_hidden']; } if (is_array($value)) { $value = trim($value[$xk]); } $options2 = JCckDev::fromJSON($field->options2); $options2['storage_format'] = isset($options2['storage_format']) ? $options2['storage_format'] : '0'; $value = $options2['storage_format'] == '0' ? $value : strtotime($value); // Validate parent::g_onCCK_FieldPrepareStore_Validation($field, $name, $value, $config); // 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 if (count($inherit)) { $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name; } else { $name = $field->name; } $doTranslation = $config['doTranslation']; if ($config['doTranslation']) { $config['doTranslation'] = $field->bool8; } // Prepare $divider = $field->divider != '' ? $field->divider : ','; if ($divider) { $nb = count($value); if (is_array($value) && $nb > 0) { $value = implode($divider, $value); } } // Validate $text = parent::g_getOptionText($value, $field->options, $divider, $config); $config['doTranslation'] = $doTranslation; parent::g_onCCK_FieldPrepareStore_Validation($field, $name, $value, $config); // Set or Return if ($return === true) { return $value; } $field->text = $text; $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 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)) { $xk = isset($inherit['xk']) ? $inherit['xk'] : -1; $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name; $itemLink = isset($inherit['post']) ? $inherit['post'][$name] : @$config['post'][$name][$xk]; $itemText = isset($inherit['post']) ? @$inherit['post'][$name . '_text'] : @$config['post'][$name . '_text'][$xk]; $itemClass = isset($inherit['post']) ? @$inherit['post'][$name . '_class'] : @$config['post'][$name . '_class'][$xk]; $itemTarget = isset($inherit['post']) ? @$inherit['post'][$name . '_target'] : @$config['post'][$name . '_target'][$xk]; } else { $name = $field->name; $itemLink = @$config['post'][$name]; $itemText = @$config['post'][$name . '_text']; $itemClass = @$config['post'][$name . '_class']; $itemTarget = @$config['post'][$name . '_target']; } // Validate $value = $itemLink; $value = str_replace(array('<', '>', '"'), '', $value); parent::g_onCCK_FieldPrepareStore_Validation($field, $name, $value, $config); $value = array_filter(array('link' => $itemLink, 'text' => $itemText, 'class' => $itemClass, 'target' => $itemTarget)); if (count($value) > 0 && ($value['link'] || $value['text'])) { $value = JCckDev::toJSON($value); } else { $value = NULL; } // 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 if (count($inherit)) { $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name; } else { $name = $field->name; } $divider = ''; $value2 = ''; // Prepare if ($field->bool3) { // Set Multiple $divider = $field->divider != '' ? $field->divider : ','; if ($divider) { $nb = count($value); if (is_array($value) && $nb > 0) { $value = implode($divider, $value); } } } /* tmp */ $jtext = $config['doTranslation']; $config['doTranslation'] = 0; /* tmp */ $options2 = JCckDev::fromJSON($field->options2); self::_languageDetection($lang_code, $value2, $options2); $options_2 = self::_getOptionsList($options2, $field->bool2, $lang_code); $field->options = $field->options ? $field->options . '||' . $options_2 : $options_2; // Validate $text = parent::g_getOptionText($value, $field->options, $divider, $config); parent::g_onCCK_FieldPrepareStore_Validation($field, $name, $value, $config); /* tmp */ $config['doTranslation'] = $jtext; /* tmp */ // Set or Return if ($return === true) { return $value; } $field->text = $text; $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_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; } $doTranslation = $config['doTranslation']; if ($config['doTranslation']) { $config['doTranslation'] = $field->bool8; } // Validate $text = parent::g_getOptionText($value, $field->options, '', $config); $config['doTranslation'] = $doTranslation; parent::g_onCCK_FieldPrepareStore_Validation($field, $name, $value, $config); // Set or Return // $field->text = $text; // $field->value = $value; if ($return === true) { return $value; } $field->text = $text; //todo: move up $field->value = $value; //todo: move up 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; } // Prepare $options2 = JCckDev::fromJSON($field->options2); if (isset($options2['preparestore']) && $options2['preparestore'] != '') { $value = self::_eval($options2['preparestore'], 'value', $field, $value, $name, $id, $config); } // Validate parent::g_onCCK_FieldPrepareStore_Validation($field, $name, $value, $config); // Set or Return if ($return === true) { return $value; } $field->value = $value; parent::g_onCCK_FieldPrepareStore($field, $name, $value, $config); }