/** */ public function load_field_options() { // file extension is required if (strlen($this->file_extension)) { // check file directory if ($this->file_directory) { // locate it $path = ICE_Scheme::instance()->locate_file($this->file_directory); // find it? if ($path) { // found the path, list files with extension $images = ICE_Files::list_filtered($path, sprintf('/\\.%s$/', $this->file_extension), true); // find any images? if (count($images)) { // options to return $field_options = array(); // format the array foreach ($images as $key => $value) { // clean up key $key = str_replace('.', '-', $key); // value is absolute URL $field_options[$key] = ICE_Files::theme_file_to_url($value); } // all done, return them return $field_options; } else { throw new Exception(sprintf('No images found with the ".%s" extension', $this->file_extension)); } } else { throw new Exception(sprintf('Unable to locate the "%s" path', $this->file_directory)); } } else { throw new Exception('No file directory has been set'); } } else { throw new Exception('No file extension has been set'); } }
/** * Return the file path for a given page * * @param string $page * @return string */ private function find_page_file($page) { // valid formats $formats = join('|', array(self::MARKUP_HTML, self::MARKUP_MARKDOWN, self::MARKUP_MARKDOWN_LONG, self::MARKUP_TEXTILE, self::MARKUP_TEXTILE_LONG)); // loop through all doc dirs looking for doc page foreach ($this->doc_dirs as $doc_dir) { try { // list all files in current dir that match page $files = ICE_Files::list_filtered($doc_dir, sprintf('/^%s\\.(%s)$/', $page, $formats), true); } catch (ICE_Files_Exception $e) { // ignore file errors continue; } // get any files? if (count($files)) { // return the first one return array_shift($files); } } // no doc page found throw new Exception(sprintf('A file for the doc page "%s" does not exist in any of the configured directories', $page)); }