?
Solved

need to edit file on server with rte

Posted on 2010-01-10
4
Medium Priority
?
304 Views
Last Modified: 2012-05-08
i have the code below
i want to use the rte i have to edit files on my server
it works fine for one file but i want to edit others
how do i make it pass a value that php can use to denote what files to use
how can i pres the link and have it load and save the data for the matched file.

i tried to use include to load another rte but this ones special cant have code on the same page, and cant use the div/textbox example as i dont want to click on each box i only want one to show up at a time so i figured id pass the values via a link to denote what file im on and what file to edit

but haven't got a clue how to do that

thank you in advance for any code or help you may provide

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
<title>LCW - Admin Section: Content</title>

<!-- Skin CSS file -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/assets/skins/sam/skin.css">
<!-- Utility Dependencies -->
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/yahoo-dom-event/yahoo-dom-event.js"></script> 
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/element/element-min.js"></script> 
<!-- Needed for Menus, Buttons and Overlays used in the Toolbar -->
<script src="http://yui.yahooapis.com/2.8.0r4/build/container/container_core-min.js"></script>
<script src="http://yui.yahooapis.com/2.8.0r4/build/menu/menu-min.js"></script>
<script src="http://yui.yahooapis.com/2.8.0r4/build/button/button-min.js"></script>
<!-- Source file for Rich Text Editor-->
<script src="http://yui.yahooapis.com/2.8.0r4/build/editor/editor-min.js"></script>
<script src="js/yui-image-uploader26.js"></script>
</head>
<?
if(isset($_POST['msgpost']))
{
    $sContent = stripslashes($_POST['msgpost']);
       //Form was submitted
       $fp = fopen("../index_bottom_left_panel.php","w");
       if (fwrite($fp, $sContent))
       {
         $sHeader .=" Successfully wrote to file.";
         //echo "content: ".$sContent;
      }
       else
       {
           $sHeader .=" Error writing to file.";
        }
  } else {
    $sHeader = 'You may edit the content... Nothing submitted yet';
    $sContent= file_get_contents("../index_bottom_left_panel.php");
  }




/*
../index_bottom_left_panel.php
../index_bottom_middle_panel.php
../index_top_right_panel.php
../index_footer_right_area.php

edit the file from what content we have now
make  flag of witch file we are useing and pass value each time in url link
need to show what page we are editing
*/





  ?>
<body class="yui-skin-sam"> 
			
				<a href="#tabs-1">Bottom Left Panel</a> |
				<a href="#tabs-2">Bottom Middle Panel</a> |
				<a href="#tabs-3">Top Right Panel</a> |
				<a href="#tabs-3">Footer Right Area</a>
			 
			<div >
			    
			    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
			    <textarea name="msgpost" id="msgpost" cols="50" rows="10"><?php echo $sContent;?></textarea>
			    <input id="FormSubmit" type="submit" name="save" value="Submit" />
			    <input type="reset" name="reset" value="Reset" />&nbsp;&nbsp;&nbsp;<?php echo $sHeader;?>
			    </form>
			    <script type="text/javascript">

				var myEditor = new YAHOO.widget.Editor('msgpost', {
				    height: '300px',
				    width: '522px',
				    dompath: false, //Turns on the bar at the bottom
				    animate: true //Animates the opening, closing and moving of Editor windows

				});
				yuiImgUploader(myEditor, 'msgpost', 'yui_img_uploader.php','image');
				myEditor.render();

				//Inside an event handler after the Editor is rendered
				YAHOO.util.Event.on('FormSubmit', 'click', function() {
				    //Put the HTML back into the text area
				    myEditor.saveHTML();
				    myEditor.handleSubmit(true);

				    //The var html will now have the contents of the textarea
				    var html = myEditor.get('msgpost').value;

				    //var html = myEditor.getEditorHTML('msgpost').value;
				    //var html = myEditor.get('element').value;
				    document.msgpost.textEntered.value = html;
				});


				</script>
			</div> 

	<!-- END TABBED PANEL EXAMPLE-->                                      

</body>
</html>

Open in new window

0
Comment
Question by:Johnny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
VanHackman earned 2000 total points
ID: 26280720

Hi again Bro!.

I code a full example to you!. =P

I attached all the files, you just download all the files, and install the scripts in some folder of your server.

Create two folders:

"your" and in the folder "your" create the folder "Directory" and put some text or html files on it.

The main script is the "YUI-Plus.php" file.
The example read all the files on "your/Directory" folder, and display a list of them, when you click in some file it is loaded to the editor and you can edit it, when you click in the "submit" button the file is updated when the new content, and you will see a message about it.

I hope that my code helps you and don't forget give me some points! =P
YUI-Plus.php
LoadFile.php
EditFile.php
browser.php
0
 

Author Comment

by:Johnny
ID: 26284545
can you try this one
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_25044553.html
thanks ever so much

id NEVER of come up with a solution like the one you presented with the file folder that exceeds what i was looking for and meet our needs so much better

thanks
0
 

Author Closing Comment

by:Johnny
ID: 31675332
this is a church project we are surly blessed by your help
0
 
LVL 11

Expert Comment

by:VanHackman
ID: 26284941
Thanks a lot for the points.
I am glad to help you!.

~VanHackman
0

Featured Post

Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question