Commit cd0c0e1a authored by lrargerich's avatar lrargerich

Some improvements

parent 713e62c3
Version 1.6 -Tau Ceti-
* [NEW] Alternative syntax for tables, you can sepparate rows using line returns instead
of ||. You have to select which syntax to use in the admin screen.
* [NEW] Admin menu submit buttons now get back to the admin section where the
submited information was found.
* [NEW] User menus, the user can add items to the application menu, an option to
automatically add top-level bookmarks to the menu is provided.
* [NEW] Theme control center: if activated you can control the theme
......
......@@ -3411,6 +3411,7 @@ function parse_data($data)
global $feature_hotwords_nw;
global $feature_wiki_pictures;
global $tiki_p_upload_picture;
global $feature_wiki_tables;
global $page;
global $dbTiki;
global $structlib;
......@@ -3495,39 +3496,74 @@ function parse_data($data)
}
//unset($smc);
if($feature_wiki_tables != 'new') {
// New syntax for tables
if (preg_match_all("/\|\|(.*)\|\|/", $data, $tables)) {
$maxcols = 1;
$cols = array();
for($i = 0; $i < count($tables[0]); $i++) {
$rows = explode('||', $tables[0][$i]);
$col[$i] = array();
for ($j = 0; $j < count($rows); $j++) {
$cols[$i][$j] = explode('|', $rows[$j]);
if (count($cols[$i][$j]) > $maxcols)
$maxcols = count($cols[$i][$j]);
}
}
for ($i = 0; $i < count($tables[0]); $i++) {
$repl = '<table class="wikitable" border="1">';
for ($j = 0; $j < count($cols[$i]); $j++) {
$ncols = count($cols[$i][$j]);
if ($ncols == 1 && !$cols[$i][$j][0])
continue;
$repl .= '<tr>';
for ($k = 0; $k < $ncols; $k++) {
$repl .= '<td';
if ($k == $ncols - 1 && $ncols < $maxcols)
$repl .= ' colspan=' . ($maxcols-$k);
$repl .= '>' . $cols[$i][$j][$k] . '</td>';
}
$repl.='</tr>';
}
$repl.='</table>';
$data = str_replace($tables[0][$i],$repl,$data);
}
}
} else {
// New syntax for tables
if (preg_match_all("/\|\|(.*)\|\|/", $data, $tables)) {
$maxcols = 1;
$cols = array();
for($i = 0; $i < count($tables[0]); $i++) {
$rows = explode("<br/>", $tables[0][$i]);
$col[$i] = array();
for ($j = 0; $j < count($rows); $j++) {
$rows[$j]=str_replace('||','',$rows[$j]);
$cols[$i][$j] = explode('|', $rows[$j]);
if (count($cols[$i][$j]) > $maxcols)
$maxcols = count($cols[$i][$j]);
}
}
for ($i = 0; $i < count($tables[0]); $i++) {
$repl = '<table class="wikitable" border="1">';
for ($j = 0; $j < count($cols[$i]); $j++) {
$ncols = count($cols[$i][$j]);
if ($ncols == 1 && !$cols[$i][$j][0])
continue;
$repl .= '<tr>';
for ($k = 0; $k < $ncols; $k++) {
$repl .= '<td';
if ($k == $ncols - 1 && $ncols < $maxcols)
$repl .= ' colspan=' . ($maxcols-$k);
$repl .= '>' . $cols[$i][$j][$k] . '</td>';
}
$repl.='</tr>';
}
$repl.='</table>';
$data = str_replace($tables[0][$i],$repl,$data);
}
}
// New syntax for tables
if (preg_match_all("/\|\|(.*)\|\|/", $data, $tables)) {
$maxcols = 1;
$cols = array();
for($i = 0; $i < count($tables[0]); $i++) {
$rows = explode('||', $tables[0][$i]);
$col[$i] = array();
for ($j = 0; $j < count($rows); $j++) {
$cols[$i][$j] = explode('|', $rows[$j]);
if (count($cols[$i][$j]) > $maxcols)
$maxcols = count($cols[$i][$j]);
}
}
for ($i = 0; $i < count($tables[0]); $i++) {
$repl = '<table class="wikitable" border="1">';
for ($j = 0; $j < count($cols[$i]); $j++) {
$ncols = count($cols[$i][$j]);
if ($ncols == 1 && !$cols[$i][$j][0])
continue;
$repl .= '<tr>';
for ($k = 0; $k < $ncols; $k++) {
$repl .= '<td';
if ($k == $ncols - 1 && $ncols < $maxcols)
$repl .= ' colspan=' . ($maxcols-$k);
$repl .= '>' . $cols[$i][$j][$k] . '</td>';
}
$repl.='</tr>';
}
$repl.='</table>';
$data = str_replace($tables[0][$i],$repl,$data);
}
}
......
This diff is collapsed.
......@@ -771,6 +771,10 @@ if(isset($_REQUEST["wikifeatures"])) {
$smarty->assign("feature_wiki_footnotes",'n');
}
$tikilib->set_preference('feature_wiki_tables',$_REQUEST['feature_wiki_tables']);
$smarty->assign('feature_wiki_tables',$_REQUEST['feature_wiki_tables']);
if(isset($_REQUEST["feature_wiki_undo"]) && $_REQUEST["feature_wiki_undo"]=="on") {
$tikilib->set_preference("feature_wiki_undo",'y');
$smarty->assign("feature_wiki_undo",'y');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment