Changeset 2622 for trunk/vendor/Sensei
- Timestamp:
- 09/23/07 22:38:11 (16 months ago)
- Location:
- trunk/vendor/Sensei/Sensei/Doc
- Files:
-
- 2 modified
-
Renderer/Xhtml.php (modified) (2 diffs)
-
Section.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/vendor/Sensei/Sensei/Doc/Renderer/Xhtml.php
r2308 r2622 188 188 } 189 189 190 public function makeUrl(Sensei_Doc_Section $section) 191 { 190 public function makeUrl($section) 191 { 192 if ($section instanceof Sensei_Doc_Section) { 193 $path = $section->getPath(); 194 } else { 195 $path = $section; 196 } 197 192 198 $url = $this->_options['url_prefix']; 193 199 194 200 if ($this->_options['section'] instanceof Sensei_Doc_Section) { 195 $path = $section->getPath();196 201 $level = $this->_options['section']->getLevel(); 197 202 $url .= implode(':', array_slice(explode(':', $path), 0, $level)); … … 206 211 } 207 212 208 public function makeAnchor(Sensei_Doc_Section $section) 209 { 210 $path = $section->getPath(); 213 public function makeAnchor($section) 214 { 215 if ($section instanceof Sensei_Doc_Section) { 216 $path = $section->getPath(); 217 } else { 218 $path = $section; 219 } 211 220 212 221 if ($this->_options['section'] instanceof Sensei_Doc_Section) { -
trunk/vendor/Sensei/Sensei/Doc/Section.php
r1957 r2622 115 115 { 116 116 if ($this->_parent->_name !== null) { 117 return $this->_parent->getIndex($separator) . ($this->_index + 1) . $separator;118 } else { 119 return ($this->_index + 1) . $separator;117 return $this->_parent->getIndex($separator) . $separator . ($this->_index + 1); 118 } else { 119 return ($this->_index + 1); 120 120 } 121 121 } … … 137 137 $path = preg_replace($patterns, $replacements, strtolower($this->_name)); 138 138 139 return $path;139 return self::convertNameToPath($this->_name); 140 140 } 141 141 } … … 386 386 } 387 387 } 388 389 /** 390 * Converts section name to section path. 391 * 392 * Section path is generated from section name by making section name 393 * lowercase, replacing all whitespace with a dash and removing all 394 * characters that are not a letter, a number or a dash. 395 * 396 * @param $name string section name 397 * @return section path 398 */ 399 public static function convertNameToPath($name) 400 { 401 $patterns = array('/\s/', '/[^a-z0-9-]/'); 402 $replacements = array('-', ''); 403 404 return preg_replace($patterns, $replacements, strtolower($name)); 405 } 388 406 }