/** * Removes the metadata files for all known studio layouts. * * @return html output record of the files deleted */ function removeCustomLayouts() { $module = StudioModuleFactory::getStudioModule($this->module); $sources = $module->getViewMetadataSources(); $out = ""; // list of existing platforms including BWC $platforms = MetaDataManager::getPlatformList(); array_unshift($platforms, ''); // Flag to tell the autoloader whether to save itself or not when done $saveMap = false; foreach ($sources as $view) { foreach ($platforms as $platform) { $file = MetaDataFiles::getDeployedFileName($view['type'], $this->module, MB_CUSTOMMETADATALOCATION, $platform); // Ensure we are working on files that the autoloader knows about if (SugarAutoLoader::fileExists($file)) { // Since we are in a loop inside of a loop do NOT send the // save flag as true to unlink() but be sure to save the file // map after the process is finished so that all changes to // the map are saved. SugarAutoLoader::unlink($file); $out .= "Removed layout {$view['type']}.php<br/>"; // Tell the autoloader to save itself $saveMap = true; } } } // now clear the cache include_once 'include/TemplateHandler/TemplateHandler.php'; TemplateHandler::clearCache($this->module); // If the file map needs saving, handle that now if ($saveMap) { SugarAutoLoader::saveMap(); } return $out; }
/** * Gets the new path and filename for this view * * @param string $view The view name to get the filename for * @return string */ public function getNewFileName($view) { // Clean up client to mobile for wireless clients $client = $this->client == 'wireless' ? 'mobile' : $this->client; if ($this->deployed) { // Deployed will always use the full key_module name for custom modules $module = $this->getNormalizedModuleName(); $newname = MetaDataFiles::getDeployedFileName($view, $module, $this->type, $client); } else { $newname = MetaDataFiles::getUndeployedFileName($view, $this->module, $this->package, $this->type, $client); } // If this is a history file then add the timestamp back on if ($this->timestamp) { $newname .= '_' . $this->timestamp; } return $newname; }