Example #1
1
 /**
  * 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;
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 public function testloadParentView()
 {
     //execute the method and test if it doesn't throws an exception
     try {
         loadParentView('classic');
         $this->assertTrue(true);
     } catch (Exception $e) {
         $this->fail();
     }
 }
Example #4
0
 /**
  * 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)) {
         if (file_exists('custom/modules/' . $target_module . '/views/view.' . $type . '.php')) {
             $view = ViewFactory::_buildFromFile('custom/modules/' . $target_module . '/views/view.' . $type . '.php', $bean, $view_object_map, $type, $target_module);
         } else {
             if (file_exists('modules/' . $target_module . '/views/view.' . $type . '.php')) {
                 $view = ViewFactory::_buildFromFile('modules/' . $target_module . '/views/view.' . $type . '.php', $bean, $view_object_map, $type, $target_module);
             }
         }
     }
     if (!isset($view)) {
         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;
 }
Example #5
0
 * 
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
//Load the parent view class if it exists.  Check for custom file first
loadParentView('edit');
require_once 'modules/ModuleBuilder/parsers/constants.php';
require_once 'include/SubPanel/SubPanel.php';
class ViewListView extends ViewEdit
{
    /**
     * @see SugarView::_getModuleTitleParams()
     */
    protected function _getModuleTitleParams($browserTitle = false)
    {
        global $mod_strings;
        return array(translate('LBL_MODULE_NAME', 'Administration'), ModuleBuilderController::getModuleTitle());
    }
    /*
     * Pseudo-constructor to enable subclasses to call a parent's constructor without knowing the parent in PHP4
     */
 public function SubpanelQuickCreate($module, $view = 'QuickCreate', $proccessOverride = false)
 {
     $this->viewType = $view;
     //treat quickedit and quickcreate views as the same
     if ($this->viewType == 'QuickEdit') {
         $this->viewType = 'QuickCreate';
     }
     // Get the viewdefs source file, called here to ensure proper viewType setting
     $source = $this->getModuleViewDefsSourceFile($module, $this->viewType);
     // locate the best viewdefs to use: 1. custom/module/quickcreatedefs.php 2. module/quickcreatedefs.php 3. custom/module/editviewdefs.php 4. module/editviewdefs.php
     $base = 'modules/' . $module . '/metadata/';
     $source = 'custom/' . $base . strtolower($view) . 'defs.php';
     if (!file_exists($source)) {
         $source = $base . strtolower($view) . 'defs.php';
         if (!file_exists($source)) {
             //if our view does not exist default to EditView
             $view = 'EditView';
             $source = 'custom/' . $base . 'editviewdefs.php';
             if (!file_exists($source)) {
                 $source = $base . 'editviewdefs.php';
             }
         }
     }
     $this->ev = $this->getEditView();
     $this->ev->view = $this->viewType;
     $this->ev->ss = new Sugar_Smarty();
     //$_REQUEST['return_action'] = 'SubPanelViewer';
     $class = $GLOBALS['beanList'][$module];
     $bean = new $class();
     if (!empty($_REQUEST['record'])) {
         $bean->retrieve($_REQUEST['record']);
     }
     $this->ev->setup($module, $bean, $source);
     unset($bean);
     // Bug 49219 - Check empty before set defaults, or the settings from viewdefs above will be overridden.
     if (!isset($this->ev->defs['templateMeta']['form']['headerTpl'])) {
         $this->ev->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl';
     }
     if (!isset($this->ev->defs['templateMeta']['form']['footerTpl'])) {
         $this->ev->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl';
     }
     // Comment below, breaks many out of the box viewdefs
     /*if (empty($this->ev->defs['templateMeta']['form']['buttons'])) $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');*/
     $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');
     //Load the parent view class if it exists.  Check for custom file first
     loadParentView('edit');
     $viewEditSource = 'modules/' . $module . '/views/view.edit.php';
     if (file_exists('custom/' . $viewEditSource)) {
         $viewEditSource = 'custom/' . $viewEditSource;
     }
     if (file_exists($viewEditSource) && !$proccessOverride) {
         include $viewEditSource;
         $c = $module . 'ViewEdit';
         $customClass = 'Custom' . $c;
         if (class_exists($customClass)) {
             $c = $customClass;
         }
         if (class_exists($c)) {
             $view = new $c();
             if ($view->useForSubpanel) {
                 $this->defaultProcess = false;
                 // Check if we should use the module's QuickCreate.tpl file.
                 if ($view->useModuleQuickCreateTemplate && file_exists('modules/' . $module . '/tpls/QuickCreate.tpl')) {
                     $this->ev->defs['templateMeta']['form']['headerTpl'] = 'modules/' . $module . '/tpls/QuickCreate.tpl';
                 }
                 $view->ev =& $this->ev;
                 $view->ss =& $this->ev->ss;
                 $class = $GLOBALS['beanList'][$module];
                 if (!empty($GLOBALS['beanFiles'][$class])) {
                     require_once $GLOBALS['beanFiles'][$class];
                     $bean = new $class();
                     $view->bean = $bean;
                 }
                 $this->ev->formName = 'form_Subpanel' . $this->ev->view . '_' . $module;
                 $view->showTitle = false;
                 // Do not show title since this is for subpanel
                 $view->display();
             }
         }
     }
     //if
     if ($this->defaultProcess && !$proccessOverride) {
         $this->process($module);
     }
 }
Example #7
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     $view = !empty($_REQUEST['target_view']) ? $_REQUEST['target_view'] : 'QuickCreate';
     $module = $_REQUEST['module'];
     // locate the best viewdefs to use: 1. custom/module/quickcreatedefs.php 2. module/quickcreatedefs.php 3. custom/module/editviewdefs.php 4. module/editviewdefs.php
     $base = 'modules/' . $module . '/metadata/';
     $source = 'custom/' . $base . strtolower($view) . 'defs.php';
     if (!file_exists($source)) {
         $source = $base . strtolower($view) . 'defs.php';
         if (!file_exists($source)) {
             //if our view does not exist default to EditView
             $view = 'EditView';
             $source = 'custom/' . $base . 'editviewdefs.php';
             if (!file_exists($source)) {
                 $source = $base . 'editviewdefs.php';
             }
         }
     }
     $this->ev = $this->getEditView();
     $this->ev->view = $view;
     $this->ev->ss = new Sugar_Smarty();
     $this->ev->ss->assign('isDCForm', $this->_isDCForm);
     //$_REQUEST['return_action'] = 'SubPanelViewer';
     $this->ev->setup($module, null, $source);
     $this->ev->showSectionPanelsTitles = false;
     $this->ev->defs['templateMeta']['form']['headerTpl'] = $this->headerTpl;
     $this->ev->defs['templateMeta']['form']['footerTpl'] = $this->footerTpl;
     $this->ev->defs['templateMeta']['form']['buttons'] = $this->defaultButtons;
     $this->ev->defs['templateMeta']['form']['button_location'] = 'bottom';
     $this->ev->defs['templateMeta']['form']['hidden'] = '<input type="hidden" name="is_ajax_call" value="1" />';
     $this->ev->defs['templateMeta']['form']['hidden'] .= '<input type="hidden" name="from_dcmenu" value="1" />';
     $defaultProcess = true;
     //Load the parent view class if it exists.  Check for custom file first
     loadParentView('edit');
     if (file_exists('modules/' . $module . '/views/view.edit.php')) {
         include 'modules/' . $module . '/views/view.edit.php';
         $c = $module . 'ViewEdit';
         if (class_exists($c)) {
             $view = new $c();
             if ($view->useForSubpanel) {
                 $defaultProcess = false;
                 //Check if we shold use the module's QuickCreate.tpl file
                 if ($view->useModuleQuickCreateTemplate && file_exists('modules/' . $module . '/tpls/QuickCreate.tpl')) {
                     $this->ev->defs['templateMeta']['form']['headerTpl'] = 'modules/' . $module . '/tpls/QuickCreate.tpl';
                 }
                 $view->ev =& $this->ev;
                 $view->ss =& $this->ev->ss;
                 $class = $GLOBALS['beanList'][$module];
                 if (!empty($GLOBALS['beanFiles'][$class])) {
                     require_once $GLOBALS['beanFiles'][$class];
                     $bean = new $class();
                     $view->bean = $bean;
                 }
                 $view->ev->formName = 'form_DC' . $view->ev->view . '_' . $module;
                 $view->showTitle = false;
                 // Do not show title since this is for subpanel
                 $view->display();
             }
         }
     }
     //if
     if ($defaultProcess) {
         $form_name = 'form_DC' . $this->ev->view . '_' . $module;
         $this->ev->formName = $form_name;
         $this->ev->process(true, $form_name);
         echo $this->ev->display(false, true);
     }
 }
 public function SubpanelQuickCreate($module, $view = 'QuickCreate', $proccessOverride = false)
 {
     $this->viewType = $view;
     //treat quickedit and quickcreate views as the same
     if ($this->viewType == 'QuickEdit') {
         $this->viewType = 'QuickCreate';
     }
     // locate the best viewdefs to use: 1. custom/module/quickcreatedefs.php 2. module/quickcreatedefs.php 3. editviewdefs as in metafile
     $source = SugarAutoLoader::existingCustomOne("modules/{$module}/metadata/quickcreatedefs.php");
     if (!$source) {
         $source = SugarAutoLoader::loadWithMetafiles($module, "editviewdefs");
         $this->viewType = 'EditView';
     }
     $this->ev = $this->getEditView();
     $this->ev->view = $this->viewType;
     $this->ev->ss = new Sugar_Smarty();
     $bean = BeanFactory::getBean($module);
     if ($bean && !empty($_REQUEST['record'])) {
         $bean->retrieve($_REQUEST['record']);
     }
     $this->ev->setup($module, $bean, $source);
     unset($bean);
     // Bug 49219 - Check empty before set defaults, or the settings from viewdefs above will be overridden.
     if (!isset($this->ev->defs['templateMeta']['form']['headerTpl'])) {
         $this->ev->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl';
     }
     if (!isset($this->ev->defs['templateMeta']['form']['footerTpl'])) {
         $this->ev->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl';
     }
     // Comment below, breaks many out of the box viewdefs
     /*if (empty($this->ev->defs['templateMeta']['form']['buttons'])) $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');*/
     $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');
     //Load the parent view class if it exists.  Check for custom file first
     loadParentView('edit');
     $viewEditSource = SugarAutoLoader::existingCustomOne('modules/' . $module . '/views/view.edit.php');
     if (!empty($viewEditSource) && !$proccessOverride) {
         require_once $viewEditSource;
         $c = SugarAutoLoader::customClass($module . 'ViewEdit');
         if (class_exists($c)) {
             $view = new $c();
             if ($view->useForSubpanel) {
                 $this->defaultProcess = false;
                 // Check if we should use the module's QuickCreate.tpl file.
                 if ($view->useModuleQuickCreateTemplate && SugarAutoLoader::fileExists('modules/' . $module . '/tpls/QuickCreate.tpl')) {
                     $this->ev->defs['templateMeta']['form']['headerTpl'] = 'modules/' . $module . '/tpls/QuickCreate.tpl';
                 }
                 $view->ev = $this->ev;
                 $view->ss = $this->ev->ss;
                 $view->bean = BeanFactory::getBean($module);
                 $this->ev->formName = 'form_Subpanel' . $this->ev->view . '_' . $module;
                 $view->showTitle = false;
                 // Do not show title since this is for subpanel
                 $view->display();
             }
         }
     }
     //if
     if ($this->defaultProcess && !$proccessOverride) {
         $this->process($module);
     }
 }
 function SubpanelQuickCreate($module, $view = 'QuickCreate', $proccessOverride = false)
 {
     // locate the best viewdefs to use: 1. custom/module/quickcreatedefs.php 2. module/quickcreatedefs.php 3. custom/module/editviewdefs.php 4. module/editviewdefs.php
     $base = 'modules/' . $module . '/metadata/';
     $source = 'custom/' . $base . strtolower($view) . 'defs.php';
     if (!file_exists($source)) {
         $source = $base . strtolower($view) . 'defs.php';
         if (!file_exists($source)) {
             //if our view does not exist default to EditView
             $view = 'EditView';
             $source = 'custom/' . $base . 'editviewdefs.php';
             if (!file_exists($source)) {
                 $source = $base . 'editviewdefs.php';
             }
         }
     }
     $this->ev = new EditView();
     $this->ev->view = $view;
     $this->ev->ss = new Sugar_Smarty();
     //$_REQUEST['return_action'] = 'SubPanelViewer';
     $this->ev->setup($module, null, $source);
     $this->ev->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl';
     $this->ev->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl';
     $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');
     //Load the parent view class if it exists.  Check for custom file first
     loadParentView('edit');
     $viewEditSource = 'modules/' . $module . '/views/view.edit.php';
     if (file_exists('custom/' . $viewEditSource)) {
         $viewEditSource = 'custom/' . $viewEditSource;
     }
     if (file_exists($viewEditSource) && !$proccessOverride) {
         include $viewEditSource;
         $c = $module . 'ViewEdit';
         $customClass = 'Custom' . $c;
         if (class_exists($customClass)) {
             $c = $customClass;
         }
         if (class_exists($c)) {
             $view = new $c();
             if ($view->useForSubpanel) {
                 $this->defaultProcess = false;
                 //Check if we shold use the module's QuickCreate.tpl file
                 if ($view->useModuleQuickCreateTemplate && file_exists('modules/' . $module . '/tpls/QuickCreate.tpl')) {
                     $this->ev->defs['templateMeta']['form']['headerTpl'] = 'modules/' . $module . '/tpls/QuickCreate.tpl';
                 }
                 $view->ev =& $this->ev;
                 $view->ss =& $this->ev->ss;
                 $class = $GLOBALS['beanList'][$module];
                 if (!empty($GLOBALS['beanFiles'][$class])) {
                     require_once $GLOBALS['beanFiles'][$class];
                     $bean = new $class();
                     $view->bean = $bean;
                 }
                 $this->ev->formName = 'form_Subpanel' . $this->ev->view . '_' . $module;
                 $view->showTitle = false;
                 // Do not show title since this is for subpanel
                 $view->display();
             }
         }
     }
     //if
     if ($this->defaultProcess && !$proccessOverride) {
         $this->process($module);
     }
 }