/** */ 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 URL to first script matching path in the scheme stack * * @package Infinity-api * @param string $path Script file path RELATIVE to your script_root setting */ function infinity_script_url($path) { // locate script in scheme stack $script_path = infinity_script_path($path); // convert path to url return $script_path ? ICE_Files::theme_file_to_url($script_path) : null; }
/** */ public function get_image_url() { // get value $value = $this->get(); // has a value? if ($value) { // yep, locate path $path = ICE_Scheme::instance()->locate_file($this->file_directory); // find that dir path? if ($path) { // yep, return as url return ICE_Files::theme_file_to_url($path . '/' . $value); } } // value not set return null; }
/** * Return URL to an ext file * * @param string $filename * @return string|false */ public final function locate_file_url($filename) { // locate the file path $path = $this->locate_file($filename); // was a path found? if ($path) { // yes, use files util to get URL return ICE_Files::theme_file_to_url($path); } // no file found return false; }
/** * Return path to a dashboard image * * @package Infinity * @subpackage dashboard * @param string $name image file name * @return string */ function infinity_dashboard_image($name) { $path = infinity_locate_file(INFINITY_ADMIN_DIR . '/assets/images/' . $name); if ($path) { return ICE_Files::theme_file_to_url($path); } else { return ''; } }