[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (tedkulp@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.org 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #BUT withOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 #$Id: class.bookmark.inc.php 2746 2006-05-09 01:18:15Z wishy $ 20 21 /** 22 * UserTags class for admin 23 * 24 * @package CMS 25 */ 26 class UserTagOperations 27 { 28 /** 29 * Retrieve the body of a user defined tag 30 * 31 * @params string $name User defined tag name 32 * 33 * @returns mixed If successfull, the body of the user tag (string). If it fails, false 34 */ 35 function GetUserTag( $name ) 36 { 37 $code = false; 38 39 global $gCms; 40 $db =& $gCms->GetDb(); 41 42 $query = 'SELECT userplugin_id, code FROM '.cms_db_prefix().'userplugins WHERE userplugin_name = ?'; 43 $result = &$db->Execute($query, array($name)); 44 45 while ($result && !$result->EOF) 46 { 47 $code = $result->fields['code']; 48 $result->MoveNext(); 49 } 50 51 return $code; 52 } 53 54 55 /** 56 * Add or update a named user defined tag into the database 57 * 58 * @params string $name User defined tag name 59 * @params string $text Body of user defined tag 60 * 61 * @returns mixed If successful, true. If it fails, false. 62 */ 63 function SetUserTag( $name, $text ) 64 { 65 global $gCms; 66 $db =& $gCms->GetDb(); 67 68 $existing = UserTagOperations::GetUserTag($name); 69 if (!$existing) 70 { 71 $query = "INSERT INTO userplugins (userplugin_name, code, create_date, modified_date) VALUES (?,?,".$db->DBTimeStamp(time()).",".$db->DBTimeStamp(time()).")"; 72 $result = $db->Execute($query, array($name, $text)); 73 if ($result) 74 return true; 75 else 76 return false; 77 } 78 else 79 { 80 $query = 'UPDATE userplugins SET code = ?, modified_date = '.$db->DBTimeStamp(time()).' WHERE userplugin_name = ?'; 81 $result = $db->Execute($query, array($text, $name)); 82 if ($result) 83 return true; 84 else 85 return false; 86 } 87 } 88 89 90 /** 91 * Remove a named user defined tag from the database 92 * 93 * @params string $name User defined tag name 94 * 95 * @returns mixed If successful, true. If it fails, false. 96 */ 97 function RemoveUserTag( $name ) 98 { 99 global $gCms; 100 $db =& $gCms->GetDb(); 101 102 $query = 'DELETE FROM '.cms_db_prefix().'userplugins WHERE userplugin_name = ?'; 103 $result = &$db->Execute($query, array($name)); 104 105 if ($result) 106 { 107 return true; 108 } 109 110 return false; 111 } 112 113 114 /** 115 * Return a list (suitable for use in a pulldown) of user tags. 116 * 117 * @returns mixed If successful, an array. If it fails, false. 118 */ 119 function ListUserTags() 120 { 121 global $gCms; 122 $db =& $gCms->GetDb(); 123 124 $plugins = array(); 125 126 //var_dump($db); 127 128 $query = 'SELECT userplugin_name FROM '.cms_db_prefix().'userplugins ORDER BY userplugin_name'; 129 //var_dump($db->Execute($query)); 130 $result = &$db->Execute($query); 131 132 //var_dump($result); 133 134 while ($result && !$result->EOF) 135 { 136 $plugins[$result->fields['userplugin_name']] =& $result->fields['userplugin_name']; 137 $result->MoveNext(); 138 } 139 140 if (count($plugins) == 0) 141 $plugins = false; 142 143 return $plugins; 144 } 145 146 function CallUserTag($name, &$params) 147 { 148 global $gCms; 149 $smarty =& $gCms->GetSmarty(); 150 $userpluginfunctions =& $gCms->userpluginfunctions; 151 152 $code = UserTags::GetUserTag($name); 153 154 $result = FALSE; 155 156 $functionname = "tmpcallusertag_".$name."_userplugin_function"; 157 158 if (function_exists($functionname) || !(@eval('function '.$functionname.'(&$params, &$smarty) {'.$code.'}') === FALSE)) 159 { 160 $result = call_user_func_array($functionname, array(&$params, &$smarty)); 161 } 162 163 return $result; 164 } 165 166 } // class 167 168 class UserTags extends UserTagOperations 169 {} 170 171 # vim:ts=4 sw=4 noet 172 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |