From: <ada...@us...> - 2003-08-06 02:27:05
|
Update of /cvsroot/phpwebsite-comm/modules/article/boost In directory sc8-pr-cvs1:/tmp/cvs-serv18667/boost Modified Files: install.sql update.php Log Message: Section templates now have no spaces in the file name. The new files are copied in and the old files are deleted with the update. Before updating, users must make sure that they have access permissions for the /article/templates/section set to 777. The import script is also updated to relfect the new filenames. Index: install.sql =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/boost/install.sql,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** install.sql 19 Jul 2003 18:05:11 -0000 1.3 --- install.sql 6 Aug 2003 02:26:29 -0000 1.4 *************** *** 69,73 **** CREATE TABLE mod_article_config ( default_article_template varchar(255) NOT NULL DEFAULT "Blank", ! default_section_template varchar(255) NOT NULL DEFAULT "Centered Image", popular_articles smallint NOT NULL DEFAULT '5', summaries_on_homepage smallint NOT NULL DEFAULT '5', --- 69,73 ---- CREATE TABLE mod_article_config ( default_article_template varchar(255) NOT NULL DEFAULT "Blank", ! default_section_template varchar(255) NOT NULL DEFAULT "Centered_Image", popular_articles smallint NOT NULL DEFAULT '5', summaries_on_homepage smallint NOT NULL DEFAULT '5', *************** *** 99,103 **** ); ! INSERT INTO mod_article_config VALUES ('Blank', 'Centered Image', 5, 5, 5, 20, 1, 1, 0, 0, 3, 0, 0, 10, 26, 400, 400, 0, 0, 0, 0, 0, 0, 0, 0, 3600, 0, 0, '\r\n\r\n'); --- 99,103 ---- ); ! INSERT INTO mod_article_config VALUES ('Blank', 'Centered_Image', 5, 5, 5, 20, 1, 1, 0, 0, 3, 0, 0, 10, 26, 400, 400, 0, 0, 0, 0, 0, 0, 0, 0, 3600, 0, 0, '\r\n\r\n'); Index: update.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/article/boost/update.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** update.php 19 Jul 2003 18:05:12 -0000 1.1 --- update.php 6 Aug 2003 02:26:29 -0000 1.2 *************** *** 26,28 **** --- 26,125 ---- } } + if($currentVersion < 1.4) + { + $content .= 'Updating Article Manager to version 1.4<br />' + . 'Converting Spaces to Underscores in all template names.<br />'; + /* Retrieve all articles to update */ + $sql = 'SELECT id,template FROM mod_article'; + if(!$result = $GLOBALS['core']->query($sql, true)) + $content .= '<br />'.$_SESSION['translate']->it('ERROR: No [var1] were found!','articles').'<br />'; + else + while($row=$result->fetchrow(DB_FETCHMODE_ASSOC)) + $GLOBALS['core']->query('UPDATE mod_article SET template="'.str_replace(' ','_',$row['template']) + . '" WHERE id='.$row['id'], true); + $row = array(); + $result = null; + /* Retrieve all sections to update */ + $sql = 'SELECT id,template FROM mod_article_sections'; + if(!$result = $GLOBALS['core']->query($sql, true)) + $content .= '<br />'.$_SESSION['translate']->it('ERROR: No [var1] were found!','sections').'<br />'; + else + while($row=$result->fetchrow(DB_FETCHMODE_ASSOC)) + $GLOBALS['core']->query('UPDATE mod_article_sections SET template="'.str_replace(' ','_',$row['template']) + . '" WHERE id='.$row['id'], true); + $row = array(); + $result = null; + /* Retrieve configuration row for updating */ + $sql = 'SELECT default_article_template,default_section_template FROM mod_article_config'; + if(!$result = $GLOBALS['core']->query($sql, true)) + $content .= '<br />'.$_SESSION['translate']->it('ERROR: No [var1] were found!','configuration datum').'<br />'; + else + while($row=$result->fetchrow(DB_FETCHMODE_ASSOC)) + $GLOBALS['core']->query('UPDATE mod_article_config SET ' + . 'default_article_template="'.str_replace(' ','_',$row['default_article_template']) + . '",default_section_template="'.str_replace(' ','_',$row['default_section_template']) + . '"', true); + $row = array(); + $result = null; + + /* Delete the old template files */ + if ( ! function_exists('delfile') ) + { + function delfile ($dir, $file) + { + if (unlink(PHPWS_SOURCE_DIR . $dir . $file)) + return $file.' Deleted.<br />'; + else + return 'ERROR: '.$file.' could not be deleted. Please delete it manually.<br />'; + } + $content .= 'Deleting old template files (the ones with spaces in the names)<br />'; + $content .= delfile('mod/article/templates/section/','Centered Image.tpl'); + $content .= delfile('mod/article/templates/section/','Image Block Left.tpl'); + $content .= delfile('mod/article/templates/section/','Image Block Right.tpl'); + $content .= delfile('mod/article/templates/section/','Image Wrap Left.tpl'); + $content .= delfile('mod/article/templates/section/','Image Wrap Right.tpl'); + $content .= delfile('mod/article/templates/section/','No Images.tpl'); + $content .= delfile('mod/article/templates/section/','Text Only.tpl'); + $content .= delfile('mod/article/templates/section/','Page Insertion (Fit Block).tpl'); + $content .= delfile('mod/article/templates/section/','Page Insertion (Fit Page).tpl'); + $content .= delfile('mod/article/templates/section/','Page Insertion (Max Page).tpl'); + $content .= delfile('mod/article/templates/section/','Page Insertion (Title is Size).tpl'); + } + + /* Rename template files inside themes */ + if ( ! function_exists('renameThemeFile') ) + { + function renameThemeFile ($theme, $file) + { + $oldname = "themes/$theme/templates/article/section/".$file; + $newname = "themes/$theme/templates/article/section/".str_replace(' ','_',$file); + if (!file_exists(PHPWS_HOME_DIR . $oldname)) + return; + if (rename(PHPWS_HOME_DIR.$oldname, PHPWS_HOME_DIR.$newname)) + return $file.' was Renamed.<br />'; + else + return 'ERROR: '.$oldname.' could not be renamed. Please rename it as ' + .$newname.' manually.<br />'; + } + } + + $theme_names = $_SESSION['OBJ_layout']->get_themes(); + $content .= 'Renaming old template files in themes<br />'; + foreach($theme_names AS $theme) + { + $content .= 'Checking theme '.$theme.'<br />'; + $content .= renameThemeFile($theme,'Centered Image.tpl'); + $content .= renameThemeFile($theme,'Image Block Left.tpl'); + $content .= renameThemeFile($theme,'Image Block Right.tpl'); + $content .= renameThemeFile($theme,'Image Wrap Left.tpl'); + $content .= renameThemeFile($theme,'Image Wrap Right.tpl'); + $content .= renameThemeFile($theme,'No Images.tpl'); + $content .= renameThemeFile($theme,'Text Only.tpl'); + $content .= renameThemeFile($theme,'Page Insertion (Fit Block).tpl'); + $content .= renameThemeFile($theme,'Page Insertion (Fit Page).tpl'); + $content .= renameThemeFile($theme,'Page Insertion (Max Page).tpl'); + $content .= renameThemeFile($theme,'Page Insertion (Title is Size).tpl'); + } + $content .= 'Update to 1.4 Finished!<br />'; + } ?> |