// You need to + sign it, so setImage will work. self::$imagePaths += [ //A //B //C //D "down" => THEMES."admin_themes/".fusion_get_settings('admin_theme')."/images/down.png", //E //F //G //H //I "imagenotfound" => IMAGES."imagenotfound.jpg", //J //K //L "left" => THEMES."admin_themes/".fusion_get_settings('admin_theme')."/images/left.png", //M //N "noavatar" => IMAGES."avatars/no-avatar.jpg", //O //P "panel_on" => IMAGES."panel_on.gif", "panel_off" => IMAGES."panel_off.gif", //Q //R "right" => THEMES."admin_themes/".fusion_get_settings('admin_theme')."/images/right.png", //S //T //U "up" => THEMES."admin_themes/".fusion_get_settings('admin_theme')."/images/up.png", //V //W //X //Y //Z ]; // $installedTables = [ 'blog' => defined('BLOG_EXIST'), 'news' => defined('NEWS_EXIST') ]; $selects = "SELECT admin_image as image, admin_rights as name, 'ac_' as prefix FROM ".DB_ADMIN; $result = dbquery($selects); if (dbrows($result)) { while ($data = dbarray($result)) { $image = file_exists(ADMIN."images/".$data['image']) ? ADMIN."images/".$data['image'] : (file_exists(INFUSIONS.$data['image']) ? INFUSIONS.$data['image'] : ADMIN."images/infusion_panel.png"); if (empty(self::$imagePaths[$data['prefix'].$data['name']])) { self::$imagePaths[$data['prefix'].$data['name']] = $image; } } } //smiley foreach (cache_smileys() as $smiley) { // set image if (empty(self::$imagePaths["smiley_".$smiley['smiley_text']])) { self::$imagePaths["smiley_".$smiley['smiley_text']] = fusion_get_settings('siteurl')."images/smiley/".$smiley['smiley_image']; } } $selects_ = []; if ($installedTables['blog']) { $selects_[] = "SELECT blog_cat_image as image, blog_cat_name as name, 'bl_' as prefix FROM ".DB_BLOG_CATS." ".(multilang_table("BL") ? " where ".in_group('blog_cat_language', LANGUAGE) : ""); } if ($installedTables['news']) { $selects_[] = "SELECT news_cat_image as image, news_cat_name as name, 'nc_' as prefix FROM ".DB_NEWS_CATS." ".(multilang_table("NS") ? " where ".in_group('news_cat_language', LANGUAGE) : ""); } if (!empty($selects_)) { $union = implode(' union ', $selects_); $result = dbquery($union); while ($data = dbarray($result)) { switch ($data['prefix']) { case 'nc_': default : $image = file_exists(INFUSIONS.'news/news_cats/'.$data['image']) ? INFUSIONS.'news/news_cats/'.$data['image'] : IMAGES."imagenotfound.jpg"; break; case 'bl_': $image = file_exists(INFUSIONS.'blog/blog_cats/'.$data['image']) ? INFUSIONS.'blog/blog_cats/'.$data['image'] : IMAGES."imagenotfound.jpg"; break; } // Set image if (empty(self::$imagePaths[$data['prefix'].$data['name']])) { self::$imagePaths[$data['prefix'].$data['name']] = $image; } } } } /** * Get the imagepath or the html "img" tag * * @param string $image The name of the image. * @param string $alt "alt" attribute of the image * @param string $style "style" attribute of the image * @param string $title "title" attribute of the image * @param string $atts Custom attributes of the image * * @return string The path of the image if the first argument is given, * but others not. Otherwise the html "img" tag */ public static function getImage($image, $alt = "", $style = "", $title = "", $atts = "") { self::cache(); $url = isset(self::$imagePaths[$image]) ? self::$imagePaths[$image] : IMAGES."imagenotfound.jpg"; if ($style) { $style = " style='$style'"; } if ($title) { $title = " title='".$title."'"; } return ($alt or $style or $title or $atts) ? "".$alt."" : $url; } /** * Set a path of an image * * @param string $name * @param string $path */ public static function setImage($name, $path) { self::$imagePaths[$name] = $path; } /** * Replace a part in each path * * @param string $source * @param string $target */ public static function replaceInAllPath($source, $target) { self::cache(); foreach (self::$imagePaths as $name => $path) { self::$imagePaths[$name] = str_replace($source, $target, $path); } } /** * Given a path, returns an array of all files * * @param $path * * @return array */ public static function getFileList($path) { $image_list = []; if (is_dir($path)) { $image_files = makefilelist($path, ".|..|index.php", TRUE); foreach ($image_files as $image) { $image_list[$image] = $image; } } return (array)$image_list; } /** * Cache installed smiley images from database * * @return array|null */ private static $smiley_cache = NULL; public static function cache_smileys() { if (self::$smiley_cache === NULL) { self::$smiley_cache = []; $result = dbquery("SELECT smiley_code, smiley_image, smiley_text FROM ".DB_SMILEYS); while ($data = dbarray($result)) { self::$smiley_cache[] = [ 'smiley_code' => $data['smiley_code'], 'smiley_image' => $data['smiley_image'], 'smiley_text' => $data['smiley_text'] ]; } } return self::$smiley_cache; } }