Project

General

Profile

« Previous | Next » 

Revision 1990

Added by darkviper about 11 years ago

added /framework/ModuleReorgAbstract provides the basics for modul depending reorganisation classes
update /modules/news/Reorg now extends ModuleReorgAbstract
fixed problem with empty directories fixed
update /modules/news/upgrade.php // rebuild all access files fixed

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12
===============================================================================
13 13

  
14
19 Oct-2013 Build 1990 Manuela v.d.Decken(DarkViper)
15
+ /framework/ModuleReorgAbstract  provides the basics for modul depending reorganisation classes
16
! /modules/news/Reorg  now extends ModuleReorgAbstract
17
#                      problem with empty directories fixed
18
! /modules/news/upgrade.php // rebuild all access files fixed
14 19
19 Oct-2013 Build 1989 Dietmar Woellbrink (Luisehahne)
15 20
# bugfix /admin/start/index.php::undefined function replace_vars()
16 21
19 Oct-2013 Build 1988 Dietmar Woellbrink (Luisehahne)
branches/2.8.x/wb/admin/interface/version.php
51 51

  
52 52
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
53 53
if(!defined('VERSION')) define('VERSION', '2.8.3');
54
if(!defined('REVISION')) define('REVISION', '1989');
54
if(!defined('REVISION')) define('REVISION', '1990');
55 55
if(!defined('SP')) define('SP', '');
branches/2.8.x/wb/framework/ModuleReorgAbstract.php
1
<?php
2

  
3
/**
4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19

  
20
/**
21
 * ModuleReorgAbstract.php
22
 *
23
 * @category     Core
24
 * @package      Core_ModuleInterface
25
 * @copyright    Manuela v.d.Decken <manuela@isteam.de>
26
 * @author       Manuela v.d.Decken <manuela@isteam.de>
27
 * @license      http://www.gnu.org/licenses/gpl.html   GPL License
28
 * @version      0.0.1
29
 * @revision     $Revision: $
30
 * @link         $HeadURL: $
31
 * @lastmodified $Date: $
32
 * @since        File available since 19.10.2013
33
 * @description  This class provides the basics for modul depending reorganisation classes
34
 */
35
abstract class ModuleReorgAbstract {
36

  
37
/** registry object */
38
	protected $oReg = null;
39
/** database object */
40
	protected $oDb  = null;
41
/** collector of return values */
42
	protected $aReport = null;
43
/** set kind of return values */
44
	protected $bDetailedLog = false;
45

  
46
/** show minimal log entries */
47
	const LOG_SHORT    = 0;
48
/** show extended log entries */
49
	const LOG_EXTENDED = 1;
50

  
51
/**
52
 * execute reorganisation
53
 * @return boolean
54
 */
55
	abstract public function execute();
56

  
57
/**
58
 * constructor
59
 * @param int $bDetailedLog  can be LOG_EXTENDED or LOG_SHORT
60
 */
61
	public function __construct($bDetailedLog = self::LOG_SHORT) {
62
		$this->bDetailedLog = (bool)($bDetailedLog & self::LOG_EXTENDED);
63
		$this->oDb          = WbDatabase::getInstance();
64
		$this->oReg         = WbAdaptor::getInstance();
65
	}
66
/**
67
 * getReport
68
 * @return array
69
 * @description a report about the whoole reorganisation<br />
70
 */
71
	public function getReport()
72
	{
73
		return $this->aReport;
74
	}
75

  
76
} // end of class ModuleReorgAbstract
branches/2.8.x/wb/modules/news/Reorg.php
32 32
 * @since        File available since 15.10.2013
33 33
 * @description  reorganisize all accessfiles of the addon 'news'
34 34
 */
35
class m_news_Reorg {
36 35

  
37
/** registry object */
38
	protected $oReg = null;
39
/** database object */
40
	protected $oDb  = null;
36
class m_news_Reorg extends ModuleReorgAbstract{
37

  
41 38
/** root directory for accessfiles */
42 39
	protected $sAccessFilesRoot = '';
43 40
/** sub directory for accessfiles
......
46 43
 *               without a hardcoded subdirectory name.
47 44
 */
48 45
	protected $sAccessFilesSubdir = 'posts/';
49
/** collector of return values */
50
	protected $aReport = null;
51
/** set kind of return values */
52
	protected $bDetailedLog = false;
53 46

  
54
/** show extended log entries */
55
	const LOG_EXTENDED = true;
56
/** show minimal log entries */
57
	const LOG_SHORT    = false;
58

  
59 47
/**
60
 * constructor
61
 * @param int $bDetailedLog  can be LOG_EXTENDED or LOG_SHORT
62
 */
63
	public function __construct($bDetailedLog = self::LOG_SHORT)
64
	{
65
		$this->bDetailedLog     = $bDetailedLog;
66
		$this->oDb              = WbDatabase::getInstance();
67
		$this->oReg             = WbAdaptor::getInstance();
68
		$this->sAccessFilesRoot = $this->oReg->AppPath.$this->oReg->PagesDir.$this->sAccessFilesSubdir;
69
	}
70
/**
71 48
 * execute reorganisation
72 49
 * @return boolean
73 50
 */
74 51
	public function execute()
75 52
	{
76
	// reset areport
53
/**
54
 * @description Structure of report array.<br />
55
 *              (int) number of 'FilesDeleted'<br />
56
 *              (int) number of 'FilesCreated'<br />
57
 *              (array) 'Success'<br />
58
 *              (array) 'Failed'
59
 */
60
	// reset report
77 61
		$this->aReport = array( 'FilesDeleted'=>0,
78 62
		                        'FilesCreated'=>0,
79 63
		                        'Success'=>array(),
80 64
		                        'Failed'=>array()
81 65
		                      );
66
	// build AccessFilesRoot
67
		$this->sAccessFilesRoot = $this->oReg->AppPath.$this->oReg->PagesDir.$this->sAccessFilesSubdir;
82 68
	// delete old accessfiles
83 69
		$this->deleteAll();
84 70
	// recreate new accessfiles
......
87 73
		return (sizeof($this->aReport['Failed']) == 0);
88 74
	}
89 75
/**
90
 * getReport
91
 * @return array
92
 * @description a report about the whoole reorganisation<br />
93
 *              returns an array including<br />
94
 *              (int) number of 'FilesDeleted'<br />
95
 *              (int) number of 'FilesCreated'<br />
96
 *              (array) 'Success'<br />
97
 *              (array) 'Failed'
98
 */
99
	public function getReport()
100
	{
101
		return $this->aReport;
102
	}
103
/**
104 76
 * deleteAll
105 77
 * @throws AccessFileException
106 78
 * @description delete all accessfiles and its children in $sAccessFilesRoot
......
108 80
	protected function deleteAll()
109 81
	{
110 82
	// scan start directory for access files
111
		foreach (glob($this->sAccessFilesRoot . '*'.$this->oReg->PageExtension, GLOB_MARK) as $sItem)
83
		$aMatches = glob($this->sAccessFilesRoot . '*'.$this->oReg->PageExtension);
84
		if(is_array($aMatches))
112 85
		{
113
		// sanitize itempath
114
            $sItem = str_replace('\\', '/', $sItem);
115
			if(AccessFileHelper::isAccessFile($sItem))
86
			foreach($aFileList as $sItem)
116 87
			{
117
			// delete accessfiles only
118
				if(is_writable($sItem) && @unlink($sItem))
88
			// sanitize itempath
89
				$sItem = str_replace('\\', '/', $sItem);
90
				if(AccessFileHelper::isAccessFile($sItem))
119 91
				{
120
				// if file is successful deleted
121
					if($this->bDetailedLog)
92
				// delete accessfiles only
93
					if(is_writable($sItem) && @unlink($sItem))
122 94
					{
123
						$this->aReport['Success'][] = 'File successful removed : '.str_replace($this->oReg->AppPath, '', $sItem);
95
					// if file is successful deleted
96
						if($this->bDetailedLog)
97
						{
98
							$this->aReport['Success'][] = 'File successful removed : '.str_replace($this->oReg->AppPath, '', $sItem);
99
						}
100
					// increment successful counter
101
						$this->aReport['FilesDeleted']++;
102
					}else
103
					{
104
					// if failed
105
						$this->aReport['Failed'][] = 'Delete file failed : '.str_replace($this->oReg->AppPath, '', $sItem);
124 106
					}
125
				// increment successful counter
126
					$this->aReport['FilesDeleted']++;
127
				}else
128
				{
129
				// if failed
130
					$this->aReport['Failed'][] = 'Delete file failed : '.str_replace($this->oReg->AppPath, '', $sItem);
131
				}
132
			} // endif
133
		} // endforeach
107
				} // endif
108
			} // endforeach
109
		}else
110
		{
111
			$this->aReport['Failed'][] = 'Directory scan failed : '.str_replace($this->oReg->AppPath, '', $this->sAccessFilesRoot);
112
		}
134 113
	} // end of function deleteAll()
135 114
/**
136 115
 * rebuildAll
branches/2.8.x/wb/modules/news/upgrade.php
179 179
	}
180 180
// ************************************************
181 181
// Check the validity of 'create-file-timestamp' and balance against 'posted-timestamp'
182
			$sql  = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` ';
183
			$sql .= 'SET `created_when`=`published_when` ';
184
			$sql .= 'WHERE `published_when`<`created_when`';
182
			$sql = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` '
183
			     . 'SET `created_when`=`published_when` '
184
			     . 'WHERE `published_when`<`created_when`';
185 185
			$database->query($sql);
186
			$sql  = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` ';
187
			$sql .= 'SET `created_when`=`posted_when` ';
188
			$sql .= 'WHERE `published_when`=0 OR `published_when`>`posted_when`';
186
			$sql = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` '
187
			     . 'SET `created_when`=`posted_when` '
188
			     . 'WHERE `published_when`=0 OR `published_when`>`posted_when`';
189 189
			$database->query($sql);
190 190
// ************************************************
191
// rebuild all access files
191 192
			$aReport = array('FilesDeleted'=>0,'FilesCreated'=>0,);
192
        	$sModulReorg = 'm_news_Reorg';
193
        	if( !$globalStarted && class_exists($sModulReorg) ) {
194
        		$oReorg = new $sModulReorg($sModulReorg::LOG_EXTENDED);
195
				$aReturnMsg = $oReorg->execute(); // show details
193
        	if( !$globalStarted && class_exists('m_news_Reorg') ) {
194
        		$oReorg = new m_news_Reorg(ModuleReorgAbstract::LOG_EXTENDED);
195
				$oReorg->execute(); // show details
196 196
                $aReport = $oReorg->getReport();
197 197
                unset($oReorg);
198 198
        	}
199

  
199
// ************************************************
200 200
			// only for upgrade-script
201 201
			if($globalStarted) {
202 202
				if($bDebug) {

Also available in: Unified diff