function Extensions_Create() { global $mysqli; $smarty = smarty_init(dirname(__FILE__) . '/templates'); // Init default template (FK_Template) $query = "SELECT PK_Template FROM Templates WHERE Protected = 1 LIMIT 1"; $result = $mysqli->query($query) or die($mysqli->error . $query); $row = $result->fetch_array(); $FK_Template = $row[0]; // If user chosed Type and FK_Template if ($_REQUEST['submit'] == 'create') { $Type = $_REQUEST['Type']; $FK_Template = $_REQUEST['FK_Template']; $Feature = $_REQUEST['Feature']; if ($Type != 'Feature') { $location = form_location($Type, $FK_Template); } else { $location = form_location($Feature, ''); } if ($location != "") { return "\n\t\t\t\t<script>\n\t\t\t\t\tdocument.location='{$location}'\n\t\t\t\t</script>\n\t\t\t"; } else { $Errors['Type'] = true; } } // Available extension tempaltes (Templates) $query = "\n\t\tSELECT\n\t\t\tPK_Template,\n\t\t\tName\n\t\tFROM\n\t\t\tTemplates\n\t\tORDER BY\n\t\t\tName\n\t"; $result = $mysqli->query($query) or die($mysqli->error . $query); $Templates = array(); while ($row = $result->fetch_assoc()) { $Templates[] = $row; } $smarty->assign('Templates', $Templates); $smarty->assign('FK_Template', $FK_Template); $smarty->assign('Feature', $Feature); $smarty->assign('Type', $Type); $smarty->assign('Errors', $Errors); return $smarty->fetch('Extensions_Create.tpl'); }
/** * Display fields for each fieldDB record entry * @param array $data The array of the user field. * @param $callback_data * @param string $method input or display. In case of any other value * the method return FALSE. See the description of return for more details. * @param array $options * <ul> * <li><strong>deactivate</strong> (boolean): FALSE by default. * disable fields</li> * <li><strong>debug</strong> (bolean): FALSE by default. * Show some information to debug.</li> * <li><strong>encrypt</strong> (boolean): FALSE by default. * encrypt field names</li> * <li><strong>error_text</strong> (string): empty string by default. * sets the field error text</li> * <li><strong>hide_value</strong> (boolean): FALSE by default. * input value is not shown on fields render</li> * <li><strong>inline</strong> (boolean): FALSE by default. * sets the field inline</li> * <li><strong>required</strong> (boolean): FALSE by default. * input must be filled when validate</li> * <li><strong>show_title</strong> (boolean): FALSE by default. * display field label</li> * <li><strong>placeholder</strong> (string): empty string by default. * helper text in field value</li> * <li><strong>plugin_folder</strong> (string): INCLUDES.'user_fields/' by default * The folder's path where the field's source files are.</li> * <li><strong>plugin_locale_folder</strong> (string): LOCALE.LOCALESET.'/user_fields/' by default. * The folder's path where the field's locale files are.</li> * </ul> * @return array|bool|string * <ul> * <li>FALSE on failure</li> * <li>string if $method 'display'</li> * <li>array if $method is 'input'</li> * </ul> */ public function display_fields(array $data, $callback_data, $method = 'input', array $options = array()) { // Add compatibality to V7's UF module. // Security concerns: remove all password hashes and salt unset($callback_data['user_algo']); unset($callback_data['user_salt']); unset($callback_data['user_password']); unset($callback_data['user_admin_algo']); unset($callback_data['user_admin_salt']); unset($callback_data['user_admin_password']); $data += array('field_required' => TRUE, 'field_error' => '', 'field_default' => ''); $default_options = array('hide_value' => FALSE, 'encrypt' => FALSE, 'show_title' => $method == "input" ? TRUE : FALSE, 'deactivate' => FALSE, 'inline' => FALSE, 'error_text' => $data['field_error'], 'required' => (bool) $data['field_required'], 'placeholder' => $data['field_default'], 'plugin_folder' => INCLUDES . 'user_fields/', 'plugin_locale_folder' => LOCALE . LOCALESET . '/user_fields/', 'debug' => FALSE); $options += $default_options; if (!$options['plugin_folder']) { $options['plugin_folder'] = $default_options['plugin_folder']; } if (!$options['plugin_locale_folder']) { $options['plugin_locale_folder'] = $default_options['plugin_locale_folder']; } if (substr($options['plugin_folder'], -1) !== '/') { $options['plugin_folder'] .= '/'; } if (substr($options['plugin_locale_folder'], -1) !== '/') { $options['plugin_locale_folder'] .= '/'; } // Sets callback data automatically. $option_list = $data['field_options'] ? explode(',', $data['field_options']) : array(); // Format Callback Data $field_value = isset($callback_data[$data['field_name']]) ? $callback_data[$data['field_name']] : ''; if (isset($_POST[$data['field_name']]) && !$options['hide_value']) { $field_value = $_POST[$data['field_name']]; } elseif ($options['hide_value']) { $field_value = ''; } switch ($data['field_type']) { case 'file': // Do not remove it. It is used in included files. $user_data = $callback_data; $profile_method = $method; // can access options vars if (file_exists($options['plugin_locale_folder'] . $data['field_name'] . ".php")) { include $options['plugin_locale_folder'] . $data['field_name'] . ".php"; } if (file_exists($options['plugin_folder'] . $data['field_name'] . "_include.php")) { include $options['plugin_folder'] . $data['field_name'] . "_include.php"; } if (isset($options['debug']) && $options['debug']) { print_p("Finding " . $options['plugin_locale_folder'] . $data['field_name'] . ".php"); if (file_exists($options['plugin_locale_folder'] . $data['field_name'] . ".php")) { print_p($data['field_name'] . " locale loaded"); } print_p("Finding " . $options['plugin_folder'] . $data['field_name'] . "_include.php"); if (file_exists($options['plugin_folder'] . $data['field_name'] . "_include.php")) { print_p($data['field_name'] . " module loaded"); } } if (isset($user_fields)) { return $user_fields; } break; case 'textbox': if ($method == 'input') { return form_text($data['field_name'], $options['show_title'] ? self::parse_label($data['field_title']) : '', $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; case 'number': if ($method == 'input') { $options += array('type' => 'number'); return form_text($data['field_name'], $options['show_title'] ? self::parse_label($data['field_title']) : '', $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; case 'url': if ($method == 'input') { $options += array('type' => 'url'); return form_text($data['field_name'], $options['show_title'] ? self::parse_label($data['field_title']) : '', $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; case 'email': if ($method == 'input') { $options += array('type' => 'email'); return form_text($data['field_name'], $options['show_title'] ? self::parse_label($data['field_title']) : '', $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; case 'select': if ($method == 'input') { $options['options'] = $option_list; return form_select($data['field_name'], self::parse_label($data['field_title']), $field_value, $options); } elseif ($method == 'display' && $field_value) { $options_value = explode(",", $data['field_options']); return array('title' => self::parse_label($data['field_title']), 'value' => !empty($options_value[$field_value]) ? $options_value[$field_value] : $field_value); } break; case 'tags': if ($method == 'input') { $options += array('options' => $option_list, 'tags' => 1, 'multiple' => 1, 'width' => '100%'); return form_select($data['field_name'], $options['show_title'] ? self::parse_label($data['field_title']) : '', $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; case 'location': if ($method == 'input') { $options += array('width' => '100%'); return form_location($data['field_name'], self::parse_label($data['field_title']), $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; case 'textarea': if ($method == 'input') { return form_textarea($data['field_name'], $options['show_title'] ? self::parse_label($data['field_title']) : '', $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; case 'checkbox': if ($method == 'input') { return form_checkbox($data['field_name'], $options['show_title'] ? self::parse_label($data['field_title']) : '', $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; case 'datepicker': if ($method == 'input') { return form_datepicker($data['field_name'], $options['show_title'] ? self::parse_label($data['field_title']) : '', $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => showdate('shortdate', $field_value)); } break; case 'colorpicker': if ($method == 'input') { return form_colorpicker($data['field_name'], $options['show_title'] ? self::parse_label($data['field_title']) : '', $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; case 'uploader': if ($method == 'input') { return form_fileinput($data['field_name'], self::parse_label($data['field_title']), $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; case 'hidden': if ($method == 'input') { return form_hidden($data['field_name'], self::parse_label($data['field_title']), $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; case 'address': if ($method == 'input') { return form_geo($data['field_name'], $options['show_title'] ? self::parse_label($data['field_title']) : '', $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => implode('|', $field_value)); } break; case 'toggle': $options['toggle'] = 1; $options['toggle_text'] = array($this->locale['off'], $this->locale['on']); if ($method == 'input') { return form_checkbox($data['field_name'], $options['show_title'] ? self::parse_label($data['field_title']) : '', $field_value, $options); } elseif ($method == 'display' && $field_value) { return array('title' => self::parse_label($data['field_title']), 'value' => $field_value); } break; } return FALSE; }