1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
3 * Help class to ease the customization of the Ninja GUI Logo
7 * Display the div with the logo if it's all enabled
9 public static function Render()
11 if (!Kohana
::Config('customlogo.enable'))
14 $logo = customlogo
::imageExists($image = customlogo
::getImage());
18 echo html
::image(array(
33 * Function to check if the image actually exists, else we won't display the logo
35 function imageExists($logo)
38 return is_readable($logo);
44 * Get the logo we should use based on some nifty logic
48 $path = 'application/views/icons/';
49 $icon = $path . Kohana
::config('customlogo.path') . Kohana
::config('customlogo.default_icon');
52 * Get list of icons found in the custom_logo dir and
53 * try to match it towards your pattern defined in config
55 $images = customlogo
::getCustomImageList();
60 if (!preg_match(Kohana
::config('customlogo.pattern'), user
::session('username'), $custom)) {
64 foreach ($images as $image) {
65 if (($image == $custom[1] . '.png') ||
($image == $custom[1] . '.jpg')) {
66 return $path . Kohana
::config('customlogo.path') . $image;
75 * Read the custom dir defined in customlogo config file
76 * return an array of the names.
78 function getCustomImageList()
81 if ($fh = opendir(APPPATH
.'views/icons/'.Kohana
::Config('customlogo.path'))) {
82 while (false !== ($file = readdir($fh))) {
83 if ((substr($file, -4) == '.png') ||
(substr($file, -4) == '.jpg')) {