render/render_list_column_special.inc.php

00001 <?php if(!function_exists('startedIndexPhp')) { header("location:../index.php"); exit();}
00002 # streber - a php5 based project management system  (c) 2005-2007  / www.streber-pm.org
00003 # Distributed under the terms and conditions of the GPL as stated in lang/license.html
00004 
00016 /***********************************************************
00017 * derived versions of ListBlockCol for special purposes
00018 */
00019 
00020 
00021 
00022 
00023 
00024 /*********
00025 * test version of column-rendering using code-eval
00026 *
00027 * early try of custimized field-rendering in lists. This is prone to errors. For most
00028 * purposes of customized rendering, we suggest ListBlockColFormat.
00029 *
00030 * @usedby: not used / obsolete
00031 */
00032 class ListBlockColEval extends ListBlockCol{
00033 
00034     function render_tr(&$obj, $style='') {
00035         $style= (isset($this->style) && $this->style!="") ? "class=\"$->style\"" : "";
00036         echo "<td $style>";
00037 
00038         //--- try to get param ---
00039         $key= $this->key;
00040         $value= isset($obj->$key) ? $obj->$key : "??$key";
00041 
00042         if(isset($this->eval)) {
00043             $tmp="\$value=\"".$this->eval."\";";
00044             eval($tmp);
00045             echo $value;
00046         }
00047         else {
00048             echo "<a href=\"\">$value</a>";
00049         }
00050         echo "</td>";
00051     }
00052 }
00053 
00054 
00074 class ListBlockColFormat extends ListBlockCol
00075 {
00076     function render_tr(&$obj, $style="") {
00077         if(!isset($obj) || !is_object($obj)) {
00078             trigger_error("ListBlock->render_tr() called without valid object",E_USER_WARNING);
00079             return;
00080         }
00081         $key= $this->key;
00082         $format= $this->format;
00083         $rest=$this->format;
00084         $style= $this->style
00085               ? "class='$this->style'"
00086               : '';
00087 
00088         while(  ereg("\{\?([a-z_]*)\}(.*)",$rest, $matches) ) {
00089             $key=$matches[1];
00090             $rest=$matches[2];
00091             $value= isset($obj->$key) ? $obj->$key : "??$key";
00092             $format=ereg_replace("\{\?$key\}",asHtml($value),$format);
00093         }
00094 
00095         print "<td $style>". $format . '</td>';
00096     }
00097 }
00098 
00099 
00100 
00118 class ListBlockColMethod extends ListBlockCol
00119 {
00120     function render_tr(&$obj, $style="") {
00121         if(!isset($obj) || !is_object($obj)) {
00122             trigger_error("ListBlock->render_tr() called without valid object",E_USER_WARNING);
00123             return;
00124         }
00125         $out=call_user_func(array($obj,$this->func));
00126         if($this->style) {
00127             print "<td class='$this->style'>$out</td>";
00128         }
00129         else {
00130             print "<td>$out</td>";
00131         }
00132     }
00133 }
00134 
00135 
00140 class ListBlockColTime extends ListBlockCol{
00141     public $style='right';
00142 
00143     function render_tr(&$obj, $style_overwrite="") {
00144         if(!isset($obj) || !is_object($obj)) {
00145             trigger_error("ListBlockColTime->render_tr() called without valid object", E_USER_WARNING);
00146             return;
00147         }
00148         $key= $this->key;
00149         $value=$obj->$key;
00150         $format='';
00151         if($value && $value!="00:00:00") {
00152             $format=$value;
00153             ereg("(..):(..):(..)",$value,$matches);
00154             list($all,$hh,$mm,$ss)=$matches;
00155             #$format="$hh:$mm";
00156             $hours=$hh*1+ ($mm/60);
00157             $format=round($hours,1)."<span class='entity'>h</span>";
00158         }
00159         print "<td class='$this->style $style_overwrite'>$format</td>";
00160     }
00161 }
00162 
00163 
00167 class ListBlockColLinkExtern extends ListBlockCol
00168 {
00169     function render_tr(&$obj, $style_overwrite="") {
00170         if(!isset($obj) || !is_object($obj)) {
00171             trigger_error("ListBlockLinkExtern->render_tr() called without valid object", E_USER_WARNING);
00172             return;
00173         }
00174         $key= $this->key;
00175         $value=$obj->$key;
00176         if($value) {
00177 
00178             $format= url2linkExtern(asHtml($value));
00179             print "<td class='$this->style $style_overwrite'>". $format ."</td>";
00180         }
00181         else {
00182             print "<td></td>";
00183         }
00184     }
00185 }
00186 
00190 class ListBlockColDate extends ListBlockCol
00191 {
00192     public $key= 'modified';
00193 
00194     function __construct($args=NULL) {
00195         parent::__construct($args);
00196         if(!$this->name) {
00197             $this->name= __('Modified');
00198         }
00199     }
00200 
00201     function render_tr(&$obj, $style="") {
00202         global $auth;
00203 
00204         if(!isset($obj) || !is_object($obj)) {
00205             trigger_error("ListBlockColDate->render_tr() called without valid object", E_USER_WARNING);
00206             return;
00207         }
00208         $key= $this->key;
00209 
00210         $value_str=renderDateHtml($obj->$key);
00211 
00212 
00213         print "<td class='nowrap'>$value_str</td>";
00214     }
00215 }
00216 
00217 
00218 
00219 
00220 
00221 class ListBlockCol_OpenTasks extends ListBlockCol
00222 {
00223 
00224     public function __construct($args=NULL) {
00225         parent::__construct($args);
00226         $this->name=__("Tasks","short column header");
00227         $this->tooltip=__("Number of open tasks is hilighted if shown home.");
00228         $this->style='narrow';
00229         $this->id='tasks';
00230     }
00231     function render_tr(&$project,$style='') {
00232         $num_tasks= $project->getNumTasks();
00233         #if($project->show_in_home) {
00234             echo "<td class='right'>$num_tasks</td>";
00235         #}
00236         #else {
00237         #    echo "<td class='right notShown' title='Tasks of this project are not shown in home'>($num_tasks)</td>";
00238         #}
00239     }
00240 }
00241 
00242 
00243 class ListBlockColPrio extends ListBlockCol{
00244 
00245     public $style='narrow';
00246 
00247     function render_tr(&$obj,$style="") { global $auth;
00248         global $g_prio_names;
00249 
00250         //--- try to get param ---
00251         if(!isset($obj->prio) || !intval($obj->prio)) {
00252             $out="?";
00253         }
00254         else {
00255             $tooltip= sprintf(__("Priority is %s"),$g_prio_names[$obj->prio]);
00256             $out= "<img title='$tooltip' src='". getThemeFile("img/prio_{$obj->prio}.png"). "'>";
00257         }
00258         $class= $this->style
00259             ?"class='$this->style'"
00260             :'';
00261         echo "<td $class>";
00262         echo $out;
00263         echo "</td>";
00264     }
00265 }
00266 
00267 class ListBlockColStatus extends ListBlockCol{
00268 
00269     public $style='narrow';
00270     public $key='status';
00271 
00272     function __construct() {
00273         $this->name     =__('Status','Short status column header');
00274     }
00275 
00276     function render_tr(&$obj, $style="")
00277     {
00278         global $auth;
00279         global $g_status_names;
00280 
00281         //--- try to get param ---
00282         $status= $obj->status;
00283 
00284         $class= $this->style
00285             ?"class='$this->style'"
00286             :'';
00287 
00288         #$tooltip=$g_status_names[$status];
00289 
00290         #echo "<td $class title='"
00291         #    . sprintf(__("Status is %s"), $tooltip)
00292         #    ."'>";
00293         #echo "<img src=\"" . getThemeFile("img/status_$status.png") ."\">";
00294         if($obj->status) {
00295             $name= isset($g_status_names[$obj->status])
00296                        ? $g_status_names[$obj->status]
00297                        : "";
00298         }
00299         else {
00300             $name="";
00301         }
00302 
00303         $extra = '';
00304         if($obj->status <= STATUS_NEW) {
00305             $extra='new';
00306         }
00307 
00308         if($obj->status >= STATUS_COMPLETED) {
00309             $extra= 'done';
00310         }
00311 
00312         if($obj->status == STATUS_OPEN) {
00313             $extra= 'open';
00314         }
00315 
00316         echo "<td class='status $extra'>";
00317         echo "$name";
00318         echo "</td>";
00319     }
00320 }
00321 
00322 
00323 class ListBlockColPubLevel extends ListBlockCol{
00324 
00325     public $style='narrow';
00326     public $key='pub_level';
00327 
00328     public function __construct($args=NULL) {
00329         parent::__construct($args);
00330         $this->tooltip=__("Item is published to");
00331         $this->name=__("Pub","column header for public level");
00332         $this->id='pub';
00333     }
00334 
00335     function render_tr(&$obj, $style="")
00336     {
00337 
00338         global $g_pub_level_names;
00339         global $g_pub_level_short_names;
00340         //--- try to get param ---
00341         $pub_level= $obj->pub_level;
00342 
00343         $class= $this->style
00344             ?"class='$this->style'"
00345             :'';
00346         $str_level=$g_pub_level_short_names[$pub_level];
00347         $title= sprintf(__("Publish to %s"),$g_pub_level_names[$pub_level]);
00348 
00349         echo "<td $class title='$title'>";
00350         echo $str_level;
00351         echo "</td>";
00352     }
00353 }
00354 
00355 
00356 class ListBlockColSelect extends ListBlockCol{
00357 
00358     public $style='narrow';
00359     public $key='_select_col_';
00360     public $name="S";
00361 
00362     function render_th() {
00363         if($this->key=="_select_col_") {
00364             $title= __("Select / Deselect");
00365             echo "<th class=select_col title='$title' style='width:1%'>";
00366             echo "<a href='#'>";
00367 
00368             echo "<img src=\"". getThemeFile("img/list_check_range.png") . "\">";
00369             echo "</a>";
00370             echo "</th>";
00371         }
00372     }
00373 
00374     function render_tr(&$obj, $style="")
00375     {
00376         echo
00377         "<td width=10 class=select_col>
00378         <input type=checkbox id={$this->parent_block->id}_{$obj->id}_chk name={$this->parent_block->id}_{$obj->id}_chk>
00379         </td>";
00380     }
00381 }
00382 
00383 class ListBlockCol_CreatedBy extends ListBlockCol
00384 {
00385     public $name;
00386     public $id='createdby';
00387     public $key='created_by';
00388 
00389     public function __construct($args=NULL) {
00390         parent::__construct($args);
00391         $this->name=__('Created by');
00392         $this->id='created_by';
00393     }
00394 
00395     function render_tr(&$obj, $style="nowrap") {
00396         if(!isset($obj) || !$obj instanceof DbProjectItem) {
00397             return;
00398         }
00399         $value="";
00400         if($obj->created_by) {
00401             if($person= Person::getVisibleById($obj->created_by)) {
00402                 $value=$person->getLink();
00403             }
00404         }
00405         print "<td class=nowrap>$value</td>";
00406     }
00407 }
00408 
00409 
00410 
00411 
00412 
00413 ?>

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