TYPO3 CMS  TYPO3_6-2
RootTemplateUpdate.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $title = 'Integrate TypoScript Root Template';
26 
34  public function checkForUpdate(&$description, &$showUpdate = 0) {
35  $pages = $this->findRootLevelPages();
36 
37  if ($pages !== NULL && $this->findRootTemplates(array_keys($pages)) !== NULL) {
38  $description = 'There is already at least one TypoScript root template available.';
39  $showUpdate = 0;
40  } else {
41  $description = 'There is no TypoScript root template! However, one is required for Extbase to behave correctly.';
42  $showUpdate = 1;
43  }
44 
45  return $showUpdate > 0;
46  }
47 
55  public function performUpdate(array &$dbQueries, &$customMessages) {
56  $now = time();
57  $result = FALSE;
58 
59  $status = $GLOBALS['TYPO3_DB']->exec_INSERTquery(
60  'pages',
61  array(
62  'pid' => 0,
63  'title' => 'Home',
64  'is_siteroot' => 1,
65  'crdate' => $now,
66  'tstamp' => $now,
67  )
68  );
69 
70  $dbQueries[] = str_replace(chr(10), ' ', $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery);
71 
72  if ($status) {
73  $pageId = $GLOBALS['TYPO3_DB']->sql_insert_id();
74 
75  $status = $GLOBALS['TYPO3_DB']->exec_INSERTquery(
76  'sys_template',
77  array(
78  'pid' => $pageId,
79  'title' => 'Default Root Template',
80  'root' => 1,
81  'clear' => 1,
82  'crdate' => $now,
83  'tstamp' => $now,
84  )
85  );
86 
87  $dbQueries[] = str_replace(chr(10), ' ', $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery);
88 
89  if ($status) {
90  $result = TRUE;
91  }
92  }
93 
94  return $result;
95  }
96 
102  protected function findRootLevelPages() {
103  $pages = NULL;
104 
105  $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
106  'uid,pid',
107  'pages',
108  'pid=0 AND deleted=0',
109  '',
110  '',
111  '',
112  'uid'
113  );
114 
115  if (is_array($rows) && !empty($rows)) {
116  $pages = $rows;
117  }
118 
119  return $pages;
120  }
121 
128  protected function findRootTemplates(array $pageUids) {
129  $templates = NULL;
130 
131  $pageUids = array_map('intval', $pageUids);
132  $pageUidList = implode(', ', $pageUids);
133 
134  $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
135  'uid,pid',
136  'sys_template',
137  'deleted=0 AND root=1 AND pid IN (' . $pageUidList . ')',
138  '',
139  '',
140  '',
141  'uid'
142  );
143 
144  if (is_array($rows)) {
145  $templates = $rows;
146  }
147 
148  return $templates;
149  }
150 }
performUpdate(array &$dbQueries, &$customMessages)
checkForUpdate(&$description, &$showUpdate=0)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]