/**
  * Returns an array of UIDs which are not referenced on
  * the page with the given uid (= parent id).
  *
  * @param	array		$allReferencedElementsArr: Array with UIDs of referenced elements
  * @return	array		Array with UIDs of tt_content records
  * @access	protected
  */
 function getUnreferencedElementsRecords($allReferencedElementsArr)
 {
     global $TYPO3_DB, $BE_USER;
     $elementRecordsArr = array();
     $res = $TYPO3_DB->exec_SELECTquery('uid', 'tt_content', 'uid NOT IN (' . implode(',', $allReferencedElementsArr) . ')' . ' AND t3ver_wsid=' . intval($BE_USER->workspace) . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'), '', 'sorting');
     if ($res) {
         while (($elementRecordArr = $TYPO3_DB->sql_fetch_assoc($res)) !== FALSE) {
             $elementRecordsArr[] = $elementRecordArr['uid'];
         }
     }
     return $elementRecordsArr;
 }
 /**
  * Generates a list of pids of all sub pages for the given depth.
  *
  * @param	integer		the pid of the page
  * @param	integer		the depth for the search
  * @return	string		the list of pids
  * @author	of method	Michael Oehlhof <*****@*****.**>
  * @access public
  */
 function getRecursiveUidList($parentUid, $depth)
 {
     global $TCA;
     if ($depth != -1) {
         $depth = $depth - 1;
         //decreasing depth
     }
     # Get ressource records:
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'pid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($parentUid) . ') ' . t3lib_BEfunc::deleteClause('pages') . t3lib_BEfunc::versioningPlaceholderClause('pages'));
     if ($depth > 0) {
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $parentUid .= ',' . $this->getRecursiveUidList($row['uid'], $depth);
         }
     }
     return $parentUid;
 }
Exemplo n.º 3
0
 /**
  * Selects records from table / pid
  *
  * @param	string		Table to select from
  * @param	integer		Page ID to select from
  * @param	integer		Max number of records to select
  * @return	pointer		SQL resource pointer
  */
 function exec_listQueryPid($table, $pid, $limit)
 {
     global $TCA, $LANG;
     $orderBy = $TCA[$table]['ctrl']['sortby'] ? 'ORDER BY ' . $TCA[$table]['ctrl']['sortby'] : $TCA[$table]['ctrl']['default_sortby'];
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'pid=' . intval($pid) . t3lib_BEfunc::deleteClause($table) . t3lib_BEfunc::versioningPlaceholderClause($table), '', $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy), $limit);
     // Warning about hitting limit:
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) == $limit) {
         $this->content .= $this->doc->section($LANG->getLL('execlistqu_maxNumberLimit'), sprintf($LANG->getLL('makeconfig_anSqlQueryReturned', 1), $limit), 0, 1, 2);
     }
     return $res;
 }
Exemplo n.º 4
0
 /**
  * Checks various GET / POST parameters for submitted commands and handles them accordingly.
  * All commands will trigger a redirect by sending a location header after they work is done.
  *
  * Currently supported commands: 'createNewRecord', 'unlinkRecord', 'deleteRecord','pasteRecord',
  * 'makeLocalRecord', 'localizeElement', 'createNewPageTranslation' and 'editPageLanguageOverlay'
  *
  * @return	void
  * @access protected
  */
 function handleIncomingCommands()
 {
     $possibleCommands = array('createNewRecord', 'unlinkRecord', 'deleteRecord', 'pasteRecord', 'makeLocalRecord', 'localizeElement', 'createNewPageTranslation', 'editPageLanguageOverlay');
     $hooks = $this->hooks_prepareObjectsArray('handleIncomingCommands');
     foreach ($possibleCommands as $command) {
         if (($commandParameters = t3lib_div::_GP($command)) != '') {
             $redirectLocation = 'index.php?' . $this->link_getParameters();
             $skipCurrentCommand = false;
             foreach ($hooks as $hookObj) {
                 if (method_exists($hookObj, 'handleIncomingCommands_preProcess')) {
                     $skipCurrentCommand = $skipCurrentCommand || $hookObj->handleIncomingCommands_preProcess($command, $redirectLocation, $this);
                 }
             }
             if ($skipCurrentCommand) {
                 continue;
             }
             switch ($command) {
                 case 'createNewRecord':
                     // Historically "defVals" has been used for submitting the preset row data for the new element, so we still support it here:
                     $defVals = t3lib_div::_GP('defVals');
                     $newRow = is_array($defVals['tt_content']) ? $defVals['tt_content'] : array();
                     // Create new record and open it for editing
                     $destinationPointer = $this->apiObj->flexform_getPointerFromString($commandParameters);
                     $newUid = $this->apiObj->insertElement($destinationPointer, $newRow);
                     if ($this->editingOfNewElementIsEnabled($newRow['tx_templavoila_ds'], $newRow['tx_templavoila_to'])) {
                         // TODO If $newUid==0, than we could create new element. Need to handle it...
                         $redirectLocation = $GLOBALS['BACK_PATH'] . 'alt_doc.php?edit[tt_content][' . $newUid . ']=edit&returnUrl=' . rawurlencode(t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?' . $this->link_getParameters());
                     }
                     break;
                 case 'unlinkRecord':
                     $unlinkDestinationPointer = $this->apiObj->flexform_getPointerFromString($commandParameters);
                     $this->apiObj->unlinkElement($unlinkDestinationPointer);
                     break;
                 case 'deleteRecord':
                     $deleteDestinationPointer = $this->apiObj->flexform_getPointerFromString($commandParameters);
                     $this->apiObj->deleteElement($deleteDestinationPointer);
                     break;
                 case 'pasteRecord':
                     $sourcePointer = $this->apiObj->flexform_getPointerFromString(t3lib_div::_GP('source'));
                     $destinationPointer = $this->apiObj->flexform_getPointerFromString(t3lib_div::_GP('destination'));
                     switch ($commandParameters) {
                         case 'copy':
                             $this->apiObj->copyElement($sourcePointer, $destinationPointer);
                             break;
                         case 'copyref':
                             $this->apiObj->copyElement($sourcePointer, $destinationPointer, FALSE);
                             break;
                         case 'cut':
                             $this->apiObj->moveElement($sourcePointer, $destinationPointer);
                             break;
                         case 'ref':
                             list(, $uid) = explode(':', t3lib_div::_GP('source'));
                             $this->apiObj->referenceElementByUid($uid, $destinationPointer);
                             break;
                     }
                     break;
                 case 'makeLocalRecord':
                     $sourcePointer = $this->apiObj->flexform_getPointerFromString($commandParameters);
                     $this->apiObj->copyElement($sourcePointer, $sourcePointer);
                     $this->apiObj->unlinkElement($sourcePointer);
                     break;
                 case 'localizeElement':
                     $sourcePointer = $this->apiObj->flexform_getPointerFromString(t3lib_div::_GP('source'));
                     $this->apiObj->localizeElement($sourcePointer, $commandParameters);
                     break;
                 case 'createNewPageTranslation':
                     // Create parameters and finally run the classic page module for creating a new page translation
                     $params = '&edit[pages_language_overlay][' . intval(t3lib_div::_GP('pid')) . ']=new&overrideVals[pages_language_overlay][doktype]=' . intval(t3lib_div::_GP('doktype')) . '&overrideVals[pages_language_overlay][sys_language_uid]=' . intval($commandParameters);
                     $returnUrl = '&returnUrl=' . rawurlencode(t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?' . $this->link_getParameters());
                     $redirectLocation = $GLOBALS['BACK_PATH'] . 'alt_doc.php?' . $params . $returnUrl;
                     break;
                 case 'editPageLanguageOverlay':
                     // Look for pages language overlay record for language:
                     $sys_language_uid = intval($commandParameters);
                     $params = '';
                     if ($sys_language_uid != 0) {
                         // Edit overlay record
                         list($pLOrecord) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'pages_language_overlay', 'pid=' . intval($this->id) . ' AND sys_language_uid=' . $sys_language_uid . t3lib_BEfunc::deleteClause('pages_language_overlay') . t3lib_BEfunc::versioningPlaceholderClause('pages_language_overlay'));
                         if ($pLOrecord) {
                             t3lib_beFunc::workspaceOL('pages_language_overlay', $pLOrecord);
                             if (is_array($pLOrecord)) {
                                 $params = '&edit[pages_language_overlay][' . $pLOrecord['uid'] . ']=edit';
                             }
                         }
                     } else {
                         // Edit default language (page properties)
                         // No workspace overlay because we already on this page
                         $params = '&edit[pages][' . intval($this->id) . ']=edit';
                     }
                     if ($params) {
                         $returnUrl = '&returnUrl=' . rawurlencode(t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?' . $this->link_getParameters());
                         $redirectLocation = $GLOBALS['BACK_PATH'] . 'alt_doc.php?' . $params . $returnUrl;
                         //.'&localizationMode=text';
                     }
                     break;
             }
             foreach ($hooks as $hookObj) {
                 if (method_exists($hookObj, 'handleIncomingCommands_postProcess')) {
                     $hookObj->handleIncomingCommands_postProcess($command, $redirectLocation, $this);
                 }
             }
         }
     }
     if (isset($redirectLocation)) {
         header('Location: ' . t3lib_div::locationHeaderUrl($redirectLocation));
     }
 }
Exemplo n.º 5
0
    /**
     * Renders the display of Data Structure Objects.
     *
     * @return	void
     */
    function renderDSO()
    {
        global $TYPO3_DB;
        if (intval($this->displayUid) > 0) {
            $row = t3lib_BEfunc::getRecordWSOL('tx_templavoila_datastructure', $this->displayUid);
            if (is_array($row)) {
                // Get title and icon:
                $icon = t3lib_iconworks::getIconImage('tx_templavoila_datastructure', $row, $GLOBALS['BACK_PATH'], ' align="top" title="UID: ' . $this->displayUid . '"');
                $title = t3lib_BEfunc::getRecordTitle('tx_templavoila_datastructure', $row, 1);
                $content .= $this->doc->wrapClickMenuOnIcon($icon, 'tx_templavoila_datastructure', $row['uid'], 1) . '<strong>' . $title . '</strong><br />';
                // Get Data Structure:
                $origDataStruct = $dataStruct = $this->getDataStructFromDSO($row['dataprot']);
                if (is_array($dataStruct)) {
                    // Showing Data Structure:
                    $tRows = $this->drawDataStructureMap($dataStruct);
                    $content .= '

					<!--
						Data Structure content:
					-->
					<div id="c-ds">
						<h4>Data Structure in record:</h4>
						<table border="0" cellspacing="2" cellpadding="2">
									<tr class="bgColor5">
										<td nowrap="nowrap"><strong>Data Element:</strong>' . $this->cshItem('xMOD_tx_templavoila', 'mapping_head_dataElement', $this->doc->backPath, '', TRUE) . '</td>
										<td nowrap="nowrap"><strong>Mapping instructions:</strong>' . $this->cshItem('xMOD_tx_templavoila', 'mapping_head_mapping_instructions', $this->doc->backPath, '', TRUE) . '</td>
										<td nowrap="nowrap"><strong>Rules:</strong>' . $this->cshItem('xMOD_tx_templavoila', 'mapping_head_Rules', $this->doc->backPath, '', TRUE) . '</td>
									</tr>
						' . implode('', $tRows) . '
						</table>
					</div>';
                    // CSH
                    $content .= $this->cshItem('xMOD_tx_templavoila', 'mapping_ds', $this->doc->backPath);
                } else {
                    $content .= '<h4>' . $GLOBALS['LANG']->getLL('error') . ': ' . $GLOBALS['LANG']->getLL('noDSDefined') . '</h4>';
                }
                // Get Template Objects pointing to this Data Structure
                $res = $TYPO3_DB->exec_SELECTquery('*', 'tx_templavoila_tmplobj', 'pid IN (' . $this->storageFolders_pidList . ') AND datastructure=' . intval($row['uid']) . t3lib_BEfunc::deleteClause('tx_templavoila_tmplobj') . t3lib_BEfunc::versioningPlaceholderClause('tx_templavoila_tmplobj'));
                $tRows = array();
                $tRows[] = '
							<tr class="bgColor5">
								<td><strong>Uid:</strong></td>
								<td><strong>Title:</strong></td>
								<td><strong>File reference:</strong></td>
								<td><strong>Mapping Data Lgd:</strong></td>
							</tr>';
                $TOicon = t3lib_iconworks::getIconImage('tx_templavoila_tmplobj', array(), $GLOBALS['BACK_PATH'], ' align="top"');
                // Listing Template Objects with links:
                while (false !== ($TO_Row = $TYPO3_DB->sql_fetch_assoc($res))) {
                    t3lib_BEfunc::workspaceOL('tx_templavoila_tmplobj', $TO_Row);
                    $tRows[] = '
							<tr class="bgColor4">
								<td>[' . $TO_Row['uid'] . ']</td>
								<td nowrap="nowrap">' . $this->doc->wrapClickMenuOnIcon($TOicon, 'tx_templavoila_tmplobj', $TO_Row['uid'], 1) . '<a href="' . htmlspecialchars('index.php?table=tx_templavoila_tmplobj&uid=' . $TO_Row['uid'] . '&_reload_from=1') . '">' . t3lib_BEfunc::getRecordTitle('tx_templavoila_tmplobj', $TO_Row, 1) . '</a>' . '</td>
								<td nowrap="nowrap">' . htmlspecialchars($TO_Row['fileref']) . ' <strong>' . (!t3lib_div::getFileAbsFileName($TO_Row['fileref'], 1) ? '(NOT FOUND!)' : '(OK)') . '</strong></td>
								<td>' . strlen($TO_Row['templatemapping']) . '</td>
							</tr>';
                }
                $content .= '

					<!--
						Template Objects attached to Data Structure Record:
					-->
					<div id="c-to">
						<h4>Template Objects using this Data Structure:</h4>
						<table border="0" cellpadding="2" cellspacing="2">
						' . implode('', $tRows) . '
						</table>
					</div>';
                // CSH
                $content .= $this->cshItem('xMOD_tx_templavoila', 'mapping_ds_to', $this->doc->backPath);
                // Display XML of data structure:
                if (is_array($dataStruct)) {
                    require_once PATH_t3lib . 'class.t3lib_syntaxhl.php';
                    // Make instance of syntax highlight class:
                    $hlObj = t3lib_div::makeInstance('t3lib_syntaxhl');
                    $dataStructureXML = t3lib_div::array2xml_cs($origDataStruct, 'T3DataStructure', array('useCDATA' => 1));
                    $content .= '

					<!--
						Data Structure XML:
					-->
					<br />
					<div id="c-dsxml">
						<h3>Data Structure XML:</h3>
						' . $this->cshItem('xMOD_tx_templavoila', 'mapping_ds_showXML', $this->doc->backPath) . '
						<p>' . t3lib_BEfunc::getFuncCheck('', 'SET[showDSxml]', $this->MOD_SETTINGS['showDSxml'], '', t3lib_div::implodeArrayForUrl('', $_GET, '', 1, 1)) . ' Show XML</p>
						<pre>' . ($this->MOD_SETTINGS['showDSxml'] ? $hlObj->highLight_DS($dataStructureXML) : '') . '
						</pre>
					</div>
					';
                }
            } else {
                $content .= 'ERROR: No Data Structure Record with the UID ' . $this->displayUid;
            }
            $this->content .= $this->doc->section('Data Structure Object', $content, 0, 1);
        } else {
            $this->content .= $this->doc->section('Data Structure Object ERROR', 'No UID was found pointing to a Data Structure Object record.', 0, 1, 3);
        }
    }
 /**
  * Build the MySql where clause by table.
  *
  * @param string $tableName Record table name
  * @param array $fieldsToSearchWithin User right based visible fields where we can search within.
  * @return string
  */
 protected function makeQuerySearchByTable($tableName, array $fieldsToSearchWithin)
 {
     // free text search
     $queryLikeStatement = ' LIKE \'%' . $this->getQueryString($tableName) . '%\'';
     $integerFieldsToSearchWithin = array();
     $queryEqualStatement = '';
     if (is_numeric($this->getQueryString($tableName))) {
         $queryEqualStatement = ' = \'' . $this->getQueryString($tableName) . '\'';
     }
     $uidPos = array_search('uid', $fieldsToSearchWithin);
     if ($uidPos) {
         $integerFieldsToSearchWithin[] = 'uid';
         unset($fieldsToSearchWithin[$uidPos]);
     }
     $pidPos = array_search('pid', $fieldsToSearchWithin);
     if ($pidPos) {
         $integerFieldsToSearchWithin[] = 'pid';
         unset($fieldsToSearchWithin[$pidPos]);
     }
     $queryPart = ' AND (';
     if (count($integerFieldsToSearchWithin) && $queryEqualStatement !== '') {
         $queryPart .= implode($queryEqualStatement . ' OR ', $integerFieldsToSearchWithin) . $queryEqualStatement . ' OR ';
     }
     $queryPart .= implode($queryLikeStatement . ' OR ', $fieldsToSearchWithin) . $queryLikeStatement . ')';
     $queryPart .= t3lib_BEfunc::deleteClause($tableName);
     $queryPart .= t3lib_BEfunc::versioningPlaceholderClause($tableName);
     return $queryPart;
 }
 /**
  * gets the icon for the shortcut
  *
  * @param	string		backend module name
  * @return	string		shortcut icon as img tag
  */
 protected function getShortcutIcon($row, $shortcut)
 {
     global $TCA;
     switch ($row['module_name']) {
         case 'xMOD_alt_doc.php':
             $table = $shortcut['table'];
             $recordid = $shortcut['recordid'];
             if ($shortcut['type'] == 'edit') {
                 // Creating the list of fields to include in the SQL query:
                 $selectFields = $this->fieldArray;
                 $selectFields[] = 'uid';
                 $selectFields[] = 'pid';
                 if ($table == 'pages') {
                     if (t3lib_extMgm::isLoaded('cms')) {
                         $selectFields[] = 'module';
                         $selectFields[] = 'extendToSubpages';
                     }
                     $selectFields[] = 'doktype';
                 }
                 if (is_array($TCA[$table]['ctrl']['enablecolumns'])) {
                     $selectFields = array_merge($selectFields, $TCA[$table]['ctrl']['enablecolumns']);
                 }
                 if ($TCA[$table]['ctrl']['type']) {
                     $selectFields[] = $TCA[$table]['ctrl']['type'];
                 }
                 if ($TCA[$table]['ctrl']['typeicon_column']) {
                     $selectFields[] = $TCA[$table]['ctrl']['typeicon_column'];
                 }
                 if ($TCA[$table]['ctrl']['versioningWS']) {
                     $selectFields[] = 't3ver_state';
                 }
                 $selectFields = array_unique($selectFields);
                 // Unique list!
                 $permissionClause = $table == 'pages' && $this->perms_clause ? ' AND ' . $this->perms_clause : '';
                 $sqlQueryParts = array('SELECT' => implode(',', $selectFields), 'FROM' => $table, 'WHERE' => 'uid IN (' . $recordid . ') ' . $permissionClause . t3lib_BEfunc::deleteClause($table) . t3lib_BEfunc::versioningPlaceholderClause($table));
                 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($sqlQueryParts);
                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
                 $icon = t3lib_iconWorks::getIcon($table, $row, $this->backPath);
             } elseif ($shortcut['type'] == 'new') {
                 $icon = t3lib_iconWorks::getIcon($table, '', $this->backPath);
             }
             $icon = t3lib_iconWorks::skinImg($this->backPath, $icon, '', 1);
             break;
         case 'xMOD_file_edit.php':
             $icon = 'gfx/edit_file.gif';
             break;
         case 'xMOD_wizard_rte.php':
             $icon = 'gfx/edit_rtewiz.gif';
             break;
         default:
             if ($GLOBALS['LANG']->moduleLabels['tabs_images'][$row['module_name'] . '_tab']) {
                 $icon = $GLOBALS['LANG']->moduleLabels['tabs_images'][$row['module_name'] . '_tab'];
                 // change icon of fileadmin references - otherwise it doesn't differ with Web->List
                 $icon = str_replace('mod/file/list/list.gif', 'mod/file/file.gif', $icon);
                 if (t3lib_div::isAbsPath($icon)) {
                     $icon = '../' . substr($icon, strlen(PATH_site));
                 }
             } else {
                 $icon = 'gfx/dummy_module.gif';
             }
     }
     return '<img src="' . $icon . '" alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:toolbarItems.shortcut', true) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:toolbarItems.shortcut', true) . '" />';
 }
Exemplo n.º 8
0
 /**
  * Function, which populates the internal editconf array with editing commands for all tt_content elements from the normal column in normal language from the page pointed to by $this->editRegularContentFromId
  *
  * @return	void
  */
 function editRegularContentFromId()
 {
     if (t3lib_extMgm::isLoaded('cms')) {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tt_content', 'pid=' . intval($this->editRegularContentFromId) . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content') . ' AND colPos=0 AND sys_language_uid=0', '', 'sorting');
         if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
             $ecUids = array();
             while ($ecRec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 $ecUids[] = $ecRec['uid'];
             }
             $this->editconf['tt_content'][implode(',', $ecUids)] = 'edit';
         }
     }
 }
 /**
  * Selecting single record from a table filtering whether it is a default language / international element.
  *
  * @param   string   $table Table name
  * @param   integer  $uid   Record uid
  * @return  array    Record array if found, otherwise FALSE
  */
 function getSingleRecordToTranslate($table, $uid)
 {
     global $TCA;
     if ($this->t8Tools->isTranslationInOwnTable($table)) {
         // First, select all records that are default language OR international:
         $allRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $table, 'uid=' . intval($uid) . ' AND ' . $TCA[$table]['ctrl']['languageField'] . '<=0' . t3lib_BEfunc::deleteClause($table) . t3lib_BEfunc::versioningPlaceholderClause($table));
         return is_array($allRows) && count($allRows) ? $allRows[0] : FALSE;
     }
 }
 /**
  * For RTE: This displays all content elements on a page and lets you create a link to the element.
  *
  * @return	string		HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
  */
 function expandPage()
 {
     $out = '';
     $expPageId = $this->browseLinks->expandPage;
     // Set page id (if any) to expand
     // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
     if (!$this->browseLinks->expandPage && $this->browseLinks->curUrlInfo['cElement']) {
         $expPageId = $this->browseLinks->curUrlInfo['pageid'];
         // Set to the current link page id.
     }
     // Draw the record list IF there is a page id to expand:
     if ($expPageId && t3lib_utility_Math::canBeInterpretedAsInteger($expPageId) && $GLOBALS['BE_USER']->isInWebMount($expPageId)) {
         // Set header:
         $out .= $this->browseLinks->barheader($GLOBALS['LANG']->getLL('contentElements') . ':');
         // Create header for listing, showing the page title/icon:
         $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
         $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages', $expPageId);
         $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
         $picon .= t3lib_BEfunc::getRecordTitle('pages', $mainPageRec, TRUE);
         $out .= $picon . '<br />';
         // Look up tt_content elements from the expanded page:
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext,tx_jfmulticontent_view,tx_jfmulticontent_pages,tx_jfmulticontent_contents', 'tt_content', 'pid=' . intval($expPageId) . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'), '', 'colPos,sorting');
         $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
         // Traverse list of records:
         $c = 0;
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $c++;
             $icon = t3lib_iconWorks::getSpriteIconForRecord('tt_content', $row);
             if ($this->browseLinks->curUrlInfo['act'] == 'page' && $this->browseLinks->curUrlInfo['cElement'] == $row['uid']) {
                 $arrCol = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
             } else {
                 $arrCol = '';
             }
             // Putting list element HTML together:
             $out .= '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/join' . ($c == $cc ? 'bottom' : '') . '.gif', 'width="18" height="16"') . ' alt="" />' . $arrCol . '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#' . $row['uid'] . '\');">' . $icon . t3lib_BEfunc::getRecordTitle('tt_content', $row, TRUE) . '</a><br />';
             $contents = array();
             // get all contents
             switch ($row['tx_jfmulticontent_view']) {
                 case "page":
                     $contents = t3lib_div::trimExplode(",", $row['tx_jfmulticontent_pages']);
                     break;
                 case "content":
                     $contents = t3lib_div::trimExplode(",", $row['tx_jfmulticontent_contents']);
                     break;
                 case "irre":
                     $resIrre = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'tx_jfmulticontent_irre_parentid=' . intval($row['uid']) . ' AND deleted = 0 AND hidden = 0', '', '');
                     while ($rowIrre = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resIrre)) {
                         $contents[] = $rowIrre['uid'];
                     }
                     break;
             }
             if (count($contents) > 0) {
                 $out .= '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />' . '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/blank.gif', 'width="18" height="16"') . ' alt="" />';
                 foreach ($contents as $key => $content) {
                     $out .= '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#jfmulticontent_c' . $row['uid'] . '-' . ($key + 1) . '\');">' . '&nbsp;' . ($key + 1) . '&nbsp;' . '</a>';
                 }
                 $out .= '<br/>';
             }
         }
     }
     return $out;
 }
 /**
  * Handler for Flex Forms
  *
  * @param	string		The table name of the record
  * @param	string		The field name which this element is supposed to edit
  * @param	array		The record data array where the value(s) for the field can be found
  * @param	array		An array with additional configuration options.
  * @return	string		The HTML code for the TCEform field
  */
 function getSingleField_typeFlex($table, $field, $row, &$PA)
 {
     // Data Structure:
     $dataStructArray = t3lib_BEfunc::getFlexFormDS($PA['fieldConf']['config'], $row, $table);
     // Manipulate Flexform DS via TSConfig and group access lists
     if (is_array($dataStructArray)) {
         $flexFormHelper = t3lib_div::makeInstance('t3lib_TCEforms_Flexforms');
         $dataStructArray = $flexFormHelper->modifyFlexFormDS($dataStructArray, $table, $field, $row, $PA['fieldConf']['config']);
         unset($flexFormHelper);
     }
     // Get data structure:
     if (is_array($dataStructArray)) {
         // Get data:
         $xmlData = $PA['itemFormElValue'];
         $xmlHeaderAttributes = t3lib_div::xmlGetHeaderAttribs($xmlData);
         $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
         if ($storeInCharset) {
             $currentCharset = $GLOBALS['LANG']->charSet;
             $xmlData = $GLOBALS['LANG']->csConvObj->conv($xmlData, $storeInCharset, $currentCharset, 1);
         }
         $editData = t3lib_div::xml2array($xmlData);
         if (!is_array($editData)) {
             // Must be XML parsing error...
             $editData = array();
         } elseif (!isset($editData['meta']) || !is_array($editData['meta'])) {
             $editData['meta'] = array();
         }
         // Find the data structure if sheets are found:
         $sheet = $editData['meta']['currentSheetId'] ? $editData['meta']['currentSheetId'] : 'sDEF';
         // Sheet to display
         // Create sheet menu:
         //TODO; Why is this commented out?
         //			if (is_array($dataStructArray['sheets']))	{
         //				#$item.=$this->getSingleField_typeFlex_sheetMenu($dataStructArray['sheets'], $PA['itemFormElName'].'[meta][currentSheetId]', $sheet).'<br />';
         //			}
         // Create language menu:
         $langChildren = $dataStructArray['meta']['langChildren'] ? 1 : 0;
         $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0;
         $editData['meta']['currentLangId'] = array();
         // Look up page overlays:
         $checkPageLanguageOverlay = $GLOBALS['BE_USER']->getTSConfigVal('options.checkPageLanguageOverlay') ? TRUE : FALSE;
         if ($checkPageLanguageOverlay) {
             $pageOverlays = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'pages_language_overlay', 'pid=' . intval($row['pid']) . t3lib_BEfunc::deleteClause('pages_language_overlay') . t3lib_BEfunc::versioningPlaceholderClause('pages_language_overlay'), '', '', '', 'sys_language_uid');
         }
         $languages = $this->getAvailableLanguages();
         foreach ($languages as $lInfo) {
             if ($GLOBALS['BE_USER']->checkLanguageAccess($lInfo['uid']) && (!$checkPageLanguageOverlay || $lInfo['uid'] <= 0 || is_array($pageOverlays[$lInfo['uid']]))) {
                 $editData['meta']['currentLangId'][] = $lInfo['ISOcode'];
             }
         }
         if (!is_array($editData['meta']['currentLangId']) || !count($editData['meta']['currentLangId'])) {
             $editData['meta']['currentLangId'] = array('DEF');
         }
         $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
         //TODO: Why is this commented out?
         //			if (!$langDisabled && count($languages) > 1)	{
         //				$item.=$this->getSingleField_typeFlex_langMenu($languages, $PA['itemFormElName'].'[meta][currentLangId]', $editData['meta']['currentLangId']).'<br />';
         //			}
         $PA['_noEditDEF'] = FALSE;
         if ($langChildren || $langDisabled) {
             $rotateLang = array('DEF');
         } else {
             if (!in_array('DEF', $editData['meta']['currentLangId'])) {
                 array_unshift($editData['meta']['currentLangId'], 'DEF');
                 $PA['_noEditDEF'] = TRUE;
             }
             $rotateLang = $editData['meta']['currentLangId'];
         }
         // Tabs sheets
         if (is_array($dataStructArray['sheets'])) {
             $tabsToTraverse = array_keys($dataStructArray['sheets']);
         } else {
             $tabsToTraverse = array($sheet);
         }
         foreach ($rotateLang as $lKey) {
             if (!$langChildren && !$langDisabled) {
                 $item .= '<strong>' . $this->getLanguageIcon($table, $row, 'v' . $lKey) . $lKey . ':</strong>';
             }
             $tabParts = array();
             foreach ($tabsToTraverse as $sheet) {
                 list($dataStruct, $sheet) = t3lib_div::resolveSheetDefInDS($dataStructArray, $sheet);
                 // Render sheet:
                 if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el'])) {
                     $lang = 'l' . $lKey;
                     // Default language, other options are "lUK" or whatever country code (independant of system!!!)
                     $PA['_valLang'] = $langChildren && !$langDisabled ? $editData['meta']['currentLangId'] : 'DEF';
                     // Default language, other options are "lUK" or whatever country code (independant of system!!!)
                     $PA['_lang'] = $lang;
                     // Assemble key for loading the correct CSH file
                     $dsPointerFields = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$field]['config']['ds_pointerField'], TRUE);
                     $PA['_cshKey'] = $table . '.' . $field;
                     foreach ($dsPointerFields as $key) {
                         $PA['_cshKey'] .= '.' . $row[$key];
                     }
                     // Push the sheet level tab to DynNestedStack
                     if (is_array($dataStructArray['sheets'])) {
                         $tabIdentString = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId('TCEFORMS:flexform:' . $PA['itemFormElName'] . $PA['_lang']);
                         $this->pushToDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) + 1));
                     }
                     // Render flexform:
                     $tRows = $this->getSingleField_typeFlex_draw($dataStruct['ROOT']['el'], $editData['data'][$sheet][$lang], $table, $field, $row, $PA, '[data][' . $sheet . '][' . $lang . ']');
                     $sheetContent = '<div class="typo3-TCEforms-flexForm">' . $tRows . '</div>';
                     // Pop the sheet level tab from DynNestedStack
                     if (is_array($dataStructArray['sheets'])) {
                         $this->popFromDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) + 1));
                     }
                 } else {
                     $sheetContent = 'Data Structure ERROR: No ROOT element found for sheet "' . $sheet . '".';
                 }
                 // Add to tab:
                 $tabParts[] = array('label' => $dataStruct['ROOT']['TCEforms']['sheetTitle'] ? $this->sL($dataStruct['ROOT']['TCEforms']['sheetTitle']) : $sheet, 'description' => $dataStruct['ROOT']['TCEforms']['sheetDescription'] ? $this->sL($dataStruct['ROOT']['TCEforms']['sheetDescription']) : '', 'linkTitle' => $dataStruct['ROOT']['TCEforms']['sheetShortDescr'] ? $this->sL($dataStruct['ROOT']['TCEforms']['sheetShortDescr']) : '', 'content' => $sheetContent);
             }
             if (is_array($dataStructArray['sheets'])) {
                 $dividersToTabsBehaviour = isset($GLOBALS['TCA'][$table]['ctrl']['dividers2tabs']) ? $GLOBALS['TCA'][$table]['ctrl']['dividers2tabs'] : 1;
                 $item .= $this->getDynTabMenu($tabParts, 'TCEFORMS:flexform:' . $PA['itemFormElName'] . $PA['_lang'], $dividersToTabsBehaviour);
             } else {
                 $item .= $sheetContent;
             }
         }
     } else {
         $item = 'Data Structure ERROR: ' . $dataStructArray;
     }
     return $item;
 }
Exemplo n.º 12
0
 /**
  * Returns the array of elements in the wizard display.
  * For the plugin section there is support for adding elements there from a global variable.
  *
  * @return	array
  */
 function wizardArray()
 {
     global $LANG, $TBE_MODULES_EXT, $TYPO3_DB;
     $defVals = t3lib_div::implodeArrayForUrl('defVals', is_array($this->defVals) ? $this->defVals : array());
     $wizardItems = array('common' => array('header' => $LANG->getLL('common')), 'common_1' => array('icon' => 'gfx/c_wiz/regular_text.gif', 'title' => $LANG->getLL('common_1_title'), 'description' => $LANG->getLL('common_1_description'), 'params' => '&defVals[tt_content][CType]=text' . $defVals), 'common_2' => array('icon' => 'gfx/c_wiz/text_image_below.gif', 'title' => $LANG->getLL('common_2_title'), 'description' => $LANG->getLL('common_2_description'), 'params' => '&defVals[tt_content][CType]=textpic&defVals[tt_content][imageorient]=8' . $defVals), 'common_3' => array('icon' => 'gfx/c_wiz/text_image_right.gif', 'title' => $LANG->getLL('common_3_title'), 'description' => $LANG->getLL('common_3_description'), 'params' => '&defVals[tt_content][CType]=textpic&defVals[tt_content][imageorient]=17' . $defVals), 'common_4' => array('icon' => 'gfx/c_wiz/images_only.gif', 'title' => $LANG->getLL('common_4_title'), 'description' => $LANG->getLL('common_4_description'), 'params' => '&defVals[tt_content][CType]=image&defVals[tt_content][imagecols]=2' . $defVals), 'common_5' => array('icon' => 'gfx/c_wiz/bullet_list.gif', 'title' => $LANG->getLL('common_5_title'), 'description' => $LANG->getLL('common_5_description'), 'params' => '&defVals[tt_content][CType]=bullets' . $defVals), 'common_6' => array('icon' => 'gfx/c_wiz/table.gif', 'title' => $LANG->getLL('common_6_title'), 'description' => $LANG->getLL('common_6_description'), 'params' => '&defVals[tt_content][CType]=table' . $defVals), 'special' => array('header' => $LANG->getLL('special')), 'special_1' => array('icon' => 'gfx/c_wiz/filelinks.gif', 'title' => $LANG->getLL('special_1_title'), 'description' => $LANG->getLL('special_1_description'), 'params' => '&defVals[tt_content][CType]=uploads' . $defVals), 'special_2' => array('icon' => 'gfx/c_wiz/multimedia.gif', 'title' => $LANG->getLL('special_2_title'), 'description' => $LANG->getLL('special_2_description'), 'params' => '&defVals[tt_content][CType]=multimedia' . $defVals), 'special_3' => array('icon' => 'gfx/c_wiz/sitemap2.gif', 'title' => $LANG->getLL('special_3_title'), 'description' => $LANG->getLL('special_3_description'), 'params' => '&defVals[tt_content][CType]=menu&defVals[tt_content][menu_type]=2' . $defVals), 'special_4' => array('icon' => 'gfx/c_wiz/html.gif', 'title' => $LANG->getLL('special_4_title'), 'description' => $LANG->getLL('special_4_description'), 'params' => '&defVals[tt_content][CType]=html' . $defVals), 'forms' => array('header' => $LANG->getLL('forms')), 'forms_1' => array('icon' => 'gfx/c_wiz/mailform.gif', 'title' => $LANG->getLL('forms_1_title'), 'description' => $LANG->getLL('forms_1_description'), 'params' => '&defVals[tt_content][CType]=mailform&defVals[tt_content][bodytext]=' . rawurlencode(trim($LANG->getLL('forms_1_example'))) . $defVals), 'forms_2' => array('icon' => 'gfx/c_wiz/searchform.gif', 'title' => $LANG->getLL('forms_2_title'), 'description' => $LANG->getLL('forms_2_description'), 'params' => '&defVals[tt_content][CType]=search' . $defVals), 'forms_3' => array('icon' => 'gfx/c_wiz/login_form.gif', 'title' => $LANG->getLL('forms_3_title'), 'description' => $LANG->getLL('forms_3_description'), 'params' => '&defVals[tt_content][CType]=login' . $defVals));
     // Flexible content elements:
     $positionPid = $this->id;
     $dataStructureRecords = array();
     $storageFolderPID = $this->apiObj->getStorageFolderPid($positionPid);
     // Fetch data structures stored in the database:
     $addWhere = $this->buildRecordWhere('tx_templavoila_datastructure');
     $res = $TYPO3_DB->exec_SELECTquery('*', 'tx_templavoila_datastructure', 'pid=' . intval($storageFolderPID) . ' AND scope=2' . $addWhere . t3lib_BEfunc::deleteClause('tx_templavoila_datastructure') . t3lib_BEfunc::versioningPlaceholderClause('tx_templavoila_datastructure'));
     while (FALSE !== ($row = $TYPO3_DB->sql_fetch_assoc($res))) {
         $dataStructureRecords[$row['uid']] = $row;
     }
     /*
             	// Fetch static data structures which are stored in XML files:
     		if (is_array($GLOBALS['TBE_MODULES_EXT']['xMOD_tx_templavoila_cm1']['staticDataStructures']))	{
     			foreach($GLOBALS['TBE_MODULES_EXT']['xMOD_tx_templavoila_cm1']['staticDataStructures'] as $staticDataStructureArr)	{
     				$staticDataStructureArr['_STATIC'] = TRUE;
     				$dataStructureRecords[$staticDataStructureArr['path']] = $staticDataStructureArr;
     			}
     		}
     */
     // Fetch all template object records which uare based one of the previously fetched data structures:
     $templateObjectRecords = array();
     $addWhere = $this->buildRecordWhere('tx_templavoila_tmplobj');
     $res = $TYPO3_DB->exec_SELECTquery('*', 'tx_templavoila_tmplobj', 'pid=' . intval($storageFolderPID) . ' AND parent=0' . $addWhere . t3lib_BEfunc::deleteClause('tx_templavoila_tmplobj') . t3lib_BEfunc::versioningPlaceholderClause('tx_templavoila_tmpl'), '', 'sorting');
     while (FALSE !== ($row = $TYPO3_DB->sql_fetch_assoc($res))) {
         if (is_array($dataStructureRecords[$row['datastructure']])) {
             $templateObjectRecords[] = $row;
         }
     }
     // Add the filtered set of TO entries to the wizard list:
     $wizardItems['fce']['header'] = $LANG->getLL('fce');
     foreach ($templateObjectRecords as $index => $templateObjectRecord) {
         $tmpFilename = 'uploads/tx_templavoila/' . $templateObjectRecord['previewicon'];
         $wizardItems['fce_' . $index]['icon'] = @is_file(PATH_site . $tmpFilename) ? '../' . $tmpFilename : '../' . t3lib_extMgm::siteRelPath('templavoila') . 'res1/default_previewicon.gif';
         $wizardItems['fce_' . $index]['description'] = $templateObjectRecord['description'] ? htmlspecialchars($templateObjectRecord['description']) : $LANG->getLL('template_nodescriptionavailable');
         $wizardItems['fce_' . $index]['title'] = $templateObjectRecord['title'];
         $wizardItems['fce_' . $index]['params'] = '&defVals[tt_content][CType]=templavoila_pi1&defVals[tt_content][tx_templavoila_ds]=' . $templateObjectRecord['datastructure'] . '&defVals[tt_content][tx_templavoila_to]=' . $templateObjectRecord['uid'] . $defVals;
         $index++;
     }
     // PLUG-INS:
     if (is_array($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses'])) {
         $wizardItems['plugins'] = array('header' => $LANG->getLL('plugins'));
         reset($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses']);
         while (list($class, $path) = each($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses'])) {
             $modObj = t3lib_div::makeInstance($class);
             $wizardItems = $modObj->proc($wizardItems);
         }
     }
     // Remove elements where preset values are not allowed:
     $this->removeInvalidElements($wizardItems);
     return $wizardItems;
 }
Exemplo n.º 13
0
 function getConfigurationsForBranch($rootid, $depth)
 {
     $configurationsForBranch = array();
     $pageTSconfig = $this->getPageTSconfigForId($rootid);
     if (is_array($pageTSconfig) && is_array($pageTSconfig['tx_crawler.']['crawlerCfg.']) && is_array($pageTSconfig['tx_crawler.']['crawlerCfg.']['paramSets.'])) {
         $sets = $pageTSconfig['tx_crawler.']['crawlerCfg.']['paramSets.'];
         if (is_array($sets)) {
             foreach ($sets as $key => $value) {
                 if (!is_array($value)) {
                     continue;
                 }
                 $configurationsForBranch[] = substr($key, -1) == '.' ? substr($key, 0, -1) : $key;
             }
         }
     }
     $pids = array();
     $rootLine = t3lib_BEfunc::BEgetRootLine($rootid);
     foreach ($rootLine as $node) {
         $pids[] = $node['uid'];
     }
     /* @var t3lib_pageTree */
     $tree = t3lib_div::makeInstance('t3lib_pageTree');
     $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
     $tree->init('AND ' . $perms_clause);
     $tree->getTree($rootid, $depth, '');
     foreach ($tree->tree as $node) {
         $pids[] = $node['row']['uid'];
     }
     $res = $this->db->exec_SELECTquery('*', 'tx_crawler_configuration', 'pid IN (' . implode(',', $pids) . ') ' . t3lib_BEfunc::BEenableFields('tx_crawler_configuration') . t3lib_BEfunc::deleteClause('tx_crawler_configuration') . ' ' . t3lib_BEfunc::versioningPlaceholderClause('tx_crawler_configuration') . ' ');
     while ($row = $this->db->sql_fetch_assoc($res)) {
         $configurationsForBranch[] = $row['name'];
     }
     $this->db->sql_free_result($res);
     return $configurationsForBranch;
 }
 /**
  * [Describe function...]
  *
  * @param	[type]		$table: ...
  * @param	[type]		$id: ...
  * @param	[type]		$addWhere: ...
  * @param	[type]		$fieldList: ...
  * @return	[type]		...
  */
 function makeQueryArray($table, $id, $addWhere = "", $fieldList = '')
 {
     global $TCA;
     if (!$fieldList) {
         $fieldList = $table . '.*';
     }
     // Set ORDER BY:
     $orderBy = $TCA[$table]['ctrl']['sortby'] ? 'ORDER BY ' . $TCA[$table]['ctrl']['sortby'] : $TCA[$table]['ctrl']['default_sortby'];
     if ($this->sortField) {
         if (in_array($this->sortField, $this->makeFieldList($table, 1))) {
             $orderBy = 'ORDER BY ' . $this->sortField;
             if ($this->sortRev) {
                 $orderBy .= ' DESC';
             }
         }
     }
     // Set LIMIT:
     $limit = $this->iLimit ? ($this->firstElementNumber ? $this->firstElementNumber . ',' : '') . $this->iLimit : '';
     // fix for 6.2
     $TCA[$table]['ctrl']['searchFields'] = $this->searchFields;
     // Adding search constraints:
     $search = $this->makeSearchString($table);
     if ($this->selectedCategories) {
         $mmTable = 'tt_news_cat_mm';
         $fieldList = 'DISTINCT ' . $table . '.uid, ' . $fieldList;
         $leftjoin = ' LEFT JOIN ' . $mmTable . ' AS mm1 ON ' . $table . '.uid=mm1.uid_local';
     }
     $catWhere = '';
     if ($this->selectedCategories) {
         $catWhere .= ' AND mm1.uid_foreign IN (' . $this->selectedCategories . ')';
     } elseif ($this->lTSprop['noListWithoutCatSelection'] && !$this->isAdmin) {
         $addWhere .= ' AND 1=0';
     }
     if ($this->searchLevels == -1) {
         $this->pidSelect = '';
     }
     $ps = $this->pidSelect ? $this->pidSelect . ' AND ' : '';
     if ($this->isAdmin) {
         $this->pidSelect = $ps . '1=1';
     } else {
         if ($this->showOnlyEditable) {
             $this->pidSelect = $ps . $table . '.pid IN (' . $this->editablePagesList . ')';
         } else {
             $this->pidSelect = $ps . $table . '.pid IN (' . $this->pidList . ')';
         }
     }
     $addWhere .= ' AND ' . $table . '.sys_language_uid=' . $this->current_sys_language;
     // Compiling query array:
     $queryParts = array('SELECT' => $fieldList, 'FROM' => $table . $leftjoin, 'WHERE' => $this->pidSelect . ' AND ' . $table . '.pid > 0' . t3lib_BEfunc::deleteClause($table) . t3lib_BEfunc::versioningPlaceholderClause($table) . ' ' . $addWhere . ' ' . $search . $catWhere, 'GROUPBY' => '', 'ORDERBY' => $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy), 'LIMIT' => $limit);
     if (!$this->isAdmin && ($this->selectedCategories || !$this->lTSprop['noListWithoutCatSelection']) && $this->showOnlyEditable) {
         $queryParts = $this->ckeckDisallowedCategories($queryParts);
     }
     // Return query:
     return $queryParts;
 }
 /**
  * Information about translation for an element
  * Will overlay workspace version of record too!
  *
  * @param	string		Table name
  * @param	integer		Record uid
  * @param	integer		Language uid. If zero, then all languages are selected.
  * @param	array		The record to be translated
  * @param	array		select fields for the query which fetches the translations of the current record
  * @return	array		Array with information. Errors will return string with message.
  */
 function translationInfo($table, $uid, $sys_language_uid = 0, $row = NULL, $selFieldList = '')
 {
     global $TCA;
     if ($TCA[$table] && $uid) {
         t3lib_div::loadTCA($table);
         if ($row === NULL) {
             $row = t3lib_BEfunc::getRecordWSOL($table, $uid);
         }
         if (is_array($row)) {
             $trTable = $this->getTranslationTable($table);
             if ($trTable) {
                 if ($trTable !== $table || $row[$TCA[$table]['ctrl']['languageField']] <= 0) {
                     if ($trTable !== $table || $row[$TCA[$table]['ctrl']['transOrigPointerField']] == 0) {
                         // Look for translations of this record, index by language field value:
                         $translationsTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($selFieldList ? $selFieldList : 'uid,' . $TCA[$trTable]['ctrl']['languageField'], $trTable, $TCA[$trTable]['ctrl']['transOrigPointerField'] . '=' . intval($uid) . ' AND pid=' . intval($table === 'pages' ? $row['uid'] : $row['pid']) . ' AND ' . $TCA[$trTable]['ctrl']['languageField'] . (!$sys_language_uid ? '>0' : '=' . intval($sys_language_uid)) . t3lib_BEfunc::deleteClause($trTable) . t3lib_BEfunc::versioningPlaceholderClause($trTable));
                         $translations = array();
                         $translations_errors = array();
                         foreach ($translationsTemp as $r) {
                             if (!isset($translations[$r[$TCA[$trTable]['ctrl']['languageField']]])) {
                                 $translations[$r[$TCA[$trTable]['ctrl']['languageField']]] = $r;
                             } else {
                                 $translations_errors[$r[$TCA[$trTable]['ctrl']['languageField']]][] = $r;
                             }
                         }
                         return array('table' => $table, 'uid' => $uid, 'CType' => $row['CType'], 'sys_language_uid' => $row[$TCA[$table]['ctrl']['languageField']], 'translation_table' => $trTable, 'translations' => $translations, 'excessive_translations' => $translations_errors);
                     } else {
                         return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a relation to record "' . $row[$TCA[$table]['ctrl']['transOrigPointerField']] . '")';
                     }
                 } else {
                     return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a language value "' . $row[$TCA[$table]['ctrl']['languageField']] . '", relation to record "' . $row[$TCA[$table]['ctrl']['transOrigPointerField']] . '")';
                 }
             } else {
                 return 'Translation is not supported for this table!';
             }
         } else {
             return 'Record "' . $table . '_' . $uid . '" was not found';
         }
     } else {
         return 'No table "' . $table . '" or no UID value';
     }
 }
 /**
  * Returns an array of tt_content records which are not referenced on
  * the page with the given uid (= parent id).
  *
  * @param	integer		$pid: Parent id of the content elements (= uid of the page)
  * @return	array		Array of tt_content records with the following fields: uid, header, bodytext, sys_language_uid and colpos
  * @access	protected
  */
 function getUnreferencedElementsRecords($pid)
 {
     global $TYPO3_DB;
     $elementRecordsArr = array();
     $referencedElementsArr = $this->templavoilaAPIObj->flexform_getListOfSubElementUidsRecursively('pages', $pid, $dummyArr = array());
     $res = $TYPO3_DB->exec_SELECTquery('uid, header, bodytext, sys_language_uid, colPos', 'tt_content', 'pid=' . intval($pid) . (count($referencedElementsArr) ? ' AND uid NOT IN (' . implode(',', $referencedElementsArr) . ')' : '') . ' AND t3ver_wsid=' . intval($BE_USER->workspace) . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'), '', 'sorting');
     if ($res) {
         while (($elementRecordArr = $TYPO3_DB->sql_fetch_assoc($res)) !== FALSE) {
             $elementRecordsArr[$elementRecordArr['uid']] = $elementRecordArr;
         }
     }
     return $elementRecordsArr;
 }
 /**
  * Initializes page languages and icons
  *
  * @return	void
  */
 function initializeLanguages()
 {
     global $TCA, $LANG;
     // Look up page overlays:
     $this->pageOverlays = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'pages_language_overlay', 'pid=' . intval($this->id) . t3lib_BEfunc::deleteClause('pages_language_overlay') . t3lib_BEfunc::versioningPlaceholderClause('pages_language_overlay'), '', '', '', 'sys_language_uid');
     $this->languageIconTitles = $this->getTranslateTools()->getSystemLanguages($this->id, $this->backPath);
 }
    /**
     * Displays a list of local content elements on the page which were NOT used in the hierarchical structure of the page.
     *
     * @param	$pObj:		Reference to the parent object ($this)
     * @return	string		HTML output
     * @access	protected
     */
    function sidebar_renderNonUsedElements()
    {
        global $LANG, $TYPO3_DB, $BE_USER;
        $output = '';
        $elementRows = array();
        $usedUids = array_keys($this->pObj->global_tt_content_elementRegister);
        $usedUids[] = 0;
        $pid = $this->pObj->id;
        // If workspaces should evaluated non-used elements it must consider the id: For "element" and "branch" versions it should accept the incoming id, for "page" type versions it must be remapped (because content elements are then related to the id of the offline version)
        $res = $TYPO3_DB->exec_SELECTquery(t3lib_BEfunc::getCommonSelectFields('tt_content', '', array('uid', 'header', 'bodytext', 'sys_language_uid')), 'tt_content', 'pid=' . intval($pid) . ' ' . 'AND uid NOT IN (' . implode(',', $usedUids) . ') ' . 'AND t3ver_state!=1' . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'), '', 'uid');
        $this->deleteUids = array();
        // Used to collect all those tt_content uids with no references which can be deleted
        while (false !== ($row = $TYPO3_DB->sql_fetch_assoc($res))) {
            $elementPointerString = 'tt_content:' . $row['uid'];
            // Prepare the language icon:
            $languageLabel = htmlspecialchars($this->pObj->allAvailableLanguages[$row['sys_language_uid']]['title']);
            $languageIcon = $this->pObj->allAvailableLanguages[$row['sys_language_uid']]['flagIcon'] ? '<img src="' . $this->pObj->allAvailableLanguages[$row['sys_language_uid']]['flagIcon'] . '" title="' . $languageLabel . '" alt="' . $languageLabel . '"  />' : ($languageLabel && $row['sys_language_uid'] ? '[' . $languageLabel . ']' : '');
            // Prepare buttons:
            $cutButton = $this->element_getSelectButtons($elementPointerString, 'ref');
            $recordIcon = '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, t3lib_iconWorks::getIcon('tt_content', $row), '') . ' width="18" height="16" border="0" title="[tt_content:' . $row['uid'] . '" alt="" />';
            $recordButton = $this->pObj->doc->wrapClickMenuOnIcon($recordIcon, 'tt_content', $row['uid'], 1, '&callingScriptId=' . rawurlencode($this->pObj->doc->scriptID), 'new,copy,cut,pasteinto,pasteafter,delete');
            $elementRows[] = '
				<tr class="bgColor4">
					<td style="width:1%">' . $cutButton . '</td>
					<td style="width:1%;">' . $languageIcon . '</td>
					<td style="width:1%;">' . $this->renderReferenceCount($row['uid']) . '</td>
					<td>' . $recordButton . htmlspecialchars(' ' . t3lib_div::fixed_lgd_cs(trim(strip_tags($row['header'] . ($row['header'] && $row['bodytext'] ? ' - ' : '') . $row['bodytext'])), 100)) . '
					</td>
				</tr>
			';
        }
        if (count($elementRows)) {
            // Control for deleting all deleteable records:
            $deleteAll = '';
            if (count($this->deleteUids) && 0 === $BE_USER->workspace) {
                $params = '';
                foreach ($this->deleteUids as $deleteUid) {
                    $params .= '&cmd[tt_content][' . $deleteUid . '][delete]=1';
                }
                $label = $LANG->getLL('rendernonusedelements_deleteall');
                $deleteAll = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(\'' . $this->doc->issueCommand($params, '') . '\');') . '">' . '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/garbage.gif', 'width="11" height="12"') . ' title="' . htmlspecialchars($label) . '" alt="" />' . htmlspecialchars($label) . '</a>';
            }
            // Create table and header cell:
            $output = '
				<table border="0" cellpadding="0" cellspacing="1" width="100%" class="lrPadding">
					<tr class="bgColor4-20">
						<td colspan="5">' . $LANG->getLL('inititemno_elementsNotBeingUsed', '1') . ':</td>
					</tr>
					' . implode('', $elementRows) . '
					<tr class="bgColor4">
						<td colspan="5">' . $deleteAll . '</td>
					</tr>
				</table>
			';
        }
        return $output;
    }
 /**
  * For RTE: This displays all content elements on a page and lets you create a link to the element.
  *
  * @return	string		HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
  */
 function expandPage()
 {
     global $BE_USER, $BACK_PATH;
     $out = '';
     $expPageId = $this->expandPage;
     // Set page id (if any) to expand
     // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
     if (!$this->expandPage && $this->curUrlInfo['cElement']) {
         $expPageId = $this->curUrlInfo['pageid'];
         // Set to the current link page id.
     }
     // Draw the record list IF there is a page id to expand:
     if ($expPageId && t3lib_div::testInt($expPageId) && $BE_USER->isInWebMount($expPageId)) {
         // Set header:
         $out .= $this->barheader($GLOBALS['LANG']->getLL('contentElements') . ':');
         // Create header for listing, showing the page title/icon:
         $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
         $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages', $expPageId);
         $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
         $picon .= htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'], $titleLen));
         $out .= $picon . '<br />';
         // Look up tt_content elements from the expanded page:
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,header,hidden,starttime,endtime,fe_group,CType,colpos,bodytext', 'tt_content', 'pid=' . intval($expPageId) . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'), '', 'colpos,sorting');
         $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
         // Traverse list of records:
         $c = 0;
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $c++;
             $icon = t3lib_iconWorks::getSpriteIconForRecord('tt_content', $row);
             if ($this->curUrlInfo['act'] == 'page' && $this->curUrlInfo['cElement'] == $row['uid']) {
                 $arrCol = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
             } else {
                 $arrCol = '';
             }
             // Putting list element HTML together:
             $out .= '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/ol/join' . ($c == $cc ? 'bottom' : '') . '.gif', 'width="18" height="16"') . ' alt="" />' . $arrCol . '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#' . $row['uid'] . '\');">' . $icon . htmlspecialchars(t3lib_div::fixed_lgd_cs($row['header'], $titleLen)) . '</a><br />';
             // Finding internal anchor points:
             if (t3lib_div::inList('text,textpic', $row['CType'])) {
                 $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
                 foreach ($split as $skey => $sval) {
                     if ($skey % 3 == 2) {
                         // Putting list element HTML together:
                         $sval = substr($sval, 0, 100);
                         $out .= '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/ol/line.gif', 'width="18" height="16"') . ' alt="" />' . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/ol/join' . ($skey + 3 > count($split) ? 'bottom' : '') . '.gif', 'width="18" height="16"') . ' alt="" />' . '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#' . rawurlencode($sval) . '\');">' . htmlspecialchars(' <A> ' . $sval) . '</a><br />';
                     }
                 }
             }
         }
     }
     return $out;
 }
    /**
     * Displays a list of local content elements on the page which were NOT used in the hierarchical structure of the page.
     *
     * @param	$pObj:		Reference to the parent object ($this)
     * @return	string		HTML output
     * @access	protected
     */
    function sidebar_renderNonUsedElements()
    {
        global $LANG, $TYPO3_DB, $BE_USER;
        $output = '';
        $elementRows = array();
        $usedUids = array_keys($this->pObj->global_tt_content_elementRegister);
        $usedUids[] = 0;
        $pid = $this->pObj->id;
        // If workspaces should evaluated non-used elements it must consider the id: For "element" and "branch" versions it should accept the incoming id, for "page" type versions it must be remapped (because content elements are then related to the id of the offline version)
        $res = $TYPO3_DB->exec_SELECTquery(t3lib_BEfunc::getCommonSelectFields('tt_content', '', array('uid', 'header', 'bodytext', 'sys_language_uid')), 'tt_content', 'pid=' . intval($pid) . ' ' . 'AND uid NOT IN (' . implode(',', $usedUids) . ') ' . 'AND ( t3ver_state NOT IN (1,3) OR (t3ver_wsid > 0 AND t3ver_wsid = ' . intval($GLOBALS['BE_USER']->workspace) . ') )' . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'), '', 'uid');
        $this->deleteUids = array();
        // Used to collect all those tt_content uids with no references which can be deleted
        while (false !== ($row = $TYPO3_DB->sql_fetch_assoc($res))) {
            $elementPointerString = 'tt_content:' . $row['uid'];
            // Prepare the language icon:
            $languageLabel = htmlspecialchars($this->pObj->allAvailableLanguages[$row['sys_language_uid']]['title']);
            if ($this->pObj->allAvailableLanguages[$row['sys_language_uid']]['flagIcon']) {
                $languageIcon = tx_templavoila_icons::getFlagIconForLanguage($this->pObj->allAvailableLanguages[$row['sys_language_uid']]['flagIcon'], array('title' => $languageLabel, 'alt' => $languageLabel));
            } else {
                $languageIcon = $languageLabel && $row['sys_language_uid'] ? '[' . $languageLabel . ']' : '';
            }
            // Prepare buttons:
            $cutButton = $this->element_getSelectButtons($elementPointerString, 'ref');
            $recordIcon = t3lib_iconWorks::getSpriteIconForRecord('tt_content', $row);
            $recordButton = $this->pObj->doc->wrapClickMenuOnIcon($recordIcon, 'tt_content', $row['uid'], 1, '&callingScriptId=' . rawurlencode($this->pObj->doc->scriptID), 'new,copy,cut,pasteinto,pasteafter,delete');
            if ($GLOBALS['BE_USER']->workspace) {
                $wsRow = t3lib_BEfunc::getRecordWSOL('tt_content', $row['uid']);
                $isDeletedInWorkspace = $wsRow['t3ver_state'] == 2;
            } else {
                $isDeletedInWorkspace = FALSE;
            }
            if (!$isDeletedInWorkspace) {
                $elementRows[] = '
					<tr id="' . $elementPointerString . '" class="tpm-nonused-element">
						<td class="tpm-nonused-controls">' . $cutButton . $languageIcon . '</td>
						<td class="tpm-nonused-ref">' . $this->renderReferenceCount($row['uid']) . '</td>
						<td class="tpm-nonused-preview">' . $recordButton . htmlspecialchars(t3lib_BEfunc::getRecordTitle('tt_content', $row)) . '</td>
					</tr>
				';
            }
        }
        if (count($elementRows)) {
            // Control for deleting all deleteable records:
            $deleteAll = '';
            if (count($this->deleteUids)) {
                $params = '';
                foreach ($this->deleteUids as $deleteUid) {
                    $params .= '&cmd[tt_content][' . $deleteUid . '][delete]=1';
                }
                $label = $LANG->getLL('rendernonusedelements_deleteall');
                $deleteAll = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(\'' . $this->doc->issueCommand($params, -1) . '\');') . '">' . t3lib_iconWorks::getSpriteIcon('actions-edit-delete', array('title' => htmlspecialchars($label))) . htmlspecialchars($label) . '</a>';
            }
            // Create table and header cell:
            $output = '
				<table class="tpm-nonused-elements lrPadding" border="0" cellpadding="0" cellspacing="1" width="100%">
					<tr class="bgColor4-20">
						<td colspan="3">' . $LANG->getLL('inititemno_elementsNotBeingUsed', '1') . ':</td>
					</tr>
					' . implode('', $elementRows) . '
					<tr class="bgColor4">
						<td colspan="3" class="tpm-nonused-deleteall">' . $deleteAll . '</td>
					</tr>
				</table>
			';
        }
        return $output;
    }
 /**
  * Retrieve a collection (array) of tx_templavoila_datastructure objects
  *
  * @return array
  */
 public function getAll($storagePid = 0)
 {
     $toList = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('tx_templavoila_tmplobj.uid', 'tx_templavoila_tmplobj', '1=1' . (intval($storagePid) > 0 ? ' AND tx_templavoila_tmplobj.pid = ' . intval($storagePid) : ' AND tx_templavoila_tmplobj.pid!=-1') . t3lib_BEfunc::deleteClause('tx_templavoila_tmplobj') . t3lib_BEfunc::versioningPlaceholderClause('tx_templavoila_tmplobj'));
     $toCollection = array();
     foreach ($toList as $toRec) {
         $toCollection[] = $this->getTemplateByUid($toRec['uid']);
     }
     usort($toCollection, array($this, 'sortTemplates'));
     return $toCollection;
 }
 /**
  * Creates HTML for inserting/moving content elements.
  *
  * @param	integer		page id onto which to insert content element.
  * @param	integer		Move-uid (tt_content element uid?)
  * @param	string		List of columns to show
  * @param	boolean		If not set, then hidden/starttime/endtime records are filtered out.
  * @param	string		Request URI
  * @return	string		HTML
  */
 function printContentElementColumns($pid, $moveUid, $colPosList, $showHidden, $R_URI)
 {
     $this->R_URI = $R_URI;
     $this->moveUid = $moveUid;
     $colPosArray = t3lib_div::trimExplode(',', $colPosList, 1);
     $lines = array();
     foreach ($colPosArray as $kk => $vv) {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . intval($pid) . ($showHidden ? '' : t3lib_BEfunc::BEenableFields('tt_content')) . ' AND colPos=' . intval($vv) . (strcmp($this->cur_sys_language, '') ? ' AND sys_language_uid=' . intval($this->cur_sys_language) : '') . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'), '', 'sorting');
         $lines[$kk] = array();
         $lines[$kk][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             t3lib_BEfunc::workspaceOL('tt_content', $row);
             if (is_array($row)) {
                 $lines[$kk][] = $this->wrapRecordHeader($this->getRecordHeader($row), $row);
                 $lines[$kk][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid);
             }
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
     }
     return $this->printRecordMap($lines, $colPosArray);
 }
 /**
  * Call back function for page tree traversal!
  *
  * @param	string		Table name
  * @param	integer		UID of record in processing
  * @param	integer		Echo level  (see calling function
  * @param	string		Version swap mode on that level (see calling function
  * @param	integer		Is root version (see calling function
  * @return	void
  */
 function main_parseTreeCallBack($tableName, $uid, $echoLevel, $versionSwapmode, $rootIsVersion)
 {
     if ($tableName == 'pages' && $uid > 0 && !in_array($uid, $this->excludePageIdList)) {
         if (!$versionSwapmode) {
             // Initialize TemplaVoila API class:
             $apiObj = t3lib_div::makeInstance('tx_templavoila_api', 'pages');
             // Fetch the content structure of page:
             $contentTreeData = $apiObj->getContentTree('pages', t3lib_BEfunc::getRecordRaw('pages', 'uid=' . intval($uid)));
             if ($contentTreeData['tree']['ds_is_found']) {
                 $usedUids = array_keys($contentTreeData['contentElementUsage']);
                 $usedUids[] = 0;
                 // Look up all content elements that are NOT used on this page...
                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid, header', 'tt_content', 'pid=' . intval($uid) . ' ' . 'AND uid NOT IN (' . implode(',', $usedUids) . ') ' . 'AND t3ver_state!=1 ' . 'AND t3ver_state!=3 ' . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'), '', 'uid');
                 // Traverse, for each find references if any and register them.
                 while (false !== ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
                     // Look up references to elements:
                     $refrows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('hash', 'sys_refindex', 'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('tt_content', 'sys_refindex') . ' AND ref_uid=' . intval($row['uid']) . ' AND deleted=0');
                     // Look up TRANSLATION references FROM this element to another content element:
                     $isATranslationChild = false;
                     $refrows_From = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('ref_uid', 'sys_refindex', 'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('tt_content', 'sys_refindex') . ' AND recuid=' . intval($row['uid']) . ' AND field=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('l18n_parent', 'sys_refindex'));
                     // Check if that other record is deleted or not:
                     if ($refrows_From[0] && $refrows_From[0]['ref_uid']) {
                         $isATranslationChild = t3lib_BEfunc::getRecord('tt_content', $refrows_From[0]['ref_uid'], 'uid') ? TRUE : FALSE;
                     }
                     // Register elements etc:
                     $this->resultArray['all_unused'][$row['uid']] = array($row['header'], count($refrows));
                     if ($echoLevel > 2) {
                         echo chr(10) . '			[tx_templavoila_unusedce:] tt_content:' . $row['uid'] . ' was not used on page...';
                     }
                     if (!count($refrows)) {
                         if ($isATranslationChild) {
                             if ($echoLevel > 2) {
                                 echo ' but is a translation of a non-deleted records and so do not delete...';
                             }
                         } else {
                             $this->resultArray['deleteMe'][$row['uid']] = $row['uid'];
                             if ($echoLevel > 2) {
                                 echo ' and can be DELETED';
                             }
                         }
                     } else {
                         if ($echoLevel > 2) {
                             echo ' but is referenced to (' . count($refrows) . ') so do not delete...';
                         }
                     }
                 }
             } else {
                 if ($echoLevel > 2) {
                     echo chr(10) . '			[tx_templavoila_unusedce:] Did not check page - did not have a Data Structure set.';
                 }
             }
         } else {
             if ($echoLevel > 2) {
                 echo chr(10) . '			[tx_templavoila_unusedce:] Did not check page - was on offline page.';
             }
         }
     }
 }
 /**
  * Getting the tree data: Selecting/Initializing data pointer to items for a certain parent id.
  * For tables: This will make a database query to select all children to "parent"
  * For arrays: This will return key to the ->dataLookup array
  *
  * @param	integer		parent item id
  * @param	string		Class for sub-elements.
  * @return	mixed		data handle (Tables: An sql-resource, arrays: A parentId integer. -1 is returned if there were NO subLevel.)
  * @access private
  */
 function getDataInit($parentId, $subCSSclass = '')
 {
     if (is_array($this->data)) {
         if (!is_array($this->dataLookup[$parentId][$this->subLevelID])) {
             $parentId = -1;
         } else {
             reset($this->dataLookup[$parentId][$this->subLevelID]);
         }
         return $parentId;
     } else {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',', $this->fieldArray), $this->table, $this->parentField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($parentId, $this->table) . t3lib_BEfunc::deleteClause($this->table) . t3lib_BEfunc::versioningPlaceholderClause($this->table) . $this->clause, '', $this->orderByFields);
         return $res;
     }
 }
 /**
  * Returns an array of available Page Template Object records from the scope of the given page.
  *
  * Note: All TO records which are found in the selected storage folder will be returned, no matter
  *       if they match the currently selected data structure for the given page.
  *
  * @param	integer		$pageUid: (current) page uid, used for finding the correct storage folder
  * @return	mixed		Array of Template Object records or FALSE if an error occurred.
  * @access	public
  */
 function ds_getAvailablePageTORecords($pageUid)
 {
     global $TYPO3_DB;
     $storageFolderPID = $this->getStorageFolderPid($pageUid);
     $tTO = 'tx_templavoila_tmplobj';
     $tDS = 'tx_templavoila_datastructure';
     $res = $TYPO3_DB->exec_SELECTquery("{$tTO}.*", "{$tTO} LEFT JOIN {$tDS} ON {$tTO}.datastructure = {$tDS}.uid", "{$tTO}.pid=" . intval($storageFolderPID) . " AND {$tDS}.scope=1" . t3lib_befunc::deleteClause($tTO) . t3lib_befunc::deleteClause($tDS) . t3lib_BEfunc::versioningPlaceholderClause($tTO) . t3lib_BEfunc::versioningPlaceholderClause($tDS));
     if (!$res) {
         return FALSE;
     }
     $templateObjectRecords = array();
     while (false != ($row = $TYPO3_DB->sql_fetch_assoc($res))) {
         $templateObjectRecords[$row['uid']] = $row;
     }
     return $templateObjectRecords;
 }
Exemplo n.º 26
0
    function main()
    {
        // Template markers
        $markers = array('CSH' => '', 'FUNC_MENU' => '', 'CONTENT' => '');
        // Access check...
        // The page will show only if there is a valid page and if this page may be viewed by the user
        $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause);
        $this->access = is_array($this->pageinfo) ? 1 : 0;
        $this->doc = t3lib_div::makeInstance('template');
        $this->doc->backPath = $GLOBALS['BACK_PATH'];
        $this->doc->setModuleTemplate('templates/tstemplate.html');
        if ($this->id && $this->access) {
            $this->doc->form = '<form action="index.php?id=' . $this->id . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editForm">';
            // JavaScript
            $this->doc->JScode = '
		<script language="javascript" type="text/javascript">
			script_ended = 0;
			function jumpToUrl(URL) {
				window.location.href = URL;
			}
			function uFormUrl(aname) {
				document.forms[0].action = "index.php?id=' . $this->id . '#"+aname;
			}
			function brPoint(lnumber,t) {
				window.location.href = "index.php?id=' . $this->id . '&SET[function]=tx_tstemplateobjbrowser&SET[ts_browser_type]="+(t?"setup":"const")+"&breakPointLN="+lnumber;
				return false;
			}
		</script>
		';
            $this->doc->postCode = '
		<script language="javascript" type="text/javascript">
			script_ended = 1;
			if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id) . ';
		</script>
		';
            $this->doc->inDocStylesArray[] = '
				TABLE#typo3-objectBrowser A { text-decoration: none; }
				TABLE#typo3-objectBrowser .comment { color: maroon; font-weight: bold; }
				TABLE#ts-analyzer tr.t3-row-header { background-color: #A2AAB8; }
				TABLE#ts-analyzer tr td {padding: 0 2px;}
				TABLE#ts-analyzer tr.t3-row-header td { padding: 2px 4px; font-weight:bold; color: #fff; }
				.tsob-menu label, .tsob-menu-row2 label, .tsob-conditions label {padding: 0 5px; vertical-align: text-top;}
				.tsob-menu-row2 {margin-top: 10px;}
				.tsob-conditions {padding: 1px 2px;}
				.tsob-search-submit {margin-left: 3px; margin-right: 3px;}
				.tst-analyzer-options { margin:5px 0; }
				.tst-analyzer-options label {padding-left:5px; vertical-align:text-top; }
				.bgColor0 {background-color:#fff;}
			';
            // Setting up the context sensitive menu:
            $this->doc->getContextMenuCode();
            // Build the modulle content
            $this->content = $this->doc->header($GLOBALS['LANG']->getLL('moduleTitle'));
            $this->extObjContent();
            $this->content .= $this->doc->spacer(10);
            // Setting up the buttons and markers for docheader
            $docHeaderButtons = $this->getButtons();
            // $markers['CSH'] = $docHeaderButtons['csh'];
            $markers['FUNC_MENU'] = t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
            $markers['CONTENT'] = $this->content;
        } else {
            // If no access or if ID == zero
            $this->doc->inDocStylesArray[] = '
				TABLE#ts-overview tr.t3-row-header { background-color: #A2AAB8; }
				TABLE#ts-overview tr td {padding: 2px;}
				TABLE#ts-overview tr.t3-row-header td { padding: 2px 4px; font-weight:bold; color: #fff; }
			';
            // Template pages:
            $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pages.uid, count(*) AS count, max(sys_template.root) AS root_max_val, min(sys_template.root) AS root_min_val', 'pages,sys_template', 'pages.uid=sys_template.pid' . t3lib_BEfunc::deleteClause('pages') . t3lib_BEfunc::versioningPlaceholderClause('pages') . t3lib_BEfunc::deleteClause('sys_template') . t3lib_BEfunc::versioningPlaceholderClause('sys_template'), 'pages.uid');
            $templateArray = array();
            $pArray = array();
            while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                $this->setInPageArray($pArray, t3lib_BEfunc::BEgetRootLine($row['uid'], 'AND 1=1'), $row);
            }
            $lines = array();
            $lines[] = '<tr class="t3-row-header">
				<td nowrap>' . $GLOBALS['LANG']->getLL('pageName') . '</td>
				<td nowrap>' . $GLOBALS['LANG']->getLL('templates') . '</td>
				<td nowrap>' . $GLOBALS['LANG']->getLL('isRoot') . '</td>
				<td nowrap>' . $GLOBALS['LANG']->getLL('isExt') . '</td>
				</tr>';
            $lines = array_merge($lines, $this->renderList($pArray));
            $table = '<table border="0" cellpadding="0" cellspacing="1" id="ts-overview">' . implode('', $lines) . '</table>';
            $this->content = $this->doc->section($GLOBALS['LANG']->getLL('moduleTitle'), '
			<br />
			' . $GLOBALS['LANG']->getLL('overview') . '
			<br /><br />' . $table);
            // ********************************************
            // RENDER LIST of pages with templates, END
            // ********************************************
            $this->content .= $this->doc->spacer(10);
            // Setting up the buttons and markers for docheader
            $docHeaderButtons = $this->getButtons();
            // $markers['CSH'] = $docHeaderButtons['csh'];
            $markers['CONTENT'] = $this->content;
        }
        // Build the <body> for the module
        $this->content = $this->doc->startPage('Template Tools');
        $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
        $this->content .= $this->doc->endPage();
        $this->content = $this->doc->insertStylesAndJS($this->content);
    }
 /**
  * Counting content elements for a single language on a page.
  *
  * @param	integer		Page id to select for.
  * @param	integer		Sys language uid
  * @return	integer		Number of content elements from the PID where the language is set to a certain value.
  */
 function getContentElementCount($pageId, $sysLang)
 {
     if ($sysLang == 0) {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'tt_content', 'pid=' . intval($pageId) . ' AND sys_language_uid=' . intval($sysLang) . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'));
         list($count) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
     }
     return $count ? $count : '-';
 }
    /**
     * Renders the template selector.
     *
     * @param	integer		Position id. Can be positive and negative depending of where the new page is going: Negative always points to a position AFTER the page having the abs. value of the positionId. Positive numbers means to create as the first subpage to another page.
     * @param	string		$templateType: The template type, 'tmplobj' or 't3d'
     * @return	string		HTML output containing a table with the template selector
     */
    function renderTemplateSelector($positionPid, $templateType = 'tmplobj')
    {
        global $LANG, $TYPO3_DB;
        $storageFolderPID = $this->apiObj->getStorageFolderPid($positionPid);
        $tmplHTML = array();
        switch ($templateType) {
            case 'tmplobj':
                // Create the "Default template" entry
                $previewIconFilename = $GLOBALS['BACK_PATH'] . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif';
                $previewIcon = '<input type="image" class="c-inputButton" name="i0" value="0" src="' . $previewIconFilename . '" title="" />';
                $description = htmlspecialchars($LANG->getLL('template_descriptiondefault'));
                $tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap">
					<h3 class="bgColor3-20">' . htmlspecialchars($LANG->getLL('template_titledefault')) . '</h3></td></tr>
					<tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $description . '</p></td></tr></table>';
                $tTO = 'tx_templavoila_tmplobj';
                $tDS = 'tx_templavoila_datastructure';
                $where = $tTO . '.parent=0 AND ' . $tTO . '.pid=' . intval($storageFolderPID) . ' AND ' . $tDS . '.scope=1' . $this->buildRecordWhere($tTO) . $this->buildRecordWhere($tDS) . t3lib_befunc::deleteClause($tTO) . t3lib_befunc::deleteClause($tDS) . t3lib_BEfunc::versioningPlaceholderClause($tTO) . t3lib_BEfunc::versioningPlaceholderClause($tDS);
                $res = $TYPO3_DB->exec_SELECTquery($tTO . '.*', $tTO . ' LEFT JOIN ' . $tDS . ' ON ' . $tTO . '.datastructure = ' . $tDS . '.uid', $where);
                while (false !== ($row = $TYPO3_DB->sql_fetch_assoc($res))) {
                    // Check if preview icon exists, otherwise use default icon:
                    $tmpFilename = 'uploads/tx_templavoila/' . $row['previewicon'];
                    $previewIconFilename = @is_file(PATH_site . $tmpFilename) ? $GLOBALS['BACK_PATH'] . '../' . $tmpFilename : $GLOBALS['BACK_PATH'] . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif';
                    // Note: we cannot use value of image input element because MSIE replaces this value with mouse coordinates! Thus on click we set value to a hidden field. See http://bugs.typo3.org/view.php?id=3376
                    $previewIcon = '<input type="image" class="c-inputButton" name="i' . $row['uid'] . '" onclick="document.getElementById(\'data_tx_templavoila_to\').value=' . $row['uid'] . '" src="' . $previewIconFilename . '" title="" />';
                    $description = $row['description'] ? htmlspecialchars($row['description']) : $LANG->getLL('template_nodescriptionavailable');
                    $tmplHTML[] = '<table style="width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"><h3 class="bgColor3-20">' . htmlspecialchars($row['title']) . '</h3></td></tr>' . '<tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $description . '</p></td></tr></table>';
                }
                $tmplHTML[] = '<input type="hidden" id="data_tx_templavoila_to" name="data[tx_templavoila_to]" value="0" />';
                break;
            case 't3d':
                if (t3lib_extMgm::isLoaded('impexp')) {
                    // Read template files from a certain folder. I suggest this is configurable in some way. But here it is hardcoded for initial tests.
                    $templateFolder = PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '/export/templates/';
                    $files = t3lib_div::getFilesInDir($templateFolder, 't3d,xml', 1, 1);
                    // Traverse the files found:
                    foreach ($files as $absPath) {
                        // Initialize the import object:
                        $import = $this->getImportObject();
                        if ($import->loadFile($absPath)) {
                            if (is_array($import->dat['header']['pagetree'])) {
                                // This means there are pages in the file, we like that...:
                                // Page tree:
                                reset($import->dat['header']['pagetree']);
                                $pageTree = current($import->dat['header']['pagetree']);
                                // Thumbnail icon:
                                if (is_array($import->dat['header']['thumbnail'])) {
                                    $pI = pathinfo($import->dat['header']['thumbnail']['filename']);
                                    if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) {
                                        // Construct filename and write it:
                                        $fileName = PATH_site . 'typo3temp/importthumb_' . t3lib_div::shortMD5($absPath) . '.' . $pI['extension'];
                                        t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']);
                                        // Check that the image really is an image and not a malicious PHP script...
                                        if (getimagesize($fileName)) {
                                            // Create icon tag:
                                            $iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />';
                                        } else {
                                            t3lib_div::unlink_tempfile($fileName);
                                            $iconTag = '';
                                        }
                                    }
                                }
                                $aTagB = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('templateFile' => $absPath))) . '">';
                                $aTagE = '</a>';
                                $tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap">
					<h3 class="bgColor3-20">' . $aTagB . htmlspecialchars($import->dat['header']['meta']['title'] ? $import->dat['header']['meta']['title'] : basename($absPath)) . $aTagE . '</h3></td></tr>
					<tr><td valign="top">' . $aTagB . $iconTag . $aTagE . '</td><td valign="top"><p>' . htmlspecialchars($import->dat['header']['meta']['description']) . '</p>
						<em>Levels: ' . (count($pageTree) > 1 ? 'Deep structure' : 'Single page') . '<br/>
						File: ' . basename($absPath) . '</em></td></tr></table>';
                            }
                        }
                    }
                }
                break;
        }
        if (is_array($tmplHTML) && count($tmplHTML)) {
            $counter = 0;
            $content .= '<table>';
            foreach ($tmplHTML as $single) {
                $content .= ($counter ? '' : '<tr>') . '<td valign="top">' . $single . '</td>' . ($counter ? '</tr>' : '');
                $counter++;
                if ($counter > 1) {
                    $counter = 0;
                }
            }
            $content .= '</table>';
        }
        return $content;
    }
 /**
  * Retrieve a collection (array) of tx_templavoila_datastructure objects
  *
  * @return array
  */
 public function getAll()
 {
     $dscollection = array();
     $confArr = self::getStaticDatastructureConfiguration();
     if (count($confArr)) {
         foreach ($confArr as $key => $conf) {
             $ds = $this->getDatastructureByUidOrFilename($conf['path']);
             $dscollection[] = $ds;
         }
     }
     if (!self::isStaticDsEnabled()) {
         $dsRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'tx_templavoila_datastructure', '1=1' . t3lib_BEfunc::deleteClause('tx_templavoila_datastructure') . ' AND pid!=-1 ' . t3lib_BEfunc::versioningPlaceholderClause('tx_templavoila_datastructure'));
         foreach ($dsRows as $ds) {
             $dscollection[] = $this->getDatastructureByUidOrFilename($ds['uid']);
         }
     }
     usort($dscollection, array($this, 'sortDatastructures'));
     return $dscollection;
 }
    /**
     * Creates a menu of the tables that can be listed by this function
     * Only tables which has records on the page will be included.
     * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
     *
     * @param	integer		Page id from which we are listing records (the function will look up if there are records on the page)
     * @return	string		HTML output.
     */
    function getTableMenu($id)
    {
        global $TCA;
        // Initialize:
        $this->activeTables = array();
        $theTables = explode(',', 'tt_content,fe_users,tt_address,tt_links,tt_board,tt_guest,tt_calender,tt_products,tt_news');
        // NOTICE: This serves double function: Both being tables names (all) and for most others also being extension keys for the extensions they are related to!
        // External tables:
        if (is_array($this->externalTables)) {
            $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
        }
        // Traverse tables to check:
        foreach ($theTables as $tName) {
            // Check access and whether the proper extensions are loaded:
            if ($GLOBALS['BE_USER']->check('tables_select', $tName) && (t3lib_extMgm::isLoaded($tName) || t3lib_div::inList('fe_users,tt_content', $tName) || isset($this->externalTables[$tName]))) {
                // Make query to count records from page:
                $c = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', $tName, 'pid=' . intval($id) . t3lib_BEfunc::deleteClause($tName) . t3lib_BEfunc::versioningPlaceholderClause($tName));
                // If records were found (or if "tt_content" is the table...):
                if ($c || t3lib_div::inList('tt_content', $tName)) {
                    // Add row to menu:
                    $out .= '
					<td><a href="#' . $tName . '"></a>' . t3lib_iconWorks::getSpriteIconForRecord($tName, array(), array('title' => $GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'], 1))) . '</td>';
                    // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
                    $this->activeTables[$tName] = t3lib_iconWorks::getSpriteIconForRecord($tName, array(), array('title' => $GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'], 1) . ': ' . $c . ' ' . $GLOBALS['LANG']->getLL('records', 1))) . '&nbsp;' . $GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'], 1);
                }
            }
        }
        // Wrap cells in table tags:
        $out = '



			<!--
				Menu of tables on the page (table menu)
			-->
			<table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
				<tr>' . $out . '
				</tr>
			</table>';
        // Return the content:
        return $out;
    }