Comments (9)
As I mentioned here http://stackoverflow.com/questions/15167249/agile-toolkit-modelgenerator-gives-errors
I fixed that exact issue in 8e6f562 commit. You should download newst version of addons and try then. I'm not sure that you'll not get any more errors (because ModelGenerator is quite old and probably a bit obsolete), but at least not this particular one :)
Please let me know if this helps and if I can close this issue.
from atk4-addons.
Dear DarkSide666,
:) two first warnings are now gone but there is some more error information:
Application Error: Method is not defined for this object
Exception_Logic, code: 0
Additional information:
class: DB
method: getAll
arguments:
0: show tables
/volume1/web/sportin/atk4/lib/AbstractObject.php:783
Stack trace:
File Object Name Stack Trace
/volume1/web/sportin/atk4/lib/BaseException.php :39 Exception_Logic Exception_Logic->collectBasicData(Null)
/volume1/web/sportin/atk4/lib/AbstractObject.php :493 Exception_Logic Exception_Logic->__construct("Method is not defined for this object", Null)
/volume1/web/sportin/atk4/lib/AbstractObject.php :783 sample_project_db DB->exception("Method is not defined for this object", "Logic")
/volume1/web/sportin/atk4-addons/mvc/Page/ModelGenerator.php :56 sample_project_db DB->__call("getAll", Array(1))
/volume1/web/sportin/atk4-addons/mvc/Page/ModelGenerator.php :56 sample_project_db DB->getAll("show tables")
/volume1/web/sportin/atk4-addons/mvc/Page/ModelGenerator.php :15 sample_project_ModelGeneratorAre page_ModelGeneratorAre->findModels()
/volume1/web/sportin/atk4/lib/AbstractObject.php :289 sample_project_ModelGeneratorAre page_ModelGeneratorAre->init()
/volume1/web/sportin/atk4/lib/ApiFrontend.php :124 sample_project Frontend->add("page_ModelGeneratorAre", "ModelGeneratorAre", "Content")
/volume1/web/sportin/atk4/lib/ApiWeb.php :408 sample_project Frontend->layout_Content()
/volume1/web/sportin/atk4/lib/ApiFrontend.php :38 sample_project Frontend->addLayout("Content")
/volume1/web/sportin/atk4/lib/ApiWeb.php :276 sample_project Frontend->initLayout()
/volume1/web/sportin/index.php :15 sample_project Frontend->main()
Note: To hide this information from your users, add $config['logger']['web_output']=false to your config.php file. Refer to documentation on 'Logger' for alternative logging options
from atk4-addons.
OK, can you test now after 6b55c43 commit?
from atk4-addons.
another error:
Application Error: Database Query Failed
Exception_DB, code: 0
Additional information:
pdo_error: SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''
mode:
params:
query: desc template: desc
/volume1/web/sportin/atk4/lib/DB/dsql.php:1513
Stack trace:
File Object Name Stack Trace
/volume1/web/sportin/atk4/lib/BaseException.php :39 Exception_DB Exception_DB->collectBasicData(Null)
/volume1/web/sportin/atk4/lib/AbstractObject.php :493 Exception_DB Exception_DB->__construct("Database Query Failed", Null)
/volume1/web/sportin/atk4/lib/DB/dsql.php :1513 sample_project_db_db_dsql_mysql_4 DB_dsql_mysql->exception("Database Query Failed")
/volume1/web/sportin/atk4/lib/DB/dsql.php :1631 sample_project_db_db_dsql_mysql_4 DB_dsql_mysql->execute()
/volume1/web/sportin/atk4-addons/mvc/Page/ModelGenerator.php :62 sample_project_db_db_dsql_mysql_4 DB_dsql_mysql->get()
/volume1/web/sportin/atk4-addons/mvc/Page/ModelGenerator.php :15 sample_project_ModelGeneratorAre page_ModelGeneratorAre->findModels()
/volume1/web/sportin/atk4/lib/AbstractObject.php :289 sample_project_ModelGeneratorAre page_ModelGeneratorAre->init()
/volume1/web/sportin/atk4/lib/ApiFrontend.php :124 sample_project Frontend->add("page_ModelGeneratorAre", "ModelGeneratorAre", "Content")
/volume1/web/sportin/atk4/lib/ApiWeb.php :408 sample_project Frontend->layout_Content()
/volume1/web/sportin/atk4/lib/ApiFrontend.php :38 sample_project Frontend->addLayout("Content")
/volume1/web/sportin/atk4/lib/ApiWeb.php :276 sample_project Frontend->initLayout()
/volume1/web/sportin/index.php :15 sample_project Frontend->main()
Note: To hide this information from your users, add $config['logger']['web_output']=false to your config.php file. Refer to documentation on 'Logger' for alternative logging options
from atk4-addons.
Maybe you can try to take out backtick symbols around $table in ModelGenerator.php line 62.
Not sure if that helps, but you can try.
I'm off to sleep now.
from atk4-addons.
this is the code which executes without errors: now I'll try to use it ...
<?php
class Page_ModelGenerator Extends Page {
private $capitalize = true;
private $postfix = "Core";
protected $skip_pages = false;
function init(){
parent::init();
/* dirty. will clean up later, but working well */
$this->add("Text")->set("Welcome. This is Model Creator Kit. It will use mysql database to create models for you");
$c=$this->add('Columns');
$f=$c->addColumn('50%')->add('Form');
$l=$this->api->locatePath('php','Model');
list($tables, $fields) = $this->findModels();
$tables = array("-1" => "All") + $tables;
$f->addField('dropdown','table')->setValueList($tables);
$f->addButton('create')->js("click", $f->js()->submit());
$r=$c->addColumn('50%');
$output_object=$r->add('HtmlElement');
$create_object=$r->add('HtmlElement')->setElement('pre');
if($f->isSubmitted()){
$code = "";
if ($f->get("table") == -1){
foreach ($tables as $k => $table){
if ($k > -1){
$code .= htmlspecialchars($this->generateModel($table, $fields[$table], $tables));
}
}
} else {
$code = $this->generateModel($tables[$f->get("table")], $fields[$tables[$f->get("table")]], $tables);
}
$create_object->js()->html($code)->execute();
return;
}
}
function resolveFieldType($type){
$cast = array(
"int" => "int(11)",
"money" => "decimal(10,2)",
"datetime" => "datetime",
"date" => "date",
"string" => "varchar(255)",
"text" => "text",
"boolean" => "enum('Y','N')",
);
$ret = array_search($type, $cast);
return $ret?$ret:"string";
}
function resolveFieldName($field){
return $field->name();
}
function findModels($dir=null, &$models=null, $prefix = null){
$r = $this->api->db->dsql()->expr('show tables')->get();
$tables = array();
foreach ($r as $row){
$arrVals = array_values($row);
$tables[] = $arrVals[0];
}
foreach ($tables as $table){
if ($table){
$fields[$table] = $this->api->db->dsql()->expr("desc `$table`")->get();
}
}
return array($tables, $fields);
}
function generateModel($table, $fields, $tables){
$ignore = $this->api->getConfig("mg/ignore", array());
if ($ignore){
foreach ($ignore as $pattern){
if (preg_match("/$pattern/", $table)){
return "Ignoring $table ($pattern)\n";
}
}
}
$v = $this->add("View", null, null, array("view/model"));
$v->template->set("php", "<?php");
$v->template->set("class_name", "Model_" . $this->getModelByTable($table) ."_" . $this->postfi . $this->postfix);
$v->template->set("entity_code", $table);
$v->template->set("extends", "Model_Table");
$v->template->set("table_alias", "al_" . substr($table, 0, 2));
$l = $v->add("Lister", null, "field_lister", array("view/model", "field_lister"));
$l->safe_html_output = false;
foreach ($fields as $k => $field){
if ($field["Field"] == "id"){
unset($fields[$k]);
continue;
}
$fields[$k]["datatype"] = $this->resolveFieldType($field["Type"]);
if ((array_search(substr($field["Field"], 0, -3), $tables) !== false) && (substr($field["Field"], -2) == "id")){
$fields[$k]["aux"] .= "->refModel(\"Model_" . $this->getModelByTable(substr($field["Field"], 0, -3)) ."\")";
} else {
$fields[$k]["aux"] .= "";
}
if ($field["Field"] == "deleted"){
$fields[$k]["aux"] .= "->system(true)->visible(false)";
}
}
$l->setStaticSource($fields);
$m = (string)$v;
$lbase = "lib/Model";
$pbase = "page";
$chunks = explode("_", $table);
$model_name = $this->uc($chunks[count($chunks)-1]);
$page_name = strtolower($this->uc($chunks[count($chunks)-1]));
$auto_model_name = $this->uc($model_name) . "_" . $this->postfix;
foreach ($chunks as $chunk){
$chunk = $this->uc($chunk);
/* create model dir */
$dir=$lbase ."/". $chunk;
if (!file_exists($dir)){
$out .= "Created dir $dir\n";
mkdir($dir);
}
$lbase = $lbase ."/" . $chunk;
/* create page dir */
if (!$this->skip_pages){
if ($model_name != $chunk){
$dir = $pbase ."/". strtolower($chunk);
if (!file_exists($dir)){
$out .= "Created dir $dir\n";
mkdir($dir);
}
$pbase = $pbase ."/" . strtolower($chunk);
}
}
}
$fid = fopen($file=$lbase . "/" . $this->postfix . ".php", "w");
$out .= "Created $file\n";
fputs($fid, $m);
fclose($fid);
if (!file_exists($file=$lbase . ".php")){
$out .= "Created $file\n";
$v = $this->add("View", null, null, array("view/model_core"));
$v->template->set("php", "<?php");
$v->template->set("class_name", "Model_" . $this->getModelByTable($table));
$v->template->set("extends", "Model_" . $this->getModelByTable($table) ."_" . $this->postfix);
$fid = fopen($lbase . ".php", "w");
fputs($fid, (string)$v);
fclose($fid);
}
if (!$this->skip_pages){
if (!file_exists($file=$pbase."/".$page_name. ".php")){
$out .= "Created $file\n";
$v = $this->add("View", null, null, array("view/page"));
$v->template->set("model", $this->getModelByTable($table));
$v->template->set("pmodel", strtolower($table));
$v->template->set("php", "<?php");
$fid = fopen($pbase."/" . $page_name . ".php", "w");
fputs($fid, (string)$v);
fclose($fid);
}
}
return $out;
}
function getModelByTable($table){
if (!$this->capitalize){
return $table;
}
$table=str_replace('_',' ',$table);
$table=ucwords($table);
$table=str_replace(' ','_',$table);
return $table;
}
function uc($p){
if (!$this->capitalize){
return $p;
}
return ucfirst($p);
}
}
from atk4-addons.
OK, thanks! I'll check it out I guess tomorrow.
from atk4-addons.
So if I try to choose a table and I hit create I am getting the following error:
Error in AJAX response: SyntaxError: Unexpected token <
Application Error: File not found
Exception_PathFinder, code: 0
Additional information:
file: view/model.html
type: template
attempted_locations:
0: /var/services/web/sportin/templates/default/view/model.html
1: /volume1/web/sportin/atk4/templates/default/view/model.html
2: /volume1/web/sportin/atk4/templates/shared/view/model.html
/volume1/web/sportin/atk4/lib/PathFinder.php:207
Stack trace:
File Object Name Stack Trace
/volume1/web/sportin/atk4/lib/BaseException.php :39 Exception_PathFinder Exception_PathFinder->collectBasicData(Null)
/volume1/web/sportin/atk4/lib/AbstractObject.php :493 Exception_PathFinder Exception_PathFinder->__construct("File not found", Null)
/volume1/web/sportin/atk4/lib/PathFinder.php :207 sample_project_pathfinder PathFinder->exception("File not found")
/volume1/web/sportin/atk4/lib/ApiCLI.php :248 sample_project_pathfinder PathFinder->locate("template", "view/model.html", "path")
/volume1/web/sportin/atk4/lib/SMlite.php :428 sample_project Frontend->locatePath("template", "view/model.html")
/volume1/web/sportin/atk4/lib/SMlite.php :455 sample_project_smlite_12 SMlite->findTemplate("view/model")
/volume1/web/sportin/atk4/lib/AbstractView.php :198 sample_project_smlite_12 SMlite->loadTemplate("view/model")
/volume1/web/sportin/atk4/lib/AbstractObject.php :281 sample_project_ModelGeneratorAre_view View->initializeTemplate(Null, Array(1))
/volume1/web/sportin/atk4-addons/mvc/Page/ModelGenerator.php :80 sample_project_ModelGeneratorAre page_ModelGeneratorAre->add("View", Null, Null, Array(1))
/volume1/web/sportin/atk4-addons/mvc/Page/ModelGenerator.php :32 sample_project_ModelGeneratorAre page_ModelGeneratorAre->generateModel("competition", Array(3), Array(9))
/volume1/web/sportin/atk4/lib/AbstractObject.php :289 sample_project_ModelGeneratorAre page_ModelGeneratorAre->init()
/volume1/web/sportin/atk4/lib/ApiFrontend.php :124 sample_project Frontend->add("page_ModelGeneratorAre", "ModelGeneratorAre", "Content")
/volume1/web/sportin/atk4/lib/ApiWeb.php :408 sample_project Frontend->layout_Content()
/volume1/web/sportin/atk4/lib/ApiFrontend.php :38 sample_project Frontend->addLayout("Content")
/volume1/web/sportin/atk4/lib/ApiWeb.php :276 sample_project Frontend->initLayout()
/volume1/web/sportin/index.php :15 sample_project Frontend->main()
Note: To hide this information from your users, add $config['logger']['web_output']=false to your config.php file. Refer to documentation on 'Logger' for alternative logging options
from atk4-addons.
Did you manage to fix this? If so, then maybe you can make pull request?
from atk4-addons.
Related Issues (20)
- suggestion: add Comment class - allowing users to post comments.
- filestore relies on Volume to be with ID=1 HOT 1
- Drilldown field don't save values on POST HOT 1
- suggestion: improve Doc_HowTo to allow to provide templates. As a result it should allow you to locally create a example and then upload it and import on other system
- when image is being deleted, it leaves record in filestore_image table
- Comment_cnt instead of comment_cnt HOT 1
- ATK4Addons.php - what's this? HOT 2
- Filestore: mime_content_type is deprecated HOT 1
- translation: Controller_Basic fixes
- create some sort of class for managing meta keywords on pages. Something like - $api->add('SEO') and it would come a model and some lightweight admin panel.
- model with recursive reference does not work HOT 7
- ref 31 is not solved still: reopen HOT 1
- AgileToolkit OAuth add-on error 500 at facebook's mobile site HOT 2
- Warning! Potential security vulnerability and data loss. HOT 1
- ModelGenerator.php error HOT 1
- ability to customize filename in filestore HOT 1
- autocomplete not working HOT 3
- highChard doesn't work
- highChard doesn't work HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atk4-addons.