PDA

View Full Version : Symfony Extjs2.0a generator



lvanderree
11 Oct 2007, 10:24 AM
I've created an Extjs plugin for symfony, (still in active development!)

maybe you can use it, maybe you can learn from it, maybe you can improve it.

Take a look at:
http://www.symfony-project.com/forum/index.php/m/37283/#msg_37283
and
http://svn.symfony-project.com/plugins/sfExtjsThemePlugin/

Cheers
Leon

lvanderree
7 Nov 2007, 1:36 PM
I have put a demo site online:

http://fun4me.demon.nl/test/test_dev.php

(edit screens might be broken at the moment)

Symfony is a PHP-framework with the ability to generate (scafold) list/edit pages. I changed the generator-theme (with the help of the community) to output Extjs powered pages.

You can create this example in symfony with the plugin by defining the data-model:


propel:
country:
id:
name: {type: varchar(255), required: true}
abbreviation: {type: varchar(255), required: true}

city:
id:
country_id:
name: {type: varchar(255), required: true}



and the page:


generator:
class: sfExtjsPropelAdminGenerator
param:
model_class: City
theme: extjs

fields:
country/name:
name: Country name
params:
editable: true
country/abbreviation:
name: Abbreviation
params:
editable: true

list:
display: [=name, country/name, country/abbreviation]

lvanderree
5 Dec 2007, 5:44 PM
The live demo starts to work and get functional... (although still very much work in progress...)

If anyone has some tips/questions, please tell me/ask me.

All 3 pages you can see are being generated, by a file similar to the one mentioned before.

SilveR316
6 Dec 2007, 10:16 AM
Looks great, can't wait till this becomes a fully integrated with symfony.

I created a few ExtJS helpers for symfony a few months back that I use to generated components (mainly grids) over and over on a few pages, but it would be great if we could get this to work with the admin generator.

lvanderree
6 Dec 2007, 2:21 PM
I don't know if I understood you completely so just to make sure: my work already works from the admin generator. you can get it from the svn from symfony, for more info see the symfony forum or symfony wiki of how to -get the code and make it work with your applications. Feel also free to contact me if you've got questions, remarks or tips. I would also like to see your work so it can improve this plugin if you agree.

snk00sj
11 Dec 2007, 7:12 AM
you're doing a great job lvanderree, keep it up :)

tidal
12 Dec 2007, 9:32 AM
Hhm, I am working on something similar (connecting symfony and Ext JS)!
But I didn

lvanderree
13 Dec 2007, 1:59 AM
[QUOTE=tidal;98185]Hhm, I am working on something similar (connecting symfony and Ext JS)!
But I didn

tidal
13 Dec 2007, 2:34 AM
Hi!

Thanx for the information :)!

Our Approach has been not to extend the symfony
admin generator, but to write kind of a proxy for it.
You have one module, where you can fetch all the
information of registered models and get the data
in one place. The original admin-pages are still usable
as a fallback.

I

lvanderree
17 Dec 2007, 4:07 PM
I've just uploaded a new demo at http://test.local/test_dev.php/city

I altered my theme is such a way that you can now also define multiple tab-pages for the edit-view in your generator.

The biggest problem which remains is the event handling of (new values in) drop-down combo-boxes (countries in my live-demo)

If someone can help me with this please contact me.

The problem is that I use the onBlur event to detect when you leave edit-field, and I use the getRawValue property to get the value a user typed in, this is all OK. I can also detect if the value is new, or already existed. BUT when it is new, I open a new window to add the value, however I haven't found a way to cancel the onBlur event so in the grid, the next field gets selected (and in the live-demo brakes because the next field-value can also not be found since the store is empty).

So the main problem is how to cancel a onBlur event.

A second problem is to reload (or at least add a value to the store) when the onFocus event is triggered. But this is probably easier to solve.
(The store does not always contain all data, and in case you enter a new field (with drop-down) you want to have at least have the current data-value in the store).


@tidal, I like to cooperate, please also take a look at the symfony forum: http://www.symfony-project.org/forum/index.php/m/41905/#msg_41905 I don't think I have seen you there, but there is also a second plugin not related to themes which makes generating of ExtJs-javascript possible from php-code. (the sfExjs2Plugin)

lvanderree
23 Jan 2008, 3:02 PM
I've updated the symfony-generator plugin, it now makes better use of json-files (although not prefect yet) and it is possible to load detail-pages in your own content-panels (E.G. tab-panels or card-layout-panels).

I've opened a demo-site on which I show a demo of my graduation project. This isn't finished by far, but can give some insight in what you can do with extjs (and the symfony-plugin).

If you have questions, remarks, improvements or other comments/hints please let me know them.

The url is: http://tejohnston.dynora.eu/
username and password are admin

lvanderree
23 Apr 2008, 5:32 PM
Code has been updated today, much improved, but far from finished.

take a look at: http://fun4me.demon.nl/test/test_dev.php for a demo.
you can press Add city (not country yet) or click on the name of a city (doesn't load the city yet...)
The first time the city-layout is requested it is loaded, after that it is known.

now I need to reimplement the construction of the datareader

lvanderree
20 Jul 2008, 5:48 AM
The plugin is still (as always) in active development, but its keeps on improving. ;-)

The latest demo can be found here:
http://tejohnston.dynora.eu (http://tejohnston.dynora.eu/) (admin admin)
a development environment can be found here:
http://tejohnston.dynora.eu/backend_dev.php/
(difference is no dynamic packing and minifying, and added symfony-toolbar)

This generator-plugin for symfony generates all grid and (tabbed-)form-panels as well as all logic at the server side.

The plugin lazy-loads panels the first time you request theme, this is done with the BaseX3.0 library of Doug Hendricks

Also other symfony plugins are used, as the sfCombinePlugin to deliver only one js and one css file to the browser.

For more info please ask, or check the wiki http://trac.symfony-project.org/wiki/sfExtjsThemePlugin
and the symfony forum: http://www.symfony-project.org/forum/index.php/m/56522/#msg_56522

As said it is still in active development, and documentation isn't finished either, but I am very happy with its current capabilities already.

lvanderree
23 Jul 2008, 1:35 AM
Hello Leon,

I'm trying to work with extjs in symfony, but I have not founded a very specific tutorial to star with it, I'm a little bit confused because I have seen two different ways to do it, one is writing the "extjs" code in the generator.yml and the other is writing that code in the templates and I don't understand wath is the difference.

Please help me:s.

Hi Sebrand,

there are two ExtJs plugins for Symfony: sfExtjs2Plugin and the sfExtjsThemePlugin. The Theme plugin depends on the sfExtjs2Plugin and is much more powerful, I assume you are talking about this Theme Plugin, since you mention the yml files.

At the moment there aren't any specifics tutorials. I am a little too busy for that and the community hasn't provided any yet either. I would very much like someone to write this, but can assist with this. I am busy with my graduation, which takes most of my time right now.

About the code in both generator.yml and partials. I assume you have seen the wiki, especially the code at the bottom of this section: http://trac.symfony-project.org/wiki/sfExtjsThemePlugin#TabpanelGridpanelSections:CreateyourownPanels

You can write both code in the generator.yml, if you use the keyword: 'source' or in a partial if you use the keyword 'partials'. The result is the same, I prefer to use partials (no code in my generator, unless it is one function call), but others prefer to write in the generator directly.

If you have more specific problems I can help you further, but from this it is hard to tell what exactly goes wrong.

Else try to meet me at irc in the #sfExtjsThemePlugin channel

kevinmk
24 Jul 2008, 4:14 AM
Hi lvanderre, could you provide me with some help on the following thread

http://extjs.com/forum/showthread.php?t=42018

It's about a rendering problem I am having with ExtJS when I use it with Symfony.
Thanks

lvanderree
25 Sep 2008, 10:12 AM
Hi Guys,

I've just finished writing my thesis report about Usable and Adaptable Business software.

The thesis is all about using Symfony and ExtJS to write custom and maintainable business software, and is the reason why I created this plugin.

You can find it via http://www.extjs.com/forum/showthread.php?p=229735#post229735

Cheers

jabb
9 Mar 2009, 8:16 AM
do you have in any place the code of the project?

lvanderree
9 Mar 2009, 12:29 PM
Hi jabb,

the graduation project itself is not released as open source. However the symfony-plugin, all extjs-patches/extensions and of course the examples are.

I am currently working on improved database tooling (joining and hydration) for the server-sided scripts. After these have matured somewhat more I will rewrite big parts of the sfExtjsThemePlugin.

Regards
Leon

jabb
9 Mar 2009, 12:42 PM
Dear Leon where can I find those examples?
Thanks
Jabb

lvanderree
9 Mar 2009, 1:44 PM
I am afraid you have to search for them in the form of Symfony
http://forum.symfony-project.org/index.php/t/5650/

The wiki is probably outdated, but also still worth mentioning:
http://raw.trac.symfony-project.org/wiki/sfExtjsThemePlugin

and the readme:
http://www.symfony-project.org/plugins/sfExtjs2Plugin/0_5_0?tab=plugin_readme

But since everything is still in active development (and low priority for me right now) I don't know how up-to-date all information currently is.

jabb
10 Mar 2009, 5:21 AM
ok Thanks..... by the way have you ever worked with ext js grid filters in symfony?Im having quite a trouble getting the ext js example to symfony.I mean getting this in the action to propel.
Thanks


<?php
mysql_pconnect("localhost", "root", "") or die("Could not connect");
mysql_select_db("demo") or die("Could not select database");

$start = ($_REQUEST["start"] == null)? 0 : $_REQUEST["start"];
$count = ($_REQUEST["limit"] == null)? 20 : $_REQUEST["limit"];
$sort = ($_REQUEST["sort"] == null)? "" : $_REQUEST["sort"];
$dir = ($_REQUEST["dir"] == "desc")? "DESC" : "";
$filter = $_REQUEST["filter"];

$where = " 0 = 0 ";
if (is_array($filter)) {
for ($i=0;$i<count($filter);$i++){
switch($filter[$i]['data']['type']){
case 'string' : $qs .= " AND ".$filter[$i]['field']." LIKE '%".$filter[$i]['data']['value']."%'"; Break;
case 'list' :
if (strstr($filter[$i]['data']['value'],',')){
$fi = explode(',',$filter[$i]['data']['value']);
for ($q=0;$q<count($fi);$q++){
$fi[$q] = "'".$fi[$q]."'";
}
$filter[$i]['data']['value'] = implode(',',$fi);
$qs .= " AND ".$filter[$i]['field']." IN (".$filter[$i]['data']['value'].")";
}else{
$qs .= " AND ".$filter[$i]['field']." = '".$filter[$i]['data']['value']."'";
}
Break;
case 'boolean' : $qs .= " AND ".$filter[$i]['field']." = ".($filter[$i]['data']['value']); Break;
case 'numeric' :
switch ($filter[$i]['data']['comparison']) {
case 'eq' : $qs .= " AND ".$filter[$i]['field']." = ".$filter[$i]['data']['value']; Break;
case 'lt' : $qs .= " AND ".$filter[$i]['field']." < ".$filter[$i]['data']['value']; Break;
case 'gt' : $qs .= " AND ".$filter[$i]['field']." > ".$filter[$i]['data']['value']; Break;
}
Break;
case 'date' :
switch ($filter[$i]['data']['comparison']) {
case 'eq' : $qs .= " AND ".$filter[$i]['field']." = '".date('Y-m-d',strtotime($filter[$i]['data']['value']))."'"; Break;
case 'lt' : $qs .= " AND ".$filter[$i]['field']." < '".date('Y-m-d',strtotime($filter[$i]['data']['value']))."'"; Break;
case 'gt' : $qs .= " AND ".$filter[$i]['field']." > '".date('Y-m-d',strtotime($filter[$i]['data']['value']))."'"; Break;
}
Break;
}
}
$where .= $qs;
}

$query = "SELECT * FROM demo WHERE ".$where;
if ($sort != "") {
$query .= " ORDER BY ".$sort." ".$dir;
}
$query .= " LIMIT ".$start.",".$count;

$rs = mysql_query($query);
$total = mysql_query("SELECT COUNT(id) FROM demo WHERE ".$where);
$total = mysql_result($total, 0, 0);

$arr = array();
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}

echo '{"total":"'.$total.'","data":'.json_encode($arr).'}';
?>

lvanderree
24 May 2009, 11:32 AM
This doesn't very much look like Symfony, let alone my (old) plugin.

However I am starting all over again, adding new classes to the sfExjts3Plugin, that can be used in new a layout for the sfGridPlugin (not released yet)

As soon as I have some more code I will show it to you all.

mystix
24 May 2009, 6:07 PM
This doesn't very much look like Symfony, let alone my (old) plugin.

However I am starting all over again, adding new classes to the sfExjts3Plugin, that can be used in new a layout for the sfGridPlugin (not released yet)

As soon as I have some more code I will show it to you all.

welcome back :)

haven't had time to dig into your thesis yet though :">

reynierpm
8 Jul 2009, 6:49 PM
Hi lvanderree:
Currently I'm developing all my projects with Symfony 1.2.7 (stable release of this branch). Will you add support for Symfony 1.2.x and also for recently ExtJS 3.0 release? What's the status of this project? How can I help?

Cheers and thanks in advance

lvanderree
11 Jul 2009, 7:36 AM
Hi reynierpm (http://extjs.com/forum/member.php?u=79305),
I am still very busy at work, so haven't had much time to continue my work at the new Symfony1.2-Extjs3 Plugins.

This will be a complete new project; taking all my/our knowledge from the previous extjs(theme)plugin in a much more flexible approach, however it won't be backwards compatible.

The "old" exjts(theme) plugin is till maintained by KRavEN and should be compatible with sf1.2 this can still be found here: http://www.symfony-project.org/plugins/sfExtjsThemePlugin

As soon as I have some examples/demos about the new plugin I will let you all know.

Czapla
25 Jan 2010, 1:21 AM
Are both those plugins compatible with Symfony 1.4.1?
Or should i change it to Symfony 1.2.10.