/** * load the correct view * * @param string $type View Type * * @param string $module * @param SugarBean|null $bean * @param array $view_object_map * @param string $target_module * * @return SugarView */ public static function loadView($type = 'default', $module, SugarBean $bean = null, array $view_object_map = [], $target_module = '') { $type = strtolower($type); //first let's check if the module handles this view $view = null; //Check to see if we should load a custom parent view instance loadParentView($type); if (!empty($target_module)) { if (file_exists($path = DOCROOT . "custom/modules/{$target_module}/views/view.{$type}.php")) { $view = ViewFactory::_buildFromFile($path, $bean, $view_object_map, $type, $target_module); } else { if (file_exists($path = DOCROOT . "modules/{$target_module}/views/view.{$type}.php")) { $view = ViewFactory::_buildFromFile($path, $bean, $view_object_map, $type, $target_module); } } } if (!isset($view)) { if (file_exists($path = DOCROOT . "custom/modules/{$module}/views/view.{$type}.php")) { $view = ViewFactory::_buildFromFile($path, $bean, $view_object_map, $type, $module); } else { if (file_exists($path = DOCROOT . "modules/{$module}/views/view.{$type}.php")) { $view = ViewFactory::_buildFromFile($path, $bean, $view_object_map, $type, $module); } else { if (file_exists($path = DOCROOT . "custom/include/MVC/View/views/view.{$type}.php")) { $view = ViewFactory::_buildFromFile($path, $bean, $view_object_map, $type, $module); } else { if (file_exists($path = DOCROOT . "include/MVC/View/views/view.{$type}.php")) { //it appears Sugar does have the proper logic for this file. $view = ViewFactory::_buildFromFile($path, $bean, $view_object_map, $type, $module); } } } } } // Default to SugarView if still nothing found/built if (is_null($view)) { $view = new SugarView(); } ViewFactory::_loadConfig($view, $type); return $view; }
/** * load the correct view * @param string $type View Type * @return valid view */ function loadView($type = 'default', $module, $bean = null, $view_object_map = array(), $target_module = '') { $type = strtolower($type); //first let's check if the module handles this view $view = null; //Check to see if we should load a custom parent view instance loadParentView($type); if (!empty($target_module)) { $view_file = SugarAutoLoader::existingCustomOne('modules/' . $target_module . '/views/view.' . $type . '.php'); $view_module = $target_module; } else { $view_module = $module; } if (empty($view_file)) { $view_file = SugarAutoLoader::existingCustomOne('modules/' . $module . '/views/view.' . $type . '.php'); } if (empty($view_file)) { $view_file = SugarAutoLoader::existingCustomOne('include/MVC/View/views/view.' . $type . '.php'); } if (!empty($view_file)) { $view = ViewFactory::_buildFromFile($view_file, $bean, $view_object_map, $type, $view_module); } if (empty($view)) { // Default to SugarView if still nothing found/built $view = new SugarView(); } ViewFactory::_loadConfig($view, $type); return $view; }
/** * load the correct view * @param string $type View Type * @return valid view */ function loadView($type = 'default', $module, $bean = null, $view_object_map = array()) { $type = strtolower($type); //first let's check if the module handles this view $view = null; if (file_exists('custom/modules/' . $module . '/views/view.' . $type . '.php')) { $view = ViewFactory::_buildFromFile('custom/modules/' . $module . '/views/view.' . $type . '.php', $bean, $view_object_map, $type, $module); } else { if (file_exists('modules/' . $module . '/views/view.' . $type . '.php')) { $view = ViewFactory::_buildFromFile('modules/' . $module . '/views/view.' . $type . '.php', $bean, $view_object_map, $type, $module); } else { if (file_exists('custom/include/MVC/View/views/view.' . $type . '.php')) { $view = ViewFactory::_buildFromFile('custom/include/MVC/View/views/view.' . $type . '.php', $bean, $view_object_map, $type, $module); } else { //if the module does not handle this view, then check if Sugar handles it OOTB $file = 'include/MVC/View/views/view.' . $type . '.php'; if (file_exists($file)) { //it appears Sugar does have the proper logic for this file. $view = ViewFactory::_buildFromFile($file, $bean, $view_object_map, $type, $module); } } } } // Default to SugarView if still nothing found/built if (!isset($view)) { $view = new SugarView(); } ViewFactory::_loadConfig($view, $type); return $view; }
public function test_buildFromFile() { //checck with valid values and test if it returns correct view instance $type = 'list'; $target_module = 'Users'; $bean = null; $view = ViewFactory::_buildFromFile('modules/' . $target_module . '/views/view.' . $type . '.php', $bean, array(), $type, $target_module); $this->assertInstanceOf('UsersViewList', $view); //checck with valid values and test if it returns correct view instance $type = 'detail'; $target_module = 'Users'; $bean = null; $view = ViewFactory::_buildFromFile('modules/' . $target_module . '/views/view.' . $type . '.php', $bean, array(), $type, $target_module); $this->assertInstanceOf('UsersViewDetail', $view); }