Esempio n. 1
0
 /**
  * Find the Live-Uid for a given page,
  * the results are cached at run-time to avoid too many database-queries
  *
  * @throws InvalidArgumentException
  * @param  $uid
  * @return void
  */
 protected function getLivePageUid($uid)
 {
     if (!isset(self::$pageCache[$uid])) {
         $rec = t3lib_beFunc::getRecord('pages', $uid);
         if (is_array($rec)) {
             self::$pageCache[$uid] = $rec['t3ver_oid'] ? $rec['t3ver_oid'] : $uid;
         } else {
             throw new InvalidArgumentException('uid is supposed to point to an existing page - given value was:' . $uid, 1290628113);
         }
     }
     return self::$pageCache[$uid];
 }
 /**
  *
  * @param integer $uid
  */
 public function __construct($uid)
 {
     $this->row = t3lib_beFunc::getRecordWSOL('tx_templavoila_tmplobj', $uid);
     $this->setLabel($this->row['title']);
     $this->setDescription($this->row['description']);
     $this->setIcon($this->row['previewicon']);
     $this->setFileref($this->row['fileref']);
     $this->setFilerefMtime($this->row['fileref_mtime']);
     $this->setFilerefMD5($this->row['fileref_md5']);
     $this->setSortbyField($GLOBALS['TCA']['tx_templavoila_tmplobj']['ctrl']['sortby']);
     $this->setParent($this->row['parent']);
 }
 function main()
 {
     $content = '<html><body>';
     $conf = t3lib_div::_GP('P');
     $conf['md5ID'];
     if ($conf['table'] == 'tx_datasources_datasource') {
         $dsRecord = t3lib_beFunc::getRecord($conf['table'], intval($conf['uid']));
         if (is_array($dsRecord)) {
             $dsArr = t3lib_div::xml2array($dsRecord['configuration']);
             $dsConf = $dsArr['data']['sDEF']['lDEF'];
             $content .= '<p>Trying to connect with Host / DSN <strong>' . htmlspecialchars($dsConf['field_host']['vDEF']) . '</strong> with user <strong>' . htmlspecialchars($dsConf['field_username']['vDEF']) . '</strong> ... ';
             $dbConn =& ADONewConnection($dsConf['field_dbtype']['vDEF']);
             $dbConn->PConnect($dsConf['field_host']['vDEF'], $dsConf['field_username']['vDEF'], $dsConf['field_password']['vDEF'], $dsConf['field_dbname']['vDEF']);
             $dbConn->SetFetchMode(ADODB_FETCH_ASSOC);
             $content .= $dbConn->ErrorMsg();
             if ($dbConn->_connectionID) {
                 $content .= '</p>';
                 $query = 'SELECT * FROM ' . $dsConf['field_table']['vDEF'];
                 $recordSet =& $dbConn->SelectLimit($query, 150);
                 if (!$recordSet) {
                     $content .= '<p>Query failed (' . htmlspecialchars($query) . '):<br />';
                     $content .= $dbConn->ErrorMsg() . '</p>';
                 } else {
                     $content .= '<span style="color:green">successful!</span></p>';
                     $counter = 0;
                     $content .= '<p>Showing the first 150 entries from the result recordset:</p>';
                     $content .= '<table border="1">';
                     while (!$recordSet->EOF) {
                         $content .= '<tr>';
                         if ($counter == 0) {
                             foreach (array_keys($recordSet->fields) as $key) {
                                 $content .= '<th>' . htmlspecialchars($key) . '</th>';
                             }
                             $content .= '</tr><tr>';
                         }
                         foreach (array_values($recordSet->fields) as $value) {
                             $content .= '<td>' . htmlspecialchars($value) . '&nbsp;</td>';
                         }
                         $recordSet->MoveNext();
                         $counter++;
                         $content .= '</tr>';
                     }
                     $content .= '<table>';
                 }
             }
         } else {
             $content .= '<span style="color:red">failed!</span></p><p><strong>Error Message:</strong>' . $dbConn->ErrorMsg() . '</p>';
         }
     }
     $content .= '</body></html>';
     echo $content;
 }
 /**
  *
  * @param integer $uid
  */
 public function __construct($uid)
 {
     // getting the DS for the DB and make sure the workspace-overlay is performed (done internally)
     if (TYPO3_MODE == 'FE') {
         $this->row = $GLOBALS['TSFE']->sys_page->checkRecord('tx_templavoila_datastructure', $uid);
     } else {
         $this->row = t3lib_beFunc::getRecordWSOL('tx_templavoila_datastructure', $uid);
     }
     $this->setLabel($this->row['title']);
     $this->setScope($this->row['scope']);
     // path relative to typo3 maindir
     $this->setIcon('../uploads/tx_templavoila/' . $this->row['previewicon']);
     $this->setSortbyField($GLOBALS['TCA']['tx_templavoila_datastructure']['ctrl']['sortby']);
 }
 /**
  * Returns information about localization of traditional content elements (non FCEs).
  * It will be added to the content tree by getContentTree().
  *
  * @param	array		$contentTreeArr: Part of the content tree of the element to create the localization information for.
  * @param	array		$tt_content_elementRegister: Array of sys_language UIDs with some information as the value
  * @return	array		Localization information
  * @access	protected
  * @see	getContentTree_element()
  */
 function getContentTree_getLocalizationInfoForElement($contentTreeArr, &$tt_content_elementRegister)
 {
     global $TYPO3_DB;
     $localizationInfoArr = array();
     if ($contentTreeArr['el']['table'] == 'tt_content' && $contentTreeArr['el']['sys_language_uid'] <= 0) {
         // Finding translations of this record and select overlay record:
         $fakeElementRow = array('uid' => $contentTreeArr['el']['uid'], 'pid' => $contentTreeArr['el']['pid']);
         t3lib_beFunc::fixVersioningPID('tt_content', $fakeElementRow);
         $res = $TYPO3_DB->exec_SELECTquery('*', 'tt_content', 'pid=' . $fakeElementRow['pid'] . ' AND sys_language_uid>0' . ' AND l18n_parent=' . intval($contentTreeArr['el']['uid']) . t3lib_BEfunc::deleteClause('tt_content'));
         $attachedLocalizations = array();
         while (TRUE == ($olrow = $TYPO3_DB->sql_fetch_assoc($res))) {
             t3lib_BEfunc::workspaceOL('tt_content', $olrow);
             if (!isset($attachedLocalizations[$olrow['sys_language_uid']])) {
                 $attachedLocalizations[$olrow['sys_language_uid']] = $olrow['uid'];
             }
         }
         $TYPO3_DB->sql_free_result($res);
         // Traverse the available languages of the page (not default and [All])
         if (is_array($this->allSystemWebsiteLanguages) && is_array($this->allSystemWebsiteLanguages['rows'])) {
             foreach (array_keys($this->allSystemWebsiteLanguages['rows']) as $sys_language_uid) {
                 if ($sys_language_uid > 0) {
                     if (isset($attachedLocalizations[$sys_language_uid])) {
                         $localizationInfoArr[$sys_language_uid] = array();
                         $localizationInfoArr[$sys_language_uid]['mode'] = 'exists';
                         $localizationInfoArr[$sys_language_uid]['localization_uid'] = $attachedLocalizations[$sys_language_uid];
                         $tt_content_elementRegister[$attachedLocalizations[$sys_language_uid]]++;
                     } elseif ($contentTreeArr['el']['CType'] != 'templavoila_pi1') {
                         // Only localize content elements with "Default" langauge set
                         if ((int) $contentTreeArr['el']['sys_language_uid'] === 0) {
                             $localizationInfoArr[$sys_language_uid] = array();
                             $localizationInfoArr[$sys_language_uid]['mode'] = 'localize';
                         }
                     } elseif (!$contentTreeArr['ds_meta']['langDisable'] && ((int) $contentTreeArr['el']['sys_language_uid'] === -1 || (int) $contentTreeArr['el']['sys_language_uid'] === 0)) {
                         $localizationInfoArr[$sys_language_uid] = array();
                         $localizationInfoArr[$sys_language_uid]['mode'] = 'localizedFlexform';
                     } else {
                         $localizationInfoArr[$sys_language_uid] = array();
                         $localizationInfoArr[$sys_language_uid]['mode'] = 'no_localization';
                     }
                 }
             }
         }
     }
     return $localizationInfoArr;
 }
 /**
  * Returns true if the current backend user has write access to the note specified by $uid
  *
  * @param	integer		$uid: The note UID
  * @param	object		&$reference: Reference to the page module
  * @return	boolean		true if the current BE user may write / delete the specified note record
  * @access private
  */
 function internal_checkWriteAccess($uid, &$reference)
 {
     $noteRecord = t3lib_beFunc::getRecord('tx_rlmptvnotes_notes', $uid);
     if (is_array($noteRecord)) {
         $pageInfoArr = t3lib_BEfunc::readPageAccess($noteRecord['pid'], $reference->perms_clause);
         return $pageInfoArr['uid'] > 0;
     }
     return false;
 }
 /**
  * A function which can be used for load a batch of records from $table into internal memory of this object.
  * The function is also used to produce proper default data for new records
  * Ultimately the function will call renderRecord()
  *
  * @param	string		Table name, must be found in $TCA
  * @param	string		Comma list of id values. If $idList is "prev" then the value from $this->prevPageID is used. NOTICE: If $operation is "new", then negative ids are meant to point to a "previous" record and positive ids are PID values for new records. Otherwise (for existing records that is) it is straight forward table/id pairs.
  * @param	string		If "new", then a record with default data is returned. Further, the $id values are meant to be PID values (or if negative, pointing to a previous record). If NOT new, then the table/ids are just pointing to an existing record!
  * @return	void
  * @see renderRecord()
  */
 function fetchRecord($table, $idList, $operation)
 {
     global $TCA;
     if ((string) $idList == 'prev') {
         $idList = $this->prevPageID;
     }
     if ($TCA[$table]) {
         t3lib_div::loadTCA($table);
         // For each ID value (integer) we
         $ids = t3lib_div::trimExplode(',', $idList, 1);
         foreach ($ids as $id) {
             if (strcmp($id, '')) {
                 // If ID is not blank:
                 // For new records to be created, find default values:
                 if ($operation == 'new') {
                     // Default values:
                     $newRow = array();
                     // Used to store default values as found here:
                     // Default values as set in userTS:
                     $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
                     if (is_array($TCAdefaultOverride[$table . '.'])) {
                         foreach ($TCAdefaultOverride[$table . '.'] as $theF => $theV) {
                             if (isset($TCA[$table]['columns'][$theF])) {
                                 $newRow[$theF] = $theV;
                             }
                         }
                     }
                     if ($id < 0) {
                         $record = t3lib_beFunc::getRecord($table, abs($id), 'pid');
                         $pid = $record['pid'];
                         unset($record);
                     } else {
                         $pid = intval($id);
                     }
                     $pageTS = t3lib_beFunc::getPagesTSconfig($pid);
                     if (isset($pageTS['TCAdefaults.'])) {
                         $TCAPageTSOverride = $pageTS['TCAdefaults.'];
                         if (is_array($TCAPageTSOverride[$table . '.'])) {
                             foreach ($TCAPageTSOverride[$table . '.'] as $theF => $theV) {
                                 if (isset($TCA[$table]['columns'][$theF])) {
                                     $newRow[$theF] = $theV;
                                 }
                             }
                         }
                     }
                     // Default values as submitted:
                     if (is_array($this->defVals[$table])) {
                         foreach ($this->defVals[$table] as $theF => $theV) {
                             if (isset($TCA[$table]['columns'][$theF])) {
                                 $newRow[$theF] = $theV;
                             }
                         }
                     }
                     // Fetch default values if a previous record exists
                     if ($id < 0 && $TCA[$table]['ctrl']['useColumnsForDefaultValues']) {
                         // Fetches the previous record:
                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid=' . abs($id) . t3lib_BEfunc::deleteClause($table));
                         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                             // Gets the list of fields to copy from the previous record.
                             $fArr = t3lib_div::trimExplode(',', $TCA[$table]['ctrl']['useColumnsForDefaultValues'], 1);
                             foreach ($fArr as $theF) {
                                 if (isset($TCA[$table]['columns'][$theF])) {
                                     $newRow[$theF] = $row[$theF];
                                 }
                             }
                         }
                         $GLOBALS['TYPO3_DB']->sql_free_result($res);
                     }
                     // Finally, call renderRecord:
                     $this->renderRecord($table, uniqid('NEW'), $id, $newRow);
                 } else {
                     $id = intval($id);
                     // Fetch database values
                     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'uid=' . intval($id) . t3lib_BEfunc::deleteClause($table));
                     if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                         t3lib_BEfunc::fixVersioningPid($table, $row);
                         $this->renderRecord($table, $id, $row['pid'], $row);
                         $contentTable = $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'];
                         $this->lockRecord($table, $id, $contentTable == $table ? $row['pid'] : 0);
                         // Locking the pid if the table edited is the content table.
                     }
                     $GLOBALS['TYPO3_DB']->sql_free_result($res);
                 }
             }
         }
     }
 }
Esempio n. 8
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));
     }
 }
 /**
  * Finds the currently selected template object by climbing up the root line.
  *
  * @param	array		$row: A page record
  * @return	mixed		The template object record or FALSE if none was found
  * @access	protected
  */
 function getContentTree_fetchPageTemplateObject($row)
 {
     $templateObjectUid = $row['tx_templavoila_ds'] ? intval($row['tx_templavoila_to']) : 0;
     if (!$templateObjectUid) {
         $rootLine = t3lib_beFunc::BEgetRootLine($row['uid'], '', TRUE);
         foreach ($rootLine as $rootLineRecord) {
             $pageRecord = t3lib_beFunc::getRecord('pages', $rootLineRecord['uid']);
             if ($row['uid'] != $pageRecord['uid'] && $pageRecord['tx_templavoila_next_ds'] && $pageRecord['tx_templavoila_next_to']) {
                 // If there is a next-level TO:
                 $templateObjectUid = $pageRecord['tx_templavoila_next_to'];
                 break;
             } elseif ($pageRecord['tx_templavoila_ds'] && $pageRecord['tx_templavoila_to']) {
                 // Otherwise try the NORMAL TO:
                 $templateObjectUid = $pageRecord['tx_templavoila_to'];
                 break;
             }
         }
     }
     return t3lib_beFunc::getRecordWSOL('tx_templavoila_tmplobj', $templateObjectUid);
 }
Esempio n. 10
0
	/**
	 * Get the processed value analog to t3lib_beFunc::getProcessedValue
	 * but take additional TSconfig values into account
	 *
	 * @param  $table
	 * @param  $typeField
	 * @param  $typeValue
	 * @return
	 */
	protected function getProcessedValue($table, $typeField, $typeValue) {
		$value =  t3lib_beFunc::getProcessedValue($table, $typeField, $typeValue);
		if (!$value) {
			$TSConfig = t3lib_beFunc::getPagesTSconfig($this->id);
			if (isset($TSConfig['TCEFORM.'][$table . '.'][$typeField . '.']['addItems.'][$typeValue])) {
				$value = $TSConfig['TCEFORM.'][$table . '.'][$typeField . '.']['addItems.'][$typeValue];
			}
		}

		return $value;
	}
Esempio n. 11
0
 /**
  * Returns the uid of the TemplaVoila page template for the given page uid
  *
  * @param $pageUid
  * @return int
  */
 public function getTvPageTemplateUid($pageUid)
 {
     $pageRecord = $this->getPage($pageUid);
     $tvTemplateObjectUid = 0;
     if ($pageRecord['tx_templavoila_to'] != '' && $pageRecord['tx_templavoila_to'] != 0) {
         $tvTemplateObjectUid = $pageRecord['tx_templavoila_to'];
     } else {
         $rootLine = t3lib_beFunc::BEgetRootLine($pageRecord['uid'], '', TRUE);
         foreach ($rootLine as $rootLineRecord) {
             $myPageRecord = t3lib_beFunc::getRecordWSOL('pages', $rootLineRecord['uid']);
             if ($myPageRecord['tx_templavoila_next_to']) {
                 $tvTemplateObjectUid = $myPageRecord['tx_templavoila_next_to'];
                 break;
             }
         }
     }
     return $tvTemplateObjectUid;
 }
    /**
     * Displays the edit page screen if the currently selected page is of the doktype "Mount Point"
     *
     * @param	array		$pageRecord: The current page record
     * @return	mixed		HTML output from this submodule or FALSE if this submodule doesn't feel responsible
     * @access	protected
     */
    function renderDoktype_7($pageRecord)
    {
        global $LANG, $BE_USER, $TYPO3_CONF_VARS;
        if (!$pageRecord['mount_pid_ol']) {
            return FALSE;
        }
        // Put together the records icon including content sensitive menu link wrapped around it:
        $recordIcon = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageRecord);
        $recordIcon = $this->doc->wrapClickMenuOnIcon($recordIcon, 'pages', $this->id, 1, '&amp;callingScriptId=' . rawurlencode($this->doc->scriptID));
        $iconEdit = t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title' => htmlspecialchars($LANG->sL('LLL:EXT:lang/locallang_mod_web_list.xml:editPage'))));
        $editButton = $this->pObj->link_edit($iconEdit, 'pages', $pageRecord['uid']);
        $mountSourcePageRecord = t3lib_beFunc::getRecordWSOL('pages', $pageRecord['mount_pid']);
        $mountSourceIcon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mountSourcePageRecord);
        $mountSourceButton = $this->doc->wrapClickMenuOnIcon($mountSourceIcon, 'pages', $mountSourcePageRecord['uid'], 1, '&callingScriptId=' . rawurlencode($this->doc->scriptID), 'new,copy,cut,pasteinto,pasteafter,delete');
        $mountSourceLink = '<br /><br />
			<a href="index.php?id=' . $pageRecord['mount_pid'] . '">' . htmlspecialchars($LANG->getLL('jumptomountsourcepage')) . '</a>
		';
        $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($LANG->getLL('cannotedit_doktypemountpoint'), $mountSourceButton . $mountSourcePageRecord['title']), '', t3lib_FlashMessage::INFO);
        $content = $flashMessage->render() . '<strong>' . $mountSourceLink . '</strong>';
        return $content;
    }
    /**
     * Creates the listing of records from a single table
     *
     * @param string $table Table name
     * @param integer $id Page id
     * @param string $rowlist List of fields to show in the listing. Pseudo fields will be added including the record header.
     * @return string HTML table with the listing for the record.
     * @todo Define visibility
     */
    public function getTable($table, $id, $rowlist)
    {
        // Loading all TCA details for this table:
        \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table);
        // Init
        $addWhere = '';
        $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
        $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
        $l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'];
        $tableCollapsed = !$this->tablesCollapsed[$table] ? FALSE : TRUE;
        // prepare space icon
        $this->spaceIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('empty-empty', array('style' => 'background-position: 0 10px;'));
        // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
        $this->fieldArray = array();
        // title Column
        // Add title column
        $this->fieldArray[] = $titleCol;
        // Control-Panel
        if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($rowlist, '_CONTROL_')) {
            $this->fieldArray[] = '_CONTROL_';
            $this->fieldArray[] = '_AFTERCONTROL_';
        }
        // Clipboard
        if ($this->showClipboard) {
            $this->fieldArray[] = '_CLIPBOARD_';
        }
        // Ref
        if (!$this->dontShowClipControlPanels) {
            $this->fieldArray[] = '_REF_';
            $this->fieldArray[] = '_AFTERREF_';
        }
        // Path
        if ($this->searchLevels) {
            $this->fieldArray[] = '_PATH_';
        }
        // Localization
        if ($this->localizationView && $l10nEnabled) {
            $this->fieldArray[] = '_LOCALIZATION_';
            $this->fieldArray[] = '_LOCALIZATION_b';
            $addWhere .= ' AND (
				' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '<=0
				OR
				' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . ' = 0
			)';
        }
        // Cleaning up:
        $this->fieldArray = array_unique(array_merge($this->fieldArray, \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $rowlist, 1)));
        if ($this->noControlPanels) {
            $tempArray = array_flip($this->fieldArray);
            unset($tempArray['_CONTROL_']);
            unset($tempArray['_CLIPBOARD_']);
            $this->fieldArray = array_keys($tempArray);
        }
        // Creating the list of fields to include in the SQL query:
        $selectFields = $this->fieldArray;
        $selectFields[] = 'uid';
        $selectFields[] = 'pid';
        // adding column for thumbnails
        if ($thumbsCol) {
            $selectFields[] = $thumbsCol;
        }
        if ($table == 'pages') {
            if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
                $selectFields[] = 'module';
                $selectFields[] = 'extendToSubpages';
                $selectFields[] = 'nav_hide';
            }
            $selectFields[] = 'doktype';
        }
        if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
            $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['type']) {
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['type'];
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['typeicon_column']) {
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column'];
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
            $selectFields[] = 't3ver_id';
            $selectFields[] = 't3ver_state';
            $selectFields[] = 't3ver_wsid';
        }
        if ($l10nEnabled) {
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
            $selectFields = array_merge($selectFields, \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], 1));
        }
        // Unique list!
        $selectFields = array_unique($selectFields);
        $fieldListFields = $this->makeFieldList($table, 1);
        if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
            $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.php:missingTcaColumnsMessage', TRUE), $table, $table);
            $messageTitle = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.php:missingTcaColumnsMessageTitle', TRUE);
            $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $message, $messageTitle, \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, TRUE);
            /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
            \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($flashMessage);
        }
        // Making sure that the fields in the field-list ARE in the field-list from TCA!
        $selectFields = array_intersect($selectFields, $fieldListFields);
        // Implode it into a list of fields for the SQL-statement.
        $selFieldList = implode(',', $selectFields);
        $this->selFieldList = $selFieldList;
        /**
         * @hook DB-List getTable
         * @date 2007-11-16
         * @request Malte Jansen <*****@*****.**>
         */
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
                $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classData);
                if (!$hookObject instanceof \TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface) {
                    throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Backend\\RecordList\\RecordListGetTableHookInterface', 1195114460);
                }
                $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
            }
        }
        // Create the SQL query for selecting the elements in the listing:
        // do not do paging when outputting as CSV
        if ($this->csvOutput) {
            $this->iLimit = 0;
        }
        if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
            // Get the two previous rows for sorting if displaying page > 1
            $this->firstElementNumber = $this->firstElementNumber - 2;
            $this->iLimit = $this->iLimit + 2;
            // (API function from class.db_list.inc)
            $queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
            $this->firstElementNumber = $this->firstElementNumber + 2;
            $this->iLimit = $this->iLimit - 2;
        } else {
            // (API function from class.db_list.inc)
            $queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
        }
        // Finding the total amount of records on the page (API function from class.db_list.inc)
        $this->setTotalItems($queryParts);
        // Init:
        $dbCount = 0;
        $out = '';
        $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
        // If the count query returned any number of records, we perform the real query, selecting records.
        if ($this->totalItems) {
            // Fetch records only if not in single table mode or if in multi table mode and not collapsed
            if ($listOnlyInSingleTableMode || !$this->table && $tableCollapsed) {
                $dbCount = $this->totalItems;
            } else {
                // Set the showLimit to the number of records when outputting as CSV
                if ($this->csvOutput) {
                    $this->showLimit = $this->totalItems;
                    $this->iLimit = $this->totalItems;
                }
                $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
                $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
            }
        }
        // If any records was selected, render the list:
        if ($dbCount) {
            // Half line is drawn between tables:
            if (!$listOnlyInSingleTableMode) {
                $theData = array();
                if (!$this->table && !$rowlist) {
                    $theData[$titleCol] = '<img src="clear.gif" width="' . ($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel'] ? '230' : '350') . '" height="1" alt="" />';
                    if (in_array('_CONTROL_', $this->fieldArray)) {
                        $theData['_CONTROL_'] = '';
                    }
                    if (in_array('_CLIPBOARD_', $this->fieldArray)) {
                        $theData['_CLIPBOARD_'] = '';
                    }
                }
                $out .= $this->addelement(0, '', $theData, 'class="c-table-row-spacer"', $this->leftMargin);
            }
            $tableTitle = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE);
            if ($tableTitle === '') {
                $tableTitle = $table;
            }
            // Header line is drawn
            $theData = array();
            if ($this->disableSingleTableView) {
                $theData[$titleCol] = '<span class="c-table">' . \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp($table, '', $tableTitle) . '</span> (' . $this->totalItems . ')';
            } else {
                $theData[$titleCol] = $this->linkWrapTable($table, '<span class="c-table">' . $tableTitle . '</span> (' . $this->totalItems . ') ' . ($this->table ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-table-collapse', array('title' => $GLOBALS['LANG']->getLL('contractView', TRUE))) : \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-table-expand', array('title' => $GLOBALS['LANG']->getLL('expandView', TRUE)))));
            }
            if ($listOnlyInSingleTableMode) {
                $out .= '
					<tr>
						<td class="t3-row-header" style="width:95%;">' . \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp($table, '', $theData[$titleCol]) . '</td>
					</tr>';
            } else {
                // Render collapse button if in multi table mode
                $collapseIcon = '';
                if (!$this->table) {
                    $collapseIcon = '<a href="' . htmlspecialchars($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1')) . '" title="' . ($tableCollapsed ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.expandTable', TRUE) : $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.collapseTable', TRUE)) . '">' . ($tableCollapsed ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-list-expand', array('class' => 'collapseIcon')) : \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-list-collapse', array('class' => 'collapseIcon'))) . '</a>';
                }
                $out .= $this->addElement(1, $collapseIcon, $theData, ' class="t3-row-header"', '');
            }
            // Render table rows only if in multi table view and not collapsed or if in single table view
            if (!$listOnlyInSingleTableMode && (!$tableCollapsed || $this->table)) {
                // Fixing a order table for sortby tables
                $this->currentTable = array();
                $currentIdList = array();
                $doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField;
                $prevUid = 0;
                $prevPrevUid = 0;
                // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
                if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
                    $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
                    $prevPrevUid = -(int) $row['uid'];
                    $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
                    $prevUid = $row['uid'];
                }
                $accRows = array();
                // Accumulate rows here
                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                    if (!$this->isRowListingConditionFulfilled($table, $row)) {
                        continue;
                    }
                    // In offline workspace, look for alternative record:
                    \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace, TRUE);
                    if (is_array($row)) {
                        $accRows[] = $row;
                        $currentIdList[] = $row['uid'];
                        if ($doSort) {
                            if ($prevUid) {
                                $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
                                $this->currentTable['next'][$prevUid] = '-' . $row['uid'];
                                $this->currentTable['prevUid'][$row['uid']] = $prevUid;
                            }
                            $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
                            $prevUid = $row['uid'];
                        }
                    }
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($result);
                $this->totalRowCount = count($accRows);
                // CSV initiated
                if ($this->csvOutput) {
                    $this->initCSV();
                }
                // Render items:
                $this->CBnames = array();
                $this->duplicateStack = array();
                $this->eCounter = $this->firstElementNumber;
                $iOut = '';
                $cc = 0;
                foreach ($accRows as $row) {
                    // Render item row if counter < limit
                    if ($cc < $this->iLimit) {
                        $cc++;
                        $this->translations = FALSE;
                        $iOut .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
                        // If localization view is enabled it means that the selected records are
                        // either default or All language and here we will not select translations
                        // which point to the main record:
                        if ($this->localizationView && $l10nEnabled) {
                            // For each available translation, render the record:
                            if (is_array($this->translations)) {
                                foreach ($this->translations as $lRow) {
                                    // $lRow isn't always what we want - if record was moved we've to work with the
                                    // placeholder records otherwise the list is messed up a bit
                                    if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
                                        $tmpRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw($table, 't3ver_move_id="' . intval($lRow['uid']) . '" AND pid="' . $row['_MOVE_PLH_pid'] . '" AND t3ver_wsid=' . $row['t3ver_wsid'] . \t3lib_beFunc::deleteClause($table), $selFieldList);
                                        $lRow = is_array($tmpRow) ? $tmpRow : $lRow;
                                    }
                                    // In offline workspace, look for alternative record:
                                    \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL($table, $lRow, $GLOBALS['BE_USER']->workspace, TRUE);
                                    if (is_array($lRow) && $GLOBALS['BE_USER']->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
                                        $currentIdList[] = $lRow['uid'];
                                        $iOut .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
                                    }
                                }
                            }
                        }
                    }
                    // Counter of total rows incremented:
                    $this->eCounter++;
                }
                // Record navigation is added to the beginning and end of the table if in single table mode
                if ($this->table) {
                    $iOut = $this->renderListNavigation('top') . $iOut . $this->renderListNavigation('bottom');
                } else {
                    // Show that there are more records than shown
                    if ($this->totalItems > $this->itemsLimitPerTable) {
                        $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
                        $hasMore = $this->totalItems > $this->itemsLimitSingleTable;
                        $iOut .= '<tr><td colspan="' . count($this->fieldArray) . '" style="padding:5px;">
								<a href="' . htmlspecialchars($this->listURL() . '&table=' . rawurlencode($table)) . '">' . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->backPath, 'gfx/pildown.gif', 'width="14" height="14"') . ' alt="" />' . ' <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
								</td></tr>';
                    }
                }
                // The header row for the table is now created:
                $out .= $this->renderListHeader($table, $currentIdList);
            }
            // The list of records is added after the header:
            $out .= $iOut;
            unset($iOut);
            // ... and it is all wrapped in a table:
            $out = '



			<!--
				DB listing of elements:	"' . htmlspecialchars($table) . '"
			-->
				<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist' . ($listOnlyInSingleTableMode ? ' typo3-dblist-overview' : '') . '">
					' . $out . '
				</table>';
            // Output csv if...
            // This ends the page with exit.
            if ($this->csvOutput) {
                $this->outputCSV($table);
            }
        }
        // Return content:
        return $out;
    }
Esempio n. 14
0
 /**
  * Determines the corrected pid to be used for a new record.
  * The pid to be used can be defined by a Page TSconfig.
  *
  * @param string $table The table name
  * @param integer $parentPid The pid of the parent record
  * @return integer The corrected pid to be used for a new record
  */
 protected function getNewRecordPid($table, $parentPid = NULL)
 {
     $newRecordPid = $this->inlineFirstPid;
     $pageTS = \t3lib_beFunc::getPagesTSconfig($parentPid, TRUE);
     if (isset($pageTS['TCAdefaults.'][$table . '.']['pid']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($pageTS['TCAdefaults.'][$table . '.']['pid'])) {
         $newRecordPid = $pageTS['TCAdefaults.'][$table . '.']['pid'];
     } elseif (isset($parentPid) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($parentPid)) {
         $newRecordPid = $parentPid;
     }
     return $newRecordPid;
 }
 /**
  * Get user Settings
  */
 public function getUserSettings()
 {
     $userSettings = t3lib_beFunc::getModTSconfig(0, 'mod.tools_em');
     return $userSettings['properties'];
 }
	/**
	 * This method is called by a hook in the TYPO3 Core Engine (TCEmain).
	 *
	 * @param	string		$status: The TCEmain operation status, fx. 'update'
	 * @param	string		$table: The table TCEmain is currently processing
	 * @param	string		$id: The records id (if any)
	 * @param	array		$fieldArray: The field names and their values to be processed
	 * @param	object		$reference: Reference to the parent object (TCEmain)
	 * @return	void
	 * @access	public
	 * @todo	"delete" should search for all references to the element.
	 */
	function processCmdmap_preProcess (&$command, $table, $id, $value, &$reference) {

		if ($this->debug) t3lib_div::devLog('processCmdmap_preProcess', 'templavoila', 0, array ($command, $table, $id, $value));
		if ($GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['tx_templavoila_api']['apiIsRunningTCEmain']) return;
		if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tx_templavoila_tcemain']['doNotInsertElementRefsToPage'])) {
			$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tx_templavoila_tcemain']['doNotInsertElementRefsToPage']++;
		}
		else {
			$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tx_templavoila_tcemain']['doNotInsertElementRefsToPage'] = 1;
		}

		if ($table != 'tt_content') return;

		$templaVoilaAPI = t3lib_div::makeInstance('tx_templavoila_api');

		switch ($command) {
			case 'delete' :
				$record = t3lib_beFunc::getRecord('tt_content', $id);
					// Check for FCE access
				$params = array(
					'table' => $table,
					'row' => $record,
				);
				$ref = null;
				if (!t3lib_div::callUserFunction('EXT:templavoila/class.tx_templavoila_access.php:&tx_templavoila_access->recordEditAccessInternals', $params, $ref)) {
					$reference->newlog(sprintf($GLOBALS['LANG']->getLL($status != 'new' ? 'access_noModifyAccess' : 'access_noCrateAccess'), $table, $id), 1);
					$command = '';	// Do not delete! A hack but there is no other way to prevent deletion...
				}
				else {
					if (intval($record['t3ver_oid']) > 0 && $record['pid'] == -1) {
							// we unlink a offline version in a workspace
						if (abs($record['t3ver_wsid']) !== 0) {
							$record = t3lib_BEfunc::getRecord('tt_content', intval($record['t3ver_oid']));
						}
					}
						// avoid that deleting offline version in the live workspace unlinks the online version - see #11359 
					if ($record['uid'] && $record['pid']) {
						$sourceFlexformPointersArr = $templaVoilaAPI->flexform_getPointersByRecord($record['uid'], $record['pid']);
						$sourceFlexformPointer = $sourceFlexformPointersArr[0];
						$templaVoilaAPI->unlinkElement($sourceFlexformPointer);
					}
				}
				break;
			case 'copy':
				unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tx_templavoila_tcemain']['doNotInsertElementRefsToPage']);
				break;
		}
		if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tx_templavoila_tcemain']['doNotInsertElementRefsToPage'])) {
			$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tx_templavoila_tcemain']['doNotInsertElementRefsToPage']--;
		}
	}
    /**
     * Displays the edit page screen if the currently selected page is of the doktype "Mount Point"
     *
     * @param	array		$pageRecord: The current page record
     * @return	mixed		HTML output from this submodule or FALSE if this submodule doesn't feel responsible
     * @access	protected
     */
    function renderDoktype_7($pageRecord)
    {
        global $LANG, $BE_USER, $TYPO3_CONF_VARS;
        if (!$pageRecord['mount_pid_ol']) {
            return FALSE;
        }
        // Put together the records icon including content sensitive menu link wrapped around it:
        $recordIcon = '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/i/pages_mountpoint.gif', '') . ' style="text-align: center; vertical-align: middle;" width="18" height="16" border="0" title="' . htmlspecialchars('[pages]') . '" alt="" />';
        $recordIcon = $this->doc->wrapClickMenuOnIcon($recordIcon, 'pages', $this->id, 1, '&amp;callingScriptId=' . rawurlencode($this->doc->scriptID));
        $editButton = $this->pObj->link_edit('<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/edit2.gif', '') . ' title="' . htmlspecialchars($LANG->sL('LLL:EXT:lang/locallang_mod_web_list.xml:editPage')) . '" alt="" style="text-align: center; vertical-align: middle; border:0;" />', 'pages', $pageRecord['uid']);
        $mountSourcePageRecord = t3lib_beFunc::getRecordWSOL('pages', $pageRecord['mount_pid']);
        $mountSourceIcon = '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, t3lib_iconWorks::getIcon('pages', $mountSourcePageRecord), '') . ' style="text-align: center; vertical-align: middle;" width="18" height="16" border="0" title="' . $mountSourcePageRecord['title'] . '" alt="" />';
        $mountSourceButton = $this->doc->wrapClickMenuOnIcon($mountSourceIcon, 'pages', $mountSourcePageRecord['uid'], 1, '&callingScriptId=' . rawurlencode($this->doc->scriptID), 'new,copy,cut,pasteinto,pasteafter,delete');
        $mountSourceLink = '<br /><br />
			<a href="index.php?id=' . $pageRecord['mount_pid'] . '">' . htmlspecialchars($LANG->getLL('jumptomountsourcepage')) . '</a>
		';
        $content = $this->doc->icons(1) . htmlspecialchars(sprintf($LANG->getLL('cannotedit_doktypemountpoint'), $mountSourcePageRecord['title'])) . $mountSourceButton . '<strong>' . $mountSourceLink . '</strong>
		';
        return $content;
    }
Esempio n. 18
0
 /**
  * Main function, adding items to the click menu array.
  *
  * @param	object		Reference to the parent object of the clickmenu class which calls this function
  * @param	array		The current array of menu items - you have to add or remove items to this array in this function. Thats the point...
  * @param	string		The database table OR filename
  * @param	integer		For database tables, the UID
  * @return	array		The modified menu array.
  */
 function main(&$backRef, $menuItems, $table, $uid)
 {
     global $BE_USER, $LANG, $TYPO3_DB;
     $localItems = array();
     if (!$backRef->cmLevel) {
         $LL = $LANG->includeLLFile(t3lib_extMgm::extPath('templavoila') . 'locallang.xml', 0);
         // Adding link for Mapping tool:
         if (@is_file($table)) {
             if ($BE_USER->isAdmin()) {
                 if (function_exists('finfo_open')) {
                     $finfoMode = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
                     $fi = finfo_open($finfoMode);
                     $mimeInformation = @finfo_file($fi, $table);
                     $enabled = FALSE;
                     if (t3lib_div::isFirstPartOfStr($mimeInformation, 'text/html') || t3lib_div::isFirstPartOfStr($mimeInformation, 'application/xml')) {
                         $enabled = TRUE;
                     }
                     finfo_close($fi);
                 } else {
                     $pi = @pathinfo($table);
                     $enabled = preg_match('/(html?|tmpl|xml)/', $pi['extension']);
                 }
                 if ($enabled) {
                     $url = t3lib_extMgm::extRelPath('templavoila') . 'cm1/index.php?file=' . rawurlencode($table);
                     $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_title', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
                 }
             }
         } elseif (t3lib_div::inList('tx_templavoila_tmplobj,tx_templavoila_datastructure,tx_templavoila_content', $table)) {
             $url = t3lib_extMgm::extRelPath('templavoila') . 'cm1/index.php?table=' . rawurlencode($table) . '&uid=' . $uid . '&_reload_from=1';
             $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_title', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
         }
         $isTVelement = ('tt_content' == $table && $backRef->rec['CType'] == 'templavoila_pi1' || 'pages' == $table) && $backRef->rec['tx_templavoila_flex'];
         // Adding link for "View: Sub elements":
         if ($table == 'tt_content' && $isTVelement) {
             $localItems = array();
             $url = t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?id=' . intval($backRef->rec['pid']) . '&altRoot[table]=' . rawurlencode($table) . '&altRoot[uid]=' . $uid . '&altRoot[field_flex]=tx_templavoila_flex';
             $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_viewsubelements', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
         }
         // Adding link for "View: Flexform XML" (admin only):
         if ($BE_USER->isAdmin() && $isTVelement) {
             $url = t3lib_extMgm::extRelPath('templavoila') . 'cm2/index.php?' . '&viewRec[table]=' . rawurlencode($table) . '&viewRec[uid]=' . $uid . '&viewRec[field_flex]=tx_templavoila_flex';
             $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_viewflexformxml', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm2/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
         }
         // Adding link for "View: DS/TO" (admin only):
         if ($BE_USER->isAdmin() && $isTVelement) {
             if (tx_templavoila_div::canBeInterpretedAsInteger($backRef->rec['tx_templavoila_ds'])) {
                 $url = t3lib_extMgm::extRelPath('templavoila') . 'cm1/index.php?' . 'table=tx_templavoila_datastructure&uid=' . $backRef->rec['tx_templavoila_ds'];
                 $localItems[] = $backRef->linkItem($LANG->getLLL('cm_viewdsto', $LL, 1) . ' [' . $backRef->rec['tx_templavoila_ds'] . '/' . $backRef->rec['tx_templavoila_to'] . ']', $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm2/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
             }
         }
         #			if ($table=='tt_content') {
         #					// Adding link for "Pages using this element":
         #				$localItems[] = $backRef->linkItem(
         #					$LANG->getLLL('cm1_pagesusingthiselement',$LL),
         #					$backRef->excludeIcon('<img src="'.t3lib_extMgm::extRelPath('templavoila').'cm1/cm_icon_activate.gif" width="15" height="12" border=0 align=top>'),
         #					"top.loadTopMenu('".t3lib_div::linkThisScript()."&cmLevel=1&subname=tx_templavoila_cm1_pagesusingthiselement');return false;",
         #					0,
         #					1
         #				);
         #			}
     } else {
         if (t3lib_div::_GP('subname') == 'tx_templavoila_cm1_pagesusingthiselement') {
             $menuItems = array();
             $url = t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?id=';
             // Generate a list of pages where this element is also being used:
             $res = $TYPO3_DB->exec_SELECTquery('*', 'tx_templavoila_elementreferences', 'uid=' . $backRef->rec['uid']);
             if ($res) {
                 while (false != ($referenceRecord = $TYPO3_DB->sql_fetch_assoc($res))) {
                     $pageRecord = t3lib_beFunc::getRecord('pages', $referenceRecord['pid']);
                     $icon = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageRecord);
                     // To do: Display language flag icon and jump to correct language
                     #						if ($referenceRecord['lkey'] != 'lDEF') {
                     #							$icon .= ' lKey:'.$referenceRecord['lkey'];
                     #						} elseif ($referenceRecord['vkey'] != 'vDEF') {
                     #							$icon .= ' vKey:'.$referenceRecord['vkey'];
                     #						}
                     if (is_array($pageRecord)) {
                         $menuItems[] = $backRef->linkItem($icon, t3lib_beFunc::getRecordTitle('pages', $pageRecord, 1), $backRef->urlRefForCM($url . $pageRecord['uid'], 'returnUrl'), 1);
                     }
                 }
             }
         }
     }
     // Simply merges the two arrays together and returns ...
     if (count($localItems)) {
         $menuItems = array_merge($menuItems, $localItems);
     }
     return $menuItems;
 }
 public function test_tcemain_moveUp_bug2154()
 {
     global $TYPO3_DB, $BE_USER;
     $BE_USER->setWorkspace(0);
     $tce = t3lib_div::makeInstance('t3lib_TCEmain');
     $tce->stripslashes_values = 0;
     $this->fixture_createTestPage();
     $this->fixture_createTestPageDSTO('twocolumns');
     // Create 3 new content elements in the main area and 3 in the right bar:
     $elementUids = array();
     for ($i = 0; $i < 3; $i++) {
         $row = $this->fixture_getContentElementRow_TEXT();
         $row['bodytext'] = 'move test element #' . ($i + 1);
         $destinationPointer = array('table' => 'pages', 'uid' => $this->testPageUID, 'sheet' => 'sDEF', 'sLang' => 'lDEF', 'field' => 'field_content', 'vLang' => 'vDEF', 'position' => $i);
         $elementUids[$i + 1] = $this->apiObj->insertElement($destinationPointer, $row);
     }
     for ($i = 3; $i < 6; $i++) {
         $row = $this->fixture_getContentElementRow_TEXT();
         $row['bodytext'] = 'move test element (right bar) #' . ($i + 1);
         $destinationPointer = array('table' => 'pages', 'uid' => $this->testPageUID, 'sheet' => 'sDEF', 'sLang' => 'lDEF', 'field' => 'field_rightbar', 'vLang' => 'vDEF', 'position' => $i - 3);
         $elementUids[$i + 1] = $this->apiObj->insertElement($destinationPointer, $row);
     }
     // Main area: move the third element to after the first element via TCEmain:
     $cmdMap = array('tt_content' => array($elementUids[3] => array('move' => '-' . $elementUids[1])));
     $tce->start(array(), $cmdMap);
     $tce->process_cmdmap();
     // ... and then move it one more up (exposes the bug 2154):
     $cmdMap = array('tt_content' => array($elementUids[3] => array('move' => '-' . $elementUids[1])));
     $tce->start(array(), $cmdMap);
     $tce->process_cmdmap();
     // Check if the elements are in the right columns in the right order:
     $testPageRecord = t3lib_beFunc::getRecordRaw('pages', 'uid=' . $this->testPageUID, 'tx_templavoila_flex');
     $flexform = simplexml_load_string($testPageRecord['tx_templavoila_flex']);
     $fieldContent_xpathResArr = $flexform->xpath("//data/sheet[@index='sDEF']/language[@index='lDEF']/field[@index='field_content']/value[@index='vDEF']");
     $fieldRightBar_xpathResArr = $flexform->xpath("//data/sheet[@index='sDEF']/language[@index='lDEF']/field[@index='field_rightbar']/value[@index='vDEF']");
     $everythingIsFine = (string) $fieldContent_xpathResArr[0] === $elementUids[3] . ',' . $elementUids[1] . ',' . $elementUids[2] && (string) $fieldRightBar_xpathResArr[0] === $elementUids[4] . ',' . $elementUids[5] . ',' . $elementUids[6];
     self::assertTrue($everythingIsFine, 'The reference list is not as expected after moving the third element up two times in the left column!');
     // ... and then move the now second element one up again, measured by the sorting field! (also exposes the bug 2154):
     $elementsBySortingFieldArr = $TYPO3_DB->exec_SELECTgetRows('uid', 'tt_content', 'pid=' . intval($this->testPageUID), '', 'sorting');
     $positionOfElement1 = NULL;
     foreach ($elementsBySortingFieldArr as $index => $row) {
         if ($elementUids[1] == $row['uid']) {
             $positionOfElement1 = $index;
         }
     }
     $cmdMap = array('tt_content' => array($elementUids[1] => array('move' => '-' . $elementsBySortingFieldArr[$positionOfElement1 - 1]['uid'])));
     $tce->start(array(), $cmdMap);
     $tce->process_cmdmap();
     // Check again if the elements are in the right columns in the right order:
     $testPageRecord = t3lib_beFunc::getRecordRaw('pages', 'uid=' . $this->testPageUID, 'tx_templavoila_flex');
     $flexform = simplexml_load_string($testPageRecord['tx_templavoila_flex']);
     $fieldContent_xpathResArr = $flexform->xpath("//data/sheet[@index='sDEF']/language[@index='lDEF']/field[@index='field_content']/value[@index='vDEF']");
     $fieldRightBar_xpathResArr = $flexform->xpath("//data/sheet[@index='sDEF']/language[@index='lDEF']/field[@index='field_rightbar']/value[@index='vDEF']");
     $everythingIsFine = (string) $fieldContent_xpathResArr[0] === $elementUids[1] . ',' . $elementUids[3] . ',' . $elementUids[2] && (string) $fieldRightBar_xpathResArr[0] === $elementUids[4] . ',' . $elementUids[5] . ',' . $elementUids[6];
     self::assertTrue($everythingIsFine, 'The reference list is not as expected after moving the second element up and choosing the destination by the sorting field!');
 }
Esempio n. 20
0
 /**
  * Remove all records which are not permitted for the user
  *
  * @param array $recs
  * @param string $table
  * @return array
  */
 protected function filterPermittedElements($recs, $table)
 {
     $checkField = $table == 'pages' ? 'uid' : 'wspid';
     $permittedElements = array();
     if (is_array($recs)) {
         foreach ($recs as $rec) {
             $page = t3lib_beFunc::getRecord('pages', $rec[$checkField], 'uid,pid,perms_userid,perms_user,perms_groupid,perms_group,perms_everybody');
             if ($GLOBALS['BE_USER']->doesUserHaveAccess($page, 1)) {
                 $permittedElements[] = $rec;
             }
         }
     }
     return $permittedElements;
 }
 /**
  * Determines the corrected pid to be used for a new record.
  * The pid to be used can be defined by a Page TSconfig.
  *
  * @param	string		$table: The table name
  * @param	integer		$parentPid: The pid of the parent record
  * @return	integer		The corrected pid to be used for a new record
  */
 protected function getNewRecordPid($table, $parentPid = null)
 {
     $newRecordPid = $this->inlineFirstPid;
     $pageTS = t3lib_beFunc::getPagesTSconfig($parentPid, true);
     if (isset($pageTS['TCAdefaults.'][$table . '.']['pid']) && t3lib_div::testInt($pageTS['TCAdefaults.'][$table . '.']['pid'])) {
         $newRecordPid = $pageTS['TCAdefaults.'][$table . '.']['pid'];
     } elseif (isset($parentPid) && t3lib_div::testInt($parentPid)) {
         $newRecordPid = $parentPid;
     }
     return $newRecordPid;
 }