function process($option)
 {
     $_REQUEST['setFile'] = $_SESSION['studio']['backupLastFile'];
     $the_module = $_SESSION['studio']['module'];
     $files = StudioParser::getFiles($the_module);
     $file = $files[$_SESSION['studio']['selectedFileId']]['template_file'];
     $preview_file = 'custom/backup/' . $file . '[' . $option . ']';
     if (!empty($_GET['preview'])) {
         $this->display();
     } else {
         if (!file_exists($preview_file)) {
             $this->display();
             return false;
         } else {
             if (!empty($_GET['delete'])) {
                 $this->sb->deleteBackup($preview_file);
                 $this->display();
             } else {
                 if (!empty($_GET['restore'])) {
                     if ($this->sb->restoreBackup($preview_file)) {
                         $this->status = 'Restored';
                     } else {
                         $this->status = ' Restore Failed';
                     }
                     $this->display();
                 }
             }
         }
     }
 }
 function process($option)
 {
     if (!empty($_SESSION['studio']['lastWizard']) && $_SESSION['studio']['lastWizard'] == 'ManageBackups') {
         header("Location: index.php?module=Studio&action=wizard&wizard=ManageBackups&setFile=" . $option);
         sugar_exit();
     }
     $the_module = $_SESSION['studio']['module'];
     require_once 'modules/Studio/parsers/StudioParser.php';
     $fileDef = StudioParser::getFiles($the_module, $option);
     $special = '';
     if ($fileDef['type'] == 'ListView') {
         $special = '&listview=true';
     }
     $_SESSION['studio']['selectedFileId'] = $option;
     header("Location: index.php?module=Studio&action=index&setLayout=true{$special}");
     sugar_exit();
 }
/**
 * The contents of this file are subject to the SugarCRM Public License Version
 * 1.1.3 ("License"); You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * All copies of the Covered Code must include on each user interface screen:
 *    (i) the "Powered by SugarCRM" logo and
 *    (ii) the SugarCRM copyright notice
 * in the same form as they appear in the distribution.  See full license for
 * requirements.
 *
 * The Original Code is: SugarCRM Open Source
 * The Initial Developer of the Original Code is SugarCRM, Inc.
 * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 */
$the_module = $_SESSION['studio']['module'];
ob_clean();
require_once 'modules/Studio/parsers/StudioParser.php';
$fileDef = StudioParser::getFiles($the_module, $_SESSION['studio']['selectedFileId']);
$workingFile = StudioParser::getWorkingFile($fileDef['template_file']);
//BACKUP EXISTING FILE
require_once 'modules/Studio/SugarBackup.php';
SugarBackup::backup($fileDef['template_file']);
copy($workingFile, $fileDef['template_file']);
sugar_cleanup(true);
 * in the same form as they appear in the distribution.  See full license for
 * requirements.
 *
 * The Original Code is: SugarCRM Open Source
 * The Initial Developer of the Original Code is SugarCRM, Inc.
 * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 */
//expects the following variables to be set (needs global scope)
//$file, $the_module
require_once 'modules/Studio/parsers/StudioParser.php';
if (!isset($the_module)) {
    $the_module = $_SESSION['studio']['module'];
}
$files = StudioParser::getFiles($the_module);
$file = $files[$_SESSION['studio']['selectedFileId']]['template_file'];
$preview_file = false;
if (isset($_REQUEST['preview_file'])) {
    $preview_file = 'custom/backup/' . $file . '[' . $_REQUEST['preview_file'] . ']';
    if (!file_exists($preview_file)) {
        echo 'no access';
        sugar_cleanup(true);
    }
}
require_once 'modules/' . $the_module . '/Forms.php';
if (!isset($sp)) {
    $sp = new StudioParser();
}
if (!$preview_file) {
    $sp->loadFile($file);
Example #5
0
 function cacheXTPL($file, $cache_file, $preview_file = false)
 {
     global $beanList;
     //now if we have a backup_file lets use that instead of the original
     if ($preview_file) {
         $file = $preview_file;
     }
     if (!isset($the_module)) {
         $the_module = $_SESSION['studio']['module'];
     }
     $files = StudioParser::getFiles($the_module);
     $xtpl = $files[$_SESSION['studio']['selectedFileId']]['php_file'];
     $originalFile = $files[$_SESSION['studio']['selectedFileId']]['template_file'];
     $type = StudioParser::getFileType($files[$_SESSION['studio']['selectedFileId']]['type']);
     $buffer = sugar_file_get_contents($xtpl);
     $cache_file = create_cache_directory('studio/' . $file);
     $xtpl_cache = create_cache_directory('studio/' . $xtpl);
     $module = $this->workingModule;
     $form_string = "require_once('modules/" . $module . "/Forms.php');";
     if ($type == 'edit' || $type == 'detail') {
         if (empty($_REQUEST['record'])) {
             $buffer = preg_replace('(\\$xtpl[\\ ]*=)', "\$focus->assign_display_fields('{$module}'); \$0", $buffer);
         } else {
             $buffer = preg_replace('(\\$xtpl[\\ ]*=)', "\$focus->retrieve('" . $_REQUEST['record'] . "');\n\$focus->assign_display_fields('{$module}');\n \$0", $buffer);
         }
     }
     $_REQUEST['query'] = true;
     if (substr_count($file, 'SearchForm') > 0) {
         $temp_xtpl = new XTemplate($file);
         if ($temp_xtpl->exists('advanced')) {
             global $current_language;
             $mods = return_module_language($current_language, 'DynamicLayout');
             $mod = BeanFactory::getBean($module);
             $this->populateRequestFromBuffer($file);
             $mod->assign_display_fields($module);
             $buffer = str_replace(array('echo $lv->display();', '$search_form->parse("advanced");', '$search_form->out("advanced");', '$search_form->parse("main");', '$search_form->out("main");'), '', $buffer);
             $buffer = str_replace('echo get_form_footer();', '$search_form->parse("main");' . "\n" . '$search_form->out("main");' . "\necho '<br><b>" . translate('LBL_ADVANCED', 'DynamicLayout') . "</b><br>';" . '$search_form->parse("advanced");' . "\n" . '$search_form->out("advanced");' . "\n \$sugar_config['list_max_entries_per_page'] = 1;", $buffer);
         }
     } else {
         if ($type == 'detail') {
             $buffer = str_replace('header(', 'if(false) header(', $buffer);
         }
     }
     $buffer = str_replace($originalFile, $cache_file, $buffer);
     $buffer = "<?php\n\$sugar_config['list_max_entries_per_page'] = 1;\n ?>" . $buffer;
     $buffer = str_replace($form_string, '', $buffer);
     $buffer = $this->disableInputs($buffer);
     $xtpl_fp_cache = sugar_fopen($xtpl_cache, 'w');
     fwrite($xtpl_fp_cache, $buffer);
     fclose($xtpl_fp_cache);
     return $xtpl_cache;
 }