You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@roller.apache.org by gregh <gr...@ricoh-uk.com> on 2007/09/11 09:58:05 UTC
ThemeManagerImpl in 4.1_dev importTheme
Hello,
On a fresh install (4.1_dev) seems to be deleting the standard <template
action="permalink"> etc from themes.xml. May need to add an
"importedActionTemplates.add(themeTemplate.getAction());" to the create
template code:
// Weblog does not have this template, so create it.
boolean newTmpl = false;
if (template == null) {
template = new WeblogTemplate();
template.setWebsite(website);
newTmpl = true;
// Here!! (to stop delete in for(int i=0; i <
WeblogTemplate.ACTIONS.length; i++) { )
}
or something similar.
eg
Set importedActionTemplates = new HashSet();
ThemeTemplate themeTemplate = null;
ThemeTemplate stylesheetTemplate = theme.getStylesheet();
Iterator iter = theme.getTemplates().iterator();
while ( iter.hasNext() ) {
themeTemplate = (ThemeTemplate) iter.next();
WeblogTemplate template = null;
// if template is an action, lookup by action
if(themeTemplate.getAction() != null &&
!themeTemplate.getAction().equals(WeblogTemplate.ACTION_CUSTOM)) {
template = wmgr.getPageByAction(website,
themeTemplate.getAction());
if(template != null) {
importedActionTemplates.add(themeTemplate.getAction());
}
// otherwise, lookup by name
} else {
template = wmgr.getPageByName(website,
themeTemplate.getName());
}
// Weblog does not have this template, so create it.
boolean newTmpl = false;
if (template == null) {
template = new WeblogTemplate();
template.setWebsite(website);
newTmpl = true;
// Add to set to stop delete!!
importedActionTemplates.add(themeTemplate.getAction());
}
// TODO: fix conflict situation
// it's possible that someone has defined a theme template
which
// matches 2 existing templates, 1 by action, the other by
name
// update template attributes
// NOTE: we don't want to copy the template data for an
existing stylesheet
if(newTmpl || !themeTemplate.equals(stylesheetTemplate)) {
.....
// save it
wmgr.savePage( template );
}
}
// now, see if the weblog has left over action templates that
// need to be deleted because they aren't in their new theme
for(int i=0; i < WeblogTemplate.ACTIONS.length; i++) {
String action = WeblogTemplate.ACTIONS[i];
// if we didn't import this action then see if it should be
deleted
if(!importedActionTemplates.contains(action)) {
WeblogTemplate toDelete = wmgr.getPageByAction(website,
action);
if(toDelete != null) {
log.debug("Removing stale action template
"+toDelete.getId());
wmgr.removePage(toDelete);
}
}
}
Cheers Greg
--
View this message in context: http://www.nabble.com/ThemeManagerImpl-in-4.1_dev-importTheme-tf4420950s12275.html#a12609917
Sent from the Roller - Dev mailing list archive at Nabble.com.