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 2003 2013-11-14 03:47:21Z Luisehahne $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/news/modify_post.php $
14
 * @lastmodified    $Date: 2013-11-14 04:47:21 +0100 (Thu, 14 Nov 2013) $
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
    	$aPostRec['content_short'] = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_short']);
71
    	$aPostRec['content_long']  = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_long']);
72
    }
73
    //$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
74
    
75
    //print '<pre style="text-align:left;color:#000;padding:1em;"><strong>function '.__FUNCTION__.'( '.$post_id.' );</strong>  basename: '.basename(__FILE__).'  line: '.__LINE__.' -> <br />'; 
76
    //print_r( $fetch_content['content_short'] ); print '</pre>'; // flush ();sleep(10); die();
77
    if(!isset($wysiwyg_editor_loaded)) {
78
        $wysiwyg_editor_loaded=true;
79
    	if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
80
    		function show_wysiwyg_editor($name,$id,$content,$width,$height) {
81
    			echo '<textarea name="'.$name.'" id="'.$id.'" rows="10" cols="1" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
82
    		}
83
    	} else {
84
    		$id_list=array("short","long");
85
    		require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
86
    	}
87
    }
88
    
89
    // include jscalendar-setup
90
    $jscal_use_time = true; // whether to use a clock, too
91
    require_once(WB_PATH."/include/jscalendar/wb-setup.php");
92
    ?>
93
    <h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['POST']; ?></h2>
94
    <div class="jsadmin jcalendar hide"></div> 
95
    <form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
96
    
97
    <input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
98
    <input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
99
    <input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
100
    <input type="hidden" name="link" value="<?php echo $aPostRec['link']; ?>" />
101
    <?php echo $admin->getFTAN(); ?>
102
    
103
    <table class="row_a" cellpadding="2" cellspacing="0" width="100%">
104
    <tr>
105
    	<td><?php echo $TEXT['TITLE']; ?>:</td>
106
    	<td width="80%">
107
    		<input type="text" name="title" value="<?php echo (htmlspecialchars($aPostRec['title'])); ?>" style="width: 98%;" maxlength="255" />
108
    	</td>
109
    </tr>
110
    <tr>
111
    	<td><?php echo $TEXT['GROUP']; ?>:</td>
112
    	<td>
113
    		<select name="group" style="width: 100%;">
114
    			<option value="0"><?php echo $TEXT['NONE']; ?></option>
115
    			<?php
116
    			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
117
    			if($query->numRows() > 0) {
118
    				// Loop through groups
119
    				while($group = $query->fetchRow(MYSQL_ASSOC)) {
120
    					?>
121
    					<option value="<?php echo $group['group_id']; ?>"<?php if($aPostRec['group_id'] == $group['group_id']) { echo ' selected="selected"'; } ?>><?php echo $group['title']; ?></option>
122
    					<?php
123
    				}
124
    			}
125
    			?>
126
    		</select>
127
    	</td>
128
    </tr>
129
    <tr>
130
    	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
131
    	<td>
132
    		<select name="commenting" style="width: 100%;">
133
    			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
134
    			<option value="public" <?php if($aPostRec['commenting'] == 'public') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
135
    			<option value="private" <?php if($aPostRec['commenting'] == 'private') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
136
    		</select>
137
    	</td>
138
    </tr>
139
    <tr>
140
    	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
141
    	<td>
142
    		<input type="radio" name="active" id="active_true" value="1" <?php if($aPostRec['active'] == 1) { echo ' checked="checked"'; } ?> />
143
    		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
144
    		<?php echo $TEXT['YES']; ?>
145
    		</a>
146
    		&nbsp;
147
    		<input type="radio" name="active" id="active_false" value="0" <?php if($aPostRec['active'] == 0) { echo ' checked="checked"'; } ?> />
148
    		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
149
    		<?php echo $TEXT['NO']; ?>
150
    		</a>
151
    	</td>
152
    </tr>
153
    <tr>
154
    	<td><?php echo $TEXT['PUBL_START_DATE']; ?>:</td>
155
    	<td>
156
    	<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;" />
157
    	<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=''" />
158
    	<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=''" />
159
    	</td>
160
    </tr>
161
    <tr>
162
    	<td><?php echo $TEXT['PUBL_END_DATE']; ?>:</td>
163
    	<td>
164
    	<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;" />
165
    	<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=''" />
166
    	<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=''" />
167
    	</td>
168
    </tr>
169
    </table>
170
    
171
    <table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
172
    <tr>
173
    	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
174
    </tr>
175
    <tr>
176
    	<td>
177
    	<?php
178
    	show_wysiwyg_editor("short","short",htmlspecialchars($aPostRec['content_short']),"100%","200px");
179
    	?>
180
    	</td>
181
    </tr>
182
    <tr>
183
    	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
184
    </tr>
185
    <tr>
186
    	<td>
187
    	<?php
188
    	show_wysiwyg_editor("long","long",htmlspecialchars($aPostRec['content_long']),"100%","650px");
189
    	?>
190
    	</td>
191
    </tr>
192
    </table>
193
    
194
    <table cellpadding="2" cellspacing="0" border="0" width="100%">
195
    <tr>
196
    	<td align="left">
197
    		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
198
    	</td>
199
    	<td align="right">
200
    		<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;" />
201
    	</td>
202
    </tr>
203
    </table>
204
    </form>
205
    
206
    <script type="text/javascript">
207
    	Calendar.setup(
208
    		{
209
    			inputField  : "publishdate",
210
    			ifFormat    : "<?php echo $jscal_ifformat ?>",
211
    			button      : "publishdate_trigger",
212
    			firstDay    : <?php echo $jscal_firstday ?>,
213
    			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
214
                { ?>
215
    				showsTime   : "true",
216
    				timeFormat  : "24",
217
    			<?php
218
                } ?>
219
    			date        : "<?php echo $jscal_today ?>",
220
    			range       : [1970, 2037],
221
    			step        : 1
222
    		}
223
    	);
224
    	Calendar.setup(
225
    		{
226
    			inputField  : "enddate",
227
    			ifFormat    : "<?php echo $jscal_ifformat ?>",
228
    			button      : "enddate_trigger",
229
    			firstDay    : <?php echo $jscal_firstday ?>,
230
    			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
231
                { ?>
232
    				showsTime   : "true",
233
    				timeFormat  : "24",
234
    			<?php
235
                } ?>
236
    			date        : "<?php echo $jscal_today ?>",
237
    			range       : [1970, 2037],
238
    			step        : 1
239
    		}
240
    	);
241
    </script>
242
    
243
    <br />
244
    
245
    <h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
246
    
247
    <?php
248
    
249
    // Loop through existing posts
250
    $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");
251
    if($query_comments->numRows() > 0) {
252
    	$row = 'a';
253
    	$pid = $admin->getIDKEY($post_id);
254
    	?>
255
    	<table cellpadding="2" cellspacing="0" border="0" width="100%">
256
    	<?php
257
    	while($comment = $query_comments->fetchRow(MYSQL_ASSOC)) {
258
    		$cid = $admin->getIDKEY($comment['comment_id']);
259
    		?>
260
    		<tr class="row_<?php echo $row; ?>" >
261
    			<td width="20" style="padding-left: 5px;">
262
    				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
263
    					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
264
    					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
265
    				</a>
266
    			</td>	
267
    			<td>
268
    				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
269
    					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>">
270
    					<?php echo $comment['title']; ?>
271
    				</a>
272
    			</td>
273
    			<td width="20">
274
    				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php
275
    					echo WB_URL; ?>/modules/news/delete_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
276
    					echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;comment_id=<?php echo $cid; ?>');" title="<?php
277
    					echo $TEXT['DELETE']; ?>">
278
    					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
279
    				</a>
280
    			</td>
281
    		</tr>
282
    		<?php
283
    		// Alternate row color
284
    		if($row == 'a') {
285
    			$row = 'b';
286
    		} else {
287
    			$row = 'a';
288
    		}
289
    	}
290
    	?>
291
    	</table>
292
    	<?php
293
    } else {
294
    	echo $TEXT['NONE_FOUND'];
295
    }
296
}
297
// Print admin footer
298
$admin->print_footer();
(21-21/34)