Skip to content

Instantly share code, notes, and snippets.

View romaninsh's full-sized avatar
🚴‍♂️
Focusing

Romans Malinovskis romaninsh

🚴‍♂️
Focusing
View GitHub Profile
@romaninsh
romaninsh / atk-demo-1.php
Created November 1, 2010 02:42
Simple Grid on Agile Toolkit , PHP5
<?php
$g=$p->add('Grid');
// All the new views or objects needs to be added. When you do that - new object becomes child. This determines location where it appears on the page.
// For example $p is the "Demo" tab. What you add into $p will always be in there.
$g->addColumn('name');
// You can define multiple columns inside grid using addColumn() method. Columns must correspond with the hash keys in the data
#!/bin/bash
if [ $# -lt 1 -o $# -gt 4 ]
then
echo "Usage: $0 log_to_be_checked [cc-emails [to-email [subject]]]" >&2
exit 1
fi
LOGFILE="$1"
TSFILE="${LOGFILE}.ts"
this.element.find('tbody').selectable({
filter: 'tr',
cancel: '.ui-button,a,:input,option',
stop: function(){ c
hb.stop.apply(chb,[this])
}
}).css({cursor:'crosshair'});
$m=$this;
$m->thumb=$m
->leftJoin('filestore_file','filestore_file_id')
->leftJoin('filestore_image.original_file_id',null,'left')
->leftJoin('filestore_file','thumb_file_id','left');
;
$m->vol=$m->thumb->leftJoin('filestore_volume',null,'left');
$m->addExpression('thumb',function($m,$s){
class Controller_Element extends Controller {
function addFields($m){
$m->addField('name');
$m->hasOne('Profile','owner_profile_id');
$m->hasOne('User','created_by');
$m->addField('element_type');
$m->addField('descr')->type('text')->caption('Description');
$m->addField('seo_name');
<?php
class Form extends Form_Basic {
public $split_columns=true;
function init(){
parent::init();
$this->setFormClass('stacked atk-row');
}
function recursiveRender(){
if(count($this->elements)>8 && $this->split_columns){
$o=$this->add('Order')

Changes 4.2.3 to 4.2.4

Note: for diff see: https://github.com/atk4/atk4/compare/4.2.3...4.2.4

General:

  • Added PSR-2 compliance to many core files. Will continue to improve other classes too.
  • Added composer.json. Agile Toolkit can be installed through Composer now
  • when calling setController, second argument can specify name or default options
  • Security fixes in Logger

Pattern Router

A typical Agile Toolkit application converts your URL into a page. For example /mysite/profile?id=123 normally could be implemented like this:

class page_profile extends Page {
     function init(){
         parent::init();
         $this->setModel('User')->load($_GET['id']);
     }

function defaultTemplate(){

@romaninsh
romaninsh / View_CommentTree.php
Created April 8, 2013 11:05
Example of hierarchy add-on use in agile toolkit
<?php
class View_CommentTree extends hierarchy\View_Tree {
function init(){
parent::init();
$this->time_ctl=$this->add('Controller_RoundTiming');
}
function formatRow(){
$this->current_row['added']=$this->time_ctl->fancy_datetime($this->current_row['added']).' ago';
$this->current_row_html['descr']=nl2br($this->makeUrls($this->current_row['descr']));
$this->current_row_html['profile_link']=
RewriteEngine On
RewriteRule ^[^\.]*$ index.php [L]