Skip to content
This repository has been archived by the owner on Sep 4, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
more examples
  • Loading branch information
Romans Malinovskis committed May 22, 2012
1 parent fa2beff commit 94344d8
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 30 deletions.
3 changes: 3 additions & 0 deletions lib/Frontend.php
Expand Up @@ -21,6 +21,9 @@ function page_back($p){
}
function initLayout(){
parent::initLayout();
$page=$this->page_object;
$page->template->eachTag('Example',function($a,$b) use($page){ $page->add('View_Example',null,$b)->set($a); });

/*
$toolbox=$this->add('Inspector');

Expand Down
3 changes: 0 additions & 3 deletions lib/Model/Employee.php
Expand Up @@ -3,9 +3,6 @@ class Model_Employee extends Model_Person {
function init(){
parent::init();

$this->addField('name')
->mandatory(true);

$this->addField('days_worked')
->system(true)
->datatype('int');
Expand Down
2 changes: 1 addition & 1 deletion lib/Model/Menu.php
Expand Up @@ -5,7 +5,7 @@ function convertArray($array){
$res=array();
foreach($array as $key=>$row){
$r=array(
'id'=>$key,
'page'=>$key,
'name'=>$row
);

Expand Down
4 changes: 2 additions & 2 deletions lib/Model/Person.php
Expand Up @@ -2,8 +2,8 @@
class Model_Person extends Model_Table {
public $entity_code='person';
public $table_alias='p';
function defineFields(){
parent::defineFields();
function init(){
parent::init();

$this->addField('name');
}
Expand Down
8 changes: 6 additions & 2 deletions lib/TreeView.php
Expand Up @@ -28,21 +28,25 @@ function setModel($m){
}

function formatRow(){
$this->current_row['page']=$this->api->url($this->stack[0]['page'].'/'.$this->current_row['page']);
}

public $stack=array();
function renderModel($model){
$output='';
foreach($model as $this->current_row){
$this->formatRow();

$t=$this->template->cloneRegion('node');
$t->set($this->current_row);

if($model[$this->child_ref.'_cnt']){
array_push($this->stack,$model);
$t->setHTML('children',$this->renderModel($model->ref($this->child_ref)));
array_pop($this->stack);
}else{
$t->tryDel('children_zone');
$t->tryDel('icon');
}
$t->set($this->current_row);
$output.=$t->render();
}
return $output;
Expand Down
20 changes: 20 additions & 0 deletions lib/View/Example.php
@@ -0,0 +1,20 @@
<?php
class View_Example extends View {
function set($code){
$this->template->set('Code',$code);
// TODO: make a dynamic paths here
if(!@$this->api->syntaxhighligter_hack)
$this->js(true,'$.SyntaxHighlighter.init({prettifyBaseUrl:"templates/js/jquery-syntaxhighlighter/prettify",baseUrl:"templates/js/jquery-syntaxhighlighter"})')->_load('jquery-syntaxhighlighter/scripts/jquery.syntaxhighlighter');
$this->api->syntaxhighligter_hack=true;

$res=$this->add('View',null,'Demo');
$this->executeDemo($res,$code);
}
function executeDemo($page,$code){
eval($code);
}

function defaultTemplate(){
return array('view/example');
}
}
51 changes: 51 additions & 0 deletions templates/default/page/gui/form.html
@@ -0,0 +1,51 @@
<h1>Basic Form Example</h1>

<p>Form is a fundamental component of any web application. Agile Toolkit greatly simplifies form creation.</p>

<?Example?>
$form=$page->add('Form');
$form->addField('line','name');
$form->addField('line','surname');
$form->addSubmit();

if($form->isSubmitted()){
$form->js()->univ()->alert('Thank you, '.
$form->get('name').' '.$form->get('surname'))->execute();
}
<?/?>

<h3>Form Elements</h3>

<p>There are many field types you can use with form. In addition you can add your own field types or use add-on which may provide additional types.</p>


<?Example?>
$form=$page->add('Form');
$form->addComment('This form shows all sorts of fields you can use by default');
$form->addField('line','line');
$form->addField('password','password');
$form->addField('checkbox','checkbox');
$form->addField('dropdown','dropdown');
$form->addField('checkboxlist','checkboxlist');
$form->addField('radio','radio');
$form->addField('DatePicker','date');
$form->addField('text','text');

$form->addSeparator();
$form->addField('Slider','Slider');
$form->addField('upload','upload');

$form->addSeparator('Here are some variations in how you can use fields');
$form->addField('Search','Search');
$form->addSubmit();
<?/?>

<h3>Use with Model</h3>

<p>The most convenient way to use form is to have it's fields populated from a Model.</p>


<?Example?>
$form=$page->add('Form');
$form->setModel('Employee');
<?/?>
57 changes: 57 additions & 0 deletions templates/default/page/gui/grid.html
@@ -0,0 +1,57 @@
<h1>Basic Grid Example</h1>

<p>Grid presents data in a tabular way. Grid always has a defined set of columns. When used with model, columns will be automatically populated. Without Models you need to use addColumn() and populate data</p>

<?Example?>
$grid=$page->add('Grid');
$grid->addColumn('name');
$grid->addColumn('surname');

$grid->setSource(array(
array('name'=>'John','surname'=>'Smith'.rand(1,20)),
array('name'=>'Peter','surname'=>'Tester'.rand(20,40))
));
<?/?>

<h3>Grid Buttons</h3>

<p>Grid has support for buttons. addButton() is merely a wrapper out of convenience. You can add button into any view.</p>

<?Example?>
$grid=$page->add('Grid');

$grid->addColumn('name');
$grid->addColumn('surname');

$grid->setSource(array(
array('name'=>'John','surname'=>'Smith'.rand(1,20)),
array('name'=>'Peter','surname'=>'Tester'.rand(20,40))
));

$grid->addButton('One');
$grid->addButton('Two')->js('click')->univ()->alert('clicked button two');
$grid->addButton('Reload Grid')->js('click',$grid->js()->reload());
$grid->addButton('With Icon')->setIcon('heart');
<?/?>

<h3>Grid from Model</h3>

<p>The most typical use is when grid is being populated through a Model.</p>

<?Example?>
$grid=$page->add('Grid');

$grid->setModel('Employee');
<?/?>

<h3>Paginator and Quicksearch</h3>

<p>The most typical use is when grid is being populated through a Model.</p>

<?Example?>
$grid=$page->add('Grid');

$grid->setModel('Employee');
$grid->addPaginator(3);
$grid->addQuickSearch(array('name'));
<?/?>
Binary file not shown.
27 changes: 27 additions & 0 deletions templates/default/page/interaction/binding.html
@@ -0,0 +1,27 @@
<h1>Binding JavaScript Events</h1>

<p>Binding allows you to modify behaviour through JavaScript / jQuery events</p>

<?Example?>
$page->add('Button')->set('click me')->js('click')
->univ()->alert('Thank you');

$bs=$page->add('ButtonSet');

$b1=$bs->addButton('Hide Myself');
$b1->js('click')->hide();

$b2=$bs->addButton('Hide next button');
$b3=$bs->addButton('Hide prev button');
$b2->js('click',$b3->js()->fadeOut('slow'));
$b3->js('click',$b2->js()->fadeOut('slow'));

$bs->addButton('Show all buttons')
->js('click',array(
$b1->js()->show(),
$b2->js()->show(),
$b3->js()->show()
));
<?/?>


23 changes: 7 additions & 16 deletions templates/default/page/newcodepad.html
Expand Up @@ -3,14 +3,12 @@ <h1>The Job: a "Slot Machine"</h1>
<p>Imagine a client, who shows up and wants to put your skills to the test by asking you to develop a simple "slot machine". The client is not yet sure of what he needs, but he says he'll figure it out once he gets his hands on a first prototype. His requirements is to make a web page display 3 random digits to the visitor.</p>
<p>"Simple enough", you say, and write some HTML for this curious task - putting it into templates/default/view/slotmachine.html</p>

<div class="example">
<div class="label">Source</div>
<?Execute?>
<?Example?>
$grid=$page->add('Grid');
$grid->addColumn('name');
$grid->addColumn('surname');
$grid->setModel('People');
<?/?></div>
$grid->setModel('Employee');
<?/?>


<p>Next, you need to generate random numbers and place them into the template slots. This logic should be contained inside a new class file, which must be created inside lib/View/SlotMachine.php:</p>
<div class="example">
<div class="label">Source</div>
Expand All @@ -34,15 +32,6 @@ <h1>The Job: a "Slot Machine"</h1>
<pre class="highlight">
$page->add('View_SlotMachine');
</div>
<div class="demo">
<div class="label">Demo</div>
<div style="background: white; padding: 3px; margin: 5px; border: 2px solid black; width: 100px">
Slot Machine<br>
<span style="margin: 4px; border: 1px solid red">7</span>
<span style="margin: 4px; border: 1px solid red">7</span>
<span style="margin: 4px; border: 1px solid red">4</span>
</div>
</div>



Expand All @@ -53,6 +42,7 @@ <h1>The Job: a "Slot Machine"</h1>

<div class="comments">
<h2>Comments</h2>
<!--
<div id="disqus_thread"></div>
<script type="text/javascript">
/**
Expand All @@ -64,4 +54,5 @@ <h2>Comments</h2>
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
-->
</div>
4 changes: 2 additions & 2 deletions templates/default/shared.html
Expand Up @@ -9,8 +9,8 @@
<link rel="stylesheet" type="text/css" href="<?template?>css/atk-codepad.css<?/?>" />
<link rel="stylesheet" type="text/css" href="<?template?>css/atk-custom.css<?/?>" />
<?$js_include?>
<script type="text/javascript" src="http://balupton.github.com/jquery-syntaxhighlighter/scripts/jquery.syntaxhighlighter.min.js"></script>
<script type="text/javascript">$.SyntaxHighlighter.init();</script>
<!-- <script type="text/javascript"
src="http://balupton.github.com/jquery-syntaxhighlighter/scripts/jquery.syntaxhighlighter.min.js"></script> -->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="<?template?>css/ie8.css<?/?>"/>
<script type="text/javascript" src="<?template?>css/ie8.js<?/?>"></script>
Expand Down
2 changes: 1 addition & 1 deletion templates/default/submenu.html
@@ -1,7 +1,7 @@
<div class="sidebar">
<ul>
<?node?>
<li><a href="#"><?icon?><i class="ui-icon ui-icon-triangle-1-s"></i><?/?><?name?>Category<?/?></a>
<li><a href="<?$page?>"><?icon?><i class="ui-icon ui-icon-triangle-1-s"></i><?/?><?name?>Category<?/?></a>
<?children_zone?>
<ul>
<?$children?>
Expand Down
14 changes: 11 additions & 3 deletions templates/default/view/example.html
@@ -1,4 +1,12 @@
<div style="width: 200px; float: left; border: 1px solid black; padding: 1em; margin: 0.5em ">
<h4><a href="/<?$name?>"><?$name?></a></h4>
<p><?$descr?></p>
<div id="<?$_name?>_ex" class="example">
<div class="label">Source</div>
<div class="actions"><a href="#"><i class="ui-icon ui-icon-comment"></i>Comment</a><a href="#"><i class="ui-icon ui-icon-link"></i>Link</a><a href="#"><i class="ui-icon ui-icon-document"></i>Copy</a></div>
<pre class="highlight language-php">
<?$Code?>
</pre>
</div>

<div id="<?$_name?>_de" class="demo">
<div class="label">Demo</div>
<?$Demo?>
</div>
1 change: 1 addition & 0 deletions templates/js/jquery-syntaxhighlighter
Submodule jquery-syntaxhighlighter added at 638919

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 94344d8

Please sign in to comment.