Пример #1
0
 /**
  * This method runs after an item has been gotten from the database in a read
  * operation. You can modify it before it's returned to the MVC triad for
  * further processing.
  *
  * @param   FOFTable  &$record  The table instance we fetched
  *
  * @return  void
  */
 protected function onAfterGetItem(&$record)
 {
     parent::onAfterGetItem($record);
     if ($record->sdate == '0000-00-00') {
         $record->sdate = '';
     }
     if ($record->edate == '0000-00-00') {
         $record->edate = '';
     }
     if (strpos($record->sdate, '-') !== false) {
         list($y, $m, $d) = explode('-', $record->sdate);
         $record->sdate = $d . '.' . $m . '.' . $y;
     }
     if (strpos($record->edate, '-') !== false) {
         list($y, $m, $d) = explode('-', $record->edate);
         $record->edate = $d . '.' . $m . '.' . $y;
     }
     if ($record->stimeset == 1) {
         list($stimehh, $stimemm) = explode(":", $record->stime);
         $record->stimehh = (int) $stimehh;
         $record->stimemm = (int) $stimemm;
     }
     if ($record->etimeset == 1) {
         list($etimehh, $etimemm) = explode(":", $record->etime);
         $record->etimehh = (int) $etimehh;
         $record->etimemm = (int) $etimemm;
     }
     $categories = $this->getCategories();
     $record->category_title = '';
     if (array_key_exists($record->catid, $categories)) {
         $record->category_title = $categories[$record->catid]->title;
     }
     // Add some fields to the know fields array; Needed because in the controller NOT know fields are removed
     $record->addKnownField('stimehh');
     $record->addKnownField('stimemm');
     $record->addKnownField('etimehh');
     $record->addKnownField('etimemm');
 }