Created
April 8, 2013 11:05
-
-
Save romaninsh/5335964 to your computer and use it in GitHub Desktop.
Example of hierarchy add-on use in agile toolkit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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']= | |
$this->api->url('profile/'.$this->current_row['profile_id'],array('endowment_id'=>null)); | |
} | |
function renderModel($m){ | |
$el=$m->leftJoin('element','profile_id'); | |
$el->addField('profile_name','name'); | |
$image=$m->add('filestore/Field_Image', array( | |
'name'=>'owner_picture_id', | |
'use_model'=>'Image_Element' | |
))->from($el)->actual('picture_id'); | |
$image | |
->addThumb('thumb', 'thumb_64') | |
; | |
return parent::renderModel($m); | |
} | |
function makeUrls($text) { | |
$text = preg_replace( | |
array( | |
'/((https:\/\/|http:\/\/)\S*)/', | |
'/(\s)((www.)\S*)/', | |
), | |
array( | |
'<a href="$1" target="_blank">$0</a>', | |
'$1<a href="http://$2" target="_blank">$2</a>', | |
), | |
$text | |
); | |
return $text; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Model definition: