fix repos containing supplementary .md files
[mdref/mdref] / mdref / Entry.php
index 587cd1e8a33122b3f44e69b78b884a912b1c9208..db858a9c2d2a207ba694ed8b4a2518c427ff405d 100644 (file)
@@ -82,6 +82,14 @@ class Entry implements \IteratorAggregate {
                return $this->file;
        }
        
+       /**
+        * Get edit URL 
+        * @return string
+        */
+       public function getEditUrl() {
+               return $this->repo->getEditUrl($this->name);
+       }
+       
        /**
         * Read the title of the ref entry file
         * @return string
@@ -145,7 +153,11 @@ class Entry implements \IteratorAggregate {
         * @return \mdref\Entry
         */
        public function getParent() {
-               if ("." !== ($dirn = dirname($this->name))) {
+               switch ($dirn = dirname($this->name)) {
+               case ".":
+               case "/":
+                       break;
+               default:
                        return $this->repo->getEntry($dirn);
                }
        }
@@ -218,9 +230,10 @@ class Entry implements \IteratorAggregate {
         * @param string $glob
         * @return boolean
         */
-       function hasIterator($glob = null) {
+       function hasIterator($glob = null, $loose = false) {
                if (strlen($glob)) {
-                       return glob($this->getBasename() . "/$glob");
+                       return glob($this->getBasename() . "/$glob") ||
+                               ($loose && glob($this->getBasename() . "/*/$glob"));
                } elseif ($this->isRoot()) {
                        return true;
                } else {
@@ -233,7 +246,7 @@ class Entry implements \IteratorAggregate {
         * @return bool
         */
        function hasNsClasses() {
-               return $this->hasIterator("/[A-Z]*.md");
+               return $this->hasIterator("/[A-Z]*.md", true);
        }
        
        /**
@@ -249,6 +262,6 @@ class Entry implements \IteratorAggregate {
         * @return \mdref\Tree child nodes
         */
        function getIterator() {
-               return new Tree($this->getBasename(), $this->repo, $this->isRoot());
+               return new Tree($this->getBasename(), $this->repo);
        }
 }