lists/list_taskfolders.inc.php

00001 <?php if(!function_exists('startedIndexPhp')) { header("location:../index.php"); exit();}
00002 # streber - a php based project management system
00003 # Copyright (c) 2005 Thomas Mann - thomas@pixtur.de
00004 # Distributed under the terms and conditions of the GPL as stated in docs/license.txt
00005 
00022 class ListBlock_taskfolders extends ListBlock {
00023 
00024     ### overwrite ###
00025     public $bg_style='bg_misc';
00026     public $id=    'folders';
00027 
00028     private $cur_task_id=-1;
00029     private $hidden=false;
00030     private $task_folders=NULL;
00031 
00032 
00036     public function __construct(Project $project)    #@@@ pixtur: this should use pass by $args
00037     {
00038         parent::__construct();
00039 
00040         $this->title= __('Folders');
00041 
00042         if(!$project) trigger_error("ListBlock_taskfolders() needs project-object as argument",E_USER_WARNING);
00043         $this->task_folders= $project->getFolders();
00044 
00045         #--- render nothing if no folders ---
00046         if(!count($this->task_folders)) {
00047             $this->hidden= true;
00048         }
00049 
00050 
00051         #--- in taskView highlight current task ---
00052         global $PH;
00053 
00054         if($PH->cur_page_id == 'taskView') {
00055             $task_id= get('tsk');
00056             $cur_task= Task::getById($task_id);
00057             if(!$cur_task) {
00058                 $PH->abortWarning("invalid task-id");   #@@@ not good inside lists / render Exception might be more appropriate
00059                 return;
00060             }
00061 
00062             #--- use parent, if not a folder for itself ------
00063             if(!$cur_task->category == TCATEGORY_FOLDER) {
00064                 $cur_task= Task::getById($cur_task->parent_task);
00065             }
00066             if($cur_task && is_object($cur_task)) {
00067                 $this->cur_task_id= $cur_task->id;
00068             }
00069         }
00070 
00071         #--- create task for project-root---
00072         $task_none=new Task(array('name'=>"..none::"));
00073         $task_none->id=0;
00074         $task_none->project= $project->id;
00075         array_unshift($this->task_folders,$task_none);
00076 
00077         #--- add columns --------------------------------------------------------
00078         $this->add_col( new ListBlockColSelect());
00079         $this->add_col( new ListBlockCol_TaskName(array(
00080             'use_short_names'=>true,
00081             'indention'=>true,
00082             'use_collapsed'=>true,
00083             'show_toggles'=>false
00084         )));
00085         $this->add_col( new ListBlockColMethod(array(
00086             'name'=>__("Tasks"),
00087             'tooltip'=>__("Number of subtasks"),
00088             'sort'=>0,
00089             'func'=>'getNumSubtasks',
00090             'style'=>'right'
00091         )));
00092         #$this->add_col( new ListBlockCol_TaskSumEfforts());
00093 
00094         #--- functions ----------------------------------------
00095         ### functions ###
00096         $this->add_function(new ListFunction(array(
00097             'target'=>$PH->getPage('taskEdit')->id,
00098             'name'  =>__('Edit'),
00099             'id'    =>'taskEdit',
00100             'icon'  =>'edit',
00101             'context_menu'=>'submit',
00102         )));
00103         $this->add_function(new ListFunction(array(
00104             'target'=>$PH->getPage('taskNewFolder')->id,
00105             'name'  =>__('New'),
00106             'id'    =>'taskNewFolder',
00107             'icon'  =>'new',
00108             'tooltip'=>__('Create new folder under selected task'),
00109         )));
00110 
00111         $this->add_function(new ListFunction(array(
00112             'target'=>$PH->getPage('tasksMoveToFolder')->id,
00113             'name'  =>__('Move selected to folder'),
00114             'id'    =>'tasksMoveToFolder',
00115             'context_menu'=>'submit',
00116             'dropdown_menu'=>0,
00117 
00118         )));
00119 
00120         $this->add_function(new ListFunction(array(
00121             'target'=>$PH->getPage('effortNew')->id,
00122             'name'  =>__('Log hours for select tasks'),
00123             'id'    =>'effortNew',
00124             'icon'    =>'loghours',
00125             'context_menu'=>'submit'
00126         )));
00127 
00128 
00129     }
00130 
00136     public function __toString() {
00137         if($this->hidden) {
00138             return;
00139         }
00140 
00141         $this->render_header();
00142         #$this->render_thead();
00143         foreach($this->task_folders as $f) {
00144             ### hilight the current task-folder ###
00145             if($f->id == $this->cur_task_id) {
00146                 $this->render_trow($f,'current');
00147             }
00148             else {
00149                 $this->render_trow($f);
00150             }
00151         }
00152         $this->render_tfoot();
00153     }
00154 }
00155 
00156 
00157 
00158 
00159 
00160 ?>

Generated on Sun Mar 4 17:19:30 2007 for streber by  doxygen 1.5.1-p1