function dev_draw_form_field($type = '', $name = '', $label = '', $value = '', $required = false, $id = '', $readonly = false, $properties = '') { $output = ''; $label_text = ''; $varname = $name; $properties = dev_value_to_array($properties); if (!isset($properties['class'])) { $properties['class'] = $type ? $type : 'formdata'; } foreach ($properties as $a => $b) { $attribs[] = "{$a}=\"{$b}\""; } $attrib = implode(' ', $attribs); $id = 'id="' . ($id != '' ? $id : $name) . '"'; $disabled = $readonly === false ? '' : 'readonly'; if ($readonly == 3) { $type = 'static'; } if ($label != '' && $type != 'static') { $label_text = '<label for="' . $name . '">' . ($required ? '*' : '') . $label . ': </label>'; } if ($type != 'date' && $type != 'select') { $name .= is_array($value) ? '[]' : ''; } $value = dev_value_to_array($value, true); switch ($type) { default: case 'text': foreach ($value as $a) { $output .= $label_text . ' <br />' . "\n\t" . '<input type="text" ' . $disabled . ' name="' . $name . '" ' . $id . ' value="' . $a . '" ' . $attrib . ' /><br />'; } break; case 'prompt': foreach ($value as $a) { $output .= $label_text . ' <br />' . "\n\t" . '<input type="text" ' . $disabled . ' name="' . $name . '" ' . $id . ' value="' . $a . '" ' . $attrib . ' onFocus="this.value=\'\'" /><br />'; } break; case 'password': foreach ($value as $a) { $output .= $label_text . ' <br />' . "\n\t" . '<input type="password" ' . $disabled . ' name="' . $name . '" ' . $id . ' value="' . $a . '" ' . $attrib . ' /><br />'; } break; case 'textarea': foreach ($value as $a) { $output .= $label_text . ' <br />' . "\n\t" . '<textarea ' . $disabled . ' name="' . $name . '" ' . $id . ' ' . $attrib . '>' . $a . '</textarea><br />'; } break; case 'select': $output .= $label_text . ' <br />' . "\n"; $output .= '<select name="' . $name . '" ' . $disabled . ' ' . $id . ' ' . $attrib . '>' . "\n"; $value = dev_value_to_array($value); global ${$varname}; foreach ($value as $a => $b) { if (is_array($b)) { $output .= "\t" . '<optgroup label="' . $a . '">' . "\n"; foreach ($b as $c => $d) { $output .= "\t\t" . '<option value="' . $d . '"'; //if the select option being drawn is the same as the //variable by the same name of this element, mark it as selected if (${$varname} == $d) { $output .= ' selected="selected"'; } $output .= '>' . $c . '</option>' . "\n"; } $output .= "\t" . '</optgroup>' . "\n"; } else { $output .= "\t" . '<option value="' . $b . '"'; //if the select option being drawn is the same as the //variable by the same name of this element, mark it as selected if (${$varname} == $b) { $output .= ' selected="selected"'; } $output .= '>' . $a . '</option>' . "\n"; } } $output .= '</select><br />'; break; case 'multiple': $output .= $label_text . ' <br />' . "\n"; $output .= '<select name="' . $name . '" ' . $disabled . ' ' . $id . ' ' . $attrib . ' size="6" multiple="multiple">' . "\n"; $value = dev_value_to_array($value); global ${$varname}; foreach ($value as $a => $b) { if (is_array($b)) { $output .= "\t" . '<optgroup label="' . $a . '">' . "\n"; foreach ($b as $c => $d) { $output .= "\t\t" . '<option value="' . $d . '"'; //if the select option being drawn is the same as the //variable by the same name of this element, mark it as selected if (is_array(${$varname})) { if (in_array($d, ${$varname})) { $output .= ' selected="selected"'; } elseif (${$varname} == $d) { $output .= ' selected="selected"'; } } $output .= '>' . $c . '</option>' . "\n"; } $output .= "\t" . '</optgroup>' . "\n"; } else { $output .= "\t" . '<option value="' . $b . '"'; //if the select option being drawn is the same as the //variable by the same name of this element, mark it as selected if (is_array(${$varname})) { if (in_array($b, ${$varname})) { $output .= ' selected="selected"'; } elseif (${$varname} == $b) { $output .= ' selected="selected"'; } } $output .= '>' . $a . '</option>' . "\n"; } } $output .= '</select><br />'; break; case 'hidden': foreach ($value as $a) { $output .= '<input type="hidden" ' . $disabled . ' name="' . $name . '" ' . $id . ' value="' . $a . '" />'; } break; case 'checkbox': if (dev_is_assoc($value)) { $output .= ($required ? '*' : '') . $label . '<br />'; $i = 1; foreach ($value as $a => $b) { $output .= '<input ' . $attrib . ' type="checkbox" ' . $disabled . ' name="' . $name . '" ' . substr_replace($id, $i . '"', -1, strlen($id)); global ${$varname}; if (${$varname} == $b) { $output .= ' checked="checked"'; } $output .= ' value="' . $b . '" />'; $output .= '<label for="' . $varname . $i . '">' . substr($a, 0, strlen($a)) . " </label><br /> \n"; $i++; } } else { foreach ($value as $a) { $output .= '<input type="checkbox" ' . $disabled . ' name="' . $name . '" ' . $id; global ${$varname}; if (${$varname} == $a) { $output .= ' checked="checked"'; } $output .= ' value="' . $a . '" /> '; $output .= '<label for="' . $varname . '">' . substr($label, 0, strlen($label)) . " </label><br /> \n"; } } break; case 'radio': if (dev_is_assoc($value)) { $output .= ($required ? '*' : '') . $label . '<br />'; $i = 1; foreach ($value as $a => $b) { $output .= '<input ' . $attrib . ' type="radio" ' . $disabled . ' name="' . $name . '" ' . substr_replace($id, $i . '"', -1, strlen($id)); global ${$varname}; if (${$varname} == $b) { $output .= ' checked="checked"'; } $output .= ' value="' . $b . '" />'; $output .= '<label for="' . $varname . $i . '">' . substr($a, 0, strlen($a)) . " </label><br /> \n"; $i++; } } else { foreach ($value as $a) { $output .= '<input type="radio" ' . $disabled . ' name="' . $name . '" ' . $id; global ${$varname}; if (${$varname} == $a) { $output .= ' checked="checked"'; } $output .= ' value="' . $a . '" /> '; $output .= '<label for="' . $varname . '">' . substr($label, 0, strlen($label)) . " </label><br /> \n"; } } break; case 'date': $output .= dev_draw_date_select($name, $label, $value[0], $readonly); break; case 'calendar': $output .= $label_text . "\n\t" . '<SCRIPT LANGUAGE="JavaScript" ID="js' . $name . '"> var cal' . $name . ' = new CalendarPopup("datediv1"); cal' . $name . '.setCssPrefix("DATE"); </SCRIPT> <SCRIPT LANGUAGE="JavaScript">writeSource("js' . $name . '");</SCRIPT> <input type="text" ' . $disabled . ' name="' . $name . '" ' . $id . ' value="' . $value[0] . '" ' . $attrib . ' /> <A HREF="#" onclick="cal' . $name . '.select(document.getElementById(\'' . $name . '\'),\'anchor' . $name . '\',\'yyyy-MM-dd\'); return false;" TITLE="cal' . $name . '.select(document.getElementById(\'' . $id . '\'),\'anchor1x\',\'yyyy-MM-dd\'); return false;" NAME="anchor' . $name . '" ID="anchor' . $name . '"><img src="' . $image_path . 'calendar.gif" alt="select" title="select" border="0" /></A><br />'; break; case 'time': $output .= dev_draw_time_select($name, $label); break; case 'file': foreach ($value as $a) { if (!$readonly && $a == '') { $output .= $label_text . ' - ' . $a . ' <br />' . "\n\t" . '<input type="file" ' . $disabled . ' name="' . $name . '" ' . $id . ' /><br />'; } else { $output = dev_draw_form_field('checkbox', $name, $label . ' (' . $a . ')', $a, $required, $name, $readonly, $properties); } } break; case 'richtext': foreach ($value as $a) { //Code provided by Kevin Roth at www.kevinroth.com/rte/demo.htm //Requires following form header: /* <script language="JavaScript" type="text/javascript"> <!-- function submitForm() { //make sure hidden and iframe values are in sync before submitting form //to sync only 1 rte, use updateRTE(rte) //to sync all rtes, use updateRTEs //updateRTE(\'rte1\'); updateRTEs(); //change the following line to true to submit form return true; } //Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML) initRTE("images/", "", "", true); //--> </script> */ //and included JS file and 'onsubmit="return submitForm();"' in form. $output .= ' <noscript>'; $output .= dev_draw_form_field('textarea', $name, $label, $a, '', $id, $readonly); $output .= ' </noscript> <script language="JavaScript" type="text/javascript"> <!-- var ' . $name . '_val = ""; '; //$output .= "\n"; $a = html_entity_decode($a); $val_search = array('"', '</script>', '</textarea>', '</noscript>'); $val_replace = array('\\"', '</script>', '</textarea>', '</noscript>'); $a = str_replace($val_search, $val_replace, $a); $val_array = explode("\n", $a); //foreach ($val_array as $a) $output .= $name . '_val += "' . html_entity_decode(rtrim($a)) . '\n";' . "\n"; foreach ($val_array as $var) { $output .= $name . '_val += "' . rtrim($var) . '\\n";' . "\n"; } $output .= ' //--> </script> '; //$output .= dev_draw_form_field('hidden', $name . '_hidden', '', $a); if ($id == 'id="big"') { $w = '100%'; $h = 400; } else { $w = 450; $h = 200; } $output .= ' <script language="JavaScript" type="text/javascript"> <!-- ' . $name . '_val = ' . $name . '_val.replace(/<\\/script>/gi, "<" + "/script>"); ' . $name . '_val = ' . $name . '_val.replace(/<\\/textarea>/gi, "<" + "/textarea>"); ' . $name . '_val = ' . $name . '_val.replace(/<\\/noscript>/gi, "<" + "/noscript>"); writeRichText(\'' . $name . '\', ' . $name . '_val, \'' . $w . '\', \'' . $h . '\', true, ' . ($readonly ? 'true' : 'false') . '); //--> </script> '; } break; case 'static': foreach ($value as $a) { $output .= $label . '<br /><span ' . implode(' ', $attribs) . ' name="' . $name . '" ' . $id . '>' . $a . '</span>'; $output .= dev_draw_form_field('hidden', $name, '', $a); } break; case 'submit': foreach ($value as $a) { $output .= '<input type="submit" ' . $disabled . ' name="' . $name . '" ' . $id . ' value="' . $a . '" onclick="this.disabled=false;this.value=' . dev_prep_input($label != '' ? $label : 'Submitting...') . ';" ' . $attrib . ' /><br />'; } break; case 'reset': foreach ($value as $a) { $output .= '<input type="reset" ' . $disabled . ' name="' . $name . '" ' . $id . ' value="' . $a . '" ' . $attrib . ' /><br />'; } break; case 'button': foreach ($value as $a) { $output .= '<input type="button" ' . $disabled . ' name="' . $name . '" ' . $id . ' value="' . $a . '" ' . $attrib . ' /><br />'; } break; } if ($label != '' && $type != 'hidden') { $output .= "<br />\n"; } return $output; }
function dev_content_select($content_r, $query_r = '', $trunc = '', $fields = 2) { $field_name = ''; $get_name = true; $content = ''; $query_r = dev_value_to_array($query_r); $output = ''; $select_r = array(); $select_r['-------'] = ''; foreach ($content_r as $row) { $row = dev_value_to_array($row); $value_r = array(); $i = 0; foreach ($row as $a => $b) { if ($get_name) { $field_name = $a; $get_name = dev_flip_bool($get_name); } if ($i > $fields) { break; } if ($i > 0) { $value_r[] = dev_format_data($b, '', $trunc); } $i++; } $select_r[implode(' - ', $value_r)] = $row[$field_name]; } foreach ($query_r as $a => $b) { $output .= dev_draw_form_field('hidden', $a, '', $b); } $output .= dev_draw_form_field('select', $field_name, '', $select_r) . dev_draw_form_field('submit', 'submit', 'Submit', 'Submit'); return $output; }
function formField($name = '', $value = '', $label = '', $type = '', $required = false, $readonly = false, $id = '', $properties = '') { $field_info = $this->getFieldInfo(); if (dev_not_null($name)) { $value = $value == '' ? $this->getField($name) : $value; $label = $label == '' ? $name : $label; $id = $id == '' ? $name : $id; if (isset($field_info[$name])) { $this_field = $field_info[$name]; $required = $required == '' ? !$this_field['Null'] || $this_field['Null'] == 'NO' ? true : false : $required; if ($type == '') { $field_type = strtolower($this_field['Type']); $field_type = $field_type == 'longtext' ? 'richtext' : (dev_is_substr($field_type, 'text') ? 'textarea' : $field_type); $field_type = dev_is_substr($field_type, 'lob') ? 'textarea' : $field_type; $field_type = dev_is_substr($field_type, 'int') ? 'int' : $field_type; $field_type = dev_is_substr($field_type, 'char') ? 'char' : $field_type; $field_type = dev_is_substr($field_type, 'date') ? 'date' : $field_type; if ($this_field['Key'] == 'PRI') { $field_type = 'hidden'; } elseif ($field_type == 'int' && isset($this_field['Length']) && $this_field['Length'] <= 1) { $field_type = 'check'; } elseif (dev_is_assoc($value)) { $field_type = 'select'; } elseif ($field_type == 'set' && dev_is_index($value)) { $field_type = 'radio'; } elseif ($field_type != 'set' && dev_is_index($value)) { $field_type = 'radio'; } switch ($field_type) { case 'int': $value = (int) $value; case 'char': default: $type = 'text'; break; case 'text': case 'textarea': case 'lob': $type = 'textarea'; break; case 'textarea': $type = 'textarea'; break; case 'date': $type = 'date'; break; case 'set': case 'check': if (dev_is_null($value)) { $value = 1; } else { $value = 1; } $type = 'checkbox'; break; case 'radio': $type = 'radio'; break; case 'select': $type = 'select'; break; case 'hidden': $type = 'hidden'; break; } } } } return "<tr><td>" . ($type != 'hidden' ? ($required ? '*' : '') . $label : '') . "</td><td>" . dev_draw_form_field($type, $name, '', $value, $required, $id, $readonly, $properties) . "</td></tr>"; }
function dev_write_edit_form($table = '', $entry_id = 'entry_id', $entry_title = 'entry_title', $date = '', $label = '', $hidden_input = '') { $output = ''; if ($label != '') { $output .= $label . ': <br />'; } $output .= ' <form name="edit" action="" method="POST"> <input type="hidden" name="action" value="edit"> '; if (is_array($hidden_input)) { foreach ($hidden_input as $a => $b) { $output .= dev_draw_form_field('hidden', $a, '', $b); } } $output .= '<select name="entry_id">'; /* $pattern = '/^(\d{4})\-(\d+)\-(\d+)[\w\W\d\D\s]+$/'; $replacement = '$2/$3/$1'; */ $query = "SELECT `{$entry_id}`, `{$entry_title}`"; //also select date field if field is specified if ($date != '') { $query .= ", `{$date}`"; } $query .= " FROM `{$table}`"; if ($date != '') { $query .= " ORDER BY `{$date}` ASC"; } else { $query .= " ORDER BY `{$entry_title}` ASC"; } $result = mysql_query($query); //echo $query; while ($entry = mysql_fetch_array($result)) { $output .= '<option value="' . $entry[$entry_id] . '">' . $entry[$entry_title]; //turn to standard date format if ($date != '') { $output .= ' - ' . dev_split_date($entry[$date]); } $output .= '</option>'; } $output .= ' </select><br /> <input type="submit" name="edit" value="edit..."> </form> '; return $output; }
function dev_edit_file($file = '', $mode = '') { if ($file != '' && file_exists($file)) { $doc = file_get_contents($file); if ($mode == '') { $mode = 'textarea'; } $output .= dev_draw_form_field('hidden', 'file', '', $file); $output .= dev_draw_form_field($mode, 'data', 'Editing "' . basename($file) . '"', $doc, '', 'data'); $output .= dev_draw_form_field('submit', 'Submit', 'Save Changes', 'Save'); } else { $output .= "No such file. File does not exist\n"; } return $output; }
function dev_email_form($href = '', $to = '', $additional_fields = '') { $href = dev_href($href); $additional_fields = dev_value_to_array($additional_fields); $output = ''; $output .= dev_draw_form() . dev_draw_form_field($to == '' ? 'text' : 'hidden', 'rcpt', 'To', '') . dev_draw_form_field('text', 'subject', 'Subject', ''); foreach ($additional_fields as $a => $b) { $output .= dev_draw_form_field('text', $a, $b, ''); } $output .= dev_draw_form_field('textarea', 'message', 'Message', '') . dev_draw_form_field('submit', 'submit', 'Send', 'Send') . dev_draw_form_field('reset', 'reset', 'Reset', 'Reset') . dev_close_form(); return $output; }
function drawControl() { //Author: Devon .M. Scott //Database and file management vars. //$action = (isset($_POST['action']) && $_POST['action'] != '') ? $_POST['action'] : $_GET['action']; $view = isset($_POST['view']) && $_POST['view'] != '' ? $_POST['view'] : (isset($_GET['view']) && $_GET['view'] != '' ? $_GET['view'] : (isset($_COOKIE['view']) && $_COOKIE['view'] != '' ? $_COOKIE['view'] : 'select')); $file = isset($_POST['file']) && $_POST['file'] != '' ? $_POST['file'] : $_GET['file']; $dir = isset($_POST['dir']) && $_POST['dir'] != '' ? $_POST['dir'] : $_GET['dir']; $action = isset($_POST['action']) && $_POST['action'] != '' ? $_POST['action'] : $_GET['action']; $mode = isset($_POST['mode']) && $_POST['mode'] != '' ? $_POST['mode'] : $_GET['mode']; $options_on = $this->getOptionsOn(); $href = dev_href($this->getHref($href)); //$href = 'index.php'; $output = ''; $status = ''; if (count($this->getOptions()) <= 0) { $option_list = new DevObject(DEV_OPTIONS); $option_list->clearMembers(); $option_list->setCondition('option_enable', '=', '1'); $option_list->setCondition('option_group', '=', $this->getTables()); $options_set = array(); foreach ($option_list->createMemberArray() as $a) { $options_set[] = $a['option_name']; } } else { $options_set = $this->getOptions(); } if (!in_array($action, $options_set) && $options_on === true) { if ($action != '') { $output .= '<b>You do not have permission to take this action.</b><br /><br />'; } $action = 'list'; } $option = array(); $image_dir = $this->getWSPath() . $this->getImageDir(); $image_upload_dir = $this->getFSPath() . $this->getImageDir(); $file_dir = $this->getWSPath() . $this->getFileDir(); $file_upload_dir = $this->getFSPath() . $this->getFileDir(); $query = array(); //$filedir = 'filedir/'; if ($dir != $file_upload_dir && $dir != '') { $query['d'] = $dir; $file_upload_dir = $dir; } $object = $this->getControlObject(0); $options = array(); if ($this->getLogo() != '') { $output .= dev_print_image($this->getLogo()); } if ($this->getTitle() != '') { $output .= "<h1>" . $this->getTitle() . "</h1>"; } //$object->toggleActiveFieldsOn(true); $object->clearMembers(); $object->setActiveFields($this->getFieldHeaders()); $entry_id_var = $object->getPrimaryKey(); ${$entry_id_var} = isset($_POST[$entry_id_var]) && $_POST[$entry_id_var] != '' ? $_POST[$entry_id_var] : $_GET[$entry_id_var]; //$files = new DevObject('files'); //$files->clearMembers(); if ($action == 'edit' || $action == 'delete' || $action == 'manageimages' || $action == 'changeimages' || $action == 'upload' || $action == 'view' || $action == 'default') { //$object->loadFreshMembers(); $object->clearMembers(); $object->loadGetVars(); $object->loadPostVars(); if ($action == 'default' || $action == 'view') { $object->loadArrayVars($this->getFieldDefaults()); } $object->loadMembers(); foreach ($object->getMemberArray() as $a => $b) { global ${$a}; ${$a} = $b; } //echo $object->getQuery(); } elseif ($action == 'deletefile') { $files->loadFreshMembers(); foreach ($files->getMemberArray() as $a => $b) { ${$a} = $b; } } $delete_form = ' Really delete entry \'' . ${$entry_id_var} . '\' From the database? (Deletion is NOT undoable).<br />' . dev_draw_form_field('hidden', $entry_id_var, '', ${$entry_id_var}) . '<a href="' . $href . '?action=edit&' . $entry_id_var . '=' . ${$entry_id_var} . '">No, return to this entry</a><br /><br />' . '<input type="submit" value="Yes, Delete Forever" /><br />'; //$options[] = '<a href="' . $href . '?action=edit&' . $entry_id_var . '=' . $$entry_id_var . '">No, return to this entry</a>'; /* $delete_file_form = ' Really delete file \'' . $files_document . '\'? (Deletion is NOT undoable).<br />' . dev_draw_form_field('hidden', $entry_id_var, '', $$entry_id_var) . dev_draw_form_field('hidden', 'files_id', '', $files_id) . '<a href="' . $href . '?action=managefiles&' . $entry_id_var . '=' . $$entry_id_var . '">No, return to this entry\'s files</a><br /><br />' . '<input type="submit" value="Yes, Delete Forever" /><br />'; */ $delete_file_form .= "Really delete file '{$file}'? (Deletion is <b>NOT</b> undoable).<br />\n" . '<a href="' . $href . '?dir=' . $dir . '&file=' . $file . '&action=removefile">Yes, delete forever.</a><br /><br />' . '<a href="' . $href . '?dir=' . $dir . '&action=listfiles">Back to List</a><br /><br />'; //$options[] = '<a href="' . $href . '?action=managefiles&' . $entry_id_var . '=' . $$entry_id_var . '">No, return to this entry\'s files</a>'; $static_fields_r = array(); foreach ($object->getFullFieldArray() as $a => $b) { $static_fields_r[$a] = 'static'; } //$view_form = $this->drawManageForm($object, 'View Details', $static_fields_r, 'Edit', 'Reset'); $view_form = dev_detail_box($object->getFullFieldArray()); $edit_form = $this->drawManageForm($object, 'Manage Entry', $this->getFieldTypes(), 'Submit', 'Clear', $action == 'edit' || $action == 'new' || $action == 'post' ? true : false); $mail_form = $this->drawManageForm($object, 'Send Message', $this->getFieldTypes(), 'Send', 'Clear'); //$options[] = '<a href="' . $href . '?action=new">Create New</a>'; //$options[] = '<a href="' . $href . '?action=list">Back to List</a>'; /* $upload_form = '<a href="' . $href . '?action=edit&' . $entry_id_var . '=' . $_GET[$entry_id_var] . '">Return to this entry</a><br /><br />' . '<a href="' . $href . '?action=managefiles&' . $entry_id_var . '=' . $_GET[$entry_id_var] . '">Manage existing uploaded files</a><br /><br />' . 'Upload files to associate to your entry<br />' . dev_draw_form_field('hidden', $entry_id_var, '', $_GET[$entry_id_var]) . dev_draw_form_field('hidden', 'MAX_FILE_SIZE', '', '1024000000') . dev_draw_form_field('text', 'project_program_title', 'Programs Title', $project_programs_title) . dev_draw_form_field('file', 'program', 'Programs', $programs) . dev_draw_form_field('text', 'project_minutes_title', 'Minutes Title', $project_minutes_title) . dev_draw_form_field('file', 'minutes', 'Minutes', $minutes) . dev_draw_form_field('text', 'project_notices_title', 'Notices Title', $project_notices_title) . dev_draw_form_field('file', 'notices', 'Notices', $notices) . dev_draw_form_field('text', 'project_images_title', 'Images Title', $project_images_title) . dev_draw_form_field('file', 'images', 'Images', $images) . dev_draw_form_field('text', 'project_misc_title', 'Miscellaneous Title', $project_misc_title) . dev_draw_form_field('textarea', 'project_misc', 'Miscellaneous', $project_misc) . '<input type="submit" value="Upload" />'; */ $upload_form = dev_draw_form_field('hidden', 'dir', '', $dir) . dev_draw_form_field('file', 'file', 'File') . dev_draw_form_field('submit', 'uploadfiles', 'Upload', 'Upload'); $edit_file_form = '<a href="' . $href . '?dir=' . $dir . '&file=' . $file . '&action=edit&mode=richtext">Rich Text Mode</a><br /><br />'; //dev_draw_form_field('hidden', 'action', '', 'savefile') . dev_edit_file($dir . $file); $view_file_form = dev_draw_form_field('hidden', 'dir', '', $dir) . dev_draw_form_field('static', 'file', 'Filename', $file) . dev_draw_form_field('static', 'data', 'Data', dev_view_file($dir . $file)) . dev_draw_form_field('submit', 'editfile', 'Edit', 'Edit'); //$options[] = '<a href="' . $href . '?action=edit&' . $entry_id_var . '=' . $_GET[$entry_id_var] . '">Return to this entry</a>'; //$options[] = '<a href="' . $href . '?action=managefiles&' . $entry_id_var . '=' . $_GET[$entry_id_var] . '">Manage existing uploaded files</a>'; $output .= dev_draw_form(); switch ($action) { case 'remove': if ($_POST[$entry_id_var] != '' && $_POST[$entry_id_var] > 0) { $object->clearMembers(); $object->loadPostVars(); $status .= $object->deleteObject() ? "Successfully Deleted Entry " : "Deletion Failed"; $object->clearMembers(); } default: case 'list': //$object->setSortOrder('entry_name', 'ASC'); $action = 'edit'; $field_names = array_values($this->getFieldHeaders()); if (is_array($field_names)) { $object->setSortOrder($field_names[1], 'ASC'); } $object->loadPostVars(); $object->setDistinction($entry_id_var); $options['new'] = '<a href="' . $href . '?action=new">' . $this->getIcon('new') . 'Create New</a>'; $options['search'] = '<a href="' . $href . '?action=search">' . $this->getIcon('search') . 'Search</a>'; $query_r = array('action' => 'view'); //$output .= dev_content_box($object->createMemberArray(), '', $href, $query_r, '#c0c0c0', '', '1', true, '../forum/'); //$output .= dev_list_results($object->createMemberArray(), 'begin', 'end', $href, true, 1, $query_r, '', $image_dir, $file_dir, $this->getFieldHeaders()); $output .= 'View: <a href="' . $href . '?view=icon">icons</a> | <a href="' . $href . '?view=search">list</a> | <a href="' . $href . '?view=select">selection</a><br />'; $output .= dev_display_box($object->createMemberArray(), $view, $href, $query_r, '#c0c0c0', $this->getFieldHeaders(), '1', true, $image_dir, $file_dir, '', 15); break; case 'advancedsearch': //if ($action == 'advancedsearch') { $options['search'] = '<a href="' . $href . '?action=search">' . $this->getIcon('search') . 'Basic Search</a>'; $options['new'] = '<a href="' . $href . '?action=new">' . $this->getIcon('new') . 'Create New</a>'; $options['list'] = '<a href="' . $href . '?action=list">' . $this->getIcon('list') . 'Back to List</a>'; //$output .= dev_draw_form() . $action = 'list'; $output .= dev_draw_form_field('hidden', 'view', '', 'search') . $object->drawForm($field_types) . dev_draw_form_field('submit', 'submit', 'Finding...', 'Find'); //dev_close_form(); //} break; case 'search': //if ($action == 'search') { $options['advancedsearch'] = '<a href="' . $href . '?action=advancedsearch">' . $this->getIcon('advancedsearch') . 'Advanced Search</a>'; $options['new'] = '<a href="' . $href . '?action=new">' . $this->getIcon('new') . 'Create New</a>'; $options['list'] = '<a href="' . $href . '?action=list">' . $this->getIcon('list') . 'Back to List</a>'; $field_names = array_values($this->getFieldHeaders()); //$object->setDistinction($entry_id_var); //$object->setSortOrder('entry_location', 'ASC'); $action = 'list'; $output .= '<table>' . dev_draw_form_field('hidden', 'view', '', 'search') . $object->formField($field_names[1]) . '</table>' . dev_draw_form_field('submit', 'submit', 'Finding...', 'Find'); //dev_close_form(); //} break; //OBJECT ACTION CASES //OBJECT ACTION CASES case 'save': $action = 'save'; $object->loadPostVars(); $success = dev_save_file($file, $view_form, $mode); $options['back'] = strpos($success, 'successful') === false ? ' <a class="dev_option" href="javascript:history.back(1)">' . $this->getIcon('back') . 'Go back</a>' : ''; break; case 'cookie': $action = 'cookie'; $object->loadPostVars(); foreach ($object->getMemberArray() as $a => $b) { $success .= dev_set_cookie($a, $b); } $options['back'] = !$success ? ' <a class="dev_option" href="javascript:history.back(1)">' . $this->getIcon('back') . 'Go back</a>' : ''; break; case 'session': $action = 'save'; $object->loadPostVars(); foreach ($object->getMemberArray() as $a => $b) { $success .= dev_set_session($a, $b); } $options['back'] = !$success ? ' <a class="dev_option" href="javascript:history.back(1)">' . $this->getIcon('back') . 'Go back</a>' : ''; break; case 'sendmail': $action = 'semdmail'; $sucess = dev_send_email($rcpt, $from, $subject, $message, $cc, $bcc, $html, $headers_r, $additional); $options['back'] = strpos($success, 'successful') === false ? ' <a class="dev_option" href="javascript:history.back(1)">' . $this->getIcon('back') . 'Go back</a>' : ''; case 'mail': $action = 'sendmail'; $output .= $mail_form; break; case 'post': $action = 'post'; $object->loadPostVars(); foreach ($_FILES as $a => $b) { if ($b['size'] > 0) { $b['name'] = str_replace(' ', '_', $b['name']); $object->{$a} = $b['name']; $status .= dev_upload_file($b, 1, $image_upload_dir); } } $success .= $object->writeObject(); $options['back'] = strpos($object->getStatusMessage(), 'Unsuccessful') !== false ? ' <a class="dev_option" href="javascript:history.back(1)">' . $this->getIcon('back') . 'Go back</a>' : ''; case 'new': $options['new'] = '<a href="' . $href . '?action=new">' . $this->getIcon('new') . 'Create New</a>'; $options['list'] = '<a href="' . $href . '?action=list">' . $this->getIcon('list') . 'Back to List</a>'; $action = 'post'; $output .= "<h5>Create New Entry</h5><br />"; $output .= $edit_form; break; case 'uploadfiles': $options['listfiles'] = '<a href="' . $href . '?action=listfiles&dir=' . $dir . '">' . $this->getIcon('listfiles') . 'Back to List</a>'; $options['choosefile'] = '<a href="' . $href . '?action=choosefile&dir=' . $dir . '">' . $this->getIcon('choosefile') . 'Upload Another File</a>'; $output .= dev_upload_file($_FILES['file'], 0, getcwd() . '/' . $dir); break; case 'removefile': $files->loadPostVars(); //$output .= ($files->deleteObject()) ? "Successfully Deleted Entry<br />" : "Deletion Failed<br />"; $output .= dev_delete_file($file, true) ? "Successfully Deleted Entry<br />" : "Deletion Failed<br />"; case 'listfiles': //$output .= dev_list_dir('file.php', 'document', $file_upload_dir, $query); $options['newfile'] = '<a href="' . $href . '?action=newfile&dir=' . $dir . '">' . $this->getIcon('newfile') . 'Create New File</a>'; $options['choosefile'] = '<a href="' . $href . '?action=choosefile&dir=' . $dir . '">' . $this->getIcon('choosefile') . 'Upload New File</a>'; $output .= dev_list_dir('file.php', '', $file_upload_dir, $query); case 'choosefile': $options['listfiles'] = '<a href="' . $href . '?action=listfiles&dir=' . $dir . '">' . $this->getIcon('listfiles') . 'Back to List</a>'; $output .= $upload_form; break; case 'savefile': $options['listfiles'] = '<a href="' . $href . '?action=listfiles&dir=' . $dir . '">' . $this->getIcon('listfiles') . 'Back to List</a>'; $output .= dev_save_file($file, $data); case 'openfile': $options['listfiles'] = '<a href="' . $href . '?action=listfiles&dir=' . $dir . '">' . $this->getIcon('listfiles') . 'Back to List</a>'; $options['editfile'] = '<a href="' . $href . '?action=editfile&dir=' . $dir . '&file=' . $file . '">' . $this->getIcon('editfile') . 'Back to List</a>'; $output .= $view_file_form; break; case 'newfile': case 'editfile': $output .= $edit_file_form; break; case 'upload': //Case following special "files" case //$object_files->loadPostVars(); //$files = new DevObject('files'); foreach ($_FILES as $a => $b) { if ($b['size'] > 0) { $files->clearMembers(); $files->loadPostVars(); $status .= dev_upload_file($b, 1, $image_upload_dir); $object->writeObject(); } } case 'default': case 'view': $action = 'edit'; //$output .= "<h5>View Existing Entry</h5><br />"; $options['list'] = '<a href="' . $href . '?action=list">' . $this->getIcon('list') . 'Back to List</a>'; $options['edit'] = '<a href="' . $href . '?action=edit&' . $entry_id_var . '=' . ${$entry_id_var} . '">' . $this->getIcon('edit') . 'Edit</a>'; $options['delete'] = '<a href="' . $href . '?action=delete&' . $entry_id_var . '=' . ${$entry_id_var} . '">' . $this->getIcon('delete') . 'Delete this entry</a>'; $options['files'] = '<a href="' . $href . '?action=files&' . $entry_id_var . '=' . ${$entry_id_var} . '">' . $this->getIcon('files') . 'Upload files for this entry</a>'; $options['manageimages'] = '<a href="' . $href . '?action=manageimages&' . $entry_id_var . '=' . ${$entry_id_var} . '">' . $this->getIcon('manageimages') . 'Manage Images</a>'; $output .= $view_form; break; case 'edit': $action = 'post'; $output .= "<h5>Edit Existing Entry</h5><br />"; $options['list'] = '<a href="' . $href . '?action=list">' . $this->getIcon('list') . 'Back to List</a>'; $options['delete'] = '<a href="' . $href . '?action=delete&' . $entry_id_var . '=' . ${$entry_id_var} . '">' . $this->getIcon('delete') . 'Delete this entry</a>'; $options['files'] = '<a href="' . $href . '?action=files&' . $entry_id_var . '=' . ${$entry_id_var} . '">' . $this->getIcon('files') . 'Upload files for this entry</a>'; $options['manageimages'] = '<a href="' . $href . '?action=manageimages&' . $entry_id_var . '=' . ${$entry_id_var} . '">' . $this->getIcon('manageimages') . 'Manage Images</a>'; //$output .= $object->formField($entry_id_var, '', '', 'hidden'); $output .= $edit_form; break; case 'delete': $action = 'remove'; $options['edit'] = '<a href="' . $href . '?action=edit&' . $entry_id_var . '=' . ${$entry_id_var} . '">' . $this->getIcon('edit') . 'No, return to this entry</a>'; $output .= "<h5>Delete Existing Entry</h5><br />"; $output .= $delete_form; break; case 'files': //Special case for minutes and programs $options['edit'] = '<a href="' . $href . '?action=edit&' . $entry_id_var . '=' . $_GET[$entry_id_var] . '">' . $this->getIcon('edit') . 'Return to this entry</a>'; $options['managefiles'] = '<a href="' . $href . '?action=managefiles&' . $entry_id_var . '=' . $_GET[$entry_id_var] . '">' . $this->getIcon('managefiles') . 'Manage existing uploaded files</a>'; $files = new DevObject($tables); $files->loadFreshMembers(); $action = 'upload'; $output .= $upload_form; break; case 'managefiles': //$object->setSortOrder('entry_name', 'ASC'); $files->loadGetVars(); $files->setSortOrder('files_document', 'ASC'); $files->setCondition('files_id', '>=', '1'); $options['edit'] = '<a href="' . $href . '?action=edit&' . $entry_id_var . '=' . ($_GET[$entry_id_var] == '' ? $_POST[$entry_id_var] : $_GET[$entry_id_var]) . '">' . $this->getIcon('edit') . 'Return to this entry</a><br />'; $output .= '<table width="100%" border="1">'; $output .= '<tr> <td>File Name</td> <td>File Type</td> <td>Delete</td> </tr>' . "\n"; foreach ($files->createMemberArray() as $a) { $output .= '<tr> <td><a href="' . DOMAIN . SITE_ROOT . 'files/' . $a['files_document'] . '" target="_blank">' . $a['files_document'] . '</a></td> <td>' . $a['files_type'] . '</td> <td><a href="' . $href . '?action=deletefile&files_id=' . $a['files_id'] . '">Remove</a></td> </tr>' . "\n"; } $output .= '</table>'; $output .= dev_list_dir(); break; case 'deletefile': $options['managefiles'] = '<a href="' . $href . '?action=managefiles&' . $entry_id_var . '=' . ${$entry_id_var} . '">' . $this->getIcon('managefiles') . 'No, return to this entry\'s files</a>'; $action = 'removefile'; $output .= "<h5>Delete Existing Document</h5><br />"; $output .= $delete_file_form; break; case 'changeimages': $old_image = new DevObject($table); $old_image->clearMembers(); $old_image->{$entry_id_var} = $_POST[$entry_id_var]; $old_image->loadMembers(); foreach ($old_image->getMemberArray() as $a => $b) { if ($_POST[$a] == 'NULL') { $old_image->{$a} = ''; } } $success .= $old_image->writeObject(1); case 'manageimages': //$object->loadFreshMembers(); $action = 'changeimages'; $options['new'] = '<a href="' . $href . '?action=new">' . $this->getIcon('new') . 'Create New</a>'; $options['edit'] = '<a href="' . $href . '?action=edit&' . $entry_id_var . '=' . ${$entry_id_var} . '">' . $this->getIcon('edit') . 'Return to this entry</a>'; $output .= '<span style="font-size: 11px; color: #ff0000; font-family: arial, helvitica, sans-serif;"> Select the checkbox to remove the image from this entry. </span><br />' . dev_draw_form_field('hidden', $entry_id_var, '', ${$entry_id_var}) . dev_draw_form_field('checkbox', 'entry_image', 'Main Image: ' . $entry_image, '') . dev_draw_form_field('checkbox', 'entry_image_1', 'Additional Image 1: ' . $entry_image_1, 'NULL') . dev_draw_form_field('checkbox', 'entry_image_2', 'Additional Image 2: ' . $entry_image_2, 'NULL') . dev_draw_form_field('checkbox', 'entry_image_3', 'Additional Image 3: ' . $entry_image_3, 'NULL') . dev_draw_form_field('checkbox', 'entry_image_4', 'Additional Image 4: ' . $entry_image_4, 'NULL') . dev_draw_form_field('checkbox', 'entry_image_5', 'Additional Image 5: ' . $entry_image_5, 'NULL') . dev_draw_form_field('checkbox', 'entry_image_6', 'Additional Image 6: ' . $entry_image_6, 'NULL') . dev_draw_form_field('checkbox', 'entry_image_7', 'Additional Image 7: ' . $entry_image_7, 'NULL') . dev_draw_form_field('checkbox', 'entry_image_8', 'Additional Image 8: ' . $entry_image_8, 'NULL') . '<input type="submit" value="Remove" />'; break; } $output .= dev_draw_form_field('hidden', 'action', '', $action); $output .= dev_close_form(); $status .= $object->getStatusMessage() != '' ? '<span class="dev_status">' . $object->getStatusMessage() . '</span><br />' : ''; $option_types = array_keys($options); if ($options_on === true) { foreach ($option_types as $a) { if (!in_array($a, $options_set)) { unset($options[$a]); } } } $options_str = implode(' ', $options); $this->setStatus($status); $this->setTasks($options_str); $this->setOutput($output); $output = "{$status}{$options_str}<br />{$output}"; //echo $object->getQuery(); return $output; }