Exemplo n.º 1
0
 public static function getList($limiterType = null, $includeInternal = false)
 {
     $db = Loader::db();
     // the purpose for this class? Well, we get an array of collection type objects,
     // we don't do a join because on big sites it's actually slower
     $mcIDs = $db->GetAll("select p.cID, cv.ctID from Pages p inner join CollectionVersions cv on p.cID = cv.cID where cIsTemplate = 1");
     $masterCollectionIDs = array();
     foreach ($mcIDs as $mc) {
         $masterCollectionIDs[$mc['ctID']] = $mc['cID'];
     }
     if ($includeInternal) {
         $internal = '1=1';
     } else {
         $internal = 'ctIsInternal = 0';
     }
     $q = "select ctID, ctHandle, ctIcon, ctName, ctIsInternal, pkgID from PageTypes where {$internal} order by ctName asc";
     $r = $db->query($q);
     $ctArray = array();
     if ($r) {
         while ($row = $r->fetchRow()) {
             $ct = new CollectionType();
             $row['mcID'] = $masterCollectionIDs[$row['ctID']];
             $ct->setPropertiesFromArray($row);
             if (is_array($limiterType)) {
                 // an array of collection type handles that we should check against
                 if (in_array($row['ctHandle'], $limiterType)) {
                     $ctArray[] = $ct;
                 }
             } else {
                 if (is_object($limiterType)) {
                     $ct->limit($limiterType);
                     $ctArray[] = $ct;
                 } else {
                     $ctArray[] = $ct;
                 }
             }
         }
         $r->free();
     }
     return $ctArray;
 }