support ext-discount and ext-cmark
[mdref/mdref] / mdref / Entry.php
index 4febd764604b678ba9e1f658b3ff3d895b479e2c..589cf412eb72b4093d485261cba99d9d33ac64e2 100644 (file)
@@ -105,7 +105,7 @@ class Entry implements \IteratorAggregate {
        }
 
        /**
-        * Read the description of the ref entry file
+        * Read the first line of the description of the ref entry file
         * @return string
         */
        public function getDescription() {
@@ -118,6 +118,20 @@ class Entry implements \IteratorAggregate {
                return $this;
        }
 
+       /**
+        * Read the full description of the ref entry file
+        * @return string
+        */
+       public function getFullDescription() {
+               if ($this->isFile()) {
+                       return trim($this->getFile()->readFullDescription());
+               }
+               if ($this->isRoot()) {
+                       return trim($this->repo->getRootEntry()->getFullDescription());
+               }
+               return $this;
+       }
+
        /**
         * Read the intriductory section of the refentry file
         * @return string
@@ -192,6 +206,22 @@ class Entry implements \IteratorAggregate {
                return ctype_upper($base{0});
        }
 
+       public function getEntryName() {
+               return end($this->list);
+       }
+
+       public function getNsName() {
+               if ($this->isRoot()) {
+                       return $this->getName();
+               } elseif ($this->isFunction()) {
+                       $parts = explode("/", trim($this->getName(), "/"));
+                       $self = array_pop($parts);
+                       return implode("\\", $parts) . "::" . $self;
+               } else {
+                       return strtr($this->getName(), "/", "\\");
+               }
+       }
+
        /**
         * Display name
         * @return string
@@ -236,8 +266,10 @@ class Entry implements \IteratorAggregate {
                                ($loose && glob($this->getBasename() . "/*/$glob"));
                } elseif ($this->isRoot()) {
                        return true;
-               } else {
+               } elseif ($this->getBasename() !== "/") {
                        return is_dir($this->getBasename());
+               } else {
+                       return false;
                }
        }
 
@@ -264,4 +296,8 @@ class Entry implements \IteratorAggregate {
        function getIterator() {
                return new Tree($this->getBasename(), $this->repo);
        }
+
+       function getStructure() {
+               return new Structure($this);
+       }
 }