[TASK] CGL Cleanup: Fix OpeningFunctionBraceKernighanRitchie-Sniff
[Packages/TYPO3.CMS.git] / typo3 / sysext / statictemplates / media / scripts / example_itemArrayProcFunc.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * This is an example of how to manipulate menu item arrays.
29 * Used in the "testsite" package
30 *
31 * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
32 * XHTML compliant
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36 /**
37 * This function basically adds the parent page to the sublevel but only if the sublevel is empty!
38 * It is also used to demonstrate the menu state items
39 *
40 * Example can be found in the testsite package at the page-path "/Intro/TypoScript examples/Menu object examples/Fake menu items/" and "/Intro/TypoScript examples/Menu object examples/Menu state test/"
41 * This TypoScript configuration will also demonstrate it ("fake menu items"):
42 *
43 * includeLibs.fakemenuitems = media/scripts/example_itemArrayProcFunc.php
44 * page = PAGE
45 * page.10 = HMENU
46 * page.10.1 = TMENU
47 * page.10.1.expAll = 1
48 * page.10.1.NO {
49 * allWrap = | <br />
50 * linkWrap = <b>|</b>
51 * }
52 * page.10.2 = TMENU
53 * page.10.2.itemArrayProcFunc = user_itemArrayProcFuncTest
54 * page.10.2.NO {
55 * allWrap = | <br />
56 * linkWrap = <b> - |</b>
57 * }
58 *
59 * @param array $menuArr The $menuArr array which simply is a num-array of page records which goes into the menu.
60 * @param array $conf TypoScript configuration for the function. Notice that the property "parentObj" is a reference to the parent (calling) object (the tslib_Xmenu class instantiated)
61 * @return array The modified $menuArr array
62 */
63 function user_itemArrayProcFuncTest($menuArr, $conf) {
64 // Used in the example of item states
65 if ($conf['demoItemStates']) {
66 $c = 0;
67 $teststates = explode(',', 'NO,ACT,IFSUB,CUR,USR,SPC,USERDEF1,USERDEF2');
68 foreach ($menuArr as $k => $v) {
69 $menuArr[$k]['ITEM_STATE'] = $teststates[$c];
70 $menuArr[$k]['title'] .= $teststates[$c] ? ' [' . $teststates[$c] . ']' : '';
71 $c++;
72 }
73 } else {
74 // There must be no menu items if we add the parent page to the submenu:
75 if (!count($menuArr)) {
76 // id of the parent page
77 $parentPageId = $conf['parentObj']->id;
78 // ... and get the record...
79 $parentPageRow = $GLOBALS['TSFE']->sys_page->getPage($parentPageId);
80 // ... and if that page existed (a row was returned) then add it!
81 if (is_array($parentPageRow)) {
82 $menuArr[] = $parentPageRow;
83 }
84 }
85 }
86 return $menuArr;
87 }
88 /**
89 * Used in the menu item state example of the "testsite" package at page-path "/Intro/TypoScript examples/Menu object examples/Menu state test/"
90 *
91 * @param array $I The menu item array, $this->I (in the parent object)
92 * @param array $conf TypoScript configuration for the function. Notice that the property "parentObj" is a reference to the parent (calling) object (the tslib_Xmenu class instantiated)
93 * @return array The processed $I array returned (and stored in $this->I of the parent object again)
94 * @see tslib_menu::userProcess(), tslib_tmenu::writeMenu(), tslib_gmenu::writeMenu()
95 */
96 function user_IProcFuncTest($I, $conf) {
97 $itemRow = $conf['parentObj']->menuArr[$I['key']];
98 // Setting the document status content to the value of the page title on mouse over
99 $I['linkHREF']['onMouseover'] .= 'extraRollover(\'' . rawurlencode($itemRow['title']) . '\');';
100 $conf['parentObj']->I = $I;
101 $conf['parentObj']->setATagParts();
102 $I = $conf['parentObj']->I;
103 if ($I['parts']['ATag_begin']) {
104 $I['parts']['ATag_begin'] = $I['A1'];
105 }
106 if ($conf['debug']) {
107 // Outputting for debug example:
108 echo 'ITEM: <h2>' . htmlspecialchars(($itemRow['uid'] . ': ' . $itemRow['title'])) . '</h2>';
109 t3lib_utility_Debug::debug($itemRow);
110 t3lib_utility_Debug::debug($I);
111 echo '<hr />';
112 }
113 // Returns:
114 return $I;
115 }
116 ?>