Exemple #1
0
function dev_assoc_to_session($assoc, $expire = '3600', $path = '', $secure = false, $httponly = false)
{
    if (dev_is_assoc($assoc)) {
        foreach ($assoc as $a => $b) {
            dev_set_session($a, $b, $expire, $path, $secure, $httponly);
        }
    }
}
function dev_month_r($sm = '', $sy = '', $timestamp = '', $event_r = '')
{
    $date = dev_get_date_info($sm, $sy, $timestamp);
    $event_r = dev_value_to_array($event_r);
    $month = array();
    $notes = array();
    for ($i = 0, $j = 1 - $date['firstweekday']; $i < 5 || $j <= $date['daysinmonth']; $i++) {
        for ($k = 0; $k < 7; $k++, $j++) {
            if (in_array($j, $event_r) && dev_is_assoc($event_r)) {
                $note_r = array_keys($event_r, $j);
                $notes = implode(', ', $note_r);
            }
            $month[$i][$k] = $i == 0 && $k < $date['firstweekday'] || $j > $date['daysinmonth'] ? ' ' : (in_array($j, $event_r) ? "<b>{$j}</b> " . ($notes ? " - {$notes}" : '') : $j);
        }
    }
    return $month;
}
function dev_menu($options = '', $href = '', $type = '', $properties = '')
{
    $output = '';
    if (dev_is_assoc($options)) {
        /*
        $output .= '<ul>' . "\n";
        foreach ($options as $a=>$b) {
        	$output .= "<li>$a\n";
                  	if (is_array($b)) {
        		$output .= "\t" . '<ul>' . "\n";
        		foreach ($b as $c=>$d) {
        			$output .= "\t\t" . '<li>' . $c . '</li>' . "\n";
        		}
        		$output .= "\t" . '</ul>' . "\n";
        	}
                       $output .= "\t" . '</li>' . "\n";
                       }
                  }
        }
        */
        $XML = new DevXML();
        $output .= $XML->buildXML($options);
    } else {
        $output = "No valid menu options provided";
    }
    return $output;
}
function dev_config_from_array($array)
{
    if (dev_is_assoc($array)) {
        foreach ($array as $a => $b) {
            if (!defined($a)) {
                define($a, $b);
            }
        }
        $status = "Loaded configuration\n";
    } else {
        $status = "Invalid data input\n";
    }
    return $status;
}
Exemple #5
0
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('\\"', '&lt;/script&gt;', '&lt;/textarea&gt;', '&lt;/noscript&gt;');
                $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(/&lt;\\/script&gt;/gi, "<" + "/script>");
		' . $name . '_val = ' . $name . '_val.replace(/&lt;\\/textarea&gt;/gi, "<" + "/textarea>");
		' . $name . '_val = ' . $name . '_val.replace(/&lt;\\/noscript&gt;/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 drawForm($field_type_r = '', $active_field_r = '', $property_r = '')
 {
     $output = '';
     $required = '';
     $id = '';
     $active_field_r = dev_value_to_array($active_field_r);
     $field_type_r = dev_value_to_array($field_type_r);
     $property_r = dev_value_to_array($property_r);
     $readonly = false;
     if (count($active_field_r) <= 0) {
         $active_field_r = $this->getActiveFields();
     }
     $output .= '<table>';
     foreach ($this->getFullFieldArray() as $a => $b) {
         if ($this->memberExists($a)) {
             $type = array_key_exists($a, $field_type_r) ? $field_type_r[$a] : '';
             $properties = array_key_exists($a, $property_r) ? $property_r[$a] : '';
             $label_r = dev_is_assoc($active_field_r) && in_array($a, $active_field_r) ? array_keys($active_field_r, $a) : '';
             $label = is_array($label_r) ? $label_r[0] : '';
             $output .= $this->formField($a, $b, $label, $type, $required, $readonly, $id, $properties);
         }
     }
     $output .= '</table>';
     return $output;
 }
Exemple #7
0
 function buildXML($data = '', $indent = 0)
 {
     $xml = '';
     $tabs = "";
     for ($i = 0; $i < $indent; $i++) {
         $tabs .= "\t";
     }
     //if (!is_array($data)) $data = dev_value_to_array($data);
     if (is_array($data)) {
         foreach ($data as $b => $a) {
             if (!dev_is_assoc($a)) {
                 $xml .= $this->buildXML($a, $indent);
             } else {
                 $attribs = '';
                 if (dev_is_assoc($a['attributes'])) {
                     foreach ($a['attributes'] as $c => $d) {
                         $attribs .= " {$c}=\"{$d}\"";
                     }
                 }
                 $xml .= "{$tabs}<" . $a['name'] . "" . $attribs . ">" . (count($a['child']) > 0 ? "\n" . $this->buildXML($a['child'], ++$indent) . "\n{$tabs}" : $a['content']) . "</" . $a['name'] . ">\n";
             }
         }
     }
     return $xml;
 }
    function drawManageForm(&$object, $form_title = '', $field_type_array = '', $submit_text = '', $reset_text = '', $load = false)
    {
        if ($load) {
            if (dev_is_assoc($this->field_data)) {
                foreach ($this->field_data as $a => $b) {
                    $object->setField($a, $b);
                }
            }
        }
        $manage_form = $form_title . ':<br /><br />
	<span style="font-size: 11px; color: #ff0000; font-family: arial, helvitica, sans-serif;">
	All fields marked by an asterix (*) are required.
	</span><br /><br />' . dev_draw_form_field('hidden', 'MAX_FILE_SIZE', '', '1024000000') . $object->drawForm($field_type_array) . dev_draw_form_field('submit', 'submit', $submit_text, $submit_text) . dev_draw_form_field('reset', 'reset', $reset_text, $reset_text);
        return $manage_form;
    }
function dev_array_tree($array, $categories = '', $nodes = '', $start = 1)
{
    $categories = array();
    if ($nodes == '' || !dev_is_assoc($nodes)) {
        $nodes = array('name' => 'name', 'attribs' => 'attribs', 'content' => 'content', 'child' => 'child');
    }
    $categories[] = 'name';
    $categories[] = 'category';
    $categories[] = 'subcategory';
    $array = dev_value_to_array($array);
    $categories = dev_value_to_array($categories);
    $tree = array();
    foreach ($array as $a => $b) {
        if ($b[$categories[$start]] != $last_cat) {
            $tree['child'] = dev_array_tree($b, ++$start);
        } else {
            $tree['name'] = 'li';
            //$tree['attribs'] = '';
            $tree['content'] = $a[$categories[0]];
        }
    }
}
Exemple #10
0
 function getFieldInfo()
 {
     if (!dev_is_assoc($this->_field_info)) {
         $this->loadFieldInfo();
     }
     return $this->_field_info;
 }