
Public Member Functions | |
| getBasicFolder ($id) | |
| getFolder ($id) | |
| getCategories ($published=false, $search=null) | |
| getDescendantIDList ($id, $search='') | |
| getSelectList ($allowTop, $default, $type, $parm, &$user) | |
| displayChildren (&$folder) | |
| delete ($deletelist) | |
| changeOrder ($id, $direction) | |
| updateOrdering ($orders, $parentid) | |
| ancestorsWithParent ($parentid, $folderIDs) | |
| setFolderPathway ($folder, $baseurl) | |
Static Public Member Functions | |
| static | getInstance () |
Protected Member Functions | |
| __construct () | |
Static Protected Attributes | |
| static | $instance = __CLASS__ |
Private Attributes | |
| $rows = array() | |
| $byancestor = array() | |
| $anchor = '' | |
Definition at line 171 of file aliroFolder.php.
| aliroFolderHandler::__construct | ( | ) | [protected] |
Definition at line 177 of file aliroFolder.php.
References aliroDatabase::getInstance().
00177 { 00178 $database = aliroDatabase::getInstance(); 00179 $this->anchor = new aliroFolder(); 00180 $sql = 'SELECT id, parentid, name, published, ordering FROM #__folders ORDER BY ordering, name'; 00181 $this->rows = $database->doSQLget($sql, 'aliroFolder', 'id'); 00182 foreach ($this->rows as $row) { 00183 $folder = $row; 00184 do $this->byancestor[$folder->parentid][$row->id] = $folder->id; 00185 while ($folder->parentid AND $folder = $this->rows[$folder->parentid]); 00186 if ($row->parentid) { 00187 $parent = $this->rows[$row->parentid]; 00188 $parent->addChild($row->id); 00189 } 00190 else $this->anchor->addChild($row->id); 00191 } 00192 }
| static aliroFolderHandler::getInstance | ( | ) | [static] |
Definition at line 194 of file aliroFolder.php.
Referenced by aliroFolder::addChildren(), aliroFolderContent::getBasicFolder(), aliroFolderContent::getFolder(), aliroFolder::getParent(), and aliroFolder::getSelectList().
00194 { 00195 return is_object(self::$instance) ? self::$instance : (self::$instance = parent::getCachedSingleton(self::$instance)); 00196 }
| aliroFolderHandler::getBasicFolder | ( | $ | id | ) |
Definition at line 198 of file aliroFolder.php.
Referenced by getDescendantIDList(), and getFolder().
00198 { 00199 if ($id == 0) return $this->anchor; 00200 return isset($this->rows[$id]) ? $this->rows[$id] : null; 00201 }
| aliroFolderHandler::getFolder | ( | $ | id | ) |
Definition at line 203 of file aliroFolder.php.
References getBasicFolder().
Referenced by ancestorsWithParent(), changeOrder(), and updateOrdering().
00203 { 00204 global $database; 00205 $result = $this->getBasicFolder($id); 00206 if ($result) $result->load(); 00207 return $result; 00208 }
| aliroFolderHandler::getCategories | ( | $ | published = false, |
|
| $ | search = null | |||
| ) |
Definition at line 210 of file aliroFolder.php.
References name, and published().
Referenced by getSelectList().
00210 { 00211 $categories = array(); 00212 foreach ($this->anchor->getChildren() as $category) { 00213 if ($published AND $category->published == 0) continue; 00214 if ($search AND strpos(strtolower($category->name), strtolower($search)) === false) continue; 00215 $categories[] = $category; 00216 } 00217 return $categories; 00218 }
| aliroFolderHandler::getDescendantIDList | ( | $ | id, | |
| $ | search = '' | |||
| ) |
Definition at line 220 of file aliroFolder.php.
References getBasicFolder().
00220 { 00221 $top = $this->getBasicFolder ($id); 00222 $descendants = $top->getDescendants ($search); 00223 $list = $id; 00224 foreach ($descendants as $descendant) $list .= ','.$descendant->id; 00225 return $list; 00226 }
| aliroFolderHandler::getSelectList | ( | $ | allowTop, | |
| $ | default, | |||
| $ | type, | |||
| $ | parm, | |||
| &$ | user | |||
| ) |
Definition at line 228 of file aliroFolder.php.
References getCategories(), and aliroHTML::getInstance().
00228 { 00229 $alirohtml = aliroHTML::getInstance(); 00230 if ($allowTop) $selector[] = $alirohtml->makeOption(0,_DOWN_NO_PARENT); 00231 foreach ($this->getCategories() as $category) $category->addSelectList('', $selector, null, $user); 00232 if (isset($selector)) return $alirohtml->selectList( $selector, $type, $parm, 'value', 'text', $default ); 00233 else return ''; 00234 }
| aliroFolderHandler::displayChildren | ( | &$ | folder | ) |
Definition at line 237 of file aliroFolder.php.
00237 { 00238 echo '<br />'.$folder->name.' has children:<br />'; 00239 foreach ($folder->children as $child) echo $child->name.' whose parent is '.$child->parent->name.'<br />'; 00240 foreach ($folder->children as $child) displayChildren ($child); 00241 }
| aliroFolderHandler::delete | ( | $ | deletelist | ) |
Definition at line 243 of file aliroFolder.php.
References cachedSingleton::clearCache(), and aliroDatabase::getInstance().
00243 { 00244 $database = aliroDatabase::getInstance(); 00245 $sql = "DELETE FROM #__folders WHERE id IN ($deletelist)"; 00246 $database->doSQL($sql); 00247 $this->clearCache(); 00248 self::$instance = __CLASS__; 00249 }
| aliroFolderHandler::changeOrder | ( | $ | id, | |
| $ | direction | |||
| ) |
Definition at line 251 of file aliroFolder.php.
References getFolder(), and updateOrdering().
00251 { 00252 $folder = $this->getFolder($id); 00253 $movement = 'down' == $direction ? 15 : -15; 00254 $this->updateOrdering (array($id => $folder->ordering + $movement), $folder->parentid); 00255 }
| aliroFolderHandler::updateOrdering | ( | $ | orders, | |
| $ | parentid | |||
| ) |
Definition at line 257 of file aliroFolder.php.
References cachedSingleton::clearCache(), getFolder(), and aliroDatabase::getInstance().
Referenced by changeOrder().
00257 { 00258 foreach ($orders as $id=>$order) { 00259 $folder = $this->getFolder($id); 00260 if ($folder->ordering != $order) $changes[$id] = $order; 00261 } 00262 $parent = $this->getFolder($parentid); 00263 foreach ($parent->getChildren(false) as $folder) { 00264 $ordering = isset($changes[$folder->id]) ? $changes[$folder->id] : $folder->ordering; 00265 $allfolders[$ordering] = $folder->id; 00266 } 00267 $changed = false; 00268 $query = "UPDATE #__folders SET ordering = CASE "; 00269 $order = 10; 00270 ksort($allfolders); 00271 foreach ($allfolders as $ordering=>$id) { 00272 $folder = $this->getFolder($id); 00273 if ($order != $folder->ordering) { 00274 $query .= "WHEN id = $id THEN $order "; 00275 $changed = true; 00276 } 00277 $order += 10; 00278 } 00279 if ($changed) { 00280 $query .= 'ELSE ordering END'; 00281 aliroDatabase::getInstance()->doSQL ($query); 00282 $this->clearCache(); 00283 } 00284 }
| aliroFolderHandler::ancestorsWithParent | ( | $ | parentid, | |
| $ | folderIDs | |||
| ) |
Definition at line 286 of file aliroFolder.php.
References getFolder().
00286 { 00287 $ancestors = array(); 00288 if (!is_array($folderIDs)) return $ancestors; 00289 foreach ($folderIDs as $folderID) if (isset($this->byancestor[$parentid][$folderID])) $results[$this->byancestor[$parentid][$folderID]] = 1; 00290 if (isset($results)) foreach (array_keys($results) as $id) $ancestors[] = $this->getFolder($id); 00291 return $ancestors; 00292 }
| aliroFolderHandler::setFolderPathway | ( | $ | folder, | |
| $ | baseurl | |||
| ) |
Definition at line 294 of file aliroFolder.php.
References aliroPathway::getInstance(), aliroSEF::getInstance(), and name.
00294 { 00295 if ($folder->parentid) $this->setFolderPathway ($folder->getParent(), $baseurl); 00296 $link = aliroSEF::getInstance()->sefRelToAbs($baseurl.$folder->id); 00297 aliroPathway::getInstance()->addItem ($folder->name, $link); 00298 }
aliroFolderHandler::$instance = __CLASS__ [static, protected] |
Definition at line 172 of file aliroFolder.php.
aliroFolderHandler::$rows = array() [private] |
Definition at line 173 of file aliroFolder.php.
aliroFolderHandler::$byancestor = array() [private] |
Definition at line 174 of file aliroFolder.php.
aliroFolderHandler::$anchor = '' [private] |
Definition at line 175 of file aliroFolder.php.
1.5.5