예제 #1
0
 public function query($query = null)
 {
     $curl = $this->_connection;
     $method = strtolower($this->config('method'));
     if ($curl) {
         if (DevValue::isNotNull($query)) {
             if (DevArray::isAssoc($query)) {
                 //$this->_data = $query;
                 $this->assign($query);
             }
         }
         $data = $this->_data;
         //set the url, number of POST vars, POST data
         if ($method == 'post') {
             curl_setopt($curl, CURLOPT_POST, count($data));
             curl_setopt($curl, CURLOPT_POSTFIELDS, HTTP::query($data));
         } elseif ($method == 'get') {
             curl_setopt($curl, CURLOPT_URL, $this->config('target') . '/' . HTTP::query($data));
         }
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
         //execute post
         $this->_result = curl_exec($curl);
         $status = $this->_result ? self::STATUS_SUCCESS : self::STATUS_FAILED;
     } else {
         $status = self::STATUS_NOTCONNECTED;
     }
     $this->status($status);
 }
예제 #2
0
 public function query($query = null)
 {
     $status = self::STATUS_NOTCONNECTED;
     $context = $this->_connection;
     $wrapper = $this->config('wrapper');
     if ($context) {
         if (DevValue::isNotNull($query)) {
             if (DevArray::isAssoc($query)) {
                 $this->_data = $query;
             } else {
                 if (is_string($query)) {
                     $data = urlencode($query);
                     stream_context_set_option($context, $wrapper, 'content', $data);
                     $this->_result = file_get_contents($target, false, $context);
                     $this->status($this->_result !== false ? self::STATUS_SUCCESS : self::STATUS_FAILED);
                     return true;
                 }
             }
         }
         $data = HTTP::query($this->_data);
         stream_context_set_option($context, $wrapper, 'content', $data);
         $this->_result = file_get_contents($target, false, $context);
         if ($this->_result !== false) {
             $status = self::STATUS_SUCCESS;
         }
     }
     $this->status($status);
 }
예제 #3
0
 public function query($query = null)
 {
     $db = $this->_connection;
     if ($db) {
         if (DevValue::isNotNull($query)) {
             $this->_query = $query;
             if (DevArray::isAssoc($query)) {
                 $this->_data = $query;
             } else {
                 if (is_string($query)) {
                     $this->_result = $db->query($query);
                     $this->status($db->error ? $db->error : self::STATUS_SUCCESS);
                     return true;
                 }
             }
         }
         $table = $this->config('table');
         $where = '';
         $update = false;
         $key = self::sanitize($this->config('key'));
         if ($this->field($key)) {
             $value = self::sanitize($this->field($key));
             $where = $key ? "`{$key}` = {$value}" : '';
             $update = true;
         }
         $data = $this->_data;
         $type = $update ? $this->config('ignore_null') ? self::UPDATE_SPECIFIED : self::UPDATE : self::INSERT;
         return $this->post($table, $data, $where, $type);
     } else {
         $this->status(self::STATUS_NOTCONNECTED);
         return false;
     }
 }
예제 #4
0
 public function __construct($value = null)
 {
     parent::__construct($value);
     if (empty($value)) {
         $this->_value = new ArrayObject();
     } else {
         $this->_value = new ArrayObject(DevArray::toArray($this->_value));
     }
 }
예제 #5
0
 public function contents($data = null)
 {
     if (DevValue::isNull($data)) {
         return $this->_rows->current() ? $this->_rows->current() : parent::contents();
     } elseif (is_array($data) && !DevArray::isAssoc($data)) {
         $this->_rows = new Group($data);
     } elseif (DevArray::isAssoc($data)) {
         parent::contents($data);
     }
     $this->perform(Event::CHANGE);
 }
예제 #6
0
 public function __construct($data = null)
 {
     parent::__construct();
     if (DevValue::isNotNull($data)) {
         if (DevArray::isAssoc($data)) {
             $this->config($data);
             // $this->dirname = $this->config('root') ? $this->config('root') : getcwd();
         } elseif (is_string($data)) {
             $this->getInfo($data);
         }
     }
 }
예제 #7
0
 public function assign($data)
 {
     if (is_object($data) || DevArray::isAssoc($data)) {
         $this->perform(State::BUSY);
         foreach ($data as $a => $b) {
             $this->field($a, $b);
         }
         $this->halt(State::BUSY);
         $this->dispatch(Event::CHANGE);
     } else {
         throw new \InvalidArgumentException("Can't import from variable type " . gettype($data));
     }
 }
예제 #8
0
 public function raise(Behavior $behavior, $args)
 {
     if ($this->_callback) {
         $args = DevArray::isEmpty($args) ? null : $args;
         if ($args == null) {
             $args = $behavior;
         }
         if (!is_array($args)) {
             $args = array($args);
         }
         if (is_callable($this->_callback)) {
             call_user_func_array($this->_callback, $args);
         }
     }
 }
예제 #9
0
 public function query($query = null)
 {
     //
     $db = $this->_connection;
     if ($db) {
         if (DevValue::isNotNull($query)) {
             $this->_query = $query;
             if (DevArray::isAssoc($query)) {
                 $this->_dataset = null;
                 $this->_data = $query;
             } else {
                 if (is_array($query) && !DevArray::isAssoc($query)) {
                     $this->_dataset = $query;
                     $this->_data = $query[0];
                 } else {
                     if (is_string($query)) {
                         $this->_result = $db->command(json_decode($query));
                         $this->status($this->error() ? $this->error() : self::STATUS_SUCCESS);
                         return true;
                     }
                 }
             }
         }
         $collection = $this->config('collection');
         $filter = null;
         $update = false;
         $key = self::sanitize($this->config('key'));
         if ($this->field($key)) {
             $value = self::sanitize($this->field($key));
             $filter = $key ? array($key => $value) : '';
             $update = true;
         }
         $data = $this->_dataset ? $this->_dataset : $this->_data;
         $type = $update ? $this->config('replace') ? self::REPLACE : self::UPDATE : self::INSERT;
         $result = false;
         try {
             $result = $this->post($collection, $data, $filter, $type);
         } catch (Exception $e) {
             $error = $e->getMessage();
             $this->status($error);
         }
         return $result;
     } else {
         $this->status(self::STATUS_NOTCONNECTED);
         return false;
     }
 }
예제 #10
0
 public function instance()
 {
     if (isset($this->instance) && $this->instance instanceof $this->type) {
         $service = $this->instance;
     } else {
         $reflection_class = new ReflectionClass($this->type);
         $args = DevArray::toArray($this->arguments);
         $this->instance = $reflection_class->getConstructor() ? $reflection_class->newInstanceArgs($args) : $reflection_class->newInstanceWithoutConstructor();
         foreach ($this->_registrations as $name => $registrations) {
             usort($registrations, function ($a, $b) {
                 if ($a['priority'] == $b['priority']) {
                     return 0;
                 }
                 return $a['priority'] < $b['priority'] ? -1 : 1;
             });
             foreach ($registrations as $registration) {
                 $this->apply($registration);
             }
         }
     }
     return $this->instance;
 }
예제 #11
0
 public function buildXML($data = null, $indent = 0)
 {
     $xml = '';
     $tabs = "";
     for ($i = 0; $i < $indent; $i++) {
         $tabs .= "\t";
     }
     //if (!is_array($data)) $data = DevArray::toArray($data);
     if (is_array($data)) {
         foreach ($data as $b => $a) {
             if (!DevArray::isAssoc($a)) {
                 $xml .= $this->buildXML($a, $indent);
             } else {
                 $attribs = '';
                 if (DevArray::isAssoc($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;
 }
예제 #12
0
 public function params($params)
 {
     $this->_parameters = DevArray::toArray($params);
     return $this;
 }
예제 #13
0
    static function field($type = '', $name = '', $label = '', $value = '', $required = false, $id = '', $readonly = false, $properties = '')
    {
        $output = '';
        $label_text = '';
        $varname = $name;
        $properties = DevArray::toArray($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 = DevArray::toArray($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 = DevArray::toArray($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 = DevArray::toArray($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 (DevArray::isAssoc($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 (DevArray::isAssoc($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 .= Form::date($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 .= Form::date($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 = 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 .= 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 .= 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 .= 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=' . htmlentities($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;
    }
예제 #14
0
 public function field($var, $content = null, $formatted = null)
 {
     if ($formatted) {
         $content = HTML::format($content);
     }
     if (is_string($var)) {
         if (!$content) {
             throw new InvalidArgumentException('Cannot assign empty value.');
         }
         if (DevValue::isNotNull($formatted) && !is_bool($formatted)) {
             throw new InvalidArgumentException('Formatted argument expects boolean');
         }
         return parent::field($var, $content);
     } elseif (is_object($var) || DevArray::isAssoc($var)) {
         if (!$formatted) {
             $formatted = $content;
         }
         foreach ($var as $a => $b) {
             $this->field($a, $b, $formatted);
         }
     } else {
         throw new InvalidArgumentException('Invalid property');
     }
 }
예제 #15
0
 public function render()
 {
     $header = $this->config('headers');
     $trunc = $this->config('truncate');
     $file_dir = $this->config('document_dir');
     $cols = $this->config('columns');
     $link_style = $this->config('link_style');
     // $href = $this->config('href');
     // $fields = $this->config('fields');
     $query_r = $this->config('query');
     $content_r = $this->content();
     extract($this->_config);
     $hori = 0;
     $output = '<table class="dev_table"' . ($header === false ? '' : ' id="anyid"') . '>';
     $bg = false;
     $href = HTML::href($href);
     $count = 0;
     $new_row = 1;
     foreach ($content_r as $row) {
         $fields = $fields != '' && $fields >= 0 && $fields < count($row) ? $fields : count($row);
         if ($count == 0) {
             if ($header !== false) {
                 $header = is_array($header) && count($header) == count($row) ? $header : $row;
                 if (DevArray::isAssoc($header)) {
                     $header = array_keys($header);
                 }
                 $output .= '<tr>';
                 $i = 0;
                 foreach ($header as $a) {
                     if ($i == 0 && $link_style != 1 && $link_style !== 0) {
                         $output .= '<th>';
                         $output .= '';
                         $output .= "</th>";
                     }
                     if ($i > 0) {
                         $output .= '<th>';
                         $output .= $a;
                         $output .= "</th>";
                     }
                     $i++;
                     if ($i > $fields) {
                         break;
                     }
                 }
                 $output .= "</tr>\n";
             }
         }
         //manage columns
         if ($hori == 0) {
             $output .= '<tr>';
         }
         $i = 0;
         foreach ($row as $a => $b) {
             if ($i > 0 || $header === false && $link_style != 1) {
                 if (!($icon != '' && $fields == 2 && $i == 2)) {
                     $output .= '<td>';
                 }
                 if (($i == 1 || $icon != '' && ($i = 2)) && $link_style == 1) {
                     $output .= '<a class="contentBox" href="' . $href . '?' . $varname . '=' . $value . (DevArray::isAssoc($query_r) ? '&' . http_build_query($query_r) : '') . '">';
                 }
                 if (!$show_image || $trunc != '') {
                     $data = HTML::format($b, '', $trunc);
                 } else {
                     $data = $b;
                 }
                 if ($i != 1) {
                     $data = HTML::file($data, $file_dir);
                 }
                 if ($icon != '' && $i == 1) {
                     $data = HTML::image($data == '' ? $icon : $data, $img_dir, '', '50', '', '', '', '', '', $icon) . ($fields == 1 ? "<br />" . $data : '');
                 } elseif ($show_image) {
                     $data = HTML::image($data, $img_dir, $data, '100', '', true, '', false);
                 }
                 $output .= $data;
                 if ($i == 1 && $link_style == 1) {
                     $output .= "</a>";
                 }
                 if (!($icon != '' && $fields == 2 && $i == 1)) {
                     $output .= "</td>";
                 }
             } elseif ($i == 0) {
                 if ($link_style == 2) {
                     $output .= '<td>';
                     $output .= Form::open($href) . Form::field('hidden', $a, '', $b) . Form::field('submit', 'submit', '', 'Go');
                     if (DevArray::isAssoc($query_r)) {
                         foreach ($query_r as $c => $d) {
                             $output .= Form::feld('hidden', $c, '', $d);
                         }
                     }
                     $output .= Form::close();
                     $output .= "</td>";
                 } elseif ($link_style == 3) {
                     $output .= '<td>';
                     $output .= Form::field('checkbox', $a . '[]', '', $b);
                     if (DevArray::isAssoc($query_r)) {
                         foreach ($query_r as $c => $d) {
                             $output .= Form::field('hidden', $c, '', $d);
                         }
                     }
                     $output .= "</td>";
                 } else {
                     $varname = $a;
                     $value = $b;
                 }
             }
             $i++;
             if ($i > $fields) {
                 break;
             }
         }
         $output .= "\n";
         if ($hori < $cols) {
             $hori++;
         } else {
             $output .= "</tr>\n";
             $hori = 0;
         }
         $count++;
     }
     if ($hori != 0) {
         $output .= "</tr>\n";
     }
     $output .= "</table>\n";
     return $output;
 }
예제 #16
0
 public function month($events = null)
 {
     $date = $this->info();
     $event_r = DevArray::toArray($events);
     $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) && DevArray::isAssoc($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;
 }
예제 #17
0
 private function validate($field_name = null, $table = null)
 {
     $fields = $this->fields();
     // if no table is specified, used the first available entry.
     $table = $table ? $table : (isset($tables[0]) ? $tables[0] : current(DevArray::toArray($this->config(self::NAME_FIELD))));
     $passed = true;
     if (isset($fields[$field_name])) {
         $field = $fields[$field_name];
         $type = strtolower($field['Type']);
         //If duplicate entry
         if ($field['Key'] == 'PRI' || $field['Key'] == 'UNI') {
             if (self::inDB($field_name, $this->field($field_name), $table)) {
                 // In what case do we really need to know this?
                 $this->status("A row having field '{$field_name}' with value '" . $this->field($field_name) . "' already exists.");
             }
         } else {
             if ($this->field($field_name) !== 0 && $this->field($field_name) == '') {
                 if (!$field['Null'] || $field['Null'] == 'NO') {
                     if (DevString::has($type, 'date')) {
                         //$this->field($field_name, dev_join_date($field_name));
                         $this->field($field_name, date('Y-m-d'));
                         if (!is_string($this->field($field_name)) || !DateTime::stringIsDate($this->field($field_name))) {
                             $this->status("Field '{$field_name}' contains an inaccurate date format!");
                             $passed = false;
                         }
                     } else {
                         $this->status("Field '{$field_name}' cannot be empty!");
                         $passed = false;
                     }
                 }
             } else {
                 //Correct Datatype/Size
                 if (DevString::has($type, 'int') || DevString::has($type, 'double') || DevString::has($type, 'float')) {
                     if (!is_numeric($this->field($field_name))) {
                         $this->status("Field '{$field_name}' must be numeric!");
                         $passed = false;
                     }
                 }
                 if (DevString::has($type, 'char') || DevString::has($type, 'text')) {
                     if (!is_string($this->field($field_name))) {
                         $this->status("Field '{$field_name}' is not text!");
                         $passed = false;
                     }
                     if (isset($field['LENGTH']) && DevValue::isNotNull($field['LENGTH']) && strlen($this->field($field_name)) > $field['LENGTH']) {
                         $this->status("Field '{$field_name}' is greater than maximum allowed string length!");
                         $passed = false;
                     }
                 }
                 if (DevString::has($type, 'date')) {
                     if (!is_string($this->field($field_name)) || !DateTime::stringIsDate($this->field($field_name))) {
                         $this->field($field_name, dev_join_date($field_name));
                         if (!is_string($this->field($field_name)) || !DateTime::stringIsDate($this->field($field_name))) {
                             $this->status("Field '{$field_name}' contains an inaccurate date format!");
                             $passed = false;
                         }
                     }
                 }
                 if (DevString::has($type, 'set')) {
                     if (is_array($this->field($field_name))) {
                         $this->field($field_name, implode(', ', $this->field($field_name)));
                     } elseif (!is_string($this->field($field_name))) {
                         $this->status("Field '{$field_name}' contains invalid input!");
                         $passed = false;
                     }
                 }
             }
         }
     }
     return $passed;
 }