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);
function upgradeHTML($file)
{
    global $studio;
    $studio->loadFile($file);
    $studio->curText = $studio->replaceH4Slots($studio->curText);
    $studio->parseSlots($studio->curText);
    $studio->cleanUpSlots();
    $newSlots = $studio->upgradeSlots();
    copy($file, $file . '.sbk');
    $studio->saveFile($file, $newSlots);
}
$htmlFiles = array();
function findHTMLFiles($path)
{
    $dir = dir($path);
    while ($entry = $dir->read()) {
        if (file_exists('modules/' . $entry . '/metadata/studio.php')) {
            require_once 'modules/' . $entry . '/metadata/studio.php';
            echo "Upgrading {$entry} for studio ... \n";
            foreach ($GLOBALS['studioDefs'][$entry] as $label => $def) {
                if (!empty($def['template_file']) && substr_count($def['template_file'], '.html') > 0) {
                    upgradeHTML($def['template_file']);
                }
            }
        }
    }
}
findHTMLFiles('modules');
StudioParser::clearWorkingDirectory();
require_once 'modules/Versions/Version.php';
Version::mark_upgraded('Studio Files', '4.5.0', '4.5.0');
Example #5
0
        } else {
            $selected_dropdown[$key] = array('lang' => $value);
        }
    }
    $selected_dropdown = $dh->filterDropDown($_REQUEST['dropdown_name'], $selected_dropdown);
    $smarty->assign('dropdown', $selected_dropdown);
    $smarty->assign('dropdown_name', $_REQUEST['dropdown_name']);
}
$smarty->assign('dropdown_languages', get_languages());
if (strcmp($_REQUEST['dropdown_name'], 'moduleList') == 0) {
    $smarty->assign('disable_remove', true);
    $smarty->assign('disable_add', true);
    $smarty->assign('use_push', 1);
} else {
    $smarty->assign('use_push', 0);
}
$imageSave = SugarThemeRegistry::current()->getImage('studio_save', '', null, null, '.gif', $mod_strings['LBL_SAVE']);
$imageUndo = SugarThemeRegistry::current()->getImage('studio_undo', '', null, null, '.gif', $mod_strings['LBL_UNDO']);
$imageRedo = SugarThemeRegistry::current()->getImage('studio_redo', '', null, null, '.gif', $mod_strings['LBL_REDO']);
$buttons = array();
$buttons[] = array('text' => $mod_strings['LBL_BTN_UNDO'], 'actionScript' => "onclick='jstransaction.undo()'");
$buttons[] = array('text' => $mod_strings['LBL_BTN_REDO'], 'actionScript' => "onclick='jstransaction.redo()'");
$buttons[] = array('text' => $mod_strings['LBL_BTN_SAVE'], 'actionScript' => "onclick='if(check_form(\"editdropdown\")){document.editdropdown.submit();}'");
$buttonTxt = StudioParser::buildImageButtons($buttons);
$smarty->assign('buttons', $buttonTxt);
$smarty->assign('dropdown_lang', $selected_lang);
$editImage = SugarThemeRegistry::current()->getImage('edit_inline', '', null, null, '.gif', $mod_strings['LBL_INLINE']);
$smarty->assign('editImage', $editImage);
$deleteImage = SugarThemeRegistry::current()->getImage('delete_inline', '', null, null, '.gif', $mod_strings['LBL_DELETE']);
$smarty->assign('deleteImage', $deleteImage);
$smarty->display("modules/Studio/DropDowns/EditView.tpl");
 function getForm()
 {
     $this->form .= "<input type='hidden' name='parser' value='StudioRowParser'>";
     return parent::getForm();
 }
Example #7
0
 /**
  * Main display function.
  *
  * @return void
  */
 protected function display()
 {
     global $app_list_strings, $mod_strings;
     require_once 'modules/Studio/parsers/StudioParser.php';
     $dh = new DropDownHelper();
     $smarty = new Sugar_Smarty();
     $smarty->assign('MOD', $GLOBALS['mod_strings']);
     $title = getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array("<a href='index.php?module=Administration&action=index'>" . $mod_strings['LBL_MODULE_NAME'] . "</a>", $mod_strings['LBL_RENAME_TABS']), false);
     $smarty->assign('title', $title);
     $selected_lang = !empty($_REQUEST['dropdown_lang']) ? $_REQUEST['dropdown_lang'] : $_SESSION['authenticated_user_language'];
     if (empty($selected_lang)) {
         $selected_lang = $GLOBALS['sugar_config']['default_language'];
     }
     if ($selected_lang == $GLOBALS['current_language']) {
         $my_list_strings = $GLOBALS['app_list_strings'];
     } else {
         $my_list_strings = return_app_list_strings_language($selected_lang);
     }
     $selected_dropdown = $my_list_strings['moduleList'];
     $selected_dropdown_singular = $my_list_strings['moduleListSingular'];
     foreach ($selected_dropdown as $key => $value) {
         $singularValue = isset($selected_dropdown_singular[$key]) ? $selected_dropdown_singular[$key] : $value;
         if ($selected_lang != $_SESSION['authenticated_user_language'] && !empty($app_list_strings['moduleList']) && isset($app_list_strings['moduleList'][$key])) {
             $selected_dropdown[$key] = array('lang' => $value, 'user_lang' => '[' . $app_list_strings['moduleList'][$key] . ']', 'singular' => $singularValue);
         } else {
             $selected_dropdown[$key] = array('lang' => $value, 'singular' => $singularValue);
         }
     }
     $selected_dropdown = $dh->filterDropDown('moduleList', $selected_dropdown);
     $smarty->assign('dropdown', $selected_dropdown);
     $smarty->assign('dropdown_languages', get_languages());
     $buttons = array();
     $buttons[] = array('text' => $mod_strings['LBL_BTN_UNDO'], 'actionScript' => "onclick='jstransaction.undo()'");
     $buttons[] = array('text' => $mod_strings['LBL_BTN_REDO'], 'actionScript' => "onclick='jstransaction.redo()'");
     $buttons[] = array('text' => $mod_strings['LBL_BTN_SAVE'], 'actionScript' => "onclick='if(check_form(\"editdropdown\")){document.editdropdown.submit();}'");
     $buttonTxt = StudioParser::buildImageButtons($buttons);
     $smarty->assign('buttons', $buttonTxt);
     $smarty->assign('dropdown_lang', $selected_lang);
     $editImage = SugarThemeRegistry::current()->getImage('edit_inline', '');
     $smarty->assign('editImage', $editImage);
     $deleteImage = SugarThemeRegistry::current()->getImage('delete_inline', '');
     $smarty->assign('deleteImage', $deleteImage);
     $smarty->display("modules/Studio/wizards/RenameModules.tpl");
 }
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);
} else {
    $sp->loadFile($preview_file);
}
$sp->workingModule = $the_module;
if (empty($preview_file)) {
    $sp->parsePositions($sp->curText);
    $view = $sp->prepYahooSlots();
    $preview_file = false;
} else {
    $view = $sp->curText;
}
require_once 'themes/' . $theme . '/layout_utils.php';
Example #9
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;
 }
if (!empty($_REQUEST['parser'])) {
    $parser = $_REQUEST['parser'];
    require_once $GLOBALS['studioConfig']['parsers'][$_REQUEST['parser']];
} else {
    require_once 'modules/Studio/parsers/' . $parser . '.php';
}
$sp = new $parser();
require_once 'modules/Studio/SugarBackup.php';
$files = $sp->getFiles($the_module);
if (empty($_SESSION['studio']['selectedFileId'])) {
    $keys = array_keys($files);
    $_SESSION['studio']['selectedFileId'] = $keys[0];
}
$studioDef = $files[$_SESSION['studio']['selectedFileId']];
$file = $studioDef['template_file'];
$file = StudioParser::getWorkingFile($file);
$the_class = $beanList[$the_module];
require_once $beanFiles[$the_class];
$the_focus = new $the_class();
$type = $sp->getFileType($studioDef['type']);
$GLOBALS['layout_edit_mode'] = true;
$sp->loadFile($file);
$sp->parse($sp->curText);
$sp->workingModule = $the_module;
$sp->focus =& $the_focus;
$view = $sp->prepSlots();
$xtpl = $sp->writeToCache($file, $view);
echo $sp->yahooJS();
echo $sp->getFormButtons();
//change mod strings to module
$prev_mod = $mod_strings;
 /**
  * Restores a backup overwriting the current working copy
  *
  * @param unknown_type $file
  * @param unknown_type $backupid
  */
 function restoreBackup($backupfile)
 {
     $info = $this->getBackupInfo($backupfile);
     $status = copy($backupfile, $info['original_file']);
     if ($status) {
         $wf = StudioParser::getWorkingFile($info['original_file'], true);
     }
     return $status;
 }
Example #12
0
 */
$the_module = $_SESSION['studio']['module'];
require_once 'modules/Studio/ajax/relatedfiles.php';
require_once 'modules/Studio/parsers/StudioParser.php';
require_once 'modules/Studio/StudioFields.php';
$fileDef = StudioParser::getFiles($the_module, $_SESSION['studio']['selectedFileId']);
$file = $fileDef['template_file'];
$file = StudioParser::getWorkingFile($file);
//Instantiate Bean
$the_class = $beanList[$the_module];
require_once $beanFiles[$the_class];
$the_focus = new $the_class();
$parsers = StudioParser::getParsers($file);
$parser = $parsers['default'];
if (!empty($_REQUEST['parser'])) {
    $parser = $_REQUEST['parser'];
}
require_once 'modules/Studio/parsers/' . $parser . '.php';
$sp = new $parser();
$sp->loadFile($file);
$sp->workingModule = $the_module;
$sp->parse($sp->curText);
$sp->focus =& $the_focus;
$sp->handleSave();
//save changes to the labels
if ($sp->labelEditor) {
    StudioParser::handleSaveLabels($the_module, $current_language);
}
//redirect
ob_clean();
header('Location: index.php?module=Studio&action=index&setLayout=true');
Example #13
0
$required_opt = !empty($_REQUEST['required_option']) ? 'required' : 'optional';
$id = !empty($_REQUEST['id']) ? $_REQUEST['id'] : '';
if (empty($id)) {
    $custom_fields->addField($_REQUEST['name'], $label, $_REQUEST['data_type'], $max_size, $required_opt, $default_value, $ext1, $ext2, $ext3, $audit_value, $mass_update, $ext4, $help, $_REQUEST['duplicate_merge']);
} else {
    $values = array('max_size' => $max_size, 'required_option' => $required_opt, 'default_value' => $default_value, 'audited' => $audit_value, 'mass_update' => $mass_update, 'ext4' => $ext4, 'help' => $help, 'duplicate_merge' => $_REQUEST['duplicate_merge']);
    if (!empty($ext1)) {
        $values['ext1'] = $ext1;
    }
    $custom_fields->updateField($id, $values);
}
if (!empty($_REQUEST['popup'])) {
    ob_clean();
    $name = $custom_fields->getDBName($_REQUEST['name']);
    $files = StudioParser::getFiles($module);
    $view = StudioParser::getFileType($files[$_SESSION['studio']['selectedFileId']]['type']);
    $custom_fields->avail_fields = array();
    $custom_fields->getAvailableFields(true);
    $field = $custom_fields->getField($name);
    $custom_fields->bean->field_defs[$name] = $field->get_field_def();
    $custom_fields->bean->field_defs[$name]['type'] = $custom_fields->bean->field_defs[$name]['custom_type'];
    $html = $custom_fields->getAllBeanFieldsView($view, 'html');
    $html = $html[$name];
    $string = '[NAME]' . $name . '[TYPE]' . $html['fieldType'] . '[LABEL]' . translate(str_replace(array('{', '}', 'MOD.', 'mod.', 'APP.', 'app.'), '', $html['label']), $module);
    $string .= '[DATA]' . $html['html'];
    echo str_replace(array('{', '}', 'MOD.', 'mod.', 'APP.', 'app.'), '', $string);
    sugar_cleanup(true);
} else {
    header("Location: index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=ViewCustomFields");
    sugar_cleanup(true);
}
 *
 * 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): ______________________________________.
 */
require_once 'include/SubPanel/SubPanel.php';
require_once 'modules/Studio/parsers/StudioParser.php';
$moduleFiles = StudioParser::getFiles($the_module);
echo '<table width="100%" class="tabForm" cellpadding="0" cellspacing="0"><tr><td align="right"><b>Layouts:</b></td><td class="dataLabel" align="left">';
$count = 0;
foreach ($moduleFiles as $id => $attr) {
    $label = translate($id, $the_module);
    if ($count > 0) {
        echo '&nbsp;|&nbsp;';
    }
    echo " <a href='index.php?module=Studio&action=wizard&wizard=SelectModuleLayout&option={$id}' class='tabFormAdvLink'>{$label}</a>&nbsp;";
    $count++;
}
echo '</td></tr>';
echo '<tr><td align="right"><b>Subpanels:</b></td><td align="left">';
$layout_def = SubPanel::getModuleSubpanels($the_module);
$count = 0;
foreach ($layout_def as $key => $sub) {