- changed component to code
Simplify the code
Issue #20
resolved
Simple code is easier to understand and to maintain.
See this part:
// get the namespace genealogy of the current id
$sub_ns = $this->_get_sub_ns($INFO["id"]);
// build the namespace tree structure
$ns_acmenu = $this->_get_ns_acmenu($sub_ns); // namespace in which <acmenu> is
Instead of these 2 functions, one this is enough:
private function _get_sidebar_dir() {
global $conf, $INFO;
$base = realpath($conf['datadir']);
$sidebar = "/" . str_replace(":", "/", $conf['sidebar']) . ".txt";
$chunks = explode(":", $INFO["id"], -1);
while ($chunks) {
$dir = $base . "/" . implode("/", $chunks);
if (file_exists($dir . $sidebar)) return $dir;
array_pop($chunks);
}
return $base;
}
(Here we can use "/" instead of DIRECTORY_SEPARATOR because we do not compare paths with them. We only perform file functions with them, in which case PHP automatically converts them to proper symbols).
So in function _tree($level) we can just
$dir = _get_sidebar_dir();
Comments (4)
-
repo owner -
repo owner Well, actually I've done a different simplification.
Since in
script.js
there was the functionget_sub_start
, which was practically similar to_get_sub_ns
defined insyntax.php
, I've decided to delete the former and reuse the latter passing it's content to_get_ns_acmenu
insyntax.php
and toset_cookie
inscript.js
. -
repo owner - changed status to resolved
→ <<cset af179f439c32>>
-
repo owner - removed version
Removing version: v1.0 (automated comment)
- Log in to comment