# HG changeset patch # User Pascal Bellard # Date 1385666713 0 # Node ID 136be2b3c08581be175338e7cfa902fb54a8f574 # Parent 63b1f79f8bd9b92ec46ee04b5bafe68d48b736fe wikiss: add Calc plugin diff -r 63b1f79f8bd9 -r 136be2b3c085 wikiss/stuff/plugins/wkp_Calc.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wikiss/stuff/plugins/wkp_Calc.css Thu Nov 28 19:25:13 2013 +0000 @@ -0,0 +1,31 @@ +.bordercalc { + background-color: #ccc; + font-weight: bold; + text-align: center; + border: 1px solid #999; + padding: 0; +} + +.inputcalc { + border: none; + width: 80px; + font-size: 14px; + padding: 2px; +} + +.inputcalc:hover { + background-color: #eee; +} + +.inputcalc:focus { + background-color: #ccf; +} + +.tablecalc { + border-collapse: collapse; +} + +.cellcalc { + border: 1px solid #999; + padding: 0; +} diff -r 63b1f79f8bd9 -r 136be2b3c085 wikiss/stuff/plugins/wkp_Calc.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wikiss/stuff/plugins/wkp_Calc.php Thu Nov 28 19:25:13 2013 +0000 @@ -0,0 +1,173 @@ +lines > 1 && $this->rows > 1) { + $id = "C".(100+$this->cnt++); + $this->newCONTENT .= "\n"; + $this->newCONTENT .= "
\n"; + $this->newCONTENT .= "\n"; + } + else for ($i = 1; $i <= $this->lines; $i++) + $this->newCONTENT .= $this->line[$i]."\n"; + $this->rows = $this->lines = $this->gotcalc = 0; + } + + function formatEnd() + { + global $CONTENT; + $headdone = $gotcalc = $showtail = $this->lines = 0; + $this->newCONTENT = ""; + $CONTENT = preg_replace("/
/","
\n",$CONTENT); + foreach (explode("\n", $CONTENT) as $current) { + if ($current == "") continue; + if (preg_match("/;
$/", $current)) { + $gotcalc = 1; + if (!$headdone) { + $headdone = 1; + $showtail = 1; + $this->newCONTENT .= << + + +EOT; + } + $this->line[++$this->lines] = $current; + $current = preg_replace("/</","<",$current); + $i = count(explode(";", $current))-1; + if ($this->lines == 1) $this->rows = $i; + if ($i != $this->rows) $this->rows = -1; + } + else { + if ($gotcalc) $this->showcalc(); + $this->newCONTENT .= $current."\n"; + } + } + if ($gotcalc) $this->showcalc(); + if ($showtail) { + $this->newCONTENT .= << + + +EOT; + } + $CONTENT = $this->newCONTENT; + } + + function template() + { + global $html; + $html = preg_replace("/<\/head>/", + "\t\n", + $html); + } +} +?>