Exemplo n.º 1
0
    public function test_should_destroy_the_thumbnail_even_when_not_loaded()
    {
        $Picture =& $this->Picture->find('first');
        $Picture->destroy();

        $this->assertFalse($this->Thumbnail->find('first'),'Issue #125');
    }
Exemplo n.º 2
0
 public function test_destroying_should_cascade()
 {
     $Property = new Property(array('description' => 'This is a Property'));
     $Picture = $Property->picture->create(array('title' => 'Front'));
     $Property->destroy();
     $this->assertFalse($this->Property->find('first', array('default' => false)));
     $this->assertFalse($this->Picture->find('first', array('default' => false)));
 }
Exemplo n.º 3
0
 function test_null_should_not_be_casted_as_false_on_booleans()
 {
     $Celebrity =& new Hybrid(array('title' => 'Franko', 'celebrity' => null));
     $Celebrity->save();
     $Celebrity =& $this->Hybrid->find('first', array('title' => 'Franko'));
     $this->assertNull($Celebrity->celebrity);
 }
Exemplo n.º 4
0
 public function verPerfil()
 {
     $db = new db();
     $db->connect();
     $C = new ActiveRecord('fk_perfiles');
     $C->find($this->id_perfil);
     $db->close();
     return $C->fields;
 }
Exemplo n.º 5
0
 public function verUsuario()
 {
     $db = new db();
     $db->connect();
     $C = new ActiveRecord('usuarios');
     $C->find($this->id_usuario);
     $db->close();
     return $C->fields;
 }
Exemplo n.º 6
0
 public static function verEstado()
 {
     $db = new db();
     $db->connect();
     $C = new ActiveRecord('lista_estados');
     $C->find(self::$id_estado);
     $db->close();
     return $C->fields;
 }
Exemplo n.º 7
0
 /**
  * Search by model pervychnomu key
  * If the pattern is not found, returns null
  * @param integer $id Ідентифікатор моделі
  * @return {Model}Lang Повернення знайденої моделі
  */
 protected function findModelLang($id)
 {
     if ($id) {
         $model = $this->modelLang->find()->andWhere(['rid' => $id])->one();
     }
     if ($model === null) {
         $model = $this->modelLang->loadDefaultValues();
     }
     return $model;
 }
Exemplo n.º 8
0
 function deleteItems()
 {
     $nr_ids = $_POST['nr_ids'];
     for ($i = 0; $i < $nr_ids; $i++) {
         $id = $_POST['delete_id_' . $i];
         $record = $this->ar->find($id);
         $record->delete();
     }
     if ($i == 1) {
         ilUtil::sendSuccess($this->getDeleteRecordMessage(), true);
     } else {
         ilUtil::sendSuccess($this->getDeleteRecordsMessage(), true);
     }
     $this->ctrl->redirect($this, "index");
 }
Exemplo n.º 9
0
 public function getPages($category)
 {
     $blog = new ActiveRecord();
     $blog->connectPdo('blogdb', 'categorytable', 'readonly', 'readonly');
     $data = $blog->findFromKey('category', $category);
     $ids = array();
     foreach ($data as $row) {
         $ids[] = $row->postid;
     }
     $blog->connectPdo('blogdb', 'blog', 'readonly', 'readonly');
     $result = array();
     foreach ($ids as $pagenum) {
         $result[] = $blog->find($pagenum);
     }
     return $result;
 }
Exemplo n.º 10
0
    /**
     *@package db_record
     *@method print_form_field()
     *@desc returns the list of html fields  automatically from a record
     *@since v0.1 beta
     * */
    public function print_form_field($field, $CssName = '', $ExtraAttributes = '', $encode_fields = FALSE, $access = TRUE, $read_only = FALSE, $code = '')
    {
        $html_fld = '';
        if ($encode_fields == TRUE) {
            $field_id_html = 'fkf_' . encode($field . $code);
            $field_name_html = encode($field . $code);
        } else {
            $field_id_html = $field . $code;
            $field_name_html = $field . $code;
        }
        $original_type = $this->form_fields[$field]['Type'];
        $type_x = explode("(", $original_type);
        if ($type_x > 1) {
            $type = $type_x[0];
        } else {
            $type = $original_type;
        }
        // Display Mode
        $mode_view_edit = $this->field_mode == 'view-edit' ? true : false;
        if ($read_only == true) {
            // read only
            $display_as = 'read-only';
        } else {
            if ($this->field_mode == 'view-edit') {
                $display_as = 'view-edit';
            } else {
                $display_as = 'edit';
            }
        }
        if ($this->useHtmlEntities_onField == true) {
            $this->fields[$field] = isset($this->fields[$field]) ? htmlentities($this->fields[$field]) : '';
        } else {
            $this->fields[$field] = isset($this->fields[$field]) ? $this->fields[$field] : '';
        }
        switch ($type) {
            case "varchar":
                // Class
                $Class = 'class="txt ' . @$CssName . '"';
                if ($access == TRUE) {
                    if ($display_as == 'view-edit') {
                        $html_fld .= '<div class="fld" onclick="appForm_updfldTxt({id:\'' . $field_id_html . '\'})"><input style="display:none" id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                        $html_fld .= '<span id="val-' . $field_id_html . '">' . @$this->fields[$field] . '</span>&nbsp;<span class="ui-icon ui-icon-gear"></span></div>';
                        $html_fld .= '<input id="cur-v-' . $field_id_html . '" type="hidden" value="' . $this->fields[$field] . '"  />';
                    } elseif ($display_as == 'edit') {
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= @$this->fields[$field] . '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    }
                }
                break;
            case "money":
                // Class
                $Class = 'class="txt ' . @$CssName . '"';
                if ($access == TRUE) {
                    if ($display_as == 'view-edit') {
                        $html_fld .= '<div class="fld" onclick="appForm_updfldTxt({id:\'' . $field_id_html . '\'})">$<input style="display:none" id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                        $html_fld .= '<span id="val-' . $field_id_html . '">' . @$this->fields[$field] . '</span>&nbsp;<span class="ui-icon ui-icon-gear"></span></div>';
                        $html_fld .= '<input id="cur-v-' . $field_id_html . '" type="hidden" value="' . $this->fields[$field] . '"  />';
                    } elseif ($display_as == 'edit') {
                        $html_fld .= '';
                        $html_fld .= '<div class="input-prepend"><span class="add-on">$</span><input id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' /></div>';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= fk_money_format($this->fields[$field]) . '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    }
                }
                break;
            case "file":
                // Class
                $Class = 'class="txt ' . @$CssName . '"';
                if ($access == TRUE) {
                    if ($display_as == 'view-edit') {
                        $html_fld .= '<div class="fld" onclick="appForm_updfldTxt({id:\'' . $field_id_html . '\'})"><input style="display:none" id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                        $html_fld .= '<span id="val-' . $field_id_html . '">' . @$this->fields[$field] . '</span>&nbsp;<span class="ui-icon ui-icon-gear"></span></div>';
                        $html_fld .= '<input id="cur-v-' . $field_id_html . '" type="hidden" value="' . $this->fields[$field] . '"  />';
                    } elseif ($display_as == 'edit') {
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                        $html_fld .= '<br><iframe src="' . fk_link() . 'FkMaster/upolader/' . $field_id_html . '/" name="ifrmupl-' . $field_id_html . '" style="width:95%;height:45px;" frameborder="0"></iframe>';
                        $file_data = '';
                        $ArUpl = new ActiveRecord('uploads');
                        $totUpl = $ArUpl->find(@$this->fields[$field]);
                        if ($totUpl == 1) {
                            if (strrpos($ArUpl->fields['tipo'], 'image') > -1) {
                                //image
                                $file_data = '<a href="' . http_uploads() . $ArUpl->fields['archivo'] . '" target="_blank"><img src="' . http_uploads() . $ArUpl->fields['archivo'] . '" ></a>';
                            } else {
                                //Other file
                                $file_data = '<a href="' . http_uploads() . $ArUpl->fields['archivo'] . '" target="_blank">' . $ArUpl->fields['titulo'] . '</a>';
                            }
                        }
                        $html_fld .= '<div id="ico-' . $field_id_html . '">' . $file_data . '</div>';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                        $file_data = '';
                        $ArUpl = new ActiveRecord('uploads');
                        $totUpl = $ArUpl->find(@$this->fields[$field]);
                        if ($totUpl == 1) {
                            if (strrpos($ArUpl->fields['tipo'], 'image') > -1) {
                                //image
                                $file_data = '<a href="' . http_uploads() . $ArUpl->fields['archivo'] . '" target="_blank"><img src="' . http_uploads() . $ArUpl->fields['archivo'] . '" ></a>';
                            } else {
                                //Other file
                                $file_data = '<a href="' . http_uploads() . $ArUpl->fields['archivo'] . '" target="_blank">' . $ArUpl->fields['titulo'] . '</a>';
                            }
                        }
                        $html_fld .= '<div id="ico-' . $this->id_field_name . '">' . $file_data . '</div>';
                    }
                }
                break;
            case "timestamp":
                // Class
                $Class = 'class="' . @$CssName . '"';
                $date_value = '';
                if (trim($this->fields[$field]) != '' && trim($this->fields[$field]) != '0000-00-00 00:00:00') {
                    $date_value = date(DATE_FORMAT . ' H:i:s', strtotime($this->fields[$field]));
                }
                if ($access == TRUE) {
                    if ($display_as == 'view-edit') {
                        $html_fld .= $this->fields[$field] . '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . $date_value . '" ' . $Class . ' ' . @$ExtraAttributes . '/>';
                        $html_fld .= '<script language="javascript" type="text/javascript">	$(function() {		$("#' . $field_id_html . '").datetimepicker({dateFormat: "' . JS_DATE_FORMAT . '",timeFormat: "hh:mm:ss",changeMonth: true,changeYear: true});});</script>';
                    } elseif ($display_as == 'edit') {
                        //$date_value = $this->fields[$field];
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . $date_value . '" ' . $Class . ' ' . @$ExtraAttributes . '/>';
                        $html_fld .= '<script language="javascript" type="text/javascript">	$(function() {		$("#' . $field_id_html . '").datetimepicker({dateFormat: "' . JS_DATE_FORMAT . '",timeFormat: "hh:mm:ss",changeMonth: true,changeYear: true});});</script>';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= $date_value . '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . $date_value . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    }
                }
                break;
            case "date-select":
                //$Class = 'class="date '.@$CssName.'"';
                $Class = 'class="' . @$CssName . '"';
                if ($access == TRUE) {
                    if ($display_as == 'view-edit') {
                        $html_fld .= '1<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . @$this->fields[$field] . '" ' . @$Class . ' ' . @$ExtraAttributes . ' />';
                        $html_fld .= '<script language="javascript" type="text/javascript">$(function() {$( "#' . $field_id_html . '" ).datetimepicker({ dateFormat: "' . JS_DATE_FORMAT . '",showOn: "button",buttonImage: HTTP+"_HTML/img/calendar.gif", buttonImageOnly: true});	});	</script>';
                    } elseif ($display_as == 'edit') {
                        $date_value = '';
                        //if(trim($this->fields[$field])!=''){$date_value = date(DATE_FORMAT,strtotime($this->fields[$field]));}
                        $date_value = $this->fields[$field];
                        $Class = rtrim(str_replace('class="', '', $Class), '"');
                        $html_fld .= fk_date_field($field_id_html, $field_name_html, $date_value, $onclick = null, $cssExtra = $Class, $mode = 'edit');
                        //$html_fld .='2<input id="'.$field_id_html.'" name="'.$field_name_html.'" type="text" value="'.$date_value.'" '.@$Class.' '.@$ExtraAttributes.' />[<a href="javascript:void(0)" onclick="$(\'#'.$field_id_html.'\').val(\''.date(DATE_FORMAT).'\')">'.__('Hoy').'</a>]';
                        //$html_fld .='<script language="javascript" type="text/javascript">$(function(){$( "#'.$field_id_html.'" ).datetimepicker({ dateFormat: "'.JS_DATE_FORMAT.'",changeMonth: true,changeYear: true});	});	</script>';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= getFormatedDate($this->fields[$field]) . '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    }
                }
                break;
            case "date":
                $Class = 'class="' . @$CssName . '"';
                if ($access == TRUE) {
                    if ($display_as == 'view-edit') {
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . @$this->fields[$field] . '" ' . @$Class . ' ' . @$ExtraAttributes . ' />';
                        $html_fld .= '<script language="javascript" type="text/javascript">$(function() {$( "#' . $field_id_html . '" ).datetimepicker({ dateFormat: "' . JS_DATE_FORMAT . '",showOn: "button",buttonImage: HTTP+"_HTML/img/calendar.gif", buttonImageOnly: true});	});	</script>';
                    } elseif ($display_as == 'edit') {
                        $date_value = '';
                        if (trim($this->fields[$field]) != '') {
                            $date_value = date(DATE_FORMAT, strtotime($this->fields[$field]));
                        }
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . $date_value . '" ' . @$Class . ' ' . @$ExtraAttributes . ' />[<a href="javascript:void(0)" onclick="$(\'#' . $field_id_html . '\').val(\'' . date(DATE_FORMAT) . '\');$(\'#' . $field_id_html . '\').change();">' . __('Hoy') . '</a>]';
                        $html_fld .= '<script language="javascript" type="text/javascript">$(function(){$( "#' . $field_id_html . '" ).datetimepicker({ dateFormat: "' . JS_DATE_FORMAT . '",changeMonth: true,changeYear: true});	});	</script>';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= getFormatedDate($this->fields[$field]) . '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    }
                }
                break;
            case "text":
                $Class = 'class="' . @$CssName . '"';
                if ($access == TRUE) {
                    if ($display_as == 'view-edit') {
                        $html_fld .= '<div class="fld" onclick="appForm_updfldTxt({id:\'' . $field_id_html . '\'})"><textarea style="display:none" id="' . $field_id_html . '" name="' . $field_name_html . '"  ' . $Class . ' ' . @$ExtraAttributes . ' >' . @$this->fields[$field] . '</textarea>';
                        $html_fld .= '<span id="val-' . $field_id_html . '">' . @$this->fields[$field] . '</span>&nbsp;<span class="ui-icon ui-icon-gear"></span></div>';
                        $html_fld .= '<input id="cur-v-' . $field_id_html . '" type="hidden" value="' . @$this->fields[$field] . '"  />';
                    } elseif ($display_as == 'edit') {
                        $html_fld .= '<textarea id="' . $field_id_html . '" name="' . $field_name_html . '"  ' . $Class . ' ' . @$ExtraAttributes . ' >' . @$this->fields[$field] . '</textarea>';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= '<div id="tx-' . $field_id_html . '">' . nl2br(@$this->fields[$field]) . '</div><input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    }
                }
                break;
            case "textarea":
                $Class = 'class="' . @$CssName . '"';
                if ($access == TRUE) {
                    if ($display_as == 'view-edit') {
                        $html_fld .= '<div class="fld" onclick="appForm_updfldTxt({id:\'' . $field_id_html . '\'})"><textarea style="display:none" id="' . $field_id_html . '" name="' . $field_name_html . '"  ' . $Class . ' ' . @$ExtraAttributes . ' >' . @$this->fields[$field] . '</textarea>';
                        $html_fld .= '<span id="val-' . $field_id_html . '">' . @$this->fields[$field] . '</span>&nbsp;<span class="ui-icon ui-icon-gear"></span></div>';
                        $html_fld .= '<input id="cur-v-' . $field_id_html . '" type="hidden" value="' . @$this->fields[$field] . '"  />';
                    } elseif ($display_as == 'edit') {
                        $html_fld .= '<textarea id="' . $field_id_html . '" name="' . $field_name_html . '"  ' . $Class . ' ' . @$ExtraAttributes . ' >' . @$this->fields[$field] . '</textarea>';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= '<div id="tx-' . $field_id_html . '">' . nl2br(@$this->fields[$field]) . '</div><input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    }
                }
                break;
            case "tinyint":
                $chk[0] = '';
                $chk[1] = '';
                $chk_read_val = @$this->fields[$field] == 1 ? 'Si' : 'No';
                if (@$this->fields[$field] == 1 || @$this->fields[$field] == 0) {
                    $chk[@$this->fields[$field]] = 'CHECKED';
                }
                $Class = 'class="' . @$CssName . '"';
                if ($access == TRUE) {
                    if ($display_as == 'view-edit' || $display_as == 'edit') {
                        $html_fld .= 'Si<input id="' . $field_id_html . '_1" name="' . $field_name_html . '" ' . $chk['1'] . ' type="radio" value="1" ' . $Class . ' ' . @$ExtraAttributes . '>
             No<input id="' . $field_id_html . '_0" name="' . $field_name_html . '" ' . $chk['0'] . ' type="radio" value="0" ' . $Class . ' ' . @$ExtraAttributes . '>';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= $chk_read_val;
                    }
                }
                break;
            case "checkbox":
                $chk[0] = '';
                $chk[1] = '';
                $chk_read_val = @$this->fields[$field] == 1 ? 'Si' : 'No';
                $chk = '';
                if (@$this->fields[$field] == 1) {
                    $chk = 'checked="checked"';
                }
                $Class = 'class="' . @$CssName . '"';
                if ($access == TRUE) {
                    if ($display_as == 'view-edit' || $display_as == 'edit') {
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . $this->fields[$field] . '" >';
                        $html_fld .= '<input id="' . $field_id_html . '_1" name="' . $field_name_html . '_1" ' . $chk . ' type="checkbox" value="1" onclick="if($(this).is(\':checked\')==true){$(\'#' . $field_id_html . '\').val(1);}else{$(\'#' . $field_id_html . '\').val(0);}" ' . $Class . ' ' . @$ExtraAttributes . '>';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= $chk_read_val;
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . $this->fields[$field] . '" >';
                    }
                }
                break;
                // Tipo Password
            // Tipo Password
            case "password":
                $Class = 'class="pass ' . @$CssName . '"';
                if ($access == TRUE) {
                    if ($display_as == 'view-edit') {
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="password" value="" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    } elseif ($display_as == 'edit') {
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="password" value="" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= '********';
                    }
                }
                break;
            case "select":
                // Get Select Options from sql
                $Class = 'class="sel ' . @$CssName . '"';
                if ($access == TRUE) {
                    $option_selected = isset($this->form_fields[$field]['selected_option']) ? $this->form_fields[$field]['selected_option'] : @$this->fields[$field];
                    if ($display_as == 'view-edit') {
                        $options = fk_select_options($this->form_fields[$field]['sql_options'], $option_selected);
                        $html_fld .= '<select id="' . $field_id_html . '" name="' . $field_name_html . '" ' . $Class . ' ' . @$ExtraAttributes . ' ><option></option>' . $options . '</select>';
                    } elseif ($display_as == 'edit') {
                        $add_new_op = '';
                        $add_new_txt = '';
                        if (isset($this->form_fields[$field]['add_new'])) {
                            $add_new_op = '<option value="new">+ Nuevo</option>';
                            $add_new_txt .= '<input type="text" id="' . $field_id_html . '-txt" name="' . $field_name_html . '-txt" style="display:none" >';
                            $add_new_txt .= '<a href="javascript:void(0)" id="' . $field_id_html . '-cancel" style="display:none" onclick="fkSelect($(this),true);" >Cancelar</a>';
                        }
                        $options = fk_select_options($this->form_fields[$field]['sql_options'], $option_selected);
                        $html_fld .= '<select id="' . $field_id_html . '" name="' . $field_name_html . '" ' . $Class . ' ' . @$ExtraAttributes . ' onchange="fkSelect($(this),false);" ><option></option>' . $options . $add_new_op . '</select>';
                        $html_fld .= $add_new_txt;
                    } elseif ($display_as == 'read-only') {
                        if (isset($this->form_fields[$field]['sql_complex'])) {
                            // query complex version
                            $options = fk_select_complex_query($this->form_fields[$field]['sql_complex'], array($option_selected));
                        } else {
                            // Simple query version
                            $slq_elements = fk_get_query_elements($this->form_fields[$field]['sql_options']);
                            $table = $slq_elements['table'];
                            $val_fld_name = $slq_elements['fields'];
                            $options = fk_select_text($table, $val_fld_name, $option_selected);
                        }
                        $html_fld .= $options[1] . '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" />';
                    }
                }
                break;
            case "hidden":
                $Class = 'class="hdn ' . @$CssName . '"';
                $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                break;
            case "search_field":
                // Class
                $Class = 'class="txt ' . @$CssName . '"';
                if ($access == TRUE) {
                    $option_selected = isset($this->form_fields[$field]['selected_option']) ? $this->form_fields[$field]['selected_option'] : @$this->fields[$field];
                    if ($display_as == 'view-edit') {
                        $html_fld .= '<div class="fld" onclick="appForm_updfldTxt({id:\'' . $field_id_html . '\'})"><input style="display:none" id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                        $html_fld .= '<span id="val-' . $field_id_html . '">' . @$this->fields[$field] . '</span>&nbsp;<span class="ui-icon ui-icon-gear"></span></div>';
                        $html_fld .= '<input id="cur-v-' . $field_id_html . '" type="hidden" value="' . $this->fields[$field] . '"  />';
                    } elseif ($display_as == 'edit') {
                        $options = fk_select_complex_query($this->form_fields[$field]['sql_complex'], array($option_selected));
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '"  />';
                        $html_fld .= '<input id="' . $field_id_html . '-2" name="' . $field_name_html . '-2" type="text" value="' . @$options[1] . '" class="txt ' . $CssName . ' searchbox" ' . @$ExtraAttributes . ' onblur="appForm_PopupSrc({id:\'' . $field_id_html . '\',tbl:\'' . $this->table . '\'})" />
						<input type="button" id="' . $field_id_html . '-btn" value="&nbsp;" class="btn search2" onclick="appForm_PopupSrc({id:\'' . $field_id_html . '\',tbl:\'' . $this->table . '\',forceOpen:true})">
						<input type="button" id="' . $field_id_html . '-btn" class="btn empty" value="&nbsp;" onclick="appForm_ClearPopupSrc({id:\'' . $field_id_html . '\',tbl:\'' . $this->table . '\'});">
						';
                        $html_fld .= '<div id="srcfld-rs-' . $field_id_html . '"></div>';
                    } elseif ($display_as == 'read-only') {
                        $options = fk_select_complex_query($this->form_fields[$field]['sql_complex'], array($option_selected));
                        $html_fld .= @$options[1] . '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    }
                }
                break;
            default:
                $Class = 'class="txt ' . @$CssName . '"';
                if ($access == TRUE) {
                    if ($display_as == 'view-edit') {
                        $html_fld .= '<div class="fld" onclick="appForm_updfldTxt({id:\'' . $field_id_html . '\'})"><input style="display:none" id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                        $html_fld .= '<span id="val-' . $field_id_html . '">' . @$this->fields[$field] . '</span>&nbsp;<span class="ui-icon ui-icon-gear"></span></div>';
                        $html_fld .= '<input id="cur-v-' . $field_id_html . '" type="hidden" value="' . @$this->fields[$field] . '"  />';
                    } elseif ($display_as == 'edit') {
                        $html_fld .= '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="text" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    } elseif ($display_as == 'read-only') {
                        $html_fld .= @$this->fields[$field] . '<input id="' . $field_id_html . '" name="' . $field_name_html . '" type="hidden" value="' . @$this->fields[$field] . '" ' . $Class . ' ' . @$ExtraAttributes . ' />';
                    }
                }
                break;
        }
        return $html_fld;
    }
Exemplo n.º 11
0
 public function test_add_group_by_clause()
 {
     $this->Db->expectAt(0,'select',array('SELECT * FROM hybrids GROUP BY id','selecting'));
     $this->Hybrid->find('all',array('group'=>'id'));
 }
Exemplo n.º 12
0
 static function find($id, $options = null)
 {
     return parent::find(__CLASS__, $id, $options);
 }
Exemplo n.º 13
0
/**
 * @desc File field Object
 * */
function fk_file_field($id, $name, $value, $onclick = null, $cssExtra = '', $mode = 'edit')
{
    $html_fld = '';
    if ($mode == 'edit') {
        $html_fld .= '<input id="' . $id . '" name="' . $name . '" type="hidden" value="' . $value . '" class="' . $cssExtra . '" />';
        $html_fld .= '<br><iframe src="' . fk_link() . 'FkMaster/upolader/' . $id . '/" name="ifrmupl-' . $id . '" style="width:95%;height:30px;" frameborder="0"></iframe>';
    }
    $file_data = '';
    $ArUpl = new ActiveRecord('uploads');
    $totUpl = $ArUpl->find($value);
    if ($totUpl == 1) {
        if (strrpos($ArUpl->fields['tipo'], 'image') > -1) {
            //image
            $file_data = '<a href="' . http_uploads() . $ArUpl->fields['archivo'] . '" target="_blank"><img src="' . http_uploads() . $ArUpl->fields['archivo'] . '" ></a>';
        } else {
            //Other file
            $file_data = '<a href="' . http_uploads() . $ArUpl->fields['archivo'] . '" target="_blank">' . $ArUpl->fields['titulo'] . '</a>';
        }
    }
    $html_fld .= '<div id="ico-' . $id . '">' . $file_data . '</div>';
    return $html_fld;
}
Exemplo n.º 14
0
 private function deleteLine()
 {
     $tableId = fk_post('tId');
     $id = fk_post($tableId . '_recId-' . fk_post('recIdToDel'));
     if ($id > 0) {
         $Ar = new ActiveRecord($this->table_name);
         $Ar->find($id);
         $Ar->delete();
     }
 }
Exemplo n.º 15
0
<form id="frm3" id="frm3" onsubmit="return false;">
<h1>Paso 2 de 3</h1>
<div>
<?php 
echo fk_message('warning', '<b>Elija informaci&oacute;n:</b> Seleccione las columnas y los renglones que desea importar', false);
$Imp = new FileImporter();
$File = new ActiveRecord('uploads');
$File->find(fk_post('archivo'));
$f = uploads_directory() . '/' . $File->fields['archivo'];
$tablefields = $GLOBALS['tableFields'];
?>
<div style="width:100%; height:500px; overflow:auto;">
<?php 
// Imprime tabla de resultado
$Imp->importExcelData($f, $tablefields);
?>
</div>
<input type="button" class="btn" onclick="$('#cont').show(800); $('#cont2').hide(800);" value=" &laquo; Regresar ">
<input type="submit" class="btn" value="Importar &raquo;">

</div>
<div class="clear"></div>
</form>
 <script type="text/javascript">
<!--

$("#frm3").validate({
	 submitHandler: function(form) {
		 
		      var pArgs = {pDiv:'cont3', 
						  pUrl:'<?php 
Exemplo n.º 16
0
 public function delete_file($id)
 {
     $rs = false;
     $File = new ActiveRecord('uploads');
     if ($File->find($id)) {
         $subfolder = $File->fields['folder'] != '' ? $File->fields['folder'] . '/' : '';
         $path = $File->fields['ruta'] . $subfolder . $File->fields['archivo'];
         $File->delete();
         if (@unlink($path)) {
             $rs = true;
         }
     }
     return $rs;
 }
Exemplo n.º 17
0
 static function authenticate_hash($name, $pass)
 {
     $user = parent::find('first', array('conditions' => array("lower(name) = lower(?) AND password_hash = ?", $name, $pass)));
     return $user;
 }
Exemplo n.º 18
0
<?php

define('SMARTY_DIR', '/usr/share/php/smarty3/');
require_once 'activerecord.php';
require_once SMARTY_DIR . 'Smarty.class.php';
$smarty = new Smarty();
$smarty->template_dir = '/srv/smarty/templates';
$smarty->compile_dir = '/srv/smarty/templates_c';
$smarty->config_dir = '/srv/smarty/configs';
$smarty->cache_dir = '/srv/smarty/cache';
$blog = new ActiveRecord();
$blog->connectPdo('blogdb', 'blog', 'readonly', 'readonly');
$num = $blog->size();
$pages = $blog->pickout($num - 10, 10);
$items = array();
$category = new ActiveRecord();
$category->connectPdo('blogdb', 'categorytable', 'readonly', 'readonly');
$categories = $category->find($num - 2)->category;
for ($i = 0; $i < 10; $i++) {
    $categorystr = $category->find($num - (9 - $i))->category;
    $datetime = new DateTime($pages[9 - $i]->date);
    $items[$i] = array('title' => $pages[9 - $i]->title, 'link' => "http://pakutoma.pw/?page={$pages[9 - $i]->pagenum}", 'category' => $categorystr, 'description' => mb_substr(str_replace("\n", " ", strip_tags($pages[9 - $i]->text)), 0, 40) . '...', 'pubDate' => $datetime->format(DATE_RSS));
}
$smarty->assign('items', $items);
$smarty->display('rss.tpl');
Exemplo n.º 19
0
            $data = $archiveview->getPages($archive);
            if (!isset($data[0]->pagenum)) {
                echo "データが存在しません。";
                return;
            }
            $latest = new LatestPages();
            $category = new Category();
            $archive = new Archive();
            foreach (array_reverse($data) as $page) {
                $main[] = array('title' => $page->title, 'date' => $page->date, 'text' => mb_substr($page->text, 0, mb_strpos($page->text, "<br />")), 'pagenum' => $page->pagenum);
            }
            $smarty->assign('title', 'アーカイブ:' . $_GET['archive']);
        } else {
            $blog = new ActiveRecord();
            $blog->connectPdo('blogdb', 'blog', 'readonly', 'readonly');
            $data = $blog->find($blog->size());
            if (!isset($data->pagenum)) {
                echo "データが存在しません。";
                return;
            }
            $latest = new LatestPages();
            $category = new Category();
            $archive = new Archive();
            $main[] = array('title' => $data->title, 'date' => $data->date, 'text' => $data->text);
            $smarty->assign('prev', $blog->find($blog->size() - 1));
        }
    }
}
$smarty->assign('main', $main);
$smarty->assign('latest', $latest->getPages());
$smarty->assign('category', $category->getCategory());
Exemplo n.º 20
0
 /**
  * Return the statement
  * @return Statement
  */
 public function all()
 {
     return $this->model->find($this->get());
 }
Exemplo n.º 21
0
 /**
  * @param       $primary_key
  * @param array $add_constructor_args
  *
  * @return ilUDFCheck
  */
 public static function find($primary_key, array $add_constructor_args = array())
 {
     return parent::find($primary_key, $add_constructor_args);
     // TODO: Change the autogenerated stub
 }
Exemplo n.º 22
0
 function set_ids($ids)
 {
     $records = ActiveRecord::find($this->class_name(), $ids);
     if ($this->owner->is_new_record()) {
         $this->collection = $records;
         $this->initialize_collection_ids_from_collection();
     } else {
         $diff;
         $this->calculate_collections_diff($records, $diff);
         $this->add_and_remove_records($diff['new'], $diff['removed']);
     }
 }