/** * Determines if any variants exist for the provided view file * * @param unknown $view * @param string $site * @return multitype: */ public function variants($view, $site = 'site') { $return = array(); $view = str_replace(".php", "", $view); $view = str_replace("::", "/", $view); $view = str_replace("\\", "/", $view); $pieces = explode('/', $view); $themes = (array) \Base::instance()->get('dsc.themes.' . $site); foreach ($themes as $theme => $theme_path) { // an overrides folder exists in this theme, let's check for the presence of an override for the requested view file $dir = \Dsc\Filesystem\Path::clean($theme_path . "Overrides/"); if ($dir = \Dsc\Filesystem\Path::real($dir)) { $path = \Dsc\Filesystem\Path::clean($dir . "/" . $view); if ($path = \Dsc\Filesystem\Path::real($path)) { $files = \Dsc\Filesystem\Folder::files($path); if ($files) { $return = \Dsc\ArrayHelper::set($return, $theme, $files); } } } } // now find the requested file's original app, and its corresponding view files $app = $pieces[0]; $apps = (array) \Base::instance()->get('dsc.apps'); if (array_key_exists($app, $apps)) { $dir = $apps[$app]; unset($pieces[0]); $view = implode('/', $pieces); if ($dir = \Dsc\Filesystem\Path::real($dir)) { $path = \Dsc\Filesystem\Path::clean($dir . "/" . $view); if ($path = \Dsc\Filesystem\Path::real($path)) { $files = \Dsc\Filesystem\Folder::files($path); if ($files) { $return = \Dsc\ArrayHelper::set($return, $app, $files); } } } } return $return; }