コード例 #1
0
ファイル: Post.php プロジェクト: sania00/ideal
 public function beforeSave()
 {
     if (strlen($this->name) < 3) {
         $this->errors['name'] = 'Слишком короткий заголовок';
     }
     return parent::beforeSave();
 }
コード例 #2
0
ファイル: EntityArray.php プロジェクト: roccosportal/pvik
 /**
  * Returns a list of an field.
  * @param type $fieldName
  * @return EntityArray 
  */
 public function getList($fieldName)
 {
     $list = new EntityArray();
     if ($this->modelTable != null) {
         $helper = $this->modelTable->getFieldDefinitionHelper();
         if ($helper->isTypeForeignObject($fieldName) || $helper->isTypeManyForeignObjects($fieldName)) {
             $list->setModelTable($helper->getModelTable($fieldName));
         }
     }
     foreach ($this as $object) {
         $list->append($object->{$fieldName});
     }
     return $list;
 }
コード例 #3
0
 private function criarMatrizCampos($tabela)
 {
     $campos = ModelTable::getDescTabela($tabela);
     foreach ($campos as $describle) {
         if (empty($describle['Key']) || $describle['Key'] == "PRI") {
             // se não for uma FK
             $p = strpos($describle['Field'], '_');
             $campo = substr($describle['Field'], $p + 1);
             // copia depois do primeiro "_"
         } else {
             $campo = $describle['Field'];
         }
         $campo = strtolower($campo);
         if (strpos($campo, "_") > 0) {
             $p = Strpos($campo, '_');
             $aux = ucwords(str_replace("_", " ", substr($campo, $p + 1)));
             $campo = substr($campo, 0, $p) . str_replace(" ", "", $aux);
         }
         $camposSaida[$describle['Field']] = array("campo" => "_" . $campo, "obs" => $describle['Key']);
     }
     return $camposSaida;
 }
コード例 #4
0
ファイル: SystemApiController.php プロジェクト: ekowabaka/wyf
 public function query()
 {
     global $redirectedPackage;
     global $packageSchema;
     $object = unserialize(base64_decode($_REQUEST["object"]));
     $redirectedPackage = $object['redirected_package'];
     $packageSchema = $object['package_schema'];
     $model = Model::load($object["model"]);
     if (isset($_REQUEST["conditions"])) {
         $conditions = explode(",", $_REQUEST["conditions"]);
         array_pop($conditions);
         //array_shift($conditions);
         foreach ($conditions as $i => $condition) {
             if (substr_count($condition, "==")) {
                 $parts = explode("==", $condition);
                 $conditions[$i] = $parts[0] . "=" . $parts[1];
             } else {
                 $parts = explode("=", $condition);
                 $conditions[$i] = $model->getSearch($parts[1], $parts[0]);
                 //"instr(lower({$parts[0]}),lower('".$model->escape($parts[1])."'))>0";//$parts[0] ." in '".$model->escape($parts[1])."'";
             }
         }
         $condition_opr = isset($_REQUEST["conditions_opr"]) ? $_REQUEST["conditions_opr"] : "AND";
         $conditions = implode(" {$condition_opr} ", $conditions);
     }
     $params = array("fields" => $object["fields"], "sort_field" => isset($_REQUEST["sort"]) ? $_REQUEST["sort"] : $object["sortField"], "sort_type" => isset($_REQUEST["sort_type"]) ? $_REQUEST["sort_type"] : "ASC", "limit" => $object["limit"], "offset" => $_REQUEST["offset"], "conditions" => "({$conditions}) " . ($object['and_conditions'] != '' ? " AND ({$object['and_conditions']})" : '') . ($_REQUEST['and_conditions'] != '' ? " AND ({$_REQUEST['and_conditions']})" : ''));
     //$data = $model->formatData();
     switch ($_REQUEST["action"]) {
         case "delete":
             $ids = json_decode($_REQUEST["params"]);
             foreach ($ids as $id) {
                 $data = $model->getWithField($model->getKeyField(), $id);
                 $model->delete($model->getKeyField("primary"), $id);
                 User::log("Deleted " . $model->name, $data[0]);
             }
             break;
     }
     switch ($object["format"]) {
         case "tbody":
             include "lib/tapi/Table.php";
             include "lib/tapi/ModelTable.php";
             $table = new ModelTable($prefix . "/" . str_replace(".", "/", $object["model"]) . "/");
             print json_encode(array("tbody" => $table->render(false), "footer" => $table->renderFooter()));
             break;
         case "json":
             $data = $model->get($params);
             print json_encode($data);
             break;
     }
 }
コード例 #5
0
ファイル: urlaccess.php プロジェクト: rocksyne/wyf
            $conditions[$i] = $model->getSearch($parts[1], $parts[0]);
            //"instr(lower({$parts[0]}),lower('".$model->escape($parts[1])."'))>0";//$parts[0] ." in '".$model->escape($parts[1])."'";
        }
    }
    $condition_opr = isset($_REQUEST["conditions_opr"]) ? $_REQUEST["conditions_opr"] : "AND";
    $conditions = implode(" {$condition_opr} ", $conditions);
}
$params = array("fields" => $object["fields"], "sort_field" => isset($_REQUEST["sort"]) ? $_REQUEST["sort"] : $object["sortField"], "sort_type" => isset($_REQUEST["sort_type"]) ? $_REQUEST["sort_type"] : "ASC", "limit" => $object["limit"], "offset" => $_REQUEST["offset"], "conditions" => "({$conditions}) " . ($object['and_conditions'] != '' ? " AND ({$object['and_conditions']})" : '') . ($_REQUEST['and_conditions'] != '' ? " AND ({$_REQUEST['and_conditions']})" : ''));
//$data = $model->formatData();
switch ($_REQUEST["action"]) {
    case "delete":
        $ids = json_decode($_REQUEST["params"]);
        foreach ($ids as $id) {
            $data = $model->getWithField($model->getKeyField(), $id);
            $model->delete($model->getKeyField("primary"), $id);
            User::log("Deleted " . $model->name, $data[0]);
        }
        break;
}
switch ($object["format"]) {
    case "tbody":
        include "lib/tapi/Table.php";
        include "lib/tapi/ModelTable.php";
        $table = new ModelTable($prefix . "/" . str_replace(".", "/", $object["model"]) . "/");
        print json_encode(array("tbody" => $table->render(false), "footer" => $table->renderFooter()));
        break;
    case "json":
        $data = $model->get($params);
        print json_encode($data);
        break;
}
コード例 #6
0
ファイル: Entity.php プロジェクト: roccosportal/pvik
 /**
  * Returns the model table for this entity
  * @return ModelTable
  */
 public function getModelTable()
 {
     return ModelTable::get($this->modelTableName);
 }
コード例 #7
0
 public function gerar_models()
 {
     $tabelas = $_POST['tabela'];
     $model = new ModelTable($tabelas);
     $this->view("morgana/lista_gerada", " - Projeto via MorganaFramework", $resposta = $model->gerarModels());
 }