Permalink
Browse files

Add comments to lots of examples, add inspector

  • Loading branch information...
1 parent 33242c9 commit 93fbdb398b4ef886c8eb10a3785b2485d0937ed1 @romaninsh romaninsh committed Nov 2, 2011
Showing with 369 additions and 486 deletions.
  1. +1 −1 atk4
  2. +0 −1 atk4-1
  3. +0 −1 atk4-1-addons
  4. +1 −1 atk4-addons
  5. +2 −7 index.php
  6. +4 −0 lib/Controller/Employee.php
  7. +7 −0 lib/FileGrid.php
  8. +12 −71 lib/Frontend.php
  9. +53 −0 lib/Hangman.php
  10. +37 −0 lib/Model/Employee.php
  11. +3 −0 lib/PersonList.php
  12. +18 −0 lib/SourceViewer.php
  13. +9 −0 lib/TaskList.php
  14. +92 −0 lib/Toolbox.php
  15. +2 −19 page/50employees.php
  16. +4 −17 page/50employees2.php
  17. +0 −3 page/about.php
  18. +0 −16 page/authtest.php
  19. +4 −17 page/autocomplete.php
  20. +3 −54 page/buttonpushing.php
  21. +18 −11 page/columns.php
  22. +2 −0 page/contact.php
  23. +0 −13 page/dbtest.php
  24. +7 −13 page/dragaction.php
  25. +8 −2 page/editablef.php
  26. +0 −17 page/entity.php
  27. +13 −0 page/hangman.php
  28. +4 −0 page/hello.php
  29. +1 −0 page/hybrid.php
  30. +6 −12 page/image.php
  31. +24 −0 page/index.php
  32. +4 −88 page/infiniteadd1.php
  33. +4 −2 page/issue12.php
  34. +3 −0 page/layoutswitch.php
  35. +5 −5 page/metatags.php
  36. +2 −0 page/multiupload.php
  37. +3 −0 page/newsletter.php
  38. +3 −1 page/quicksearch.php
  39. +1 −0 page/reloadform.php
  40. +1 −0 page/reloadformac.php
  41. +3 −0 page/reloadtest.php
  42. +3 −1 page/slider.php
  43. +1 −0 page/slotmachine.php
  44. +0 −13 page/source.php
  45. +1 −0 page/tmail.php
  46. +0 −1 templates/default
  47. +0 −7 templates/jui/README
  48. +0 −4 templates/jui/page/about.html
  49. +0 −34 templates/jui/page/dragaction.html
  50. +0 −15 templates/jui/page/how.html
  51. +0 −5 templates/jui/page/index.html
  52. +0 −5 templates/jui/page/layoutswitch1.html
  53. +0 −5 templates/jui/page/layoutswitch2.html
  54. +0 −19 templates/jui/page/projects.html
  55. +0 −5 templates/jui/view/slotmachine.html
2 atk4
Submodule atk4 updated 458 files
1 atk4-1
Submodule atk4-1 deleted from 1d4e90
Submodule atk4-1-addons deleted from f55ce3
Submodule atk4-addons updated 77 files
+1 −0 .gitignore
+7 −0 ATK4Addons.php
+20 −673 LICENSE
+1 −1 VERSION
+56 −0 billing/lib/billing/Model/PaymentMethod/RealexRedirect.php
+0 −1 billing/update.sh
+47 −0 misc/docs/counties.sql
+55 −0 misc/docs/country.001.sql
+8 −0 misc/docs/dbupdates/filestore-001.sql
+70 −0 misc/docs/filestore.001.sql
+9 −0 misc/docs/misc.001.sql
+148 −0 misc/lib/Controller/Encrypt.php
+32 −0 misc/lib/Controller/Fancy.php
+4 −0 misc/lib/Controller/Filestore/Image.php
+309 −0 misc/lib/Controller/OAuth.php
+75 −0 misc/lib/Controller/OAuth/Facebook.php
+35 −0 misc/lib/Controller/OAuth/Google.php
+5 −0 misc/lib/Controller/OAuth/Google/YouTube.php
+19 −0 misc/lib/Controller/OAuth/LinkedIn.php
+20 −0 misc/lib/Controller/OAuth/Twitter.php
+3 −0 misc/lib/Controller/SNI.php
+13 −0 misc/lib/Controller/SNI/Facebook.php
+23 −0 misc/lib/Controller/SNI/Google.php
+55 −0 misc/lib/Controller/SNI/Google/YouTube.php
+12 −0 misc/lib/Controller/SNI/LinkedIn.php
+17 −0 misc/lib/Controller/SNI/Twitter.php
+12 −0 misc/lib/Controller/Seo.php
+49 −0 misc/lib/Doc/Example/Upload.php
+244 −0 misc/lib/Export.php
+20 −0 misc/lib/Export/EMT.php
+3 −0 misc/lib/Form/Field/image.php
+13 −0 misc/lib/FormAndSave.php
+59 −0 misc/lib/InfiniteAddForm.php
+33 −0 misc/lib/Model/Country.php
+13 −0 misc/lib/Model/Feedback.php
+40 −26 misc/lib/Model/Filestore/File.php
+79 −0 misc/lib/Model/Filestore/Image.php
+1 −1 misc/lib/Model/Filestore/Volume.php
+33 −0 misc/lib/Model/Region.php
+50 −0 misc/lib/Model/Session.php
+58 −0 misc/lib/MultiController.php
+20 −6 misc/lib/Page/Filestore/FileAdmin.php
+78 −0 misc/lib/StrengthChecker.php
+71 −0 misc/lib/TMail/Transport/SES.php
+10 −0 misc/lib/View/Filestore/ImageList.php
+28 −1 misc/lib/View/Google/Map.php
+48 −0 misc/lib/View/ReCaptcha.php
+59 −0 misc/templates/js/ui.highcharts.js
+71 −0 misc/templates/js/ui.highstock.js
+19 −0 misc/templates/view/export/pdf.html
+15 −0 misc/templates/view/export/xls.html
+4 −0 misc/templates/view/export/xls_cell.html
+9 −0 misc/templates/view/filestore/imagelist.html
+16 −0 misc/templates/view/model.html
+7 −0 misc/templates/view/model_core.html
+8 −0 misc/templates/view/page.html
+2 −0 mvc/CRUD.php
+62 −0 mvc/CRUD/Export.php
+0 −283 mvc/CmdGrid.php
+51 −28 mvc/Controller.php
+0 −8 mvc/Exception/ForUser.php
+0 −8 mvc/Exception/InitError.php
+1 −391 mvc/FieldDefinition.php
+1 −1 mvc/Form/Field/autocomplete.php
+4 −52 mvc/Form/Field/reference.php
+448 −0 mvc/MVCFieldDefinition.php
+24 −22 mvc/MVCForm.php
+32 −0 mvc/MVCForm/Export.php
+8 −8 mvc/MVCGrid.php
+62 −0 mvc/MVCGrid/Export.php
+1,612 −0 mvc/Model/MVCTable.php
+1 −1,528 mvc/Model/Table.php
+165 −0 mvc/Page/ModelGenerator.php
+162 −0 mvc/Page/SchemaGenerator.php
+0 −15 mvc/SafeFilter.php
+2 −2 mvc/SelectGrid.php
+84 −0 mvc/View/CRUD.php
View
@@ -10,11 +10,6 @@
// agile_project - this is realm. It should be unique per-project
// jui - this is theme. Keep it jui unless you want to make your own theme
-if($_GET['b']=='4.0'){
- include 'atk4/loader.php';
-}else{
- include 'atk4-1/loader.php';
-}
-$api=new Frontend('sample_project',$_GET['b']=='4.1'?'jui':'default');
+include 'atk4/loader.php';
+$api=new Frontend('codepad');
$api->main();
-?>
@@ -0,0 +1,4 @@
+<?php
+class Controller_Employee extends Controller {
+ public $model_name='Model_Employee';
+}
View
@@ -0,0 +1,7 @@
+<?php
+class FileGrid extends MVCGrid {
+ function setModel($m){
+ parent::setModel($m,array('id','filestore_type','name_size'));
+ $this->dq->order('id desc')->limit(10);
+ }
+}
View
@@ -1,90 +1,31 @@
<?php
-/*
- Commonly you would want to re-define ApiFrontend for your own application.
- */
class Frontend extends ApiFrontend {
function init(){
parent::init();
- // Keep this if you are going to use database on all pages
- //$this->dbConnect();
-
$this->dbConnect();
-
-
- // This will add some resources from atk4-addons, which would be located
- // in atk4-addons subdirectory.
- $this->api->stickyGET('b');
- if($_GET['b']=='4.0'){
- $dir='atk4-addons';
- }else{
- $dir='atk4-1-addons';
- }
- $this->addLocation($dir,array(
+ $this->addLocation('atk4-addons',array(
'php'=>array(
'mvc',
'misc/lib',
)
))
->setParent($this->pathfinder->base_location);
- // A lot of the functionality in Agile Toolkit requires jUI
$this->add('jUI');
- $p=explode('_',$this->page);
- $this->add('Button')->set('View source')->addStyle('float','right')
- ->js('click')
- ->univ()->redirect('source/'.$p[0]);
- // Initialize any system-wide javascript libraries here
- // If you are willing to write custom JavaScritp code,
- // place it into templates/js/atk4_univ_ext.js and
- // include it here
- $this->js()
- ->_load('ui.atk4_notify')
- ->_load('atk4_univ')
- // ->_load('ui.atk4_expander')
- ;
-
- // If you wish to restrict actess to your pages, use BasicAuth class
- $this->add('BasicAuth')
- ->allow('demo','demo')
- // use check() and allowPage for white-list based auth checking
- //->check()
- ;
-
-
- // Initialize objects which you want to see on ALL of your pages in this method
- // If you, however, want to place object only on a single page, then
- // create page/mytestpage.php with class page_mytestpage and put objects
- // into it's init() method.
-
- // Menu:
-
- // If you are using a complex menu, you can re-define
- // it and place in a separate class
$m=$this->add('Menu',null,'Menu');
- $m->addMenuItem('Welcome','index');
- $m->addMenuItem('about');
-
- // If you want to use ajax-ify your menu
- // $m->js(true)->_load('ui.atk4_menu')->atk4_menu(array('content'=>'#Content'));
+ $m->addMenuItem('Index','index');
+ $m->addMenuItem('Back to Agile Toolkit','back');
+ }
+ function page_back($p){
+ $this->redirect('http://agiletoolkit.org/doc/');
+ }
+ function initLayout(){
+ $toolbox=$this->add('Toolbox',null,'Toolbox');
+ parent::initLayout();
- // Finally if you want to use a simple menu, you can either put it into shared.html
- // or include it from other file
- // $m=$this->add('Menu',null,'Menu',array('view/mymenu'));
+ $toolbox->initButtons();
- // You need to call initLayout which will determine current page and load
- // respective page/...php class.
- if($_GET['b']=='4.0'){
- $this->initLayout();
- }
- }
-
- function page_pref($p){
- $this->dbConnect();
-
- // This is example of how you can use form with MVC support
- $p->frame('Preferences')->add('MVCForm')
- ->setController('Controller_User');
- }
+ }
}
View
@@ -0,0 +1,53 @@
+<?php
+class Hangman extends HtmlElement {
+ function init(){
+ parent::init();
+ if(!$_GET[$this->name]){
+ $this->add('H3')->set('Select Difficulty');
+ $f=$this->add('Form');
+ $f->addField('radio','difficulty')->setValueList(array(10=>'Easy',5=>'Medium',3=>'Hard'));
+ $f->addSubmit('Start Game');
+ if($f->isSubmitted()){
+ $this->memorize('word','back');
+ $this->memorize('tries',$f->get('difficulty'));
+ $this->memorize('letters',range('a','z'));
+ $this->js()->reload(array($this->name=>1))->execute();
+ }
+ return;
+ }
+
+
+
+ $letter=$_GET[$this->name];
+ $word=$this->recall('word');
+ $tries=$this->recall('tries');
+ $letters=$this->recall('letters');
+
+ $this->api->stickyGET($this->name);
+ if($letter!=1){
+ unset($letters[array_search($letter,$letters)]);
+ if(strpos($word,$letter)===false)$tries--;
+ $this->memorize('tries',$tries);
+ $this->memorize('letters',$letters);
+ }
+ $word=str_replace($letters,'-',$word);
+ if($tries<0){
+ $this->add('P')->set('Game Over');
+ return;
+ }
+ if(strpos($word,'-')===false){
+ $this->add('P')->set('You won!');
+ return;
+ }
+ $this->add('H3')->set('Mistakes remaining: '.$tries);
+ foreach ($letters as $i){
+ $l=$this->add('HtmlElement')
+ ->setElement('a')
+ ->setAttr('href','#')
+ ->set(strtoupper($i))
+ ->js('click',$this->js()->reload(array($this->name=>$i)));
+ }
+
+ $this->add('P')->set('Word: '.$word);
+ }
+}
View
@@ -0,0 +1,37 @@
+<?php
+class Model_Employee extends Model_Person {
+ function init(){
+ parent::init();
+
+ $this->addField('name')
+ ->mandatory(true);
+
+ $this->addField('days_worked')
+ ->system(true)
+ ->datatype('int');
+
+ $this->addField('salary')
+ ->mandatory(true)
+ ->datatype('money');
+ }
+ function gotoWork(){
+ $this->set('days_worked',
+ $this->get('days_worked')+1);
+ return $this;
+ }
+ function paySalary(){
+ $c= $this->add('Model_Salary')
+ ->set('amount',
+ $this->get('money_owed'))
+ ->set('employee_id',
+ $this->get('id'))
+ ;
+ $c->update();
+ $this->set('days_worked',0)
+ ->update();
+ return $c;
+ }
+ function calculate_money_owed(){
+ return 'days_worked * salary';
+ }
+}
View
@@ -0,0 +1,3 @@
+<?php
+class PersonList extends MVCLister {
+}
View
@@ -0,0 +1,18 @@
+<?php
+class SourceViewer extends View {
+ public $relative;
+ public $file;
+ public $type;
+
+ function load($type,$file){
+ $this->file=$this->api->locatePath($type,$file);
+ $this->relative=$this->api->locate($type,$file);
+ $this->type=$type;
+
+ $this->add('H3')->set('Source located: '.preg_replace('|.*codepad/|','',$this->file));
+ $t=$this->add('Text');
+ $t->set(highlight_string($f=file_get_contents($this->file),true));
+
+ return $this;
+ }
+}
View
@@ -0,0 +1,9 @@
+<?php
+class TaskList extends MVCLister {
+ function formatRow(){
+ $id=$this->current_row['id'];
+
+ $this->current_row['allocated']=print_r($this->owner->allocated[$id],true);
+ }
+}
+
View
@@ -0,0 +1,92 @@
+<?php
+class Toolbox extends View {
+ function initButtons(){
+ $page=$this->api->page_object;
+
+ $tabs=$this->add('Tabs');
+
+ // add Info Tab
+ $basic=$tabs->addTab('About');
+ $source=$tabs->addTab('Source');
+ $share=$tabs->addTab('Share');
+
+ $p=explode('_',$this->api->page);
+
+
+ $basic->add('H3')->set(ucwords($p[0]));
+ if($page->descr)$basic->add("P")->set($page->descr);
+
+ $form=$share->add('Form');
+ $form->setFormClass('vertical');
+ $field=$form->addField('line','link','Share this link')->set(
+ $this->api->getDestinationURL()->useAbsoluteURL());
+ $field->js('click')->select();
+
+
+ /* Add [View Template] Button if custom template is used */
+ if(($t=$page->defaultTemplate())!=array('page') && is_array($t)){
+ $source->add('Button')->set('Page template')
+ ->js('click')
+ ->univ()->frameURL('Page Source',$this->api->getDestinationURL(null,array('pagetemplate'=>true)));
+ if($_GET['pagetemplate']){
+ $this->api->renderOnly($this->add('SourceViewer')->load('template',$t[0].'.html'));
+ }
+ }
+
+ $source->add('H3')->set('Component Sources');
+ $node=$source->add('TreeNode')->useObject($page);
+ $this->showChildren($page,$node);
+ }
+ function showChildren($sorc,$dest){
+ foreach($sorc->elements as $key=>$obj){
+ if($obj instanceof jQuery_Chain)continue;
+ $node=$dest->add('TreeNode')->useObject($obj);
+ if($obj->elements)$this->showChildren($obj,$node);
+ }
+ }
+ function defaultTemplate(){
+ return array('view/toolbox');
+ }
+}
+class TreeNode extends View {
+ function useObject($obj){
+ $this->template->set('name',$obj->name);
+ $this->template->set('class',get_class($obj));
+ if($obj instanceof Page){
+ $this->js('click')->_selector('#'.$this->name.'_a')
+ ->univ()->frameURL('Page Source',$this->api->getDestinationURL(null,array('source'=>true)
+ ),array('height'=>'700'));
+ if($_GET['source']){
+ $p=explode('_',$this->api->page);
+ $this->api->renderOnly($this->add('SourceViewer')->load('page',$p[0].'.php'));
+ }
+ return$this;
+ }
+ $this->js('click')->_selector('#'.$this->name.'_a')
+ ->univ()->frameURL('Inspecting object '.$obj->name,$this->api->getDestinationURL(null,
+ array('inspect'=>$this->name)
+ ),array('height'=>'700'));
+ if($_GET['inspect']==$this->name){
+ return $this->api->renderOnly($v=$this->add('SourceViewer')
+ ->load('php',str_replace('_','/',$this->sourceSubst(get_class($obj))).'.php'));
+ }
+ if(!$obj instanceof AbstractView)return$this;
+ $this->js('mouseover',$obj->js()->css('background','pink'))->_selector('#'.$this->name.'>a');
+ $this->js('mouseleave',$obj->js()->css('background',''))->_selector('#'.$this->name.'>a');
+
+
+
+ return $this;
+ }
+ function sourceSubst($class){
+ if($class=='Form')return 'Form_Basic';
+ if($class=='Columns')return 'View_Columns';
+ if($class=='Form_Field_Line')return 'Form_Field';
+ if($class=='Grid')return 'Grid_Basic';
+ if($class=='Button')return 'View_Button';
+ return $class;
+ }
+ function defaultTemplate(){
+ return array('view/treenode');
+ }
+}
View
@@ -1,5 +1,7 @@
<?php
class page_50employees extends Page {
+ public $descr='The other day I got asked: "I have lots of employees to enter. What\'s the fastest name to enter them?".
+ We can certainly build a form with lots of fields and the make it produce many records when it\'s submitted.';
function init(){
parent::init();
@@ -28,23 +30,4 @@ function init(){
}
}
-class Controller_Employee extends Controller {
- public $model_name='Model_Employee';
-}
-
-class Model_Employee extends Model_Person {
- function defineFields(){
- parent::defineFields();
-
- $this->addField('name')
- ->mandatory(true);
- $this->addField('days_worked')
- ->system(true)
- ->datatype('int');
-
- $this->addField('salary')
- ->mandatory(true)
- ->datatype('money');
- }
-}
Oops, something went wrong.

0 comments on commit 93fbdb3

Please sign in to comment.