コード例 #1
0
ファイル: grid.php プロジェクト: linuxwhy/tiki-1
 function _load(TikiSheet &$sheet)
 {
     $tikilib = TikiLib::lib('tiki');
     $result = $tikilib->query("SELECT `data` FROM `tiki_pages` WHERE `pageName` = ?", array($this->pageName));
     if ($row = $result->fetchRow()) {
         $tables = $this->getRawTables($row['data']);
         $row = 0;
         foreach ($tables as $table) {
             $table = explode("\n", $table);
             foreach ($table as $line) {
                 $line = explode('|', trim($line));
                 foreach ($line as $col => $value) {
                     $sheet->initCell($row, $col);
                     $sheet->setValue($value);
                     if (isset($value)) {
                         if (preg_match("/^::(.*)::\$/", $value, $matches)) {
                             $sheet->setClass($sheet->getClass() . " styleCenter");
                             $value = $matches[1];
                             $sheet->setValue($value);
                         }
                         if (preg_match("/^__(.*)__\$/", $value, $matches)) {
                             $sheet->setClass($sheet->getClass() . " styleBold");
                             $value = $matches[1];
                             $sheet->setValue($value);
                         }
                         if (preg_match("/^''(.*)''\$/", $value, $matches)) {
                             $sheet->setClass($sheet->getClass() . " styleItalic");
                             $value = $matches[1];
                             $sheet->setValue($value);
                         }
                         if (strlen($value)) {
                             if ($value[0] == '=') {
                                 $sheet->setCalculation(substr($value, 1));
                             } else {
                                 $sheet->setCalculation($value);
                             }
                         }
                     }
                     $sheet->setRowSpan(1);
                     $sheet->setColSpan(1);
                     $sheet->setDeadCells();
                 }
                 ++$row;
             }
         }
         return true;
     } else {
         return false;
     }
 }