Changeset 441
- Timestamp:
- Dec 5, 2013 6:58:11 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Hierarchy.inc.php
r396 r441 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 23 23 /** 24 24 * Hierarchy.inc.php 25 * 25 * 26 26 * Objective: This class provides the tools to organize pieces of data into a 27 27 * hierarchy of nodes. Any form of data (article, product, image) can be … … 116 116 { 117 117 $app =& App::getInstance(); 118 118 119 119 if (!isset($child_type) || !isset($child_id)) { 120 120 if ($this->node_init) { … … 122 122 $child_id =& $this->child_id; 123 123 } 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__); 125 125 return false; 126 126 } … … 150 150 { 151 151 $app =& App::getInstance(); 152 152 153 153 if (preg_match('/^([[:alnum:]]+)__-?([[:digit:]]+)$/', $node, $node_parts)) { 154 154 return array('node_type' => $node_parts[1], 'node_id' => $node_parts[2]); 155 155 } 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__); 157 157 return false; 158 158 } … … 171 171 $app =& App::getInstance(); 172 172 $db =& DB::getInstance(); 173 173 174 174 if (!isset($child_type) || !isset($child_id)) { 175 175 if ($this->node_init) { … … 177 177 $child_id =& $this->child_id; 178 178 } 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__); 180 180 return false; 181 181 } … … 250 250 $app =& App::getInstance(); 251 251 $db =& DB::getInstance(); 252 252 253 253 if (!isset($child_type) || !isset($child_id)) { 254 254 if ($this->node_init) { … … 256 256 $child_id =& $this->child_id; 257 257 } 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__); 259 259 return false; 260 260 } … … 306 306 $child_id =& $this->child_id; 307 307 } 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__); 309 309 return false; 310 310 } … … 377 377 $app =& App::getInstance(); 378 378 $db =& DB::getInstance(); 379 379 380 380 if (!isset($child_type) || !isset($child_id)) { 381 381 if ($this->node_init) { … … 383 383 $child_id =& $this->child_id; 384 384 } 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__); 386 386 return false; 387 387 } … … 428 428 $app =& App::getInstance(); 429 429 $db =& DB::getInstance(); 430 430 431 431 if (!isset($child_type) || !isset($child_id)) { 432 432 if ($this->node_init) { … … 434 434 $child_id =& $this->child_id; 435 435 } 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__); 437 437 return false; 438 438 } … … 472 472 $app =& App::getInstance(); 473 473 $db =& DB::getInstance(); 474 474 475 475 if (!isset($child_type) || !isset($child_id)) { 476 476 if ($this->node_init) { … … 478 478 $child_id =& $this->child_id; 479 479 } 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__); 481 481 return false; 482 482 } … … 530 530 $child_id =& $this->child_id; 531 531 } 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__); 533 533 return false; 534 534 } … … 564 564 { 565 565 $app =& App::getInstance(); 566 566 567 567 if (!isset($child_type) || !isset($child_id)) { 568 568 if ($this->node_init) { … … 570 570 $child_id =& $this->child_id; 571 571 } 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__); 573 573 return false; 574 574 } … … 625 625 { 626 626 $db =& DB::getInstance(); 627 627 628 628 static $output = array(); 629 629 static $return_flag; … … 680 680 $app =& App::getInstance(); 681 681 $db =& DB::getInstance(); 682 682 683 683 if (!isset($child_type) || !isset($child_id)) { 684 684 if ($this->node_init) { … … 686 686 $child_id =& $this->child_id; 687 687 } 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__); 689 689 return false; 690 690 } … … 731 731 { 732 732 $app =& App::getInstance(); 733 733 734 734 static $output = array(); 735 735 static $is_a_leaf = array(); … … 740 740 $child_id =& $this->child_id; 741 741 } 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__); 743 743 return false; 744 744 } … … 804 804 { 805 805 $db =& DB::getInstance(); 806 806 807 807 // Reset all the category counters to zero. 808 808 $db->query("UPDATE node_tbl SET subnode_quantity = 0"); … … 828 828 { 829 829 $db =& DB::getInstance(); 830 830 831 831 $db->query(" 832 832 UPDATE node_tbl -
trunk/lib/PEdit.inc.php
r421 r441 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 35 35 * and call printing/editing functions where you want data and forms to 36 36 * show up. 37 * 37 * 38 38 * @author Quinn Comendant <quinn@strangecode.com> 39 39 * @concept Beau Smith <beau@beausmith.com> 40 * @version 2.0 41 * 40 * @version 2.0 41 * 42 42 * Example of use: 43 43 44 44 // Initialize PEdit object. 45 45 require_once 'codebase/lib/PEdit.inc.php'; … … 48 48 'authorized' => true, 49 49 )); 50 50 51 51 // Setup content data types. 52 52 $pedit->set('title'); 53 53 $pedit->set('content', array('type' => 'textarea')); 54 54 55 55 // After setting all parameters and data, load the data. 56 56 $pedit->start(); 57 57 58 58 // Print content. 59 59 echo $pedit->get('title'); 60 60 echo $pedit->get('content'); 61 61 62 62 // Print additional PEdit functionality. 63 63 $pedit->formBegin(); … … 96 96 { 97 97 $this->setParam($params); 98 98 99 99 if ($this->getParam('authorized') === true) { 100 100 $this->_authorized = true; 101 101 } 102 102 103 103 // Setup PEAR XML libraries. 104 104 require_once 'XML/Serializer.php'; … … 114 114 )); 115 115 } 116 116 117 117 /** 118 118 * Set (or overwrite existing) parameters by passing an array of new parameters. … … 143 143 { 144 144 $app =& App::getInstance(); 145 145 146 146 if (isset($this->_params[$param])) { 147 147 return $this->_params[$param]; … … 151 151 } 152 152 } 153 153 154 154 /* 155 155 * Load the pedit data and run automatic functions. … … 166 166 trigger_error(sprintf('PEdit data directory not found: %s', $this->getParam('data_dir')), E_USER_WARNING); 167 167 } 168 168 169 169 // The location of the data file. (i.e.: "COMMON_DIR/html/_pedit_data/news/index.xml") 170 170 $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 /../../); 173 173 // if realpath returns FALSE we're not concerned because it means the file doesn't exist (_initializeDataFile() will create it). 174 174 if (false !== realpath($this->_data_file) && $this->_data_file !== realpath($this->_data_file)) { … … 199 199 break; 200 200 } 201 201 202 202 // Load data. 203 203 $this->_loadDataFile(); … … 258 258 return false; 259 259 } 260 ?> 260 ?> 261 261 <form action="<?php echo oTxt($_SERVER['PHP_SELF']); ?>" method="post" id="sc-pedit-form"> 262 262 <input type="hidden" name="filename" value="<?php echo oTxt($_SERVER['PHP_SELF']); ?>" /> … … 307 307 function printForm($name, $type='text') 308 308 { 309 if ($this->_authorized && $this->op == 'Edit' && $this->_data_loaded) { 309 if ($this->_authorized && $this->op == 'Edit' && $this->_data_loaded) { 310 310 ?> 311 311 <div class="sc-pedit-item"> … … 468 468 } 469 469 $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); 471 471 if (PEAR::isError($status)) { 472 472 $app->logMsg(sprintf('XML_Unserialize error: %s', $status->getMessage()), LOG_WARNING, __FILE__, __LINE__); … … 487 487 return true; 488 488 } 489 489 490 490 /* 491 491 * Start a new data file. … … 535 535 return false; 536 536 } 537 537 538 538 // Collect posted data that is already specified in _data (by set()). 539 539 foreach ($new_data as $name => $content) { … … 542 542 } 543 543 } 544 544 545 545 if (is_array($this->_data) && !empty($this->_data)) { 546 546 $xml_file_contents = $this->xml_serializer->serialize($this->_data); … … 549 549 } 550 550 } 551 551 552 552 /* 553 553 * Writes content to the specified file. … … 587 587 if ($fp = fopen($filename, 'w')) { 588 588 if (flock($fp, LOCK_EX)) { 589 fwrite($fp, $content , mb_strlen($content));589 fwrite($fp, $content); 590 590 flock($fp, LOCK_UN); 591 591 } else { … … 639 639 return true; 640 640 } 641 641 642 642 /* 643 643 * Delete all versions older than versions_min_days if there are more than versions_min_qty or 100. … … 714 714 return false; 715 715 } 716 716 717 717 // The file to restore. 718 718 $version_file = sprintf('%s__%s.xml', preg_replace('/\.xml$/', '', $this->_data_file), $version); 719 719 720 720 // Ensure specified version exists. 721 721 if (!file_exists($version_file)) { -
trunk/services/admins.php
r432 r441 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 282 282 $app =& App::getInstance(); 283 283 $db =& DB::getInstance(); 284 284 285 285 $lock->select($auth->getParam('db_table'), $auth->getParam('db_primary_key'), $id); 286 286 if ($lock->isLocked() && !$lock->isMine()) { … … 341 341 $app =& App::getInstance(); 342 342 $db =& DB::getInstance(); 343 343 344 344 $lock->select($auth->getParam('db_table'), $auth->getParam('db_primary_key'), $id); 345 345 if ($lock->isLocked() && !$lock->isMine()) { … … 386 386 $app =& App::getInstance(); 387 387 $db =& DB::getInstance(); 388 388 389 389 // Remove any stale cached list data. 390 390 $cache->delete('list'); … … 429 429 $app =& App::getInstance(); 430 430 $db =& DB::getInstance(); 431 431 432 432 $lock->select($auth->getParam('db_table'), $auth->getParam('db_primary_key'), $frm['admin_id']); 433 433 if ($lock->isLocked() && !$lock->isMine()) { … … 474 474 global $auth; 475 475 $db =& DB::getInstance(); 476 476 477 477 $where_clause = ''; 478 478 … … 508 508 SELECT 509 509 " . $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, 511 511 a1." . $auth->getParam('db_username_column') . " AS added_admin_username, 512 512 a2." . $auth->getParam('db_username_column') . " AS modified_admin_username … … 536 536 return $list; 537 537 } 538 538 539 539 // The list was not cached, so issue the real query. 540 540 $qid = $db->query($sql);
Note: See TracChangeset
for help on using the changeset viewer.