Ignore:
Timestamp:
Dec 5, 2013 6:58:11 AM (10 years ago)
Author:
anonymous
Message:

Very minor things

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/PEdit.inc.php

    r421 r441  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3535 * and call printing/editing functions where you want data and forms to
    3636 * show up.
    37  * 
     37 *
    3838 * @author  Quinn Comendant <quinn@strangecode.com>
    3939 * @concept Beau Smith <beau@beausmith.com>
    40  * @version 2.0 
    41  * 
     40 * @version 2.0
     41 *
    4242 * Example of use:
    43  
     43
    4444 // Initialize PEdit object.
    4545 require_once 'codebase/lib/PEdit.inc.php';
     
    4848     'authorized' => true,
    4949 ));
    50  
     50
    5151 // Setup content data types.
    5252 $pedit->set('title');
    5353 $pedit->set('content', array('type' => 'textarea'));
    54  
     54
    5555 // After setting all parameters and data, load the data.
    5656 $pedit->start();
    57  
     57
    5858 // Print content.
    5959 echo $pedit->get('title');
    6060 echo $pedit->get('content');
    61  
     61
    6262 // Print additional PEdit functionality.
    6363 $pedit->formBegin();
     
    9696    {
    9797        $this->setParam($params);
    98        
     98
    9999        if ($this->getParam('authorized') === true) {
    100100            $this->_authorized = true;
    101101        }
    102        
     102
    103103        // Setup PEAR XML libraries.
    104104        require_once 'XML/Serializer.php';
     
    114114        ));
    115115    }
    116    
     116
    117117    /**
    118118     * Set (or overwrite existing) parameters by passing an array of new parameters.
     
    143143    {
    144144        $app =& App::getInstance();
    145    
     145
    146146        if (isset($this->_params[$param])) {
    147147            return $this->_params[$param];
     
    151151        }
    152152    }
    153    
     153
    154154    /*
    155155    * Load the pedit data and run automatic functions.
     
    166166            trigger_error(sprintf('PEdit data directory not found: %s', $this->getParam('data_dir')), E_USER_WARNING);
    167167        }
    168        
     168
    169169        // The location of the data file. (i.e.: "COMMON_DIR/html/_pedit_data/news/index.xml")
    170170        $this->_data_file = sprintf('%s%s.xml', $this->getParam('data_dir'), $_SERVER['SCRIPT_NAME']);
    171        
    172         // Make certain the evaluated path matches the assumed path (realpath will expand /../../); 
     171
     172        // Make certain the evaluated path matches the assumed path (realpath will expand /../../);
    173173        // if realpath returns FALSE we're not concerned because it means the file doesn't exist (_initializeDataFile() will create it).
    174174        if (false !== realpath($this->_data_file) && $this->_data_file !== realpath($this->_data_file)) {
     
    199199            break;
    200200        }
    201        
     201
    202202        // Load data.
    203203        $this->_loadDataFile();
     
    258258            return false;
    259259        }
    260         ?>       
     260        ?>
    261261        <form action="<?php echo oTxt($_SERVER['PHP_SELF']); ?>" method="post" id="sc-pedit-form">
    262262        <input type="hidden" name="filename" value="<?php echo oTxt($_SERVER['PHP_SELF']); ?>" />
     
    307307    function printForm($name, $type='text')
    308308    {
    309         if ($this->_authorized && $this->op == 'Edit' && $this->_data_loaded) {       
     309        if ($this->_authorized && $this->op == 'Edit' && $this->_data_loaded) {
    310310            ?>
    311311            <div class="sc-pedit-item">
     
    468468        }
    469469        $xml_file_contents = file_get_contents($this->_data_file);
    470         $status = $this->xml_unserializer->unserialize($xml_file_contents, false);   
     470        $status = $this->xml_unserializer->unserialize($xml_file_contents, false);
    471471        if (PEAR::isError($status)) {
    472472            $app->logMsg(sprintf('XML_Unserialize error: %s', $status->getMessage()), LOG_WARNING, __FILE__, __LINE__);
     
    487487        return true;
    488488    }
    489    
     489
    490490    /*
    491491    * Start a new data file.
     
    535535                return false;
    536536            }
    537            
     537
    538538            // Collect posted data that is already specified in _data (by set()).
    539539            foreach ($new_data as $name => $content) {
     
    542542                }
    543543            }
    544            
     544
    545545            if (is_array($this->_data) && !empty($this->_data)) {
    546546                $xml_file_contents = $this->xml_serializer->serialize($this->_data);
     
    549549        }
    550550    }
    551    
     551
    552552    /*
    553553    * Writes content to the specified file.
     
    587587        if ($fp = fopen($filename, 'w')) {
    588588            if (flock($fp, LOCK_EX)) {
    589                 fwrite($fp, $content, mb_strlen($content));
     589                fwrite($fp, $content);
    590590                flock($fp, LOCK_UN);
    591591            } else {
     
    639639        return true;
    640640    }
    641    
     641
    642642    /*
    643643    * Delete all versions older than versions_min_days if there are more than versions_min_qty or 100.
     
    714714            return false;
    715715        }
    716        
     716
    717717        // The file to restore.
    718718        $version_file = sprintf('%s__%s.xml', preg_replace('/\.xml$/', '', $this->_data_file), $version);
    719        
     719
    720720        // Ensure specified version exists.
    721721        if (!file_exists($version_file)) {
Note: See TracChangeset for help on using the changeset viewer.