Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Douglas Ianitsky  >  Edit File Tags  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example to use the class
Class: Edit File Tags
Find and replace tags in files with new values
Author: By
Last change:
Date: 7 years ago
Size: 1,587 bytes
 

Contents

Class file image Download
<?php

require_once('EditFileTags.class.php');

//Begin class. Send the file for read
$edit = new EditFileTags('http://www.ianitsky.com/files/phpclasses/EditDocumentTags.rtf');

if (
$_POST) {//If post save the document
   //After submitting the data in the form send create a string already formatted in the way we want.
   
$string $edit->write($_POST['tag']);
   
header('Content-Type: application/msword');
     
header('Content-Disposition: inline, filename=ianitsky_test.rtf');
     
$string str_replace"\n"" \par "$string);
     
$string str_replace"\t""        "$string);
     echo 
$string;
} else { 
//Else create the form
  //Read the document and return the tags for form
  
$fileTags $edit->read();
  if (
$error $edit->getLastError()) {
    echo 
$error;
  }
?>
    <html>
    <head>
    </head>
      <body>
      <center><h1>Edit file tags example</h1></center>
        <table>
          <form action="" method="POST">
            <?php
              
//Create form
              
foreach ($fileTags as $key => $value) {
                echo 
'<tr>';
                echo 
'<td>';
                echo 
$value ':';
                echo 
'</td>';
                echo 
'<td>';
                echo 
'<input type="text" name="tag[]" />';
                echo 
'</td>';
                echo 
'</tr>';
              }
            
?>
            <tr>
              <td>
                <input type="submit" value="Send">
              </td>
            </tr>
          </form>
        </table>
      </body>
    </html>
<?php
  
}
?>