1
|
<?php
|
2
|
/**
|
3
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
4
|
*
|
5
|
* This program is free software: you can redistribute it and/or modify
|
6
|
* it under the terms of the GNU General Public License as published by
|
7
|
* the Free Software Foundation, either version 3 of the License, or
|
8
|
* (at your option) any later version.
|
9
|
*
|
10
|
* This program is distributed in the hope that it will be useful,
|
11
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
* GNU General Public License for more details.
|
14
|
*
|
15
|
* You should have received a copy of the GNU General Public License
|
16
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
*/
|
18
|
|
19
|
/**
|
20
|
* Reorg.php
|
21
|
*
|
22
|
* @category Module
|
23
|
* @package Module_news
|
24
|
* @author Werner v.d.Decken <wkl@isteam.de>
|
25
|
* @copyright Werner v.d.Decken <wkl@isteam.de>
|
26
|
* @license http://www.gnu.org/licenses/gpl.html GPL License
|
27
|
* @version 0.0.1
|
28
|
* @revision $Revision: $
|
29
|
* @link $HeadURL: $
|
30
|
* @lastmodified $Date: $
|
31
|
* @since File available since 17.01.2013
|
32
|
* @description Reorganisation jobs for the 'news' module
|
33
|
*/
|
34
|
|
35
|
class m_news_Reorg {
|
36
|
|
37
|
protected $_oReg = null;
|
38
|
protected $_sPagesDir = '';
|
39
|
|
40
|
/**
|
41
|
* Execute reorganisation
|
42
|
* @return string all occured messages
|
43
|
*/
|
44
|
public function execute()
|
45
|
{
|
46
|
$sOutput = null;
|
47
|
$this->_oReg = null;
|
48
|
if(class_exists('WbAdaptor')) {
|
49
|
$this->_oReg = WbAdaptor::getInstance();
|
50
|
$sTmp = trim($this->_oReg->PagesDir, '/');
|
51
|
$sTmp = ($sTmp == '' ? '' : $sTmp.'/');
|
52
|
$this->_sPagesDir = $sTmp;
|
53
|
$sOutput = $this->createAccessFiles();
|
54
|
}
|
55
|
// add here the requests for additional reorg methods
|
56
|
return $sOutput;
|
57
|
}
|
58
|
/**
|
59
|
* Creates all Accessfiles from DB
|
60
|
* @return string all occured messages
|
61
|
*/
|
62
|
protected function createAccessFiles()
|
63
|
{
|
64
|
$count = 0;
|
65
|
$aReturnMsg = array();
|
66
|
$sql = 'SELECT `page_id`,`post_id`,`section_id`,`link` ';
|
67
|
$sql .= 'FROM `'.$this->_oReg->TablePrefix.'mod_news_posts`';
|
68
|
$sql .= 'WHERE `link` != \'\'';
|
69
|
if(($oPosts = WbDatabase::getInstance()->query($sql))) {
|
70
|
while($aPost = $oPosts->fetchRow(MYSQL_ASSOC))
|
71
|
{
|
72
|
$sAccessFile = $this->_oReg->AppPath.$this->_sPagesDir
|
73
|
. trim(str_replace('\\', '/', $aPost['link']), '/')
|
74
|
. $this->_oReg->PageExtension;
|
75
|
$aOptionalCommand = array(
|
76
|
'$section_id = '.$aPost['section_id'].';',
|
77
|
'$post_section = '.$aPost['section_id'].';',
|
78
|
'$post_id = '.$aPost['post_id'].';'
|
79
|
);
|
80
|
|
81
|
if(create_access_file($sAccessFile, $aPost['page_id'], 0, $aOptionalCommand)){
|
82
|
$count++;
|
83
|
} else {
|
84
|
$aReturnMsg[] = 'Can\'t create '.$sAccessFile;
|
85
|
}
|
86
|
}
|
87
|
$aReturnMsg[] = 'Number of new created access files: '.$count;
|
88
|
}
|
89
|
return $aReturnMsg;
|
90
|
}
|
91
|
// add here some additional reorg methods **************************************** *//
|
92
|
} // end of class Reorg
|