TYPO3 CMS  TYPO3_6-2
CategoryCollection.php
Go to the documentation of this file.
1 <?php
3 
24 
35  static public function create(array $collectionRecord, $fillItems = FALSE) {
38  'TYPO3\\CMS\\Frontend\\Category\\Collection\\CategoryCollection',
39  $collectionRecord['table_name'],
40  $collectionRecord['field_name']
41  );
42  $collection->fromArray($collectionRecord);
43  if ($fillItems) {
44  $collection->loadContents();
45  }
46  return $collection;
47  }
48 
63  static public function load($id, $fillItems = FALSE, $tableName = '', $fieldName = '') {
64  $collectionRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
65  '*',
66  static::$storageTableName,
67  'uid = ' . (int)$id . self::getFrontendObject()->sys_page->enableFields(static::$storageTableName)
68  );
69  $collectionRecord['table_name'] = $tableName;
70  $collectionRecord['field_name'] = $fieldName;
71  return self::create($collectionRecord, $fillItems);
72  }
73 
84  protected function getCollectedRecords() {
85  $relatedRecords = array();
86  // Assemble where clause
87  $where = 'AND ' . self::$storageTableName . '.uid = ' . (int)$this->getIdentifier();
88  // Add condition on tablenames fields
89  $where .= ' AND sys_category_record_mm.tablenames = ' . $this->getDatabaseConnection()->fullQuoteStr(
90  $this->getItemTableName(),
91  'sys_category_record_mm'
92  );
93  // Add condition on fieldname field
94  $where .= ' AND sys_category_record_mm.fieldname = ' . $this->getDatabaseConnection()->fullQuoteStr(
95  $this->getRelationFieldName(),
96  'sys_category_record_mm'
97  );
98  // Add enable fields for item table
99  $where .= self::getFrontendObject()->sys_page->enableFields($this->getItemTableName());
100  // If language handling is defined for item table, add language condition
101  if (isset($GLOBALS['TCA'][$this->getItemTableName()]['ctrl']['languageField'])) {
102  // Consider default or "all" language
103  $languageField = $this->getItemTableName() . '.' . $GLOBALS['TCA'][$this->getItemTableName()]['ctrl']['languageField'];
104  $languageCondition = $languageField . ' IN (0, -1)';
105  // If not in default language, also consider items in current language with no original
106  if ($this->getFrontendObject()->sys_language_content > 0) {
107  $languageCondition .= '
108  OR (' . $languageField . ' = ' . (int)$this->getFrontendObject()->sys_language_content . '
109  AND ' . $this->getItemTableName() . '.' .
110  $GLOBALS['TCA'][$this->getItemTableName()]['ctrl']['transOrigPointerField'] . ' = 0)
111  ';
112  }
113  $where .= ' AND (' . $languageCondition . ')';
114  }
115  // Get the related records from the database
116  $resource = $this->getDatabaseConnection()->exec_SELECT_mm_query(
117  $this->getItemTableName() . '.*',
118  self::$storageTableName,
119  'sys_category_record_mm',
120  $this->getItemTableName(),
121  $where
122  );
123 
124  if ($resource) {
125  while ($record = $this->getDatabaseConnection()->sql_fetch_assoc($resource)) {
126  // Overlay the record for workspaces
127  $this->getFrontendObject()->sys_page->versionOL(
128  $this->getItemTableName(),
129  $record
130  );
131  // Overlay the record for translations
132  if (is_array($record) && $this->getFrontendObject()->sys_language_contentOL) {
133  if ($this->getItemTableName() === 'pages') {
134  $record = $this->getFrontendObject()->sys_page->getPageOverlay($record);
135  } else {
136  $record = $this->getFrontendObject()->sys_page->getRecordOverlay(
137  $this->getItemTableName(),
138  $record,
139  $this->getFrontendObject()->sys_language_content,
140  $this->getFrontendObject()->sys_language_contentOL
141  );
142  }
143  }
144  // Record may have been unset during the overlay process
145  if (is_array($record)) {
146  $relatedRecords[] = $record;
147  }
148  }
149  $this->getDatabaseConnection()->sql_free_result($resource);
150  }
151  return $relatedRecords;
152  }
153 
159  static protected function getFrontendObject() {
160  return $GLOBALS['TSFE'];
161  }
162 }
static load($id, $fillItems=FALSE, $tableName='', $fieldName='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static create(array $collectionRecord, $fillItems=FALSE)