Changeset 77 for branches/1.1dev/lib
- Timestamp:
- Mar 30, 2006 10:40:42 PM (18 years ago)
- Location:
- branches/1.1dev/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1dev/lib/NodeHeirarchy.inc.php
r76 r77 347 347 * @return string The parents as an array of serialized node identifiers. 348 348 */ 349 function getParents($child_type=null, $child_id=null )349 function getParents($child_type=null, $child_id=null, $type_constraint=null, $order='') 350 350 { 351 351 if (!isset($child_type) || !isset($child_id)) { … … 357 357 return false; 358 358 } 359 } 360 361 $in_clause = ''; 362 if (isset($type_constraint)) { 363 if (!is_array($type_constraint)) { 364 $type_constraint = array($type_constraint); 365 } 366 $in_clause = "AND parent_type IN ('" . join("','", array_map('addslashes', $type_constraint)) . "')"; 359 367 } 360 368 361 369 $qid = dbQuery(" 362 370 SELECT parent_type, parent_id 363 FROM node_tbl 371 FROM node_tbl 364 372 WHERE child_type = '" . addslashes($child_type) . "' 365 AND child_id = '" . addslashes($child_id) . "' 373 AND child_id = '" . addslashes($child_id) . "' 374 $in_clause 375 " . addslashes($order) . " 366 376 "); 367 377 -
branches/1.1dev/lib/Utilities.inc.php
r76 r77 143 143 } 144 144 145 /** 146 * Turns "a really long string" into "a rea...string" 147 * 148 * @access public 149 * @param string $str Input string 150 * @param int $len Maximum string length. 151 * @param string $where Where to cut the string. One of: 'start', 'middle', or 'end'. 152 * @return string Truncated output string 153 * @author Quinn Comendant <quinn@strangecode.com> 154 * @since 29 Mar 2006 13:48:49 155 */ 156 function truncate($str, $len, $where='middle') 157 { 158 $part1 = floor(($len - 3) / 2); 159 $part2 = ceil(($len - 3) / 2); 160 switch ($where) { 161 case 'start' : 162 return preg_replace(array(sprintf('/^.{4,}(.{%s})$/', $part1 + $part2), '/\s*\.{3,}\s*/'), array('...$1', '...'), $str); 163 break; 164 default : 165 case 'middle' : 166 return preg_replace(array(sprintf('/^(.{%s}).{4,}(.{%s})$/', $part1, $part2), '/\s*\.{3,}\s*/'), array('$1...$2', '...'), $str); 167 break; 168 case 'end' : 169 return preg_replace(array(sprintf('/^(.{%s}).{4,}$/', $part1 + $part2), '/\s*\.{3,}\s*/'), array('$1...', '...'), $str); 170 break; 171 } 172 } 145 173 146 174 /**
Note: See TracChangeset
for help on using the changeset viewer.