/**
  * Liefert bereits selektierte Elemente.
  * @param 	tx_mklib_treelib_TreeView 	$oTreeView
  * @return 	array
  */
 private function getItemArray(&$oTreeView)
 {
     $itemArrayProcessed = array();
     foreach ($oTreeView->getItemArray() as $tk => $tv) {
         $tvP = explode('|', $tv, 2);
         $tvP[1] = rawurlencode($this->oTceForm->sL(rawurldecode($tvP[1])));
         $itemArrayProcessed[$tk] = implode('|', $tvP);
     }
     return $itemArrayProcessed;
 }
    /**
     * Creating form for editing the permissions	($this->edit = true)
     * (Adding content to internal content variable)
     *
     * @return	void
     */
    function doEdit()
    {
        global $BE_USER, $LANG;
        // get ACL configuration
        $beAclConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['be_acl']);
        if ($beAclConfig['disableOldPermissionSystem']) {
            $disableOldPermissionSystem = 1;
        } else {
            $disableOldPermissionSystem = 0;
        }
        $LANG->includeLLFile('EXT:be_acl/res/locallang_perm.php');
        // Get usernames and groupnames
        $be_group_Array = t3lib_BEfunc::getListGroupNames('title,uid');
        $groupArray = array_keys($be_group_Array);
        $be_user_Array = t3lib_BEfunc::getUserNames();
        if (!$GLOBALS['BE_USER']->isAdmin()) {
            $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array, $groupArray, 1);
        }
        $be_group_Array_o = $be_group_Array = t3lib_BEfunc::getGroupNames();
        if (!$GLOBALS['BE_USER']->isAdmin()) {
            $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array_o, $groupArray, 1);
        }
        $firstGroup = $groupArray[0] ? $be_group_Array[$groupArray[0]] : '';
        // data of the first group, the user is member of
        // set JavaScript
        $subPagesData = '';
        // generate list if record is available on subpages, if yes, enter the id
        $this->content .= '<script src="../../../' . t3lib_extMgm::extRelPath('be_acl') . 'res/acl.js" type="text/javascript">
			' . $subPagesData . '
		</script>';
        // Owner selector:
        $options = '';
        $userset = 0;
        // flag: is set if the page-userid equals one from the user-list
        foreach ($be_user_Array as $uid => $row) {
            if ($uid == $this->pageinfo['perms_userid']) {
                $userset = 1;
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
            $options .= '
				<option value="' . $uid . '"' . $selected . '>' . htmlspecialchars($row['username']) . '</option>';
        }
        $options = '
				<option value="0"></option>' . $options;
        // hide selector if not needed
        if ($disableOldPermissionSystem) {
            $hidden = ' style="display:none;" ';
        } else {
            $hidden = '';
        }
        $selector = '
			<select name="data[pages][' . $this->id . '][perms_userid]" ' . $hidden . '>
				' . $options . '
			</select>';
        if ($disableOldPermissionSystem) {
            $this->content .= $selector;
        } else {
            $this->content .= $this->doc->section($LANG->getLL('Owner') . ':', $selector);
        }
        // Group selector:
        $options = '';
        $userset = 0;
        foreach ($be_group_Array as $uid => $row) {
            if ($uid == $this->pageinfo['perms_groupid']) {
                $userset = 1;
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
            $options .= '
				<option value="' . $uid . '"' . $selected . '>' . htmlspecialchars($row['title']) . '</option>';
        }
        if (!$userset && $this->pageinfo['perms_groupid']) {
            // If the group was not set AND there is a group for the page
            $options = '
				<option value="' . $this->pageinfo['perms_groupid'] . '" selected="selected">' . htmlspecialchars($be_group_Array_o[$this->pageinfo['perms_groupid']]['title']) . '</option>' . $options;
        }
        $options = '
				<option value="0"></option>' . $options;
        $selector = '
			<select name="data[pages][' . $this->id . '][perms_groupid]"  ' . $hidden . '>
				' . $options . '
			</select>';
        if ($disableOldPermissionSystem) {
            $this->content .= $selector;
        } else {
            $this->content .= $this->doc->divider(5);
            $this->content .= $this->doc->section($LANG->getLL('Group') . ':', $selector);
        }
        // Permissions checkbox matrix:
        $code = '
		<input type="hidden" name="pageID" value="' . $this->id . '" />
			<table border="0" cellspacing="2" cellpadding="0" id="typo3-permissionMatrix"><tbody>
				<tr>
					<td></td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $LANG->getLL('1', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $LANG->getLL('16', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $LANG->getLL('2', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $LANG->getLL('4', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $LANG->getLL('8', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $LANG->getLL('recursiveAcl', 1)) . '</td>
					<td></td>
				</tr>';
        if (!$disableOldPermissionSystem) {
            $code .= '
				<tr>
					<td align="right" class="bgColor2">' . $LANG->getLL('Owner', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 5) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 2) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 3) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 4) . '</td>
					<td class="bgColor-20"></td>
					<td></td>
				</tr>
				<tr>
					<td align="right" class="bgColor2">' . $LANG->getLL('Group', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 5) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 2) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 3) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 4) . '</td>
					<td class="bgColor-20"></td>
					<td></td>
				</tr>
				<tr>
					<td align="right" class="bgColor2">' . $LANG->getLL('Everybody', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 5) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 2) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 3) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 4) . '</td>
					<td class="bgColor-20"></td>
					<td></td>
				</tr>';
        }
        // ACL CODE
        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_beacl_acl', 'pid=' . intval($this->id));
        while ($result = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
            $acl_prefix = 'data[tx_beacl_acl][' . $result['uid'] . ']';
            $code .= '<tr>
					<td align="right" class="bgColor2"><select name="' . $acl_prefix . '[type]" onChange="updateUserGroup(' . $result['uid'] . ')"><option value="0" ' . ($result['type'] ? '' : 'selected="selected"') . '>User</option><option value="1" ' . ($result['type'] ? 'selected="selected"' : '') . '>Group</option></select><select name="' . $acl_prefix . '[object_id]"></select></td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_acl_' . $result['uid'], 1, 'data[tx_beacl_acl][' . $result['uid'] . '][permissions]') . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_acl_' . $result['uid'], 5, 'data[tx_beacl_acl][' . $result['uid'] . '][permissions]') . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_acl_' . $result['uid'], 2, 'data[tx_beacl_acl][' . $result['uid'] . '][permissions]') . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_acl_' . $result['uid'], 3, 'data[tx_beacl_acl][' . $result['uid'] . '][permissions]') . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_acl_' . $result['uid'], 4, 'data[tx_beacl_acl][' . $result['uid'] . '][permissions]') . '
						<input type="hidden" name="' . $acl_prefix . '[permissions]" value="' . $result['permissions'] . '" />

						<script type="text/javascript">updateUserGroup(' . $result['uid'] . ', ' . $result['object_id'] . ');
						setCheck("check[perms_acl_' . $result['uid'] . ']","data[tx_beacl_acl][' . $result['uid'] . '][permissions]");
						global_currentACLs[global_currentACLs.length] = ' . $result['uid'] . ' ;
						</script>

					</td>
					<td class="bgColor-20">
						<input type="hidden" name="' . $acl_prefix . '[recursive]" value="0" />
						<input type="checkbox" name="' . $acl_prefix . '[recursive]" value="1" ' . ($result['recursive'] ? 'checked="checked"' : '') . ' />
					</td>
					<td><a href="#" onClick="deleteACL(' . $result['uid'] . ')"><img ' . t3lib_iconWorks::skinImg('../../../', 'gfx/garbage.gif') . ' alt="' . $LANG->getLL('delAcl', 1) . '" /></a></td>
				</tr>';
        }
        $code .= '
				</tbody>
			</table>
			<br />
			<span id="insertHiddenFields"></span>
			<img ' . t3lib_iconWorks::skinImg('../../../', 'gfx/garbage.gif') . ' alt="' . $LANG->getLL('delAcl', 1) . '" / id="templateDeleteImage" style="display:none">
			<a href="javascript:addACL()"><img  ' . t3lib_iconWorks::skinImg('../../../', 'gfx/new_el.gif') . ' alt="' . $LANG->getLL('addAcl', 1) . '" />' . $LANG->getLL('addAcl', 1) . '</a><br>

			<input type="hidden" name="data[pages][' . $this->id . '][perms_user]" value="' . $this->pageinfo['perms_user'] . '" />
			<input type="hidden" name="data[pages][' . $this->id . '][perms_group]" value="' . $this->pageinfo['perms_group'] . '" />
			<input type="hidden" name="data[pages][' . $this->id . '][perms_everybody]" value="' . $this->pageinfo['perms_everybody'] . '" />
			' . ($disableOldPermissionSystem ? '' : $this->getRecursiveSelect($this->id, $this->perms_clause)) . '
			<input type="submit" name="submit" value="' . $LANG->getLL('saveAndClose', 1) . '" />' . '<input type="submit" value="' . $LANG->getLL('Abort', 1) . '" onclick="' . htmlspecialchars('jumpToUrl(\'index.php?id=' . $this->id . '\'); return false') . '" />
			<input type="hidden" name="redirect" value="' . htmlspecialchars(TYPO3_MOD_PATH . 'index.php?mode=' . $this->MOD_SETTINGS['mode'] . '&depth=' . $this->MOD_SETTINGS['depth'] . '&id=' . intval($this->return_id) . '&lastEdited=' . $this->id) . '" />
		';
        if (t3lib_div::int_from_ver(TYPO3_version) >= 4005000) {
            $code .= t3lib_TCEforms::getHiddenTokenField('tceAction');
        }
        // only Typo3 V4.5 or later
        // Adding section with the permission setting matrix:
        $this->content .= $this->doc->divider(5);
        $this->content .= $this->doc->section($LANG->getLL('permissions') . ':', $code);
        // CSH for permissions setting
        $this->content .= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module_setting', $GLOBALS['BACK_PATH'], '<br/><br/>');
        // Adding help text:
        if ($BE_USER->uc['helpText']) {
            $this->content .= $this->doc->divider(20);
            $legendText = '<b>' . $LANG->getLL('1', 1) . '</b>: ' . $LANG->getLL('1_t', 1);
            $legendText .= '<br /><b>' . $LANG->getLL('16', 1) . '</b>: ' . $LANG->getLL('16_t', 1);
            $legendText .= '<br /><b>' . $LANG->getLL('2', 1) . '</b>: ' . $LANG->getLL('2_t', 1);
            $legendText .= '<br /><b>' . $LANG->getLL('4', 1) . '</b>: ' . $LANG->getLL('4_t', 1);
            $legendText .= '<br /><b>' . $LANG->getLL('8', 1) . '</b>: ' . $LANG->getLL('8_t', 1);
            $code = $legendText . '<br /><br />' . $LANG->getLL('def', 1);
            $this->content .= $this->doc->section($LANG->getLL('Legend', 1) . ':', $code);
        }
    }
Exemplo n.º 3
0
 function renderTree()
 {
     t3lib_div::loadTCA($this->fieldConfig['foreign_table']);
     $orderBy = $GLOBALS['TCA'][$this->fieldConfig['foreign_table']]['ctrl']['sortby'] ? $this->fieldConfig['foreign_table'] . '.' . $GLOBALS['TCA'][$this->fieldConfig['foreign_table']]['ctrl']['sortby'] : substr($GLOBALS['TCA'][$this->fieldConfig['foreign_table']]['ctrl']['default_sortby'], 9);
     $treeViewObj = t3lib_div::makeInstance('tx_cpstcatree_treeview');
     $treeViewObj->thisScript = 'class.tx_cpstcatree.php';
     $treeViewObj->title = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->fieldConfig['foreign_table']]['ctrl']['title']);
     $treeViewObj->treeName = $this->table . '_' . $this->field . '_tree';
     $treeViewObj->table = $this->fieldConfig['foreign_table'];
     // Set parent field of table
     if (isset($this->fieldConfig['treeViewParentField'])) {
         $this->parentField = $this->fieldConfig['treeViewParentField'];
     } else {
         $this->parentField = $GLOBALS['TCA'][$this->fieldConfig['foreign_table']]['ctrl']['treeParentField'];
     }
     if (!$this->parentField) {
         $this->parentField = 'pid';
     }
     $treeViewObj->parentField = $this->parentField;
     $treeViewObj->parentField = $this->parentField;
     // Set select fields
     $treeViewObj->fieldArray = array('uid');
     $treeViewObj->addField($GLOBALS['TCA'][$treeViewObj->table]['ctrl']['label']);
     if (isset($GLOBALS['TCA'][$treeViewObj->table]['ctrl']['label_alt'])) {
         $treeViewObj->addField($GLOBALS['TCA'][$treeViewObj->table]['ctrl']['label_alt']);
     }
     $treeViewObj->tceFormsTable = $this->table;
     if ($this->table == 'tt_content') {
         $treeViewObj->tceFormsField = $this->field . ',' . $this->fieldConfig['piFlexFormSheet'] . ',' . $this->fieldConfig['piFlexFormLang'] . ',' . $this->fieldConfig['piFlexFormValue'] . ',' . $this->row['CType'] . ',' . $this->row['list_type'];
     } else {
         $treeViewObj->tceFormsField = $this->field;
     }
     $treeViewObj->tceFormsRecID = $this->row['uid'];
     $treeViewObj->ext_IconMode = '0';
     $treeViewObj->treeView = $this->fieldConfig['treeView'];
     $treeViewObj->expandable = $this->fieldConfig['expandable'];
     $treeViewObj->expandFirst = $this->fieldConfig['expandFirst'];
     $treeViewObj->expandAll = $this->fieldConfig['expandAll'];
     $treeViewObj->ignorePermsClause = $this->fieldConfig['ignorePermsClause'];
     // Get TSconfig
     $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($this->table, $this->row);
     // Get TSconfig for field
     if ($this->table == 'tt_content') {
         $fieldTSconfig = t3lib_TCEforms::setTSconfig($this->table, $this->row);
         $fieldTSconfig = $fieldTSconfig['pi_flexform'][$this->row['list_type'] . '.'][$this->field . '.'];
     } else {
         $fieldTSconfig = t3lib_TCEforms::setTSconfig($this->table, $this->row, $this->field);
     }
     $clause = '';
     // removeItems
     if (isset($fieldTSconfig['removeItems'])) {
         $this->removeItems = tx_cpsdevlib_div::toListArray(tx_cpsdevlib_db::getRootLineDownwards($treeViewObj->table, $treeViewObj->parentField, $fieldTSconfig['removeItems']), '', 1, 1, 1);
     }
     // keepItems
     if (isset($fieldTSconfig['keepItems'])) {
         $this->keepItems = tx_cpsdevlib_div::toListArray($fieldTSconfig['keepItems']);
         if (count($this->removeItems)) {
             // If items were removed from list check keepItems to add back
             foreach ($this->keepItems as $value) {
                 if (($key = array_search($value, $this->removeItems)) !== false) {
                     unset($this->removeItems[$key]);
                     // Get rootline upwards to restore parent items
                     $rL = tx_cpsdevlib_div::toListArray(tx_cpsdevlib_db::getRootLineUpwards($treeViewObj->table, 'pid', $value), '', 1, 1, 1);
                     foreach ($rL as $v) {
                         if (($k = array_search($v, $this->removeItems)) !== false) {
                             $treeViewObj->TCEforms_nonSelectableItemsArray[] = $v;
                             unset($this->removeItems[$k]);
                         }
                     }
                 }
             }
         } else {
             // If just keepItems is set only show selected
             if (count($this->keepItems)) {
                 $clause = ' AND ' . $treeViewObj->table . '.uid IN (' . implode(',', $this->keepItems) . ')';
             }
         }
     }
     if (count($this->removeItems)) {
         $clause = ' AND ' . $treeViewObj->table . '.uid NOT IN (' . implode(',', $this->removeItems) . ')';
     }
     // hideItems
     if (isset($fieldTSconfig['hideItems'])) {
         $this->hideItems = tx_cpsdevlib_div::toListArray($fieldTSconfig['hideItems']);
         $treeViewObj->TCEforms_nonSelectableItemsArray = array_merge($treeViewObj->TCEforms_nonSelectableItemsArray, $this->hideItems);
     }
     // Add foreign_table_where
     if ($this->fieldConfig['foreign_table_where']) {
         // Remove ORDER BY part if present
         if (strpos(strtolower($this->fieldConfig['foreign_table_where']), 'order by') !== false) {
             $ftWhere = substr($this->fieldConfig['foreign_table_where'], 0, strpos(strtolower($this->fieldConfig['foreign_table_where']), 'order by'));
         } else {
             $ftWhere = $this->fieldConfig['foreign_table_where'];
         }
         // Replace record maker in foreign_table_where
         if (strstr($ftWhere, '###REC_FIELD_')) {
             $ftWhereParts = explode('###REC_FIELD_', $ftWhere);
             foreach ($ftWhereParts as $key => $value) {
                 if ($key) {
                     $ftWhereSubpart = explode('###', $value, 2);
                     if (substr($ftWhereParts[0], -1) === '\'' && $ftWhereSubpart[1][0] === '\'') {
                         $ftWhereParts[$key] = $GLOBALS['TYPO3_DB']->quoteStr($TSconfig['_THIS_ROW'][$ftWhereSubpart[0]], $treeViewObj->table) . $ftWhereSubpart[1];
                     } else {
                         $ftWhereParts[$key] = $GLOBALS['TYPO3_DB']->fullQuoteStr($TSconfig['_THIS_ROW'][$ftWhereSubpart[0]], $treeViewObj->table) . $ftWhereSubpart[1];
                     }
                 }
             }
             $ftWhere = implode('', $ftWhereParts);
         }
         // Replace special marker in foreign_table_where
         $ftWhere = str_replace('###CURRENT_PID###', intval($TSconfig['_CURRENT_PID']), $ftWhere);
         $ftWhere = str_replace('###THIS_UID###', intval($TSconfig['_THIS_UID']), $ftWhere);
         $ftWhere = str_replace('###THIS_CID###', intval($TSconfig['_THIS_CID']), $ftWhere);
         $ftWhere = str_replace('###STORAGE_PID###', intval($TSconfig['_STORAGE_PID']), $ftWhere);
         $ftWhere = str_replace('###SITEROOT###', intval($TSconfig['_SITEROOT']), $ftWhere);
         $ftWhere = str_replace('###PAGE_TSCONFIG_ID###', intval($TSconfig[$this->field]['PAGE_TSCONFIG_ID']), $ftWhere);
         $ftWhere = str_replace('###PAGE_TSCONFIG_IDLIST###', $GLOBALS['TYPO3_DB']->cleanIntList($TSconfig[$this->field]['PAGE_TSCONFIG_IDLIST']), $ftWhere);
         $ftWhere = str_replace('###PAGE_TSCONFIG_STR###', $GLOBALS['TYPO3_DB']->quoteStr($TSconfig[$this->field]['PAGE_TSCONFIG_STR'], $this->fieldConfig['foreign_table']), $ftWhere);
         $clause .= ' ' . trim($ftWhere);
     }
     // Hook to manipulate clause
     $parameter = array('clause' => &$clause, 'treeViewObj' => &$treeViewObj);
     tx_cpsdevlib_div::callHookObjects('cps_tcatree', 'changeClauseHook', $parameter, $this);
     $treeViewObj->init($clause, $orderBy);
     $treeViewObj->TCEforms_itemFormElName = $this->itemFormElName;
     if ($this->table == $this->fieldConfig['foreign_table']) {
         $treeViewObj->TCEforms_nonSelectableItemsArray[] = $this->row['uid'];
     }
     $treeViewObj->TCEforms_selectedItemsArray = $this->selectedItems;
     $treeViewObj->selectedItemsArrayParents = $this->getItemRootline($this->selectedItems);
     $treeContent = $treeViewObj->getBrowsableTree();
     return $treeContent;
 }
Exemplo n.º 4
0
    /**
     * Main function, rendering the document with the iframe with the RTE in.
     *
     * @return	void
     */
    function main()
    {
        global $BE_USER, $LANG;
        // translate id to the workspace version:
        if ($versionRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->P['table'], $this->P['uid'], 'uid')) {
            $this->P['uid'] = $versionRec['uid'];
        }
        // If all parameters are available:
        if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'], $this->P['uid'])) {
            // Getting the raw record (we need only the pid-value from here...)
            $rawRec = t3lib_BEfunc::getRecord($this->P['table'], $this->P['uid']);
            t3lib_BEfunc::fixVersioningPid($this->P['table'], $rawRec);
            // Setting JavaScript, including the pid value for viewing:
            $this->doc->JScode = $this->doc->wrapScriptTags('
					function jumpToUrl(URL,formEl)	{	//
						if (document.editform)	{
							if (!TBE_EDITOR.isFormChanged())	{
								window.location.href = URL;
							} else if (formEl) {
								if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
							}
						} else window.location.href = URL;
					}
				' . ($this->popView ? t3lib_BEfunc::viewOnClick($rawRec['pid'], '', t3lib_BEfunc::BEgetRootLine($rawRec['pid'])) : '') . '
			');
            // Initialize TCeforms - for rendering the field:
            $tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
            $tceforms->initDefaultBEMode();
            // Init...
            $tceforms->disableWizards = 1;
            // SPECIAL: Disables all wizards - we are NOT going to need them.
            $tceforms->colorScheme[0] = $this->doc->bgColor;
            // SPECIAL: Setting background color of the RTE to ordinary background
            // Initialize style for RTE object:
            $RTEobj = t3lib_BEfunc::RTEgetObj();
            // Getting reference to the RTE object used to render the field!
            if ($RTEobj->ID == 'rte') {
                $RTEobj->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border:solid 0px;';
                // SPECIAL: Setting style for the RTE <DIV> layer containing the IFRAME
            }
            // Fetching content of record:
            $trData = t3lib_div::makeInstance('t3lib_transferData');
            $trData->lockRecords = 1;
            $trData->fetchRecord($this->P['table'], $this->P['uid'], '');
            // Getting the processed record content out:
            reset($trData->regTableItems_data);
            $rec = current($trData->regTableItems_data);
            $rec['uid'] = $this->P['uid'];
            $rec['pid'] = $rawRec['pid'];
            // TSconfig, setting width:
            $fieldTSConfig = $tceforms->setTSconfig($this->P['table'], $rec, $this->P['field']);
            if (strcmp($fieldTSConfig['RTEfullScreenWidth'], '')) {
                $width = $fieldTSConfig['RTEfullScreenWidth'];
            } else {
                $width = '100%';
            }
            // Get the form field and wrap it in the table with the buttons:
            $formContent = $tceforms->getSoloField($this->P['table'], $rec, $this->P['field']);
            $formContent = '


			<!--
				RTE wizard:
			-->
				<table border="0" cellpadding="0" cellspacing="0" width="' . $width . '" id="typo3-rtewizard">
					<tr>
						<td width="' . $width . '" colspan="2" id="c-formContent">' . $formContent . '</td>
						<td></td>
					</tr>
				</table>';
            // Adding hidden fields:
            $formContent .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($this->R_URI) . '" />
						<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />' . t3lib_TCEforms::getHiddenTokenField('tceAction');
            // Finally, add the whole setup:
            $this->content .= $tceforms->printNeededJSFunctions_top() . $formContent . $tceforms->printNeededJSFunctions();
        } else {
            // ERROR:
            $this->content .= $this->doc->section($LANG->getLL('forms_title'), '<span class="typo3-red">' . $LANG->getLL('table_noData', 1) . '</span>', 0, 1);
        }
        // Setting up the buttons and markers for docheader
        $docHeaderButtons = $this->getButtons();
        $markers['CONTENT'] = $this->content;
        // Build the <body> for the module
        $this->content = $this->doc->startPage('');
        $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
        $this->content .= $this->doc->endPage();
        $this->content = $this->doc->insertStylesAndJS($this->content);
    }
Exemplo n.º 5
0
 /**
  * Creates a form for new workspace. Parts are adopted from <code>alt_doc.php</code>.
  *
  * @return	string		Generated form
  */
 function buildNewForm()
 {
     $content = '';
     $table = 'sys_workspace';
     $prevPageID = '';
     $trData = t3lib_div::makeInstance('t3lib_transferData');
     $trData->addRawData = TRUE;
     $trData->defVals = $this->defVals;
     $trData->lockRecords = 1;
     $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
     $trData->prevPageID = $prevPageID;
     $trData->fetchRecord($table, 0, 'new');
     reset($trData->regTableItems_data);
     $rec = current($trData->regTableItems_data);
     $rec['uid'] = uniqid('NEW');
     $rec['pid'] = 0;
     $rec['adminusers'] = $this->getOwnerUser($rec['uid']);
     // Setting variables in TCEforms object:
     $this->tceforms->hiddenFieldList = '';
     // Register default language labels, if any:
     $this->tceforms->registerDefaultLanguageData($table, $rec);
     $this->fixVariousTCAFields();
     if (!$GLOBALS['BE_USER']->isAdmin()) {
         // Non-admins cannot select users from the root. We "fix" it for them.
         $this->fixTCAUserField('adminusers');
         $this->fixTCAUserField('members');
         $this->fixTCAUserField('reviewers');
     }
     // Create form for the record (either specific list of fields or the whole record):
     $form = '';
     $form .= $this->doc->spacer(5);
     $form .= $this->tceforms->getMainFields($table, $rec);
     $form .= '<input type="hidden" name="workspace_form_submited" value="1" />';
     $form .= '<input type="hidden" name="data[' . $table . '][' . $rec['uid'] . '][pid]" value="' . $rec['pid'] . '" />';
     $form .= '<input type="hidden" name="returnUrl" value="index.php" />';
     $form .= '<input type="hidden" name="action" value="new" />';
     $form .= '<input type="hidden" name="closeDoc" value="0" />';
     $form .= '<input type="hidden" name="doSave" value="0" />';
     $form .= '<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />';
     $form .= '<input type="hidden" name="_disableRTE" value="' . $this->tceforms->disableRTE . '" />';
     $form = $this->tceforms->wrapTotal($form, $rec, $table);
     // Combine it all:
     $content .= $form;
     return $content;
 }
Exemplo n.º 6
0
    /**
     * Put together the various elements (buttons, selectors, form) into a table
     *
     * @param	string		HTML form.
     * @return	string		Composite HTML
     */
    function compileForm($editForm)
    {
        global $LANG;
        $formContent = '
			<!-- EDITING FORM -->
			' . $editForm . '

			<input type="hidden" name="returnUrl" value="' . htmlspecialchars($this->retUrl) . '" />
			<input type="hidden" name="viewUrl" value="' . htmlspecialchars($this->viewUrl) . '" />';
        if ($this->returnNewPageId) {
            $formContent .= '<input type="hidden" name="returnNewPageId" value="1" />';
        }
        $formContent .= '<input type="hidden" name="popViewId" value="' . htmlspecialchars($this->viewId) . '" />';
        if ($this->viewId_addParams) {
            $formContent .= '<input type="hidden" name="popViewId_addParams" value="' . htmlspecialchars($this->viewId_addParams) . '" />';
        }
        $formContent .= '
			<input type="hidden" name="closeDoc" value="0" />
			<input type="hidden" name="doSave" value="0" />
			<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
			<input type="hidden" name="_scrollPosition" value="" />' . t3lib_TCEforms::getHiddenTokenField('editRecord');
        return $formContent;
    }
 /**
  * Wraps all the table rows into a single table.
  * Used externally from scripts like alt_doc.php and db_layout.php (which uses TCEforms...)
  *
  * @param	string		Code to output between table-parts; table rows
  * @param	array		The record
  * @param	string		The table name
  * @return	string
  */
 function wrapTotal($c, $rec, $table = '')
 {
     $table = $table ? $table : $this->virtual;
     return parent::wrapTotal($c, $rec, $table);
 }
Exemplo n.º 8
0
 /**
  * Render a checkbox for the default settings of records in
  * this table
  *
  * @param array $params
  * @param t3lib_TCEforms $fobj
  * @return string
  */
 public function renderDefaultSettingsField($params, $fobj)
 {
     global $TCA;
     $table = $params['fieldConf']['config']['table'];
     t3lib_div::loadTCA($table);
     $content = '';
     $namePre = str_replace('[default_settings_', '[default_settings][', $params['itemFormElName']);
     /* @var $context Tx_Contexts_Context_Abstract */
     $uid = (int) $params['row']['uid'];
     $context = $uid ? Tx_Contexts_Context_Container::get()->initAll()->find($uid) : null;
     foreach ($params['fieldConf']['config']['settings'] as $setting => $config) {
         $id = $params['itemFormElID'] . '-' . $setting;
         $name = $namePre . '[' . $setting . ']';
         $content .= '<input type="hidden" name="' . $name . '" value="0"/>';
         $content .= '<input class="checkbox" type="checkbox" name="' . $name . '" ';
         if (!$context || !$context->hasSetting($table, $setting, 0) || $context->getSetting($table, $setting, 0)->getEnabled()) {
             $content .= 'checked="checked" ';
         }
         $content .= 'value="1" id="' . $id . '" /> ';
         $content .= '<label for="' . $id . '">';
         $content .= $fobj->sL($config['label']);
         $content .= '</label><br/>';
     }
     return $content;
 }
 /**
  * Constructs this object.
  */
 public function __construct()
 {
     $this->initializeTemplateContainer();
     parent::__construct();
 }
Exemplo n.º 10
0
    /**
     * Management of versions for record
     *
     * @return	void
     */
    function versioningMgm()
    {
        global $TCA;
        // Diffing:
        $diff_1 = t3lib_div::_POST('diff_1');
        $diff_2 = t3lib_div::_POST('diff_2');
        if (t3lib_div::_POST('do_diff')) {
            $content = '';
            $content .= '<h3>' . $GLOBALS['LANG']->getLL('diffing') . ':</h3>';
            if ($diff_1 && $diff_2) {
                $diff_1_record = t3lib_BEfunc::getRecord($this->table, $diff_1);
                $diff_2_record = t3lib_BEfunc::getRecord($this->table, $diff_2);
                if (is_array($diff_1_record) && is_array($diff_2_record)) {
                    t3lib_div::loadTCA($this->table);
                    $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
                    $tRows = array();
                    $tRows[] = '
									<tr class="bgColor5 tableheader">
										<td>' . $GLOBALS['LANG']->getLL('fieldname') . '</td>
										<td width="98%">' . $GLOBALS['LANG']->getLL('coloredDiffView') . ':</td>
									</tr>
								';
                    foreach ($diff_1_record as $fN => $fV) {
                        if ($TCA[$this->table]['columns'][$fN] && $TCA[$this->table]['columns'][$fN]['config']['type'] != 'passthrough' && !t3lib_div::inList('t3ver_label', $fN)) {
                            if (strcmp($diff_1_record[$fN], $diff_2_record[$fN])) {
                                $diffres = $t3lib_diff_Obj->makeDiffDisplay(t3lib_BEfunc::getProcessedValue($this->table, $fN, $diff_2_record[$fN], 0, 1), t3lib_BEfunc::getProcessedValue($this->table, $fN, $diff_1_record[$fN], 0, 1));
                                $tRows[] = '
									<tr class="bgColor4">
										<td>' . $fN . '</td>
										<td width="98%">' . $diffres . '</td>
									</tr>
								';
                            }
                        }
                    }
                    if (count($tRows) > 1) {
                        $content .= '<table border="0" cellpadding="1" cellspacing="1" width="100%">' . implode('', $tRows) . '</table><br /><br />';
                    } else {
                        $content .= $GLOBALS['LANG']->getLL('recordsMatchesCompletely');
                    }
                } else {
                    $content .= $GLOBALS['LANG']->getLL('errorRecordsNotFound');
                }
            } else {
                $content .= $GLOBALS['LANG']->getLL('errorDiffSources');
            }
        }
        // Element:
        $record = t3lib_BEfunc::getRecord($this->table, $this->uid);
        $recordIcon = t3lib_iconWorks::getSpriteIconForRecord($this->table, $record);
        $recTitle = t3lib_BEfunc::getRecordTitle($this->table, $record, TRUE);
        // Display versions:
        $content .= '
			' . $recordIcon . $recTitle . '
			<form name="theform" action="' . str_replace('&sendToReview=1', '', $this->REQUEST_URI) . '" method="post">
			<table border="0" cellspacing="1" cellpadding="1">';
        $content .= '
				<tr class="bgColor5 tableheader">
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_title') . '">' . $GLOBALS['LANG']->getLL('tblHeader_title') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_uid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_uid') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_oid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_oid') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_id') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_id') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_wsid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_wsid') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_state') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_state') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_stage') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_stage') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_count') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_count') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_pid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_pid') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_label') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_label') . '</td>
					<td colspan="2"><input type="submit" name="do_diff" value="' . $GLOBALS['LANG']->getLL('diff') . '" /></td>
				</tr>';
        $versions = t3lib_BEfunc::selectVersionsOfRecord($this->table, $this->uid, '*', $GLOBALS['BE_USER']->workspace);
        foreach ($versions as $row) {
            $adminLinks = $this->adminLinks($this->table, $row);
            $content .= '
				<tr class="' . ($row['uid'] != $this->uid ? 'bgColor4' : 'bgColor2 tableheader') . '">
					<td>' . ($row['uid'] != $this->uid ? '<a href="' . $this->doc->issueCommand('&cmd[' . $this->table . '][' . $this->uid . '][version][swapWith]=' . $row['uid'] . '&cmd[' . $this->table . '][' . $this->uid . '][version][action]=swap') . '" title="' . $GLOBALS['LANG']->getLL('swapWithCurrent', TRUE) . '">' . t3lib_iconWorks::getSpriteIcon('actions-version-swap-version') . '</a>' : t3lib_iconWorks::getSpriteIcon('status-status-current', array('title' => $GLOBALS['LANG']->getLL('currentOnlineVersion', TRUE)))) . '</td>
					<td nowrap="nowrap">' . $adminLinks . '</td>
					<td nowrap="nowrap">' . t3lib_BEfunc::getRecordTitle($this->table, $row, TRUE) . '</td>
					<td>' . $row['uid'] . '</td>
					<td>' . $row['t3ver_oid'] . '</td>
					<td>' . $row['t3ver_id'] . '</td>
					<td>' . $row['t3ver_wsid'] . '</td>
					<td>' . $row['t3ver_state'] . '</td>
					<td>' . $row['t3ver_stage'] . '</td>
					<td>' . $row['t3ver_count'] . '</td>
					<td>' . $row['pid'] . '</td>
					<td nowrap="nowrap"><a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[' . $this->table . '][' . $row['uid'] . ']=edit&columnsOnly=t3ver_label', $this->doc->backPath)) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.edit', TRUE) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>' . htmlspecialchars($row['t3ver_label']) . '</td>
					<td class="version-diff-1"><input type="radio" name="diff_1" value="' . $row['uid'] . '"' . ($diff_1 == $row['uid'] ? ' checked="checked"' : '') . '/></td>
					<td class="version-diff-2"><input type="radio" name="diff_2" value="' . $row['uid'] . '"' . ($diff_2 == $row['uid'] ? ' checked="checked"' : '') . '/></td>
				</tr>';
            // Show sub-content if the table is pages AND it is not the online branch (because that will mostly render the WHOLE tree below - not smart;)
            if ($this->table == 'pages' && $row['uid'] != $this->uid) {
                $sub = $this->pageSubContent($row['uid']);
                if ($sub) {
                    $content .= '
						<tr>
							<td></td>
							<td></td>
							<td colspan="10">' . $sub . '</td>
							<td colspan="2"></td>
						</tr>';
                }
            }
        }
        $content .= '</table></form>';
        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('title'), $content, 0, 1);
        // Create new:
        $content = '

			<form action="' . $this->doc->backPath . 'tce_db.php" method="post">
			' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_label') . ': <input type="text" name="cmd[' . $this->table . '][' . $this->uid . '][version][label]" /><br />
			' . ($this->table == 'pages' && $GLOBALS['TYPO3_CONF_VARS']['BE']['elementVersioningOnly'] == FALSE ? '<select name="cmd[' . $this->table . '][' . $this->uid . '][version][treeLevels]">
				' . ($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(0) ? '<option value="0">' . $GLOBALS['LANG']->getLL('cmdPid0') . '</option>' : '') . '
				' . ($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(1) ? '<option value="100">' . $GLOBALS['LANG']->getLL('cmdPid100') . '</option>' : '') . '
				' . ($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(-1) ? '<option value="-1">' . $GLOBALS['LANG']->getLL('cmdPid1') . '</option>' : '') . '
			</select>' : '') . '
			<br /><input type="hidden" name="cmd[' . $this->table . '][' . $this->uid . '][version][action]" value="new" />
			<input type="hidden" name="prErr" value="1" />
			<input type="hidden" name="redirect" value="' . htmlspecialchars($this->REQUEST_URI) . '" />
			<input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('createNewVersion') . '" />
			' . t3lib_TCEforms::getHiddenTokenField('tceAction') . '
			</form>

		';
        $this->content .= $this->doc->spacer(15);
        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('createNewVersion'), $content, 0, 1);
    }
    /**
     * Return the Javascript code for configuring the RTE
     *
     * @param	integer		$RTEcounter: The index number of the current RTE editing area within the form.
     * @param	string		$table: The table that includes this RTE (optional, necessary for IRRE).
     * @param	string		$uid: The uid of that table that includes this RTE (optional, necessary for IRRE).
     * @param	string		$field: The field of that record that includes this RTE (optional).
     *
     * @return	string		the Javascript code for configuring the RTE
     */
    function registerRTEinJS($RTEcounter, $table = '', $uid = '', $field = '', $textAreaId = '')
    {
        $configureRTEInJavascriptString = (!$this->is_FE() ? '' : '
			' . '/*<![CDATA[*/') . '
			if (typeof(configureEditorInstance) == "undefined") {
				configureEditorInstance = new Object();
			}
			configureEditorInstance["' . $textAreaId . '"] = function() {
				if (typeof(RTEarea) == "undefined" || typeof(HTMLArea) == "undefined") {
					window.setTimeout("configureEditorInstance[\'' . $textAreaId . '\']();", 40);
				} else {
			editornumber = "' . $textAreaId . '";
			RTEarea[editornumber] = new Object();
			RTEarea[editornumber].RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";
			RTEarea[editornumber].number = editornumber;
			RTEarea[editornumber].deleted = false;
			RTEarea[editornumber].textAreaId = "' . $textAreaId . '";
			RTEarea[editornumber].id = "RTEarea" + editornumber;
			RTEarea[editornumber].RTEWidthOverride = "' . trim($this->thisConfig['RTEWidthOverride']) . '";
			RTEarea[editornumber].RTEHeightOverride = "' . trim($this->thisConfig['RTEHeightOverride']) . '";
			RTEarea[editornumber].fullScreen = ' . ($this->fullScreen ? 'true' : 'false') . ';
			RTEarea[editornumber].showStatusBar = ' . (trim($this->thisConfig['showStatusBar']) ? 'true' : 'false') . ';
			RTEarea[editornumber].enableWordClean = ' . (trim($this->thisConfig['enableWordClean']) ? 'true' : 'false') . ';
			RTEarea[editornumber].htmlRemoveComments = ' . (trim($this->thisConfig['removeComments']) ? 'true' : 'false') . ';
			RTEarea[editornumber].disableEnterParagraphs = ' . (trim($this->thisConfig['disableEnterParagraphs']) ? 'true' : 'false') . ';
			RTEarea[editornumber].disableObjectResizing = ' . (trim($this->thisConfig['disableObjectResizing']) ? 'true' : 'false') . ';
			RTEarea[editornumber].removeTrailingBR = ' . (trim($this->thisConfig['removeTrailingBR']) ? 'true' : 'false') . ';
			RTEarea[editornumber].useCSS = ' . (trim($this->thisConfig['useCSS']) ? 'true' : 'false') . ';
			RTEarea[editornumber].keepButtonGroupTogether = ' . (trim($this->thisConfig['keepButtonGroupTogether']) ? 'true' : 'false') . ';
			RTEarea[editornumber].disablePCexamples = ' . (trim($this->thisConfig['disablePCexamples']) ? 'true' : 'false') . ';
			RTEarea[editornumber].showTagFreeClasses = ' . (trim($this->thisConfig['showTagFreeClasses']) ? 'true' : 'false') . ';
			RTEarea[editornumber].useHTTPS = ' . (trim(stristr($this->siteURL, 'https')) || $this->thisConfig['forceHTTPS'] ? 'true' : 'false') . ';
			RTEarea[editornumber].tceformsNested = ' . (is_object($this->TCEform) && method_exists($this->TCEform, 'getDynNestedStack') ? $this->TCEform->getDynNestedStack(true) : '[]') . ';
			RTEarea[editornumber].dialogueWindows = new Object();
			RTEarea[editornumber].dialogueWindows.defaultPositionFromTop = ' . (isset($this->thisConfig['dialogueWindows.']['defaultPositionFromTop']) ? intval($this->thisConfig['dialogueWindows.']['defaultPositionFromTop']) : '100') . ';
			RTEarea[editornumber].dialogueWindows.defaultPositionFromLeft = ' . (isset($this->thisConfig['dialogueWindows.']['defaultPositionFromLeft']) ? intval($this->thisConfig['dialogueWindows.']['defaultPositionFromLeft']) : '100') . ';
			RTEarea[editornumber].dialogueWindows.doNotResize = ' . (trim($this->thisConfig['dialogueWindows.']['doNotResize']) ? 'true' : 'false') . ';
			RTEarea[editornumber].dialogueWindows.doNotCenter = ' . (trim($this->thisConfig['dialogueWindows.']['doNotCenter']) ? 'true' : 'false') . ';';
        // The following properties apply only to the backend
        if (!$this->is_FE()) {
            $configureRTEInJavascriptString .= '
			RTEarea[editornumber].sys_language_content = "' . $this->contentLanguageUid . '";
			RTEarea[editornumber].typo3ContentLanguage = "' . $this->contentTypo3Language . '";
			RTEarea[editornumber].typo3ContentCharset = "' . $this->contentCharset . '";
			RTEarea[editornumber].userUid = "' . $this->userUid . '";';
        }
        // Setting the plugin flags
        $configureRTEInJavascriptString .= '
			RTEarea[editornumber].plugin = new Object();
			RTEarea[editornumber].pathToPluginDirectory = new Object();';
        foreach ($this->pluginEnabledArray as $pluginId) {
            $configureRTEInJavascriptString .= '
			RTEarea[editornumber].plugin.' . $pluginId . ' = true;';
            if (is_object($this->registeredPlugins[$pluginId])) {
                $pathToPluginDirectory = $this->registeredPlugins[$pluginId]->getPathToPluginDirectory();
                if ($pathToPluginDirectory) {
                    $configureRTEInJavascriptString .= '
			RTEarea[editornumber].pathToPluginDirectory.' . $pluginId . ' = "' . $pathToPluginDirectory . '";';
                }
            }
        }
        // Setting the buttons configuration
        $configureRTEInJavascriptString .= '
			RTEarea[editornumber].buttons = new Object();';
        if (is_array($this->thisConfig['buttons.'])) {
            foreach ($this->thisConfig['buttons.'] as $buttonIndex => $conf) {
                $button = substr($buttonIndex, 0, -1);
                if (in_array($button, $this->toolbar)) {
                    $configureRTEInJavascriptString .= '
			RTEarea[editornumber].buttons.' . $button . ' = ' . $this->buildNestedJSArray($conf) . ';';
                }
            }
        }
        // Setting the list of tags to be removed if specified in the RTE config
        if (trim($this->thisConfig['removeTags'])) {
            $configureRTEInJavascriptString .= '
			RTEarea[editornumber].htmlRemoveTags = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTags'], 1)) . ')$/i;';
        }
        // Setting the list of tags to be removed with their contents if specified in the RTE config
        if (trim($this->thisConfig['removeTagsAndContents'])) {
            $configureRTEInJavascriptString .= '
			RTEarea[editornumber].htmlRemoveTagsAndContents = /^(' . implode('|', t3lib_div::trimExplode(',', $this->thisConfig['removeTagsAndContents'], 1)) . ')$/i;';
        }
        // Process default style configuration
        $configureRTEInJavascriptString .= '
			RTEarea[editornumber].defaultPageStyle = "' . $this->writeTemporaryFile('', 'defaultPageStyle', 'css', $this->buildStyleSheet()) . '";';
        // Setting the pageStyle
        $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/res/contentcss/default.css';
        $configureRTEInJavascriptString .= '
			RTEarea[editornumber].pageStyle = "' . t3lib_div::createVersionNumberedFilename($this->getFullFileName($filename)) . '";';
        // Process classes configuration
        $classesConfigurationRequired = false;
        foreach ($this->registeredPlugins as $pluginId => $plugin) {
            if ($this->isPluginEnabled($pluginId)) {
                $classesConfigurationRequired = $classesConfigurationRequired || $plugin->requiresClassesConfiguration();
            }
        }
        if ($classesConfigurationRequired) {
            $configureRTEInJavascriptString .= $this->buildJSClassesConfig($RTEcounter);
        }
        // Add Javascript configuration for registered plugins
        foreach ($this->registeredPlugins as $pluginId => $plugin) {
            if ($this->isPluginEnabled($pluginId)) {
                $configureRTEInJavascriptString .= $plugin->buildJavascriptConfiguration('editornumber');
            }
        }
        // Avoid premature reference to HTMLArea when being initially loaded by IRRE Ajax call
        $configureRTEInJavascriptString .= '
			RTEarea[editornumber].toolbar = ' . $this->getJSToolbarArray() . ';
			RTEarea[editornumber].convertButtonId = ' . json_encode(array_flip($this->convertToolbarForHtmlAreaArray)) . ';
			RTEarea.initEditor(editornumber);
				}
			};
			configureEditorInstance["' . $textAreaId . '"]();' . (!$this->is_FE() ? '' : '
			/*]]>*/');
        return $configureRTEInJavascriptString;
    }
Exemplo n.º 12
0
    /**
     * Rendering the quick-edit view.
     *
     * @return	void
     */
    function renderQuickEdit()
    {
        global $LANG, $BE_USER, $BACK_PATH;
        // Alternative template
        $this->doc->setModuleTemplate('templates/db_layout_quickedit.html');
        // Alternative form tag; Quick Edit submits its content to tce_db.php.
        $this->doc->form = '<form action="' . htmlspecialchars($BACK_PATH . 'tce_db.php?&prErr=1&uPT=1') . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
        // Setting up the context sensitive menu:
        $this->doc->getContextMenuCode();
        // Set the edit_record value for internal use in this function:
        $edit_record = $this->edit_record;
        // If a command to edit all records in a column is issue, then select all those elements, and redirect to alt_doc.php:
        if (substr($edit_record, 0, 9) == '_EDIT_COL') {
            $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . intval($this->id) . ' AND colPos=' . intval(substr($edit_record, 10)) . ' AND sys_language_uid=' . intval($this->current_sys_language) . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content')) . t3lib_BEfunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'), '', 'sorting');
            $idListA = array();
            while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                $idListA[] = $cRow['uid'];
            }
            $url = $BACK_PATH . 'alt_doc.php?edit[tt_content][' . implode(',', $idListA) . ']=edit&returnUrl=' . rawurlencode($this->local_linkThisScript(array('edit_record' => '')));
            t3lib_utility_Http::redirect($url);
        }
        // If the former record edited was the creation of a NEW record, this will look up the created records uid:
        if ($this->new_unique_uid) {
            $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', 'userid=' . intval($BE_USER->user['uid']) . ' AND NEWid=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->new_unique_uid, 'sys_log'));
            $sys_log_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
            if (is_array($sys_log_row)) {
                $edit_record = $sys_log_row['tablename'] . ':' . $sys_log_row['recuid'];
            }
        }
        // Creating the selector box, allowing the user to select which element to edit:
        $opt = array();
        $is_selected = 0;
        $languageOverlayRecord = '';
        if ($this->current_sys_language) {
            list($languageOverlayRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . intval($this->current_sys_language));
        }
        if (is_array($languageOverlayRecord)) {
            $inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid'];
            $is_selected += intval($edit_record == $inValue);
            $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $LANG->getLL('editLanguageHeader', 1) . ' ]</option>';
        } else {
            $inValue = 'pages:' . $this->id;
            $is_selected += intval($edit_record == $inValue);
            $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $LANG->getLL('editPageProperties', 1) . ' ]</option>';
        }
        // Selecting all content elements from this language and allowed colPos:
        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . intval($this->id) . ' AND sys_language_uid=' . intval($this->current_sys_language) . ' AND colPos IN (' . $this->colPosList . ')' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content')) . t3lib_Befunc::deleteClause('tt_content') . t3lib_BEfunc::versioningPlaceholderClause('tt_content'), '', 'colPos,sorting');
        $colPos = '';
        $first = 1;
        $prev = $this->id;
        // Page is the pid if no record to put this after.
        while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
            t3lib_BEfunc::workspaceOL('tt_content', $cRow);
            if (is_array($cRow)) {
                if ($first) {
                    if (!$edit_record) {
                        $edit_record = 'tt_content:' . $cRow['uid'];
                    }
                    $first = 0;
                }
                if (strcmp($cRow['colPos'], $colPos)) {
                    $colPos = $cRow['colPos'];
                    $opt[] = '<option value=""></option>';
                    $opt[] = '<option value="_EDIT_COL:' . $colPos . '">__' . $LANG->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content', 'colPos', $colPos), 1) . ':__</option>';
                }
                $inValue = 'tt_content:' . $cRow['uid'];
                $is_selected += intval($edit_record == $inValue);
                $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>' . htmlspecialchars(t3lib_div::fixed_lgd_cs($cRow['header'] ? $cRow['header'] : '[' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.no_title') . '] ' . strip_tags($cRow['bodytext']), $BE_USER->uc['titleLen'])) . '</option>';
                $prev = -$cRow['uid'];
            }
        }
        // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
        if (!$edit_record) {
            $edit_record = 'tt_content:new/' . $prev . '/' . $colPos;
            $inValue = 'tt_content:new/' . $prev . '/' . $colPos;
            $is_selected += intval($edit_record == $inValue);
            $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $LANG->getLL('newLabel', 1) . ' ]</option>';
        }
        // If none is yet selected...
        if (!$is_selected) {
            $opt[] = '<option value=""></option>';
            $opt[] = '<option value="' . $edit_record . '"  selected="selected">[ ' . $LANG->getLL('newLabel', 1) . ' ]</option>';
        }
        // Splitting the edit-record cmd value into table/uid:
        $this->eRParts = explode(':', $edit_record);
        // Delete-button flag?
        $this->deleteButton = t3lib_div::testInt($this->eRParts[1]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & 4);
        // If undo-button should be rendered (depends on available items in sys_history)
        $this->undoButton = 0;
        $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->eRParts[0], 'sys_history') . ' AND recuid=' . intval($this->eRParts[1]), '', 'tstamp DESC', '1');
        if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
            $this->undoButton = 1;
        }
        // Setting up the Return URL for coming back to THIS script (if links take the user to another script)
        $R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
        $R_URL_getvars = t3lib_div::_GET();
        unset($R_URL_getvars['popView']);
        unset($R_URL_getvars['new_unique_uid']);
        $R_URL_getvars['edit_record'] = $edit_record;
        $this->R_URI = $R_URL_parts['path'] . '?' . t3lib_div::implodeArrayForUrl('', $R_URL_getvars);
        // Setting close url/return url for exiting this script:
        $this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
        // Goes to 'Columns' view if close is pressed (default)
        if ($BE_USER->uc['condensedMode']) {
            $this->closeUrl = $BACK_PATH . 'alt_db_navframe.php';
        }
        if ($this->returnUrl) {
            $this->closeUrl = $this->returnUrl;
        }
        // Return-url for JavaScript:
        $retUrlStr = $this->returnUrl ? "+'&returnUrl='+'" . rawurlencode($this->returnUrl) . "'" : '';
        // Drawing the edit record selectbox
        $this->editSelect = '<select name="edit_record" onchange="' . htmlspecialchars('jumpToUrl(\'db_layout.php?id=' . $this->id . '&edit_record=\'+escape(this.options[this.selectedIndex].value)' . $retUrlStr . ',this);') . '">' . implode('', $opt) . '</select>';
        // Creating editing form:
        if ($BE_USER->check('tables_modify', $this->eRParts[0]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & 1)) {
            // Splitting uid parts for special features, if new:
            list($uidVal, $ex_pid, $ex_colPos) = explode('/', $this->eRParts[1]);
            // Convert $uidVal to workspace version if any:
            if ($uidVal != 'new') {
                if ($draftRecord = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->eRParts[0], $uidVal, 'uid')) {
                    $uidVal = $draftRecord['uid'];
                }
            }
            // Initializing transfer-data object:
            $trData = t3lib_div::makeInstance('t3lib_transferData');
            $trData->addRawData = TRUE;
            $trData->defVals[$this->eRParts[0]] = array('colPos' => intval($ex_colPos), 'sys_language_uid' => intval($this->current_sys_language));
            $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
            $trData->lockRecords = 1;
            $trData->fetchRecord($this->eRParts[0], $uidVal == 'new' ? $this->id : $uidVal, $uidVal);
            // 'new'
            // Getting/Making the record:
            reset($trData->regTableItems_data);
            $rec = current($trData->regTableItems_data);
            if ($uidVal == 'new') {
                $new_unique_uid = uniqid('NEW');
                $rec['uid'] = $new_unique_uid;
                $rec['pid'] = intval($ex_pid) ? intval($ex_pid) : $this->id;
                $recordAccess = TRUE;
            } else {
                $rec['uid'] = $uidVal;
                // Checking internals access:
                $recordAccess = $BE_USER->recordEditAccessInternals($this->eRParts[0], $uidVal);
            }
            if (!$recordAccess) {
                // If no edit access, print error message:
                $content .= $this->doc->section($LANG->getLL('noAccess'), $LANG->getLL('noAccess_msg') . '<br /><br />' . ($BE_USER->errorMsg ? 'Reason: ' . $BE_USER->errorMsg . '<br /><br />' : ''), 0, 1);
            } elseif (is_array($rec)) {
                // If the record is an array (which it will always be... :-)
                // Create instance of TCEforms, setting defaults:
                $tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
                $tceforms->backPath = $BACK_PATH;
                $tceforms->initDefaultBEMode();
                $tceforms->fieldOrder = $this->modTSconfig['properties']['tt_content.']['fieldOrder'];
                $tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
                $tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
                $tceforms->enableClickMenu = TRUE;
                // Clipboard is initialized:
                $tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
                // Start clipboard
                $tceforms->clipObj->initializeClipboard();
                // Initialize - reads the clipboard content from the user session
                if ($BE_USER->uc['edit_showFieldHelp'] != 'text' && $this->MOD_SETTINGS['showDescriptions']) {
                    $tceforms->edit_showFieldHelp = 'text';
                }
                // Render form, wrap it:
                $panel = '';
                $panel .= $tceforms->getMainFields($this->eRParts[0], $rec);
                $panel = $tceforms->wrapTotal($panel, $rec, $this->eRParts[0]);
                // Add hidden fields:
                $theCode = $panel;
                if ($uidVal == 'new') {
                    $theCode .= '<input type="hidden" name="data[' . $this->eRParts[0] . '][' . $rec['uid'] . '][pid]" value="' . $rec['pid'] . '" />';
                }
                $theCode .= '
					<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
					<input type="hidden" name="_disableRTE" value="' . $tceforms->disableRTE . '" />
					<input type="hidden" name="edit_record" value="' . $edit_record . '" />
					<input type="hidden" name="redirect" value="' . htmlspecialchars($uidVal == 'new' ? t3lib_extMgm::extRelPath('cms') . 'layout/db_layout.php?id=' . $this->id . '&new_unique_uid=' . $new_unique_uid . '&returnUrl=' . rawurlencode($this->returnUrl) : $this->R_URI) . '" />
					' . t3lib_TCEforms::getHiddenTokenField('tceAction');
                // Add JavaScript as needed around the form:
                $theCode = $tceforms->printNeededJSFunctions_top() . $theCode . $tceforms->printNeededJSFunctions();
                // Add warning sign if record was "locked":
                if ($lockInfo = t3lib_BEfunc::isRecordLocked($this->eRParts[0], $rec['uid'])) {
                    $lockedMessage = t3lib_div::makeInstance('t3lib_FlashMessage', htmlspecialchars($lockInfo['msg']), '', t3lib_FlashMessage::WARNING);
                    t3lib_FlashMessageQueue::addMessage($lockedMessage);
                }
                // Add whole form as a document section:
                $content .= $this->doc->section('', $theCode);
            }
        } else {
            // If no edit access, print error message:
            $content .= $this->doc->section($LANG->getLL('noAccess'), $LANG->getLL('noAccess_msg') . '<br /><br />', 0, 1);
        }
        // Bottom controls (function menus):
        $q_count = $this->getNumberOfHiddenElements();
        $h_func_b = t3lib_BEfunc::getFuncCheck($this->id, 'SET[tt_content_showHidden]', $this->MOD_SETTINGS['tt_content_showHidden'], 'db_layout.php', '', 'id="checkTt_content_showHidden"') . '<label for="checkTt_content_showHidden">' . (!$q_count ? $GLOBALS['TBE_TEMPLATE']->dfw($LANG->getLL('hiddenCE', 1)) : $LANG->getLL('hiddenCE', 1) . ' (' . $q_count . ')') . '</label>';
        $h_func_b .= '<br />' . t3lib_BEfunc::getFuncCheck($this->id, 'SET[showPalettes]', $this->MOD_SETTINGS['showPalettes'], 'db_layout.php', '', 'id="checkShowPalettes"') . '<label for="checkShowPalettes">' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPalettes', 1) . '</label>';
        if (t3lib_extMgm::isLoaded('context_help') && $BE_USER->uc['edit_showFieldHelp'] != 'text') {
            $h_func_b .= '<br />' . t3lib_BEfunc::getFuncCheck($this->id, 'SET[showDescriptions]', $this->MOD_SETTINGS['showDescriptions'], 'db_layout.php', '', 'id="checkShowDescriptions"') . '<label for="checkShowDescriptions">' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showDescriptions', 1) . '</label>';
        }
        if ($BE_USER->isRTE()) {
            $h_func_b .= '<br />' . t3lib_BEfunc::getFuncCheck($this->id, 'SET[disableRTE]', $this->MOD_SETTINGS['disableRTE'], 'db_layout.php', '', 'id="checkDisableRTE"') . '<label for="checkDisableRTE">' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.disableRTE', 1) . '</label>';
        }
        // Add the function menus to bottom:
        $content .= $this->doc->section('', $h_func_b, 0, 0);
        $content .= $this->doc->spacer(10);
        // Select element matrix:
        if ($this->eRParts[0] == 'tt_content' && t3lib_div::testInt($this->eRParts[1])) {
            $posMap = t3lib_div::makeInstance('ext_posMap');
            $posMap->backPath = $BACK_PATH;
            $posMap->cur_sys_language = $this->current_sys_language;
            $HTMLcode = '';
            // CSH:
            $HTMLcode .= t3lib_BEfunc::cshItem($this->descrTable, 'quickEdit_selElement', $BACK_PATH, '|<br />');
            $HTMLcode .= $posMap->printContentElementColumns($this->id, $this->eRParts[1], $this->colPosList, $this->MOD_SETTINGS['tt_content_showHidden'], $this->R_URI);
            $content .= $this->doc->spacer(20);
            $content .= $this->doc->section($LANG->getLL('CEonThisPage'), $HTMLcode, 0, 1);
            $content .= $this->doc->spacer(20);
        }
        // Finally, if comments were generated in TCEforms object, print these as a HTML comment:
        if (count($tceforms->commentMessages)) {
            $content .= '
	<!-- TCEFORM messages
	' . htmlspecialchars(implode(LF, $tceforms->commentMessages)) . '
	-->
	';
        }
        return $content;
    }
Exemplo n.º 13
0
    /**
     * Creating form for editing the permissions	($this->edit = true)
     * (Adding content to internal content variable)
     *
     * @return	void
     */
    public function doEdit()
    {
        global $BE_USER, $LANG;
        if ($BE_USER->workspace != 0) {
            // Adding section with the permission setting matrix:
            $lockedMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('WorkspaceWarningText'), $LANG->getLL('WorkspaceWarning'), t3lib_FlashMessage::WARNING);
            t3lib_FlashMessageQueue::addMessage($lockedMessage);
        }
        // Get usernames and groupnames
        $beGroupArray = t3lib_BEfunc::getListGroupNames('title,uid');
        $beGroupKeys = array_keys($beGroupArray);
        $beUserArray = t3lib_BEfunc::getUserNames();
        if (!$GLOBALS['BE_USER']->isAdmin()) {
            $beUserArray = t3lib_BEfunc::blindUserNames($beUserArray, $beGroupKeys, 1);
        }
        $beGroupArray_o = $beGroupArray = t3lib_BEfunc::getGroupNames();
        if (!$GLOBALS['BE_USER']->isAdmin()) {
            $beGroupArray = t3lib_BEfunc::blindGroupNames($beGroupArray_o, $beGroupKeys, 1);
        }
        $firstGroup = $beGroupKeys[0] ? $beGroupArray[$beGroupKeys[0]] : '';
        // data of the first group, the user is member of
        // Owner selector:
        $options = '';
        $userset = 0;
        // flag: is set if the page-userid equals one from the user-list
        foreach ($beUserArray as $uid => $row) {
            if ($uid == $this->pageinfo['perms_userid']) {
                $userset = 1;
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
            $options .= '
				<option value="' . $uid . '"' . $selected . '>' . htmlspecialchars($row['username']) . '</option>';
        }
        $options = '
				<option value="0"></option>' . $options;
        $selector = '
			<select name="data[pages][' . $this->id . '][perms_userid]">
				' . $options . '
			</select>';
        $this->content .= $this->doc->section($LANG->getLL('Owner') . ':', $selector);
        // Group selector:
        $options = '';
        $userset = 0;
        foreach ($beGroupArray as $uid => $row) {
            if ($uid == $this->pageinfo['perms_groupid']) {
                $userset = 1;
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
            $options .= '
				<option value="' . $uid . '"' . $selected . '>' . htmlspecialchars($row['title']) . '</option>';
        }
        if (!$userset && $this->pageinfo['perms_groupid']) {
            // If the group was not set AND there is a group for the page
            $options = '
				<option value="' . $this->pageinfo['perms_groupid'] . '" selected="selected">' . htmlspecialchars($beGroupArray_o[$this->pageinfo['perms_groupid']]['title']) . '</option>' . $options;
        }
        $options = '
				<option value="0"></option>' . $options;
        $selector = '
			<select name="data[pages][' . $this->id . '][perms_groupid]">
				' . $options . '
			</select>';
        $this->content .= $this->doc->divider(5);
        $this->content .= $this->doc->section($LANG->getLL('Group') . ':', $selector);
        // Permissions checkbox matrix:
        $code = '
			<table border="0" cellspacing="2" cellpadding="0" id="typo3-permissionMatrix">
				<tr>
					<td></td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $LANG->getLL('1', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $LANG->getLL('16', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $LANG->getLL('2', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $LANG->getLL('4', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $LANG->getLL('8', 1)) . '</td>
				</tr>
				<tr>
					<td align="right" class="bgColor2">' . $LANG->getLL('Owner', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 5) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 2) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 3) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 4) . '</td>
				</tr>
				<tr>
					<td align="right" class="bgColor2">' . $LANG->getLL('Group', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 5) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 2) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 3) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 4) . '</td>
				</tr>
				<tr>
					<td align="right" class="bgColor2">' . $LANG->getLL('Everybody', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 5) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 2) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 3) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 4) . '</td>
				</tr>
			</table>
			<br />

			<input type="hidden" name="data[pages][' . $this->id . '][perms_user]" value="' . $this->pageinfo['perms_user'] . '" />
			<input type="hidden" name="data[pages][' . $this->id . '][perms_group]" value="' . $this->pageinfo['perms_group'] . '" />
			<input type="hidden" name="data[pages][' . $this->id . '][perms_everybody]" value="' . $this->pageinfo['perms_everybody'] . '" />
			' . $this->getRecursiveSelect($this->id, $this->perms_clause) . '
			<input type="submit" name="submit" value="' . $LANG->getLL('Save', 1) . '" />' . '<input type="submit" value="' . $LANG->getLL('Abort', 1) . '" onclick="' . htmlspecialchars('jumpToUrl(\'index.php?id=' . $this->id . '\'); return false;') . '" />
			<input type="hidden" name="redirect" value="' . htmlspecialchars(TYPO3_MOD_PATH . 'index.php?mode=' . $this->MOD_SETTINGS['mode'] . '&depth=' . $this->MOD_SETTINGS['depth'] . '&id=' . intval($this->return_id) . '&lastEdited=' . $this->id) . '" />
		' . t3lib_TCEforms::getHiddenTokenField('tceAction');
        // Adding section with the permission setting matrix:
        $this->content .= $this->doc->divider(5);
        $this->content .= $this->doc->section($LANG->getLL('permissions') . ':', $code);
        // CSH for permissions setting
        $this->content .= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module_setting', $GLOBALS['BACK_PATH'], '<br /><br />');
        // Adding help text:
        if ($BE_USER->uc['helpText']) {
            $this->content .= $this->doc->divider(20);
            $legendText = '<strong>' . $LANG->getLL('1', 1) . '</strong>: ' . $LANG->getLL('1_t', 1);
            $legendText .= '<br /><strong>' . $LANG->getLL('16', 1) . '</strong>: ' . $LANG->getLL('16_t', 1);
            $legendText .= '<br /><strong>' . $LANG->getLL('2', 1) . '</strong>: ' . $LANG->getLL('2_t', 1);
            $legendText .= '<br /><strong>' . $LANG->getLL('4', 1) . '</strong>: ' . $LANG->getLL('4_t', 1);
            $legendText .= '<br /><strong>' . $LANG->getLL('8', 1) . '</strong>: ' . $LANG->getLL('8_t', 1);
            $code = $legendText . '<br /><br />' . $LANG->getLL('def', 1);
            $this->content .= $this->doc->section($LANG->getLL('Legend', 1) . ':', $code);
        }
    }
Exemplo n.º 14
0
 /**
  * Creates the editing form with TCEforms, based on the input from GPvars.
  *
  * @return	string		HTML form elements wrapped in tables
  */
 function makeEditForm()
 {
     global $BE_USER, $LANG, $TCA;
     // Initialize variables:
     $this->elementsData = array();
     $this->errorC = 0;
     $this->newC = 0;
     $thePrevUid = '';
     $editForm = '';
     // Traverse the GPvar edit array
     foreach ($this->editconf as $table => $conf) {
         // Tables:
         if (is_array($conf) && $TCA[$table] && $BE_USER->check('tables_modify', $table)) {
             // Traverse the keys/comments of each table (keys can be a commalist of uids)
             foreach ($conf as $cKey => $cmd) {
                 if ($cmd == 'edit' || $cmd == 'new') {
                     // Get the ids:
                     $ids = t3lib_div::trimExplode(',', $cKey, 1);
                     // Traverse the ids:
                     foreach ($ids as $theUid) {
                         // Checking if the user has permissions? (Only working as a precaution, because the final permission check is always down in TCE. But it's good to notify the user on beforehand...)
                         // First, resetting flags.
                         $hasAccess = 1;
                         $deniedAccessReason = '';
                         $deleteAccess = 0;
                         $this->viewId = 0;
                         // If the command is to create a NEW record...:
                         if ($cmd == 'new') {
                             if (intval($theUid)) {
                                 // NOTICE: the id values in this case points to the page uid onto which the record should be create OR (if the id is negativ) to a record from the same table AFTER which to create the record.
                                 // Find parent page on which the new record reside
                                 if ($theUid < 0) {
                                     // Less than zero - find parent page
                                     $calcPRec = t3lib_BEfunc::getRecord($table, abs($theUid));
                                     $calcPRec = t3lib_BEfunc::getRecord('pages', $calcPRec['pid']);
                                 } else {
                                     // always a page
                                     $calcPRec = t3lib_BEfunc::getRecord('pages', abs($theUid));
                                 }
                                 // Now, calculate whether the user has access to creating new records on this position:
                                 if (is_array($calcPRec)) {
                                     $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
                                     // Permissions for the parent page
                                     if ($table == 'pages') {
                                         // If pages:
                                         $hasAccess = $CALC_PERMS & 8 ? 1 : 0;
                                         #$this->viewId = $calcPRec['pid'];
                                         $this->viewId = 0;
                                     } else {
                                         $hasAccess = $CALC_PERMS & 16 ? 1 : 0;
                                         $this->viewId = $calcPRec['uid'];
                                     }
                                 }
                             }
                             $this->dontStoreDocumentRef = 1;
                             // Don't save this document title in the document selector if the document is new.
                         } else {
                             // Edit:
                             $calcPRec = t3lib_BEfunc::getRecord($table, $theUid);
                             t3lib_BEfunc::fixVersioningPid($table, $calcPRec);
                             if (is_array($calcPRec)) {
                                 if ($table == 'pages') {
                                     // If pages:
                                     $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
                                     $hasAccess = $CALC_PERMS & 2 ? 1 : 0;
                                     $deleteAccess = $CALC_PERMS & 4 ? 1 : 0;
                                     $this->viewId = $calcPRec['uid'];
                                 } else {
                                     $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages', $calcPRec['pid']));
                                     // Fetching pid-record first.
                                     $hasAccess = $CALC_PERMS & 16 ? 1 : 0;
                                     $deleteAccess = $CALC_PERMS & 16 ? 1 : 0;
                                     $this->viewId = $calcPRec['pid'];
                                     // Adding "&L=xx" if the record being edited has a languageField with a value larger than zero!
                                     if ($TCA[$table]['ctrl']['languageField'] && $calcPRec[$TCA[$table]['ctrl']['languageField']] > 0) {
                                         $this->viewId_addParams = '&L=' . $calcPRec[$TCA[$table]['ctrl']['languageField']];
                                     }
                                 }
                                 // Check internals regarding access:
                                 if ($hasAccess) {
                                     $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
                                     $deniedAccessReason = $BE_USER->errorMsg;
                                 }
                             } else {
                                 $hasAccess = 0;
                             }
                         }
                         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['makeEditForm_accessCheck'])) {
                             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['makeEditForm_accessCheck'] as $_funcRef) {
                                 $_params = array('table' => $table, 'uid' => $theUid, 'cmd' => $cmd, 'hasAccess' => $hasAccess);
                                 $hasAccess = t3lib_div::callUserFunction($_funcRef, $_params, $this);
                             }
                         }
                         // AT THIS POINT we have checked the access status of the editing/creation of records and we can now proceed with creating the form elements:
                         if ($hasAccess) {
                             $prevPageID = is_object($trData) ? $trData->prevPageID : '';
                             $trData = t3lib_div::makeInstance('t3lib_transferData');
                             $trData->addRawData = TRUE;
                             $trData->defVals = $this->defVals;
                             $trData->lockRecords = 1;
                             $trData->disableRTE = !$BE_USER->isRTE();
                             $trData->prevPageID = $prevPageID;
                             $trData->fetchRecord($table, $theUid, $cmd == 'new' ? 'new' : '');
                             // 'new'
                             reset($trData->regTableItems_data);
                             $rec = current($trData->regTableItems_data);
                             $rec['uid'] = $cmd == 'new' ? uniqid('NEW') : $theUid;
                             if ($cmd == 'new') {
                                 $rec['pid'] = $theUid == 'prev' ? $thePrevUid : $theUid;
                             }
                             $this->elementsData[] = array('table' => $table, 'uid' => $rec['uid'], 'pid' => $rec['pid'], 'cmd' => $cmd, 'deleteAccess' => $deleteAccess);
                             // Now, render the form:
                             if (is_array($rec)) {
                                 // Setting visual path / title of form:
                                 $this->generalPathOfForm = $this->tceforms->getRecordPath($table, $rec);
                                 if (!$this->storeTitle) {
                                     $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : t3lib_BEfunc::getRecordTitle($table, $rec, TRUE);
                                 }
                                 // Setting variables in TCEforms object:
                                 $this->tceforms->hiddenFieldList = '';
                                 $this->tceforms->globalShowHelp = $this->disHelp ? 0 : 1;
                                 if (is_array($this->overrideVals[$table])) {
                                     $this->tceforms->hiddenFieldListArr = array_keys($this->overrideVals[$table]);
                                 }
                                 // Register default language labels, if any:
                                 $this->tceforms->registerDefaultLanguageData($table, $rec);
                                 // Create form for the record (either specific list of fields or the whole record):
                                 $panel = '';
                                 if ($this->columnsOnly) {
                                     if (is_array($this->columnsOnly)) {
                                         $panel .= $this->tceforms->getListedFields($table, $rec, $this->columnsOnly[$table]);
                                     } else {
                                         $panel .= $this->tceforms->getListedFields($table, $rec, $this->columnsOnly);
                                     }
                                 } else {
                                     $panel .= $this->tceforms->getMainFields($table, $rec);
                                 }
                                 $panel = $this->tceforms->wrapTotal($panel, $rec, $table);
                                 // Setting the pid value for new records:
                                 if ($cmd == 'new') {
                                     $panel .= '<input type="hidden" name="data[' . $table . '][' . $rec['uid'] . '][pid]" value="' . $rec['pid'] . '" />';
                                     $this->newC++;
                                 }
                                 // Display "is-locked" message:
                                 if ($lockInfo = t3lib_BEfunc::isRecordLocked($table, $rec['uid'])) {
                                     $lockedMessage = t3lib_div::makeInstance('t3lib_FlashMessage', htmlspecialchars($lockInfo['msg']), '', t3lib_FlashMessage::WARNING);
                                     t3lib_FlashMessageQueue::addMessage($lockedMessage);
                                 }
                                 // Combine it all:
                                 $editForm .= $panel;
                             }
                             $thePrevUid = $rec['uid'];
                         } else {
                             $this->errorC++;
                             $editForm .= $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.noEditPermission', 1) . '<br /><br />' . ($deniedAccessReason ? 'Reason: ' . htmlspecialchars($deniedAccessReason) . '<br /><br />' : '');
                         }
                     }
                 }
             }
         }
     }
     return $editForm;
 }
 /**
  * Parses the HTML tags that would have been inserted to the <head> of a HTML document and returns the found tags as multidimensional array.
  *
  * @return	array		The parsed tags with their attributes and innerHTML parts
  */
 protected function getHeadTags()
 {
     $headTags = array();
     $headDataRaw = $this->fObj->JStop();
     if ($headDataRaw) {
         // Create instance of the HTML parser:
         $parseObj = t3lib_div::makeInstance('t3lib_parsehtml');
         // Removes script wraps:
         $headDataRaw = str_replace(array('/*<![CDATA[*/', '/*]]>*/'), '', $headDataRaw);
         // Removes leading spaces of a multiline string:
         $headDataRaw = trim(preg_replace('/(^|\\r|\\n)( |\\t)+/', '$1', $headDataRaw));
         // Get script and link tags:
         $tags = array_merge($parseObj->getAllParts($parseObj->splitTags('link', $headDataRaw)), $parseObj->getAllParts($parseObj->splitIntoBlock('script', $headDataRaw)));
         foreach ($tags as $tagData) {
             $tagAttributes = $parseObj->get_tag_attributes($parseObj->getFirstTag($tagData), true);
             $headTags[] = array('name' => $parseObj->getFirstTagName($tagData), 'attributes' => $tagAttributes[0], 'innerHTML' => $parseObj->removeFirstAndLastTag($tagData));
         }
     }
     return $headTags;
 }