Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

t3lib_pageSelect Class Reference

List of all members.

Public Member Functions

 init ($show_hidden)
 init() MUST be run directly after creating a new template-object This sets the internal variable $this->where_hid_del to the correct where clause for page records taking deleted/hidden/starttime/endtime into account
 getPage ($uid)
 Returns the $row for the page with uid = $uid (observing ->where_hid_del) Any pages_language_overlay will be applied before the result is returned.
 getPage_noCheck ($uid)
 Return the $row for the page with uid = $uid WITHOUT checking for ->where_hid_del (start- and endtime or hidden).
 getFirstWebPage ($uid)
 Returns the $row of the first web-page in the tree (for the default menu...).
 getPageIdFromAlias ($alias)
 Returns a pagerow for the page with alias $alias.
 getPageOverlay ($pageInput, $lUid=-1)
 Returns the relevant page overlay record fields.
 getRecordOverlay ($table, $row, $sys_language_content, $OLmode='')
 Creates language-overlay for records in general (where translation is found in records from the same table).
 getMenu ($uid, $fields='*', $sortField='sorting', $addWhere='')
 Returns an array with pagerows for subpages with pid=$uid (which is pid here!).
 getDomainStartPage ($domain, $path='', $request_uri='')
 Will find the page carrying the domain record matching the input domain.

Public Attributes

 $urltypes = Array('','http://','ftp://','mailto:')
 $where_hid_del = ' AND pages.deleted=0'
 $sys_language_uid = 0
 $versioningPreview = FALSE
 $versionPreviewMap
 $error_getRootLine = ''
 $error_getRootLine_failPid = 0

Member Function Documentation

t3lib_pageSelect::getDomainStartPage domain,
path = '',
request_uri = ''
 

Will find the page carrying the domain record matching the input domain.

Might exit after sending a redirect-header IF a found domain record instructs to do so.

Parameters:
string Domain name to search for. Eg. "www.typo3.com". Typical the HTTP_HOST value.
string Path for the current script in domain. Eg. "/somedir/subdir". Typ. supplied by t3lib_div::getIndpEnv('SCRIPT_NAME')
string Request URI: Used to get parameters from if they should be appended. Typ. supplied by t3lib_div::getIndpEnv('REQUEST_URI')
Returns:
mixed If found, returns integer with page UID where found. Otherwise blank. Might exit if location-header is sent, see description.
See also:
tslib_fe::findDomainRecord()

Creates a "path" string for the input root line array titles. Used for writing statistics.

Parameters:
array A rootline array!
integer The max length of each title from the rootline.
Returns:
string The path in the form "/page title/This is another pageti.../Another page"
See also:
tslib_fe::getConfigArray()

Returns the URL type for the input page row IF the doktype is 3 and not disabled.

Parameters:
array The page row to return URL type for
boolean A flag to simply disable any output from here.
Returns:
string The URL type from $this->urltypes array. False if not found or disabled.
See also:
tslib_fe::checkJumpUrl()

Returns MountPoint id for page Does a recursive search if the mounted page should be a mount page itself. It has a run-away break so it can't go into infinite loops.

Parameters:
integer Page id for which to look for a mount pid. Will be returned only if mount pages are enabled, the correct doktype (7) is set for page and there IS a mount_pid (which has a valid record that is not deleted...)
array Optional page record for the page id. If not supplied it will be looked up by the system. Must contain at least uid,pid,doktype,mount_pid,mount_pid_ol
array Array accumulating formerly tested page ids for mount points. Used for recursivity brake.
integer The first page id.
Returns:
mixed Returns FALSE if no mount point was found, "-1" if there should have been one, but no connection to it, otherwise an array with information about mount pid and modes.
See also:
tslib_menu

Checks if a record exists and is accessible. The row is returned if everything's OK.

Parameters:
string The table name to search
integer The uid to look up in $table
boolean If checkPage is set, it's also required that the page on which the record resides is accessible
Returns:
mixed Returns array (the record) if OK, otherwise blank/0 (zero)

Returns record no matter what - except if record is deleted

Parameters:
string The table name to search
integer The uid to look up in $table
string The fields to select, default is "*"
Returns:
mixed Returns array (the record) if found, otherwise blank/0 (zero)
See also:
getPage_noCheck()

Selects records based on matching a field (ei. other than UID) with a value

Parameters:
string The table name to search, eg. "pages" or "tt_content"
string The fieldname to match, eg. "uid" or "alias"
string The value that fieldname must match, eg. "123" or "frontpage"
string Optional additional WHERE clauses put in the end of the query. DO NOT PUT IN GROUP BY, ORDER BY or LIMIT!
string Optional GROUP BY field(s), if none, supply blank string.
string Optional ORDER BY field(s), if none, supply blank string.
string Optional LIMIT value ([begin,]max), if none, supply blank string.
Returns:
mixed Returns array (the record) if found, otherwise blank/0 (zero)

Returns string value stored for the hash string in the table "cache_hash" Can be used to retrieved a cached value Can be used from your frontend plugins if you like. Is also used to store the parsed TypoScript template structures. You can call it directly like t3lib_pageSelect::getHash()

Parameters:
string The hash-string which was used to store the data value
integer Allowed expiretime in seconds. Basically a record is selected only if it is not older than this value in seconds. If expTime is not set, the hashed value will never expire.
Returns:
string The "content" field of the "cache_hash" table row.
See also:
tslib_TStemplate::start(), storeHash()

Stores a string value in the cache_hash table identified by $hash. Can be used from your frontend plugins if you like. You can call it directly like t3lib_pageSelect::storeHash()

Parameters:
string 32 bit hash string (eg. a md5 hash of a serialized array identifying the data being stored)
string The data string. If you want to store an array, then just serialize it first.
string $ident is just a textual identification in order to inform about the content! May be 20 characters long.
Returns:
void
See also:
tslib_TStemplate::start(), getHash()

Returns the "AND NOT deleted" clause for the tablename given IF $TCA configuration points to such a field.

Parameters:
string Tablename
Returns:
string
See also:
enableFields()

Returns a part of a WHERE clause which will filter out records with start/end times or hidden/fe_groups fields set to values that should de-select them according to the current time, preview settings or user login. Definitely a frontend function. Is using the $TCA arrays "ctrl" part where the key "enablefields" determines for each table which of these features applies to that table.

Parameters:
string Table name found in the $TCA array
integer If $show_hidden is set (0/1), any hidden-fields in records are ignored. NOTICE: If you call this function, consider what to do with the show_hidden parameter. Maybe it should be set? See tslib_cObj->enableFields where it's implemented correctly.
array Array you can pass where keys can be "disabled", "starttime", "endtime", "fe_group" (keys from "enablefields" in TCA) and if set they will make sure that part of the clause is not added. Thus disables the specific part of the clause. For previewing etc.
Returns:
string The clause starting like " AND ...=... AND ...=..."
See also:
tslib_cObj::enableFields(), deleteClause()

Find page-tree PID for versionized record Will look if the "pid" value of the input record is -1 and if the table supports versioning - if so, it will translate the -1 PID into the PID of the original record

Parameters:
string Table name
array Record array passed by reference. As minimum, "pid" and "uid" fields must exist! "t3ver_oid" is nice and will save you a DB query.
Returns:
void (Passed by ref).
See also:
t3lib_BEfunc::fixVersioningPid()

Versioning Preview Overlay ONLY active when backend user is previewing records. MUST NEVER affect a site served which is not previewed by backend users!!!

Parameters:
string Table name
array Record array passed by reference. As minimum, the "uid" field must exist!
Returns:
void (Passed by ref).

Definition at line 431 of file class.t3lib_page.php.

References table().

t3lib_pageSelect::getFirstWebPage uid  ) 
 

Returns the $row of the first web-page in the tree (for the default menu...).

Parameters:
integer The page id for which to fetch first subpages (PID)
Returns:
mixed If found: The page record (with overlayed localized fields, if any). If NOT found: blank value (not array!)
See also:
tslib_fe::fetch_the_id()

Definition at line 203 of file class.t3lib_page.php.

00203                                     {
00204       $output = '';
00205       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'pid='.intval($uid).$this->where_hid_del, '', 'sorting', '1');
00206       if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
00207 #??         $this->versionOL('pages',$row);
00208          $output = $this->getPageOverlay($row);
00209       }
00210       $GLOBALS['TYPO3_DB']->sql_free_result($res);
00211       return $output;
00212    }

t3lib_pageSelect::getMenu uid,
fields = '*',
sortField = 'sorting',
addWhere = ''
 

Returns an array with pagerows for subpages with pid=$uid (which is pid here!).

This is used for menus. If there are mount points in overlay mode the _MP_PARAM field is set to the corret MPvar. If the $uid being input does in itself require MPvars to define a correct rootline these must be handled externally to this function.

Parameters:
integer The page id for which to fetch subpages (PID)
string List of fields to select. Default is "*" = all
string The field to sort by. Default is "sorting"
string Optional additional where clauses. Like "AND title like '%blabla%'" for instance.
Returns:
array Array with key/value pairs; keys are page-uid numbers. values are the corresponding page records (with overlayed localized fields, if any)
See also:
tslib_fe::getPageShortcut(), tslib_menu::makeMenu(), tx_wizardcrpages_webfunc_2, tx_wizardsortpages_webfunc_2

Definition at line 396 of file class.t3lib_page.php.

00396                                                                         {
00397       $output = Array();
00398       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, 'pages', 'pid='.intval($uid).$this->where_hid_del.' '.$addWhere, '', $sortField);
00399       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
00400 #??         $this->versionOL('pages',$row);
00401 
00402             // Keep mount point:
00403          $origUid = $row['uid'];
00404          $mount_info = $this->getMountPointInfo($origUid, $row);  // $row MUST have "uid", "pid", "doktype", "mount_pid", "mount_pid_ol" fields in it
00405          if (is_array($mount_info) && $mount_info['overlay'])  {  // There is a valid mount point.
00406             $mp_row = $this->getPage($mount_info['mount_pid']);      // Using "getPage" is OK since we need the check for enableFields AND for type 2 of mount pids we DO require a doktype < 200!
00407             if (count($mp_row))  {
00408                $row = $mp_row;
00409                $row['_MP_PARAM'] = $mount_info['MPvar'];
00410             } else unset($row);  // If the mount point could not be fetched with respect to enableFields, unset the row so it does not become a part of the menu!
00411          }
00412 
00413             // Add to output array after overlaying language:
00414          if (is_array($row))  {
00415             $output[$origUid] = $this->getPageOverlay($row);
00416          }
00417       }
00418       return $output;
00419    }

t3lib_pageSelect::getPage uid  ) 
 

Returns the $row for the page with uid = $uid (observing ->where_hid_del) Any pages_language_overlay will be applied before the result is returned.

If no page is found an empty array is returned.

Parameters:
integer The page id to look up.
Returns:
array The page row with overlayed localized fields. Empty it no page.
See also:
getPage_noCheck()

Definition at line 171 of file class.t3lib_page.php.

00171                            {
00172       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid='.intval($uid).$this->where_hid_del);
00173       if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
00174 #??         $this->versionOL('pages',$row);
00175          return $this->getPageOverlay($row);
00176       }
00177       return Array();
00178    }

t3lib_pageSelect::getPage_noCheck uid  ) 
 

Return the $row for the page with uid = $uid WITHOUT checking for ->where_hid_del (start- and endtime or hidden).

Only "deleted" is checked!

Parameters:
integer The page id to look up
Returns:
array The page row with overlayed localized fields. Empty it no page.
See also:
getPage()

Definition at line 187 of file class.t3lib_page.php.

00187                                     {
00188       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid='.intval($uid).$this->deleteClause('pages'));
00189       if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
00190 #??         $this->versionOL('pages',$row);
00191          return $this->getPageOverlay($row);
00192       }
00193       return Array();
00194    }

t3lib_pageSelect::getPageIdFromAlias alias  ) 
 

Returns a pagerow for the page with alias $alias.

Parameters:
string The alias to look up the page uid for.
Returns:
integer Returns page uid (integer) if found, otherwise 0 (zero)
See also:
tslib_fe::checkAndSetAlias(), tslib_cObj::typoLink()

Definition at line 221 of file class.t3lib_page.php.

00221                                        {
00222       $alias = strtolower($alias);
00223       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'alias="'.$GLOBALS['TYPO3_DB']->quoteStr($alias, 'pages').'" AND pid>=0 AND pages.deleted=0');   // "AND pid>=0" is because of versioning...
00224       if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
00225          return $row['uid'];
00226       }
00227       return 0;
00228    }

t3lib_pageSelect::getPageOverlay pageInput,
lUid = -1
 

Returns the relevant page overlay record fields.

Parameters:
mixed If $pageInput is an integer, it's the pid of the pageOverlay record and thus the page overlay record is returned. If $pageInput is an array, it's a page-record and based on this page record the language record is found and OVERLAYED before the page record is returned.
integer Language UID if you want to set an alternative value to $this->sys_language_uid which is default. Should be >=0
Returns:
array Page row which is overlayed with language_overlay record (or the overlay record alone)

Definition at line 237 of file class.t3lib_page.php.

00237                                                 {
00238 
00239          // Initialize:
00240       if ($lUid<0)   $lUid = $this->sys_language_uid;
00241       unset($row);
00242 
00243          // If language UID is different from zero, do overlay:
00244       if ($lUid)  {
00245          $fieldArr = explode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']);
00246          if (is_array($pageInput))  {
00247             $page_id = $pageInput['uid']; // Was the whole record
00248             $fieldArr = array_intersect($fieldArr,array_keys($pageInput));    // Make sure that only fields which exist in the incoming record are overlaid!
00249          } else {
00250             $page_id = $pageInput;  // Was the id
00251          }
00252 
00253          if (count($fieldArr))   {
00254             /*
00255                NOTE to enabledFields('pages_language_overlay'):
00256                Currently the showHiddenRecords of TSFE set will allow pages_language_overlay records to be selected as they are child-records of a page.
00257                However you may argue that the showHiddenField flag should determine this. But that's not how it's done right now.
00258             */
00259 
00260                // Selecting overlay record:
00261             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00262                      implode(',',$fieldArr),
00263                      'pages_language_overlay',
00264                      'pid='.intval($page_id).'
00265                         AND sys_language_uid='.intval($lUid).
00266                         $this->enableFields('pages_language_overlay'),
00267                      '',
00268                      '',
00269                      '1'
00270                   );
00271             $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00272             if (is_array($row))  {
00273                $row['_PAGES_OVERLAY'] = TRUE;
00274                $this->versionOL('pages_language_overlay',$row);
00275 
00276                   // Unset vital fields that are NOT allowed to be overlaid:
00277                unset($row['uid']);
00278                unset($row['pid']);
00279             }
00280          }
00281       }
00282 
00283          // Create output:
00284       if (is_array($pageInput))  {
00285          return is_array($row) ? array_merge($pageInput,$row) : $pageInput;   // If the input was an array, simply overlay the newfound array and return...
00286       } else {
00287          return is_array($row) ? $row : array();   // always an array in return
00288       }
00289    }

t3lib_pageSelect::getRecordOverlay table,
row,
sys_language_content,
OLmode = ''
 

Creates language-overlay for records in general (where translation is found in records from the same table).

Parameters:
string Table name
array Record to overlay. Must containt uid, pid and $table]['ctrl']['languageField']
integer Pointer to the sys_language uid for content on the site.
string Overlay mode. If "hideNonTranslated" then records without translation will not be returned un-translated but unset (and return value is false)
Returns:
mixed Returns the input record, possibly overlaid with a translation. But if $OLmode is "hideNonTranslated" then it will return false if no translation is found.

Definition at line 300 of file class.t3lib_page.php.

References $TCA, and table().

00300                                                                            {
00301       global $TCA;
00302 
00303       if ($row['uid']>0 && $row['pid']>0) {
00304          if ($TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField']) {
00305             if (!$TCA[$table]['ctrl']['transOrigPointerTable'])   {  // Will not be able to work with other tables (Just didn't implement it yet; Requires a scan over all tables [ctrl] part for first FIND the table that carries localization information for this table (which could even be more than a single table) and then use that. Could be implemented, but obviously takes a little more....)
00306 
00307                   // Will try to overlay a record only if the sys_language_content value is larger that zero.
00308                if ($sys_language_content>0)  {
00309 
00310                      // Must be default language or [All], otherwise no overlaying:
00311                   if ($row[$TCA[$table]['ctrl']['languageField']]<=0)   {
00312 
00313                         // Select overlay record:
00314                      $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00315                               '*',
00316                               $table,
00317                               'pid='.intval($row['pid']).
00318                                  ' AND '.$TCA[$table]['ctrl']['languageField'].'='.intval($sys_language_content).
00319                                  ' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']).
00320                                  $this->enableFields($table),
00321                               '',
00322                               '',
00323                               '1'
00324                            );
00325                      $olrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00326                      $this->versionOL($table,$olrow);
00327    #debug($row);
00328    #debug($olrow);
00329                         // Merge record content by traversing all fields:
00330                      if (is_array($olrow))   {
00331                         foreach($row as $fN => $fV)   {
00332                            if ($fN!='uid' && $fN!='pid' && isset($olrow[$fN]))   {
00333 
00334                               if ($GLOBALS['TSFE']->TCAcachedExtras[$table]['l10n_mode'][$fN]!='exclude'
00335                                     && ($GLOBALS['TSFE']->TCAcachedExtras[$table]['l10n_mode'][$fN]!='mergeIfNotBlank' || strcmp(trim($olrow[$fN]),''))) {
00336                                  $row[$fN] = $olrow[$fN];
00337                               }
00338                            }
00339                         }
00340                      } elseif ($OLmode==='hideNonTranslated' && $row[$TCA[$table]['ctrl']['languageField']]==0)   {  // Unset, if non-translated records should be hidden. ONLY done if the source record really is default language and not [All] in which case it is allowed.
00341                         unset($row);
00342                      }
00343 
00344                      // Otherwise, check if sys_language_content is different from the value of the record - that means a japanese site might try to display french content.
00345                   } elseif ($sys_language_content!=$row[$TCA[$table]['ctrl']['languageField']]) {
00346                      unset($row);
00347                   }
00348                } else {
00349                      // When default language is displayed, we never want to return a record carrying another language!:
00350                   if ($row[$TCA[$table]['ctrl']['languageField']]>0) {
00351                      unset($row);
00352                   }
00353                }
00354             }
00355          }
00356       }
00357 
00358       return $row;
00359    }

t3lib_pageSelect::init show_hidden  ) 
 

init() MUST be run directly after creating a new template-object This sets the internal variable $this->where_hid_del to the correct where clause for page records taking deleted/hidden/starttime/endtime into account

Parameters:
boolean If $show_hidden is true, the hidden-field is ignored!! Normally this should be false. Is used for previewing.
Returns:
void
See also:
tslib_fe::fetch_the_id(), tx_tstemplateanalyzer::initialize_editor()

Definition at line 132 of file class.t3lib_page.php.

00132                                  {
00133       $this->where_hid_del = ' AND pages.deleted=0 ';
00134       if (!$show_hidden)   {
00135          $this->where_hid_del.= 'AND pages.hidden=0 ';
00136       }
00137       $this->where_hid_del.= 'AND (pages.starttime<='.$GLOBALS['SIM_EXEC_TIME'].') AND (pages.endtime=0 OR pages.endtime>'.$GLOBALS['SIM_EXEC_TIME'].') ';
00138    }


Member Data Documentation

t3lib_pageSelect::$error_getRootLine = ''
 

Definition at line 120 of file class.t3lib_page.php.

t3lib_pageSelect::$error_getRootLine_failPid = 0
 

Definition at line 121 of file class.t3lib_page.php.

t3lib_pageSelect::$sys_language_uid = 0
 

Definition at line 110 of file class.t3lib_page.php.

t3lib_pageSelect::$urltypes = Array('','http://','ftp://','mailto:')
 

Definition at line 108 of file class.t3lib_page.php.

t3lib_pageSelect::$versioningPreview = FALSE
 

Definition at line 113 of file class.t3lib_page.php.

t3lib_pageSelect::$versionPreviewMap
 

Initial value:

 array(
# EXAMPLE:     'tt_content:421' => 427
   )

Definition at line 114 of file class.t3lib_page.php.

t3lib_pageSelect::$where_hid_del = ' AND pages.deleted=0'
 

Definition at line 109 of file class.t3lib_page.php.


The documentation for this class was generated from the following file:
Generated on Sun Oct 3 01:07:03 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913