Changeset 441


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

Very minor things

Location:
trunk
Files:
3 edited

Legend:

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

    r396 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/>.
     
    2323/**
    2424 * Hierarchy.inc.php
    25  * 
     25 *
    2626 * Objective: This class provides the tools to organize pieces of data into a
    2727 * hierarchy of nodes. Any form of data (article, product, image) can be
     
    116116    {
    117117            $app =& App::getInstance();
    118    
     118
    119119            if (!isset($child_type) || !isset($child_id)) {
    120120            if ($this->node_init) {
     
    122122                $child_id =& $this->child_id;
    123123            } else {
    124                 $app->logMsg('toStringID failed. Arguments not specified properly.'), LOG_ERR, __FILE__, __LINE__);
     124                $app->logMsg('toStringID failed. Arguments not specified properly.', LOG_ERR, __FILE__, __LINE__);
    125125                return false;
    126126            }
     
    150150    {
    151151            $app =& App::getInstance();
    152    
     152
    153153            if (preg_match('/^([[:alnum:]]+)__-?([[:digit:]]+)$/', $node, $node_parts)) {
    154154            return array('node_type' => $node_parts[1], 'node_id' => $node_parts[2]);
    155155        } else {
    156             $app->logMsg('Cannot parse node identifier, not formated correctly.'), LOG_ERR, __FILE__, __LINE__);
     156            $app->logMsg('Cannot parse node identifier, not formated correctly.', LOG_ERR, __FILE__, __LINE__);
    157157            return false;
    158158        }
     
    171171        $app =& App::getInstance();
    172172        $db =& DB::getInstance();
    173    
     173
    174174        if (!isset($child_type) || !isset($child_id)) {
    175175            if ($this->node_init) {
     
    177177                $child_id =& $this->child_id;
    178178            } else {
    179                 $app->logMsg('insertNode failed. Arguments not specified properly.'), LOG_ERR, __FILE__, __LINE__);
     179                $app->logMsg('insertNode failed. Arguments not specified properly.', LOG_ERR, __FILE__, __LINE__);
    180180                return false;
    181181            }
     
    250250        $app =& App::getInstance();
    251251        $db =& DB::getInstance();
    252    
     252
    253253        if (!isset($child_type) || !isset($child_id)) {
    254254            if ($this->node_init) {
     
    256256                $child_id =& $this->child_id;
    257257            } else {
    258                 $app->logMsg('deleteNode failed. Arguments not specified properly.'), LOG_ERR, __FILE__, __LINE__);
     258                $app->logMsg('deleteNode failed. Arguments not specified properly.', LOG_ERR, __FILE__, __LINE__);
    259259                return false;
    260260            }
     
    306306                $child_id =& $this->child_id;
    307307            } else {
    308                 $app->logMsg('moveNode failed. Arguments not specified properly.'), LOG_ERR, __FILE__, __LINE__);
     308                $app->logMsg('moveNode failed. Arguments not specified properly.', LOG_ERR, __FILE__, __LINE__);
    309309                return false;
    310310            }
     
    377377        $app =& App::getInstance();
    378378        $db =& DB::getInstance();
    379    
     379
    380380        if (!isset($child_type) || !isset($child_id)) {
    381381            if ($this->node_init) {
     
    383383                $child_id =& $this->child_id;
    384384            } else {
    385                 $app->logMsg('getParents failed. Arguments not specified properly.'), LOG_ERR, __FILE__, __LINE__);
     385                $app->logMsg('getParents failed. Arguments not specified properly.', LOG_ERR, __FILE__, __LINE__);
    386386                return false;
    387387            }
     
    428428        $app =& App::getInstance();
    429429        $db =& DB::getInstance();
    430    
     430
    431431        if (!isset($child_type) || !isset($child_id)) {
    432432            if ($this->node_init) {
     
    434434                $child_id =& $this->child_id;
    435435            } else {
    436                 $app->logMsg('getNode failed. Arguments not specified properly.'), LOG_ERR, __FILE__, __LINE__);
     436                $app->logMsg('getNode failed. Arguments not specified properly.', LOG_ERR, __FILE__, __LINE__);
    437437                return false;
    438438            }
     
    472472        $app =& App::getInstance();
    473473        $db =& DB::getInstance();
    474    
     474
    475475        if (!isset($child_type) || !isset($child_id)) {
    476476            if ($this->node_init) {
     
    478478                $child_id =& $this->child_id;
    479479            } else {
    480                 $app->logMsg('getChildren failed. Arguments not specified properly.'), LOG_ERR, __FILE__, __LINE__);
     480                $app->logMsg('getChildren failed. Arguments not specified properly.', LOG_ERR, __FILE__, __LINE__);
    481481                return false;
    482482            }
     
    530530                $child_id =& $this->child_id;
    531531            } else {
    532                 $app->logMsg('getNumberChildren failed. Arguments not specified properly.'), LOG_ERR, __FILE__, __LINE__);
     532                $app->logMsg('getNumberChildren failed. Arguments not specified properly.', LOG_ERR, __FILE__, __LINE__);
    533533                return false;
    534534            }
     
    564564    {
    565565        $app =& App::getInstance();
    566    
     566
    567567        if (!isset($child_type) || !isset($child_id)) {
    568568            if ($this->node_init) {
     
    570570                $child_id =& $this->child_id;
    571571            } else {
    572                 $app->logMsg('isLeaf failed. Arguments not specified properly.'), LOG_ERR, __FILE__, __LINE__);
     572                $app->logMsg('isLeaf failed. Arguments not specified properly.', LOG_ERR, __FILE__, __LINE__);
    573573                return false;
    574574            }
     
    625625    {
    626626        $db =& DB::getInstance();
    627    
     627
    628628        static $output = array();
    629629        static $return_flag;
     
    680680        $app =& App::getInstance();
    681681        $db =& DB::getInstance();
    682    
     682
    683683        if (!isset($child_type) || !isset($child_id)) {
    684684            if ($this->node_init) {
     
    686686                $child_id =& $this->child_id;
    687687            } else {
    688                 $app->logMsg('nodeExists failed. Arguments not specified properly.'), LOG_ERR, __FILE__, __LINE__);
     688                $app->logMsg('nodeExists failed. Arguments not specified properly.', LOG_ERR, __FILE__, __LINE__);
    689689                return false;
    690690            }
     
    731731    {
    732732        $app =& App::getInstance();
    733    
     733
    734734        static $output = array();
    735735        static $is_a_leaf = array();
     
    740740                $child_id =& $this->child_id;
    741741            } else {
    742                 $app->logMsg('getNodeList failed. Arguments not specified properly.'), LOG_ERR, __FILE__, __LINE__);
     742                $app->logMsg('getNodeList failed. Arguments not specified properly.', LOG_ERR, __FILE__, __LINE__);
    743743                return false;
    744744            }
     
    804804    {
    805805        $db =& DB::getInstance();
    806    
     806
    807807        // Reset all the category counters to zero.
    808808        $db->query("UPDATE node_tbl SET subnode_quantity = 0");
     
    828828    {
    829829        $db =& DB::getInstance();
    830    
     830
    831831        $db->query("
    832832            UPDATE node_tbl
  • 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)) {
  • trunk/services/admins.php

    r432 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/>.
     
    282282    $app =& App::getInstance();
    283283    $db =& DB::getInstance();
    284    
     284
    285285    $lock->select($auth->getParam('db_table'), $auth->getParam('db_primary_key'), $id);
    286286    if ($lock->isLocked() && !$lock->isMine()) {
     
    341341    $app =& App::getInstance();
    342342    $db =& DB::getInstance();
    343    
     343
    344344    $lock->select($auth->getParam('db_table'), $auth->getParam('db_primary_key'), $id);
    345345    if ($lock->isLocked() && !$lock->isMine()) {
     
    386386    $app =& App::getInstance();
    387387    $db =& DB::getInstance();
    388    
     388
    389389    // Remove any stale cached list data.
    390390    $cache->delete('list');
     
    429429    $app =& App::getInstance();
    430430    $db =& DB::getInstance();
    431    
     431
    432432    $lock->select($auth->getParam('db_table'), $auth->getParam('db_primary_key'), $frm['admin_id']);
    433433    if ($lock->isLocked() && !$lock->isMine()) {
     
    474474    global $auth;
    475475    $db =& DB::getInstance();
    476    
     476
    477477    $where_clause = '';
    478478
     
    508508        SELECT
    509509            " . $auth->getParam('db_table') . ".*,
    510             " . $auth->getParam('db_table') . "." . $auth->getParam('db_primary_key') . " AS admin_id,           
     510            " . $auth->getParam('db_table') . "." . $auth->getParam('db_primary_key') . " AS admin_id,
    511511            a1." . $auth->getParam('db_username_column') . " AS added_admin_username,
    512512            a2." . $auth->getParam('db_username_column') . " AS modified_admin_username
     
    536536        return $list;
    537537    }
    538    
     538
    539539    // The list was not cached, so issue the real query.
    540540    $qid = $db->query($sql);
Note: See TracChangeset for help on using the changeset viewer.