示例#1
0
 public static function show()
 {
     parent::show();
     $taskP = TASK_PATH . $_GET['task'] . '/data/';
     $tableF = $taskP . $_GET['table'];
     $infoF = $taskP . $_GET['info'];
     $detail = array(ucfirst($_GET['task']), ucfirst($_GET['table']));
     //echo $tableF;
     $table = Task::ReadTable($tableF);
     //var_dump($table);
     $header = array();
     $footer = array();
     $i = 0;
     foreach ($table[0] as $k => $v) {
         $header[] = $k;
         $footer[] = '$' . chr(65 + $i++);
     }
     //echo $infoF;
     $info = BaseFile::getFileContent($infoF);
     $info = $info ? explode("\r\n", $info) : array();
     self::setTitle($detail[1] . ' - ' . $detail[0]);
     self::$smarty->assign('historyUrl', Url::getBasePhp('History'));
     self::$smarty->assign('favoriteUrl', Url::getBasePhp('Favorite'));
     self::$smarty->assign('detail', $detail);
     self::$smarty->assign('info', $info);
     self::$smarty->assign('header', $header);
     self::$smarty->assign('footer', $footer);
     self::$smarty->assign('table', $table);
     self::$smarty->display('Sheet.tpl');
 }
 public static function testRGB()
 {
     $contents = BaseFile::getFileContent(TMP_PATH . 'datatables.txt.css');
     $pattern = "/#[0-9a-fA-F]{3,}/";
     preg_match_all($pattern, $contents, $k);
     $tongji = array_count_values($k[0]);
     ksort($tongji);
     $pa = array();
     $re = array();
     echo '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body>';
     foreach ($tongji as $k => $v) {
         $s = '0123456789abcdef';
         $t = array();
         for ($i = 0; $i < strlen($s); $i++) {
             $t[$s[$i]] = $s[strlen($s) - $i - 1];
         }
         $s = strtolower($k);
         $n = '#';
         for ($i = 1; $i < strlen($s); $i++) {
             $n .= $t[$s[$i]];
         }
         echo '<p><div style="background-color: ' . $k . '; width: 500px; float:left;">' . $k . '</div>' . $v;
         echo '<div style="background-color: ' . $n . '; width: 500px; float:left;">' . $n . '</div></p>';
         //$pa[] = '/'.$k.'/';
         //$re[] = $n;
     }
     //echo preg_replace($pa, $re, $contents);
 }
 public static function putSomeData($file, $data)
 {
     if (empty($data)) {
         return true;
     }
     if (!file_exists($file)) {
         return self::putAllData($file, $data);
     }
     if ($content = parent::getFileContent($file)) {
         //得到表头数据
         $rows = explode("\r\n", $content);
         $title = explode("|", $rows[0]);
         $rows = array();
         $special = array("|", "\r\n");
         //按照表头数据 来整合新数据
         foreach ($data as $adata) {
             if (!$adata) {
                 continue;
             }
             $row = array();
             foreach ($title as $item) {
                 $row[] = str_replace($special, " ", $adata[$item]);
             }
             $rows[] = join("|", $row);
         }
         $content = "\r\n" . join("\r\n", $rows);
         return parent::putFileContent($file, $content, FILE_APPEND);
     } else {
         return false;
     }
 }
示例#4
0
 public function getTmpContent($label)
 {
     $file = $this->getTmpFile($label);
     if ($file) {
         return parent::getFileContent($file);
     } else {
         return false;
     }
 }
示例#5
0
 public static function Vague2List($importFile, $exportFile)
 {
     if ($content = BaseFile::getFileContent($importFile)) {
         $codeArr = array();
         $r = "/[0-9.]{6}/";
         preg_match_all($r, $content, $k);
         foreach ($k[0] as $t) {
             $tt = CommonInfo::Num2Code($t);
             if ($tt) {
                 $codeArr[] = array('code' => $tt);
             }
         }
     } else {
         return false;
     }
     $codeNameArray = CommonInfo::CodeArray2CodeNameArray($codeArr);
     self::putList($exportFile, $codeNameArray);
 }
 public static function getPurposeList()
 {
     $purpose = array();
     if (($d1 = opendir(TASK_PATH)) == false) {
         return $purpose;
     }
     while (($d2 = readdir($d1)) !== false) {
         if (!is_dir(TASK_PATH . $d2) || $d2 == "." || $d2 == "..") {
             continue;
         }
         $p = TASK_PATH . $d2 . "/";
         $f = $p . "SUMMARY.txt";
         if (!file_exists($f)) {
             continue;
         }
         $sd = TableFile::getAllData($f);
         if (!$sd) {
             continue;
         }
         $l = array();
         foreach ($sd as $d) {
             if ($d['aim'] != self::$aim) {
                 continue;
             }
             $f = $p . 'data/' . $d['table'];
             if (file_exists($f)) {
                 $l[] = array('table' => $d['table'], 'info' => $d['info'], 'url' => Url::getBasePhp('Sheet') . '?task=' . $d2 . '&table=' . $d['table'] . '&info=' . $d['info']);
             }
         }
         if ($l) {
             $f = $p . "README.txt";
             $re = array();
             if (file_exists($f)) {
                 $re = BaseFile::getFileContent($f);
                 $re = explode("\r\n", $re);
             }
             $purpose[ucfirst($d2)] = array('readme' => $re, 'list' => $l);
         }
     }
     return $purpose;
 }