ruạṛ
<?php /** * Edit page * @version 0.10 * @author Robert Urquhart <programmer@activatedesign.co.nz> * @package WEP-CMS * @todo pull slideshow into {page} class in same manner as {product} gallery */ session_start(); require_once 'scripts-includes/universal.php'; require_once 'scripts-includes/display.php'; $connID = connect_to_db(); if(!$page_id = is_numeric_id($_GET['page'], 0)) { $p = new page(); if(isset($_SESSION['passback'])) { $p->load_from_data($_SESSION['passback']); } $button = $h1 = 'Add page'; $action = 'process-page-new.php'; } else { $p = new page($page_id); //if(!$product = mysql_query("select * from products where prod_id = '$prod_id'")) if(!$p->page_id) { getout('Page not found','pages.php'); exit; } $action = 'process-page-edit.php'; $button = 'Update page'; $h1 = 'Edit '.$p->name; $dir = '/resources/images/page/'.$page_id.'/'; } //@todo put this in {page} like {product} gallery $slideshow = mysql_query("select * from image_data where image_type = 'page-slideshow' and container_id='$p->page_id' order by image_position"); head('pages','Edit a page'); ?> <h1><?php echo $h1; ?></h1> <div class="tabs"> <ul> <li><a href="#tab1">Content</a></li> <?php if($p->page_id): ?> <li><a href="#tab2">Page options</a></li> <?php if(PAGE_HAS_SLIDESHOW): ?> <li><a href="#tab3">Slideshow</a></li> <?php endif; ?> <?php /* @todo <li><a href="#tab4">Background</a></li> */ ?> <?php endif; ?> </ul> <div class="mock_table" id="tab1"> <form method="post" action="processes/<?php echo $action; ?>" name="page_edit" id="page_edit" enctype="multipart/form-data"> <input name="page_id" id="page_id1" type="hidden" value="<?php echo $page_id; ?>" /> <label for="title"><span class="right">Title:</span><span class="left"><input name="title" id="title" type="text" size="60" maxlength="65" value="<?php echo $p->title; ?>" /></span></label> <label for="keywords"><span class="right">Keywords:</span><span class="left"><textarea name="keywords" id="short_description" cols="50" rows="2" title="Comma-separated list"><?php echo $p->keywords; ?></textarea></span></label> <label for="description"><span class="right">Description:</span><span class="left"><textarea name="description" id="description" cols="50" rows="4"><?php echo $p->description; ?></textarea></span></label> <label for="content"><span class="right">Content:</span></label> <br class="clear" /> <?php if($p->type != 'page'): ?> <p class="center">This page displays content from the <?php echo ucfirst($p->type); ?> module <strong> <?php if($p->display_content): ?> in addition to <?php else: ?> in place of <?php endif; ?> </strong> anything entered here. </p> <?php endif; ?> <div style="margin: 0px auto; text-align: center;" class='editWindow'> <textarea name="content" class="content editor editWindow" style="height:600px"><?php echo $p->content; ?></textarea> </div> <p> </p> <p class="center"><input name="submit" id="submit" type="submit" value="<?php echo $button; ?>" /></p> </form> </div><!-- end #tab1 --> <?php if($p->page_id) { /* * menu settings */ ?> <div class="mock_table<?php if($_GET['tab']=='options'){ echo ' active'; } ?>" id="tab2"> <form method="post" action="processes/process-page-options.php" name="page_options" id="page_options" enctype="multipart/form-data"> <input name="page_id" id="page_id2" type="hidden" value="<?php echo $page_id; ?>" /> <label for="menu_text"><span class="right">Menu text:</span><span class="left"><input name="menu_text" id="menu_text" type="text" size="20" maxlength="30" value="<?php echo $p->menu_text; ?>" /></span></label> <label for="index_page"><span class="right">Set as homepage:</span><span class="left"><input name="index_page" id="index_page" type="checkbox" value="1" <?php if($p->homepage){ echo 'checked="checked"'; } ?> /></span></label> <label for="error_page"><span class="right">Set as 404 error page:</span><span class="left"><input name="error_page" id="error_page" type="checkbox" value="1" <?php if($p->errorpage){ echo 'checked="checked"'; } ?> /></span></label> <p><span class="right"><label for="external" class="inline">External link:</label></span> <span class="left"> <input name="external" id="external" type="checkbox" value="1" <?php if($p->external){ echo 'checked="checked"'; } ?> /> <label for="link" class="inline">Link: <input type="text" name="link" id="link" size="50" maxlength="60" value="<?php echo $p->link; ?>" /></label> </span> </p> <p class="center"><input name="submit" id="submit" type="submit" value="Update options" /></p> </form> </div><!-- end #tab2 --> <?php /* * slideshow */ if(PAGE_HAS_SLIDESHOW) { $maxPos = select_one('image_data','max(image_position)',"concat_ws(':',image_type,container_id)",'page-slideshow:'.$page_id)+10; $refresh = '?refresh='.time(); //foil caching ?> <div class="mock_table<?php if($_GET['tab']=='slideshow'){ echo ' active'; } ?>" id="tab3"> <form method="post" action="processes/process-page-slideshow.php" name="page_slideshow" id="page_slideshow" enctype="multipart/form-data"> <input name="page_id" id="page_id3" type="hidden" value="<?php echo $page_id; ?>" /> <label for="has_slideshow"><span class="right">Use slideshow:</span><span class="left"><input name="has_slideshow" id="has_slideshow" type="checkbox" value="1" <?php if($p->slideshow){ echo 'checked="checked"'; } ?> /></span></label> <br class="clear" /> <label for="slideshow_image"><span class="right">Add Slideshow Image:</span><span class="left"><input name="slideshow_image" id="slideshow_image" type="file" size="30" /></span></label> <label for="slideshow_title"><span class="right">With caption (optional):</span><span class="left"><input name="slideshow_image_caption" id="slideshow_image_caption" type="text" size="30" value="" /></span></label> <label for="slideshow_position"><span class="right">At position:</span><span class="left"><input name="slideshow_image_position" id="slideshow_image_position" type="text" size="3" maxlength="3" value="<?php echo $maxPos; ?>" /></span></label> <br class="clear" /> <p> </p> <p class="center"><input name="submit" id="submit" type="submit" value="Update slideshow" /></p> <?php if($slideshow && mysql_num_rows($slideshow)>0) { while($s = mysql_fetch_assoc($slideshow)) { $sid = $s['image_id']; ?> <hr /> <label for="slidetitle<?php echo $sid; ?>"><span class="right">Caption:</span><span class="left"><input name="slidetitle[title<?php echo $sid; ?>]" id="slidetitle<?php echo $sid; ?>" type="text" size="30" value="<?php echo $s['title']; ?>" /></span></label> <label for="slideposition<?php echo $sid; ?>"><span class="right">Image position:</span><span class="left"><input name="slideposition[<?php echo $sid; ?>]" id="slideposition<?php echo $sid; ?>" type="text" size="3" maxlength="3" value="<?php echo $s['image_position']; ?>" /></span></label> <label for="slideshow<?php echo $sid; ?>"><span class="right">Replace Image:</span><span class="left"><input name="slideshow[slide<?php echo $sid; ?>]" id="slideshow<?php echo $sid; ?>" type="file" size="30" /></span></label> <p class="center"> <img align="middle" src="<?php echo $s['image_path'].$s['image_filename'].$refresh; ?>" /><br /> <input name="imgdel" type="button" value="Remove image" onclick="if(confirm('Remove image?')){window.location='processes/process-image-remove.php?page=<?php echo $page_id; ?>&image=<?php echo $sid; ?>';return true;}else{return false;}" /> </p> <br class="clear" /> <?php } } ?> <hr /> <p> </p> <p class="center"><input name="submit" id="submit" type="submit" value="Update slideshow" /></p> </form> </div><!-- end #tab3 --> <?php } //end if PAGE_HAS_SLIDESHOW /** * other images * @todo this form and process script (code not written in {page} yet) */ /* ?> <div class="mock_table<?php if($_GET['tab']=='images'){ echo ' active'; } ?>" id="tab4"> <label for="background"><span class="right">Add/Replace Background Image:</span><span class="left"><input name="background" id="background" type="file" size="30" /></span></label> <br class="clear" /> <p class="center"> <?php $file = '..'.$path.'background.jpg'; echo (file_exists($file)) ? '<img align="middle" src="'.$file.'" width="50%" /> <input name="imgdel" type="button" value="Remove image" onclick="if(confirm(\'Remove image?\')){window.location=\'process-page-image-remove.php?page='.$page_id.'\';return true;}else{return false;}" />' : 'No image found '; ?> </p> <p> </p> <?php // */ } //end if $page_id ?> </div><!-- end .tabs --> <?php footer(); exit; ?>
cải xoăn