|
3 | 3 | use Illuminate\Config\Repository as Config; |
4 | 4 | use Illuminate\Filesystem\Filesystem; |
5 | 5 |
|
6 | | -class CodexRepositoryFlat implements CodexRepositoryInterface |
| 6 | +class CodexRepositoryFlat extends AbstractCodexRepository |
7 | 7 | { |
8 | 8 | use CacheTrait; |
9 | 9 |
|
@@ -81,94 +81,6 @@ public function get($manual, $version, $page) |
81 | 81 | } |
82 | 82 | } |
83 | 83 |
|
84 | | - /** |
85 | | - * Gets the given documentation page modification time. |
86 | | - * |
87 | | - * @param string $manual |
88 | | - * @param string $version |
89 | | - * @param string $page |
90 | | - * @return mixed |
91 | | - */ |
92 | | - public function getUpdatedTimestamp($manual, $version, $page) |
93 | | - { |
94 | | - $page = $this->storagePath.'/'.$manual.'/'.$version.'/'.$page.'.md'; |
95 | | - |
96 | | - if ($this->files->exists($page)) { |
97 | | - $timestamp = DateTime::createFromFormat('U', filemtime($page)); |
98 | | - |
99 | | - return $timestamp->format($this->config->get('codex.modified_timestamp')); |
100 | | - } else { |
101 | | - return false; |
102 | | - } |
103 | | - } |
104 | | - |
105 | | - /** |
106 | | - * Get all manuals from documentation directory. |
107 | | - * |
108 | | - * @return array |
109 | | - */ |
110 | | - public function getManuals() |
111 | | - { |
112 | | - return $this->getDirectories($this->storagePath); |
113 | | - } |
114 | | - |
115 | | - /** |
116 | | - * Get all versions for the given manual. |
117 | | - * |
118 | | - * @param string $manual |
119 | | - * @return array |
120 | | - */ |
121 | | - public function getVersions($manual) |
122 | | - { |
123 | | - $manualDir = $this->storagePath.'/'.$manual; |
124 | | - |
125 | | - return $this->getDirectories($manualDir); |
126 | | - } |
127 | | - |
128 | | - /** |
129 | | - * Get the default manual. |
130 | | - * |
131 | | - * @return mixed |
132 | | - */ |
133 | | - public function getDefaultManual() |
134 | | - { |
135 | | - $manuals = $this->getManuals(); |
136 | | - |
137 | | - if (count($manuals) > 1) { |
138 | | - if ( ! is_null($this->config->get('codex.default_manual'))) { |
139 | | - return $this->config->get('codex.default_manual'); |
140 | | - } else { |
141 | | - return strval($manuals[0]); |
142 | | - } |
143 | | - } elseif (count($manuals) === 1) { |
144 | | - return strval($manuals[0]); |
145 | | - } else { |
146 | | - return null; |
147 | | - } |
148 | | - } |
149 | | - |
150 | | - /** |
151 | | - * Get the default version for the given manual. |
152 | | - * |
153 | | - * @param string $manual |
154 | | - * @return string |
155 | | - */ |
156 | | - public function getDefaultVersion($manual) |
157 | | - { |
158 | | - $versions = $this->getVersions($manual); |
159 | | - |
160 | | - switch ($this->config->get('codex.version_ordering')) { |
161 | | - case 'numerical': |
162 | | - sort($versions, SORT_NATURAL); |
163 | | - break; |
164 | | - case 'alphabetically': |
165 | | - sort($versions, SORT_NUMERIC); |
166 | | - break; |
167 | | - } |
168 | | - |
169 | | - return $versions[0]; |
170 | | - } |
171 | | - |
172 | 84 | /** |
173 | 85 | * Search manual for given string. |
174 | 86 | * |
@@ -200,48 +112,4 @@ public function search($manual, $version, $needle = '') |
200 | 112 | return $results; |
201 | 113 | } |
202 | 114 |
|
203 | | - /** |
204 | | - * Return the first line of the supplied page. This will (or rather should) |
205 | | - * always be an <h1> tag. |
206 | | - * |
207 | | - * @param string $page |
208 | | - * @return string |
209 | | - */ |
210 | | - private function getPageTitle($page) |
211 | | - { |
212 | | - $file = fopen($page, 'r'); |
213 | | - $title = fgets($file); |
214 | | - |
215 | | - fclose($file); |
216 | | - |
217 | | - return $title; |
218 | | - } |
219 | | - |
220 | | - /** |
221 | | - * Return an array of folders within the supplied path. |
222 | | - * |
223 | | - * @param string $path |
224 | | - * @return array |
225 | | - */ |
226 | | - private function getDirectories($path) |
227 | | - { |
228 | | - if ( ! $this->files->exists($path)) { |
229 | | - App::abort(404); |
230 | | - } |
231 | | - |
232 | | - $directories = $this->files->directories($path); |
233 | | - $folders = []; |
234 | | - |
235 | | - if (count($directories) > 0) { |
236 | | - |
237 | | - } |
238 | | - |
239 | | - foreach ($directories as $dir) { |
240 | | - $dir = str_replace('\\', '/', $dir); |
241 | | - $folder = explode('/', $dir); |
242 | | - $folders[] = end($folder); |
243 | | - } |
244 | | - |
245 | | - return $folders; |
246 | | - } |
247 | 115 | } |
0 commit comments