Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         news
6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id: modify_post.php 2069 2014-01-03 00:54:16Z darkviper $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/news/modify_post.php $
14
 * @lastmodified    $Date: 2014-01-03 01:54:16 +0100 (Fri, 03 Jan 2014) $
15
 *
16
 */
17

    
18
$config_file = realpath('../../config.php');
19
if(file_exists($config_file) && !defined('WB_URL'))
20
{
21
	require($config_file);
22
}
23

    
24
// $admin_header = true;
25
// Tells script to update when this page was last updated
26
$update_when_modified = false;
27
// show the info banner
28
$print_info_banner = true;
29
// Include WB admin wrapper script
30
require(WB_PATH.'/modules/admin.php');
31

    
32
$backlink = ADMIN_URL.'/pages/modify.php?page_id='.(int)$page_id;
33

    
34
// Make news post access files dir
35
if(!function_exists('make_dir')) {require(WB_PATH.'/framework/functions.php');}
36

    
37
if(!make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
38
	$admin->print_error($MESSAGE['GENERIC_BAD_PERMISSIONS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
39
} else {
40
    
41
    $post_id = intval($admin->checkIDKEY('post_id', false, 'GET'));
42
    if (!$post_id) {
43
    	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $backlink);
44
    }
45
    $aPostRec = 
46
        array(
47
            'post_id'         => 0,
48
            'section_id'      => 0,
49
            'page_id'         => 0,
50
            'group_id'        => 0,
51
            'active'          => 0,
52
            'position'        => 0,
53
            'title'           => '',
54
            'link'            => '',
55
            'content_short'   => '',
56
            'content_long'    => '',
57
            'commenting'      => '',
58
            'created_when'    => 0,
59
            'created_by'      => 0,
60
            'published_when'  => 0,
61
            'published_until' => 0,
62
            'posted_when'     => 0,
63
            'posted_by'       => 0
64
    );
65
    $sMediaUrl = WB_URL.MEDIA_DIRECTORY;
66
    // Get header and footer
67
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` WHERE `post_id`='.(int)$post_id;
68
    if (($oPostRes = $database->query($sql))) {
69
    	$aPostRec = $oPostRes->fetchRow(MYSQL_ASSOC);
70
        $sFilterApi = WB_PATH.'/modules/output_filter/OutputFilterApi.php';
71
        if (is_readable($sFilterApi)) {
72
            require_once($sFilterApi);
73
            $aPostRec['content_short'] = OutputFilterApi('ReplaceSysvar', $aPostRec['content_short']);
74
            $aPostRec['content_long'] = OutputFilterApi('ReplaceSysvar', $aPostRec['content_long']);
75
        }
76
    }
77
    //$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
78
    
79
    //print '<pre style="text-align:left;color:#000;padding:1em;"><strong>function '.__FUNCTION__.'( '.$post_id.' );</strong>  basename: '.basename(__FILE__).'  line: '.__LINE__.' -> <br />'; 
80
    //print_r( $fetch_content['content_short'] ); print '</pre>'; // flush ();sleep(10); die();
81
    if(!isset($wysiwyg_editor_loaded)) {
82
        $wysiwyg_editor_loaded=true;
83
    	if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
84
    		function show_wysiwyg_editor($name,$id,$content,$width,$height) {
85
    			echo '<textarea name="'.$name.'" id="'.$id.'" rows="10" cols="1" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
86
    		}
87
    	} else {
88
    		$id_list=array("short","long");
89
    		require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
90
    	}
91
    }
92
    
93
    // include jscalendar-setup
94
    $jscal_use_time = true; // whether to use a clock, too
95
    require_once(WB_PATH."/include/jscalendar/wb-setup.php");
96
    ?>
97
    <h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['POST']; ?></h2>
98
    <div class="jsadmin jcalendar hide"></div> 
99
    <form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
100
    
101
    <input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
102
    <input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
103
    <input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
104
    <input type="hidden" name="link" value="<?php echo $aPostRec['link']; ?>" />
105
    <?php echo $admin->getFTAN(); ?>
106
    
107
    <table class="row_a" cellpadding="2" cellspacing="0" width="100%">
108
    <tr>
109
    	<td><?php echo $TEXT['TITLE']; ?>:</td>
110
    	<td width="80%">
111
    		<input type="text" name="title" value="<?php echo (htmlspecialchars($aPostRec['title'])); ?>" style="width: 98%;" maxlength="255" />
112
    	</td>
113
    </tr>
114
    <tr>
115
    	<td><?php echo $TEXT['GROUP']; ?>:</td>
116
    	<td>
117
    		<select name="group" style="width: 100%;">
118
    			<option value="0"><?php echo $TEXT['NONE']; ?></option>
119
    			<?php
120
    			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
121
    			if($query->numRows() > 0) {
122
    				// Loop through groups
123
    				while($group = $query->fetchRow(MYSQL_ASSOC)) {
124
    					?>
125
    					<option value="<?php echo $group['group_id']; ?>"<?php if($aPostRec['group_id'] == $group['group_id']) { echo ' selected="selected"'; } ?>><?php echo $group['title']; ?></option>
126
    					<?php
127
    				}
128
    			}
129
    			?>
130
    		</select>
131
    	</td>
132
    </tr>
133
    <tr>
134
    	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
135
    	<td>
136
    		<select name="commenting" style="width: 100%;">
137
    			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
138
    			<option value="public" <?php if($aPostRec['commenting'] == 'public') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
139
    			<option value="private" <?php if($aPostRec['commenting'] == 'private') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
140
    		</select>
141
    	</td>
142
    </tr>
143
    <tr>
144
    	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
145
    	<td>
146
    		<input type="radio" name="active" id="active_true" value="1" <?php if($aPostRec['active'] == 1) { echo ' checked="checked"'; } ?> />
147
    		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
148
    		<?php echo $TEXT['YES']; ?>
149
    		</a>
150
    		&nbsp;
151
    		<input type="radio" name="active" id="active_false" value="0" <?php if($aPostRec['active'] == 0) { echo ' checked="checked"'; } ?> />
152
    		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
153
    		<?php echo $TEXT['NO']; ?>
154
    		</a>
155
    	</td>
156
    </tr>
157
    <tr>
158
    	<td><?php echo $TEXT['PUBL_START_DATE']; ?>:</td>
159
    	<td>
160
    	<input type="text" id="publishdate" name="publishdate" value="<?php if($aPostRec['published_when']==0) print date($jscal_format, strtotime((date('Y-m-d H:i')))); else print date($jscal_format, $aPostRec['published_when']);?>" style="width: 120px;" />
161
    	<img src="<?php echo THEME_URL ?>/images/clock_16.png" id="publishdate_trigger" style="cursor: pointer;" title="<?php echo $TEXT['CALENDAR']; ?>" alt="<?php echo $TEXT['CALENDAR']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" />
162
    	<img src="<?php echo THEME_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="<?php echo $TEXT['DELETE_DATE']; ?>" alt="<?php echo $TEXT['DELETE_DATE']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.publishdate.value=''" />
163
    	</td>
164
    </tr>
165
    <tr>
166
    	<td><?php echo $TEXT['PUBL_END_DATE']; ?>:</td>
167
    	<td>
168
    	<input type="text" id="enddate" name="enddate" value="<?php if($aPostRec['published_until']==0) print ""; else print date($jscal_format, $aPostRec['published_until'])?>" style="width: 120px;" />
169
    	<img src="<?php echo THEME_URL ?>/images/clock_16.png" id="enddate_trigger" style="cursor: pointer;" title="<?php echo $TEXT['CALENDAR']; ?>" alt="<?php echo $TEXT['CALENDAR']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" />
170
    	<img src="<?php echo THEME_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="<?php echo $TEXT['DELETE_DATE']; ?>" alt="<?php echo $TEXT['DELETE_DATE']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.enddate.value=''" />
171
    	</td>
172
    </tr>
173
    </table>
174
    
175
    <table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
176
    <tr>
177
    	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
178
    </tr>
179
    <tr>
180
    	<td>
181
    	<?php
182
    	show_wysiwyg_editor("short","short",htmlspecialchars($aPostRec['content_short']),"100%","200px");
183
    	?>
184
    	</td>
185
    </tr>
186
    <tr>
187
    	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
188
    </tr>
189
    <tr>
190
    	<td>
191
    	<?php
192
    	show_wysiwyg_editor("long","long",htmlspecialchars($aPostRec['content_long']),"100%","650px");
193
    	?>
194
    	</td>
195
    </tr>
196
    </table>
197
    
198
    <table cellpadding="2" cellspacing="0" border="0" width="100%">
199
    <tr>
200
    	<td align="left">
201
    		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
202
    	</td>
203
    	<td align="right">
204
    		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
205
    	</td>
206
    </tr>
207
    </table>
208
    </form>
209
    
210
    <script type="text/javascript">
211
    	Calendar.setup(
212
    		{
213
    			inputField  : "publishdate",
214
    			ifFormat    : "<?php echo $jscal_ifformat ?>",
215
    			button      : "publishdate_trigger",
216
    			firstDay    : <?php echo $jscal_firstday ?>,
217
    			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
218
                { ?>
219
    				showsTime   : "true",
220
    				timeFormat  : "24",
221
    			<?php
222
                } ?>
223
    			date        : "<?php echo $jscal_today ?>",
224
    			range       : [1970, 2037],
225
    			step        : 1
226
    		}
227
    	);
228
    	Calendar.setup(
229
    		{
230
    			inputField  : "enddate",
231
    			ifFormat    : "<?php echo $jscal_ifformat ?>",
232
    			button      : "enddate_trigger",
233
    			firstDay    : <?php echo $jscal_firstday ?>,
234
    			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
235
                { ?>
236
    				showsTime   : "true",
237
    				timeFormat  : "24",
238
    			<?php
239
                } ?>
240
    			date        : "<?php echo $jscal_today ?>",
241
    			range       : [1970, 2037],
242
    			step        : 1
243
    		}
244
    	);
245
    </script>
246
    
247
    <br />
248
    
249
    <h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
250
    
251
    <?php
252
    
253
    // Loop through existing posts
254
    $query_comments = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_comments` WHERE section_id = '$section_id' AND post_id = '$post_id' ORDER BY commented_when DESC");
255
    if($query_comments->numRows() > 0) {
256
    	$row = 'a';
257
    	$pid = $admin->getIDKEY($post_id);
258
    	?>
259
    	<table cellpadding="2" cellspacing="0" border="0" width="100%">
260
    	<?php
261
    	while($comment = $query_comments->fetchRow(MYSQL_ASSOC)) {
262
    		$cid = $admin->getIDKEY($comment['comment_id']);
263
    		?>
264
    		<tr class="row_<?php echo $row; ?>" >
265
    			<td width="20" style="padding-left: 5px;">
266
    				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
267
    					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
268
    					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
269
    				</a>
270
    			</td>	
271
    			<td>
272
    				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
273
    					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>">
274
    					<?php echo $comment['title']; ?>
275
    				</a>
276
    			</td>
277
    			<td width="20">
278
    				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php
279
    					echo WB_URL; ?>/modules/news/delete_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
280
    					echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;comment_id=<?php echo $cid; ?>');" title="<?php
281
    					echo $TEXT['DELETE']; ?>">
282
    					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
283
    				</a>
284
    			</td>
285
    		</tr>
286
    		<?php
287
    		// Alternate row color
288
    		if($row == 'a') {
289
    			$row = 'b';
290
    		} else {
291
    			$row = 'a';
292
    		}
293
    	}
294
    	?>
295
    	</table>
296
    	<?php
297
    } else {
298
    	echo $TEXT['NONE_FOUND'];
299
    }
300
}
301
// Print admin footer
302
$admin->print_footer();
(21-21/34)