/**
  * Entry function that hooks into the main typo3/alt_clickmenu.php,
  * see ext_tables.php of this extension for more info
  *
  * @param $backRef		the clickMenu object
  * @param $menuItems	the menuItems as an array that are already filled from the main clickmenu 
  * @param $table	the table that is worked on (tx_dam_cat only)
  * @param $uid		the item UID that is worked on
  * @return unknown
  */
 function main(&$backRef, $menuItems, $table, $uid)
 {
     if ($table != 'tx_dam_cat') {
         return $menuItems;
     }
     $this->backRef =& $backRef;
     // Get record
     $this->rec = t3lib_BEfunc::getRecordWSOL($table, $uid);
     $menuItems = array();
     $root = !strcmp($uid, '0') ? true : false;
     if (is_array($this->rec) || $root) {
         $lCP = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages', $root ? tx_dam_db::getPid() : $this->rec['pid']));
         // Edit
         if (!$root && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'edit') && !in_array('edit', $this->backRef->disabledItems)) {
             $menuItems['edit'] = $this->DAMcatEdit($table, $uid);
         }
         // New Category
         if (!in_array('new', $this->backRef->disabledItems) && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'new')) {
             $menuItems['new'] = $this->DAMnewSubCat($table, $uid);
         }
         // Info
         if (!in_array('info', $this->backRef->disabledItems) && !$root) {
             $menuItems['info'] = $this->DAMcatInfo($table, $uid);
         }
         // Delete
         $elInfo = array(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $this->rec), $GLOBALS['BE_USER']->uc['titleLen']));
         if (!in_array('delete', $this->backRef->disabledItems) && !$root && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'delete')) {
             $menuItems['spacer2'] = 'spacer';
             $menuItems['delete'] = $this->DAMcatDelete($table, $uid, $elInfo);
         }
     }
     return $menuItems;
 }
 /**
  * Builds a complete node including children
  *
  * @param \t3lib_tree_Node|\TYPO3\CMS\Backend\Tree\TreeNode $basicNode
  * @param NULL|t3lib_tree_tca_DatabaseNode $parent
  * @param integer $level
  * @param bool $restriction
  * @return t3lib_tree_tca_DatabaseNode node
  */
 protected function buildRepresentationForNode(t3lib_tree_Node $basicNode, t3lib_tree_tca_DatabaseNode $parent = NULL, $level = 0, $restriction = FALSE)
 {
     /**@param $node t3lib_tree_tca_DatabaseNode */
     $node = t3lib_div::makeInstance('t3lib_tree_tca_DatabaseNode');
     $row = array();
     if ($basicNode->getId() == 0) {
         $node->setSelected(FALSE);
         $node->setExpanded(TRUE);
         $node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title']));
     } else {
         $row = t3lib_BEfunc::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', FALSE);
         if ($this->getLabelField() !== '') {
             $label = Tx_News_Service_CategoryService::translateCategoryRecord($row[$this->getLabelField()], $row);
             $node->setLabel($label);
         } else {
             $node->setLabel($basicNode->getId());
         }
         $node->setSelected(t3lib_div::inList($this->getSelectedList(), $basicNode->getId()));
         $node->setExpanded($this->isExpanded($basicNode));
         $node->setLabel($node->getLabel());
     }
     $node->setId($basicNode->getId());
     // Break to force single category activation
     if ($parent != NULL && $level != 0 && $this->isSingleCategoryAclActivated() && !$this->isCategoryAllowed($node)) {
         return NULL;
     }
     $node->setSelectable(!t3lib_div::inList($this->getNonSelectableLevelList(), $level) && !in_array($basicNode->getId(), $this->getItemUnselectableList()));
     $node->setSortValue($this->nodeSortValues[$basicNode->getId()]);
     $node->setIcon(t3lib_iconWorks::mapRecordTypeToSpriteIconClass($this->tableName, $row));
     $node->setParentNode($parent);
     if ($basicNode->hasChildNodes()) {
         $node->setHasChildren(TRUE);
         $childNodes = t3lib_div::makeInstance('t3lib_tree_SortedNodeCollection');
         $foundSomeChild = FALSE;
         foreach ($basicNode->getChildNodes() as $child) {
             // Change in custom TreeDataProvider by adding the if clause
             if ($restriction || $this->isCategoryAllowed($child)) {
                 $returnedChild = $this->buildRepresentationForNode($child, $node, $level + 1, TRUE);
                 if (!is_null($returnedChild)) {
                     $foundSomeChild = TRUE;
                     $childNodes->append($returnedChild);
                 } else {
                     $node->setParentNode(NULL);
                     $node->setHasChildren(FALSE);
                 }
             }
             // Change in custom TreeDataProvider end
         }
         if ($foundSomeChild) {
             $node->setChildNodes($childNodes);
         }
     }
     return $node;
 }
    /**
     * MAIN function for page information of localization
     *
     * @return	string		Output HTML for the module.
     */
    function main()
    {
        global $BACK_PATH, $LANG, $SOBE;
        if ($this->pObj->id) {
            $theOutput = '';
            // Depth selector:
            $h_func = t3lib_BEfunc::getFuncMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth'], 'index.php');
            $h_func .= t3lib_BEfunc::getFuncMenu($this->pObj->id, 'SET[lang]', $this->pObj->MOD_SETTINGS['lang'], $this->pObj->MOD_MENU['lang'], 'index.php');
            $theOutput .= $h_func;
            // Add CSH:
            $theOutput .= t3lib_BEfunc::cshItem('_MOD_web_info', 'lang', $GLOBALS['BACK_PATH'], '|<br/>');
            // Showing the tree:
            // Initialize starting point of page tree:
            $treeStartingPoint = intval($this->pObj->id);
            $treeStartingRecord = t3lib_BEfunc::getRecordWSOL('pages', $treeStartingPoint);
            $depth = $this->pObj->MOD_SETTINGS['depth'];
            // Initialize tree object:
            $tree = t3lib_div::makeInstance('t3lib_pageTree');
            $tree->init('AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
            $tree->addField('l18n_cfg');
            // Creating top icon; the current page
            $HTML = t3lib_iconWorks::getIconImage('pages', $treeStartingRecord, $GLOBALS['BACK_PATH'], 'align="top"');
            $tree->tree[] = array('row' => $treeStartingRecord, 'HTML' => $HTML);
            // Create the tree from starting point:
            if ($depth) {
                $tree->getTree($treeStartingPoint, $depth, '');
            }
            #debug($tree->tree);
            // Add CSS needed:
            $css_content = '
				TABLE#langTable {
					margin-top: 10px;
				}
				TABLE#langTable TR TD {
					padding-left : 2px;
					padding-right : 2px;
					white-space: nowrap;
				}
				TD.c-notvisible { background-color: red; }
				TD.c-visible { background-color: #669966; }
				TD.c-translated { background-color: #A8E95C; }
				TD.c-nottranslated { background-color: #E9CD5C; }
				TD.c-leftLine {border-left: 2px solid black; }
				.bgColor5 { font-weight: bold; }
			';
            $marker = '/*###POSTCSSMARKER###*/';
            $this->pObj->content = str_replace($marker, $css_content . chr(10) . $marker, $this->pObj->content);
            // Render information table:
            $theOutput .= $this->renderL10nTable($tree);
        }
        return $theOutput;
    }
 function main(&$backRef, $menuItems, $tableID, $srcId)
 {
     $this->includeLocalLang();
     $this->backRef =& $backRef;
     /**
      * TODO
      *
      * FIXME
      * backpath will not work in global installations
      */
     if (($tableID == 'dragDrop_tt_news_cat' || $tableID == 'tt_news_cat_CM') && $srcId) {
         $table = 'tt_news_cat';
         $rec = t3lib_BEfunc::getRecordWSOL($table, $srcId);
         // fetch page record to get editing permissions
         $lCP = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages', $rec['pid']));
         $doEdit = $lCP & 16;
         //print_r( array($lCP));
         if ($doEdit && $tableID == 'dragDrop_tt_news_cat') {
             $this->backRef->backPath = '../../../';
             $dstId = intval(t3lib_div::_GP('dstId'));
             $menuItems['moveinto'] = $this->dragDrop_moveCategory($srcId, $dstId);
             $menuItems['copyinto'] = $this->dragDrop_copyCategory($srcId, $dstId);
         }
         if ($tableID == 'tt_news_cat_CM') {
             $this->backRef->backPath = '../../../../typo3/';
             $menuItems = array();
             if ($doEdit) {
                 $menuItems['edit'] = $this->DB_edit($table, $srcId);
                 $menuItems['new'] = $this->DB_new($table, $rec);
                 $menuItems['newsub'] = $this->DB_new($table, $rec, true);
             }
             $menuItems['info'] = $backRef->DB_info($table, $srcId);
             if ($doEdit) {
                 $menuItems['hide'] = $this->DB_hideUnhide($table, $rec, 'hidden');
                 $elInfo = array(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle('tt_news_cat', $rec), $GLOBALS['BE_USER']->uc['titleLen']));
                 $menuItems['spacer2'] = 'spacer';
                 $menuItems['delete'] = $this->DB_delete($table, $srcId, $elInfo);
             }
         }
     }
     return $menuItems;
 }
Esempio n. 5
0
 /**
  * @param  $table
  * @param  $record
  * @return bool
  */
 protected function hasBasicEditRights($table = null, array $record = null)
 {
     $hasEditRights = FALSE;
     if ($table == null) {
         $table = $this->rootElementTable;
     }
     if (empty($record)) {
         $record = $this->rootElementRecord;
     }
     if ($GLOBALS['BE_USER']->isAdmin()) {
         $hasEditRights = TRUE;
     } else {
         $id = $record[$table == 'pages' ? 'uid' : 'pid'];
         $pageRecord = t3lib_BEfunc::getRecordWSOL('pages', $id);
         $mayEditPage = $GLOBALS['BE_USER']->doesUserHaveAccess($pageRecord, 16);
         $mayModifyTable = t3lib_div::inList($GLOBALS['BE_USER']->groupData['tables_modify'], $table);
         $mayEditContentField = t3lib_div::inList($GLOBALS['BE_USER']->groupData['non_exclude_fields'], $table . ':tx_templavoila_flex');
         $hasEditRights = $mayEditPage && $mayModifyTable && $mayEditContentField;
     }
     return $hasEditRights;
 }
 /**
  * Returns the page uid of the selected storage folder from the context of the given page uid.
  *
  * @param	integer		$pageUid: Context page uid
  * @return	integer		PID of the storage folder
  * @access	public
  */
 function getStorageFolderPid($pageUid)
 {
     // Negative PID values is pointing to a page on the same level as the current.
     if ($pageUid < 0) {
         $pidRow = t3lib_BEfunc::getRecordWSOL('pages', abs($pageUid), 'pid');
         $pageUid = $pidRow['pid'];
     }
     $row = t3lib_BEfunc::getRecordWSOL('pages', $pageUid);
     $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig('pages', $row);
     return intval($TSconfig['_STORAGE_PID']);
 }
    /**
     * Prints the selector box form-field for the db/file/select elements (multiple)
     *
     * @param	string		Form element name
     * @param	string		Mode "db", "file" (internal_type for the "group" type) OR blank (then for the "select" type). Seperated with '|' a user defined mode can be set to be passed as param to the EB.
     * @param	string		Commalist of "allowed"
     * @param	array		The array of items. For "select" and "group"/"file" this is just a set of value. For "db" its an array of arrays with table/uid pairs.
     * @param	string		Alternative selector box.
     * @param	array		An array of additional parameters, eg: "size", "info", "headers" (array with "selector" and "items"), "noBrowser", "thumbnails"
     * @param	string		On focus attribute string
     * @param	string		$user_el_param Additional parameter for the EB
     * @return	string		The form fields for the selection.
     */
    function dbFileIcons($fName, $mode, $allowed, $itemArray, $selector = '', $params = array(), $onFocus = '', $userEBParam = '')
    {
        list($mode, $modeEB) = explode('|', $mode);
        $modeEB = $modeEB ? $modeEB : $mode;
        $disabled = '';
        if ($this->tceforms->renderReadonly || $params['readOnly']) {
            $disabled = ' disabled="disabled"';
        }
        // Sets a flag which means some JavaScript is included on the page to support this element.
        $this->tceforms->printNeededJS['dbFileIcons'] = 1;
        // INIT
        $uidList = array();
        $opt = array();
        $itemArrayC = 0;
        // Creating <option> elements:
        if (is_array($itemArray)) {
            $itemArrayC = count($itemArray);
            reset($itemArray);
            switch ($mode) {
                case 'db':
                    while (list(, $pp) = each($itemArray)) {
                        if ($pp['title']) {
                            $pTitle = $pp['title'];
                        } else {
                            if (function_exists('t3lib_BEfunc::getRecordWSOL')) {
                                $pRec = t3lib_BEfunc::getRecordWSOL($pp['table'], $pp['id']);
                            } else {
                                $pRec = t3lib_BEfunc::getRecord($pp['table'], $pp['id']);
                            }
                            $pTitle = is_array($pRec) ? $pRec[$GLOBALS['TCA'][$pp['table']]['ctrl']['label']] : NULL;
                        }
                        if ($pTitle) {
                            $pTitle = $pTitle ? t3lib_div::fixed_lgd_cs($pTitle, $this->tceforms->titleLen) : t3lib_BEfunc::getNoRecordTitle();
                            $pUid = $pp['table'] . '_' . $pp['id'];
                            $uidList[] = $pUid;
                            $opt[] = '<option value="' . htmlspecialchars($pUid) . '">' . htmlspecialchars($pTitle) . '</option>';
                        }
                    }
                    break;
                case 'folder':
                case 'file':
                    while (list(, $pp) = each($itemArray)) {
                        $pParts = explode('|', $pp);
                        $uidList[] = $pUid = $pTitle = $pParts[0];
                        $opt[] = '<option value="' . htmlspecialchars(rawurldecode($pParts[0])) . '">' . htmlspecialchars(rawurldecode($pParts[0])) . '</option>';
                    }
                    break;
                default:
                    while (list(, $pp) = each($itemArray)) {
                        $pParts = explode('|', $pp, 2);
                        $uidList[] = $pUid = $pParts[0];
                        $pTitle = $pParts[1] ? $pParts[1] : $pParts[0];
                        $opt[] = '<option value="' . htmlspecialchars(rawurldecode($pUid)) . '">' . htmlspecialchars(rawurldecode($pTitle)) . '</option>';
                    }
                    break;
            }
        }
        // Create selector box of the options
        $sSize = $params['autoSizeMax'] ? t3lib_div::intInRange($itemArrayC + 1, t3lib_div::intInRange($params['size'], 1), $params['autoSizeMax']) : $params['size'];
        if (!$selector) {
            $selector = '<select size="' . $sSize . '"' . $this->tceforms->insertDefStyle('group') . ' multiple="multiple" name="' . $fName . '_list" ' . $onFocus . $params['style'] . $disabled . '>' . implode('', $opt) . '</select>';
        }
        $icons = array('L' => array(), 'R' => array());
        if (!$params['readOnly']) {
            if (!$params['noBrowser']) {
                $aOnClick = 'setFormValueOpenBrowser(\'' . $modeEB . '\',\'' . ($fName . '|||' . $allowed . '|' . $userEBParam . '|') . '\'); return false;';
                $icons['R'][] = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/insert3.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_browse_' . ($mode === 'file' ? 'file' : 'db'))) . ' />' . '</a>';
            }
            if (!$params['dontShowMoveIcons']) {
                if ($sSize >= 5) {
                    $icons['L'][] = '<a href="#" onclick="setFormValueManipulate(\'' . $fName . '\',\'Top\'); return false;">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/group_totop.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_move_to_top')) . ' />' . '</a>';
                }
                $icons['L'][] = '<a href="#" onclick="setFormValueManipulate(\'' . $fName . '\',\'Up\'); return false;">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/up.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_move_up')) . ' />' . '</a>';
                $icons['L'][] = '<a href="#" onclick="setFormValueManipulate(\'' . $fName . '\',\'Down\'); return false;">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/down.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_move_down')) . ' />' . '</a>';
                if ($sSize >= 5) {
                    $icons['L'][] = '<a href="#" onclick="setFormValueManipulate(\'' . $fName . '\',\'Bottom\'); return false;">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/group_tobottom.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_move_to_bottom')) . ' />' . '</a>';
                }
            }
            // todo Clipboard
            $clipElements = $this->tceforms->getClipboardElements($allowed, $mode);
            if (count($clipElements)) {
                $aOnClick = '';
                #			$counter = 0;
                foreach ($clipElements as $elValue) {
                    if ($mode === 'file' or $mode === 'folder') {
                        $itemTitle = 'unescape(\'' . rawurlencode(tx_dam::file_basename($elValue)) . '\')';
                    } else {
                        // 'db' mode assumed
                        list($itemTable, $itemUid) = explode('|', $elValue);
                        if (function_exists('t3lib_BEfunc::getRecordWSOL')) {
                            $rec = t3lib_BEfunc::getRecordWSOL($itemTable, $itemUid);
                        } else {
                            $rec = t3lib_BEfunc::getRecord($itemTable, $itemUid);
                        }
                        $itemTitle = $GLOBALS['LANG']->JScharCode(t3lib_BEfunc::getRecordTitle($itemTable, $rec));
                        $elValue = $itemTable . '_' . $itemUid;
                    }
                    $aOnClick .= 'setFormValueFromBrowseWin(\'' . $fName . '\',\'' . t3lib_div::slashJS(t3lib_div::rawUrlEncodeJS($elValue)) . '\',' . t3lib_div::slashJS($itemTitle) . ');';
                    #$aOnClick .= 'setFormValueFromBrowseWin(\''.$fName.'\',unescape(\''.rawurlencode(str_replace('%20', ' ', $elValue)).'\'),'.$itemTitle.');';
                    #				$counter++;
                    #				if ($params['maxitems'] && $counter >= $params['maxitems'])	{	break;	}	// Makes sure that no more than the max items are inserted... for convenience.
                }
                $aOnClick .= 'return false;';
                $icons['R'][] = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/insert5.png', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib(sprintf($this->tceforms->getLL('l_clipInsert_' . ($mode === 'file' ? 'file' : 'db')), count($clipElements))) . ' />' . '</a>';
            }
            $icons['L'][] = '<a href="#" onclick="setFormValueManipulate(\'' . $fName . '\',\'Remove\'); return false;">' . '<img' . t3lib_iconWorks::skinImg($this->tceforms->backPath, 'gfx/group_clear.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->tceforms->getLL('l_remove_selected')) . ' />' . '</a>';
        }
        $str = '<table border="0" cellpadding="0" cellspacing="0" width="1">
			' . ($params['headers'] ? '
				<tr>
					<td>' . $this->tceforms->wrapLabels($params['headers']['selector']) . '</td>
					<td></td>
					<td></td>
					<td></td>
					<td>' . ($params['thumbnails'] ? $this->tceforms->wrapLabels($params['headers']['items']) : '') . '</td>
				</tr>' : '') . '
			<tr>
				<td valign="top">' . $selector . '<br />' . $this->tceforms->wrapLabels($params['info']) . '</td>
				<td valign="top">' . implode('<br />', $icons['L']) . '</td>
				<td valign="top">' . implode('<br />', $icons['R']) . '</td>
				<td style="height:5px;"><span></span></td>
				<td valign="top">' . $this->tceforms->wrapLabels($params['thumbnails']) . '</td>
			</tr>
		</table>';
        // Creating the hidden field which contains the actual value as a comma list.
        $str .= '<input type="hidden" name="' . $fName . '" value="' . htmlspecialchars(implode(',', $uidList)) . '" />';
        return $str;
    }
Esempio n. 8
0
    /**
     * Creating the module output.
     *
     * @return	void
     * @todo	provide position mapping if no position is given already. Like the columns selector but for our cascading element style ...
     */
    function main()
    {
        global $LANG, $BACK_PATH;
        if ($this->id && $this->access) {
            // Creating content
            $this->content = $this->doc->header($LANG->getLL('newContentElement'));
            $this->content .= $this->doc->spacer(5);
            $elRow = t3lib_BEfunc::getRecordWSOL('pages', $this->id);
            $header = t3lib_iconWorks::getSpriteIconForRecord('pages', $elRow);
            $header .= t3lib_BEfunc::getRecordTitle('pages', $elRow, 1);
            $this->content .= $this->doc->section('', $header, 0, 1);
            $this->content .= $this->doc->spacer(10);
            // Wizard
            $wizardCode = '';
            $tableRows = array();
            $wizardItems = $this->getWizardItems();
            // Wrapper for wizards
            $this->elementWrapper['sectionHeader'] = array('<h3 class="bgColor5">', '</h3>');
            $this->elementWrapper['section'] = array('<table border="0" cellpadding="1" cellspacing="2">', '</table>');
            $this->elementWrapper['wizard'] = array('<tr>', '</tr>');
            $this->elementWrapper['wizardPart'] = array('<td>', '</td>');
            // copy wrapper for tabs
            $this->elementWrapperForTabs = $this->elementWrapper;
            // Hook for manipulating wizardItems, wrapper, onClickEvent etc.
            if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['templavoila']['db_new_content_el']['wizardItemsHook'])) {
                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['templavoila']['db_new_content_el']['wizardItemsHook'] as $classData) {
                    $hookObject = t3lib_div::getUserObj($classData);
                    if (!$hookObject instanceof cms_newContentElementWizardsHook) {
                        throw new UnexpectedValueException('$hookObject must implement interface cms_newContentElementWizardItemsHook', 1227834741);
                    }
                    $hookObject->manipulateWizardItems($wizardItems, $this);
                }
            }
            if ($this->config['renderMode'] == 'tabs' && $this->elementWrapperForTabs != $this->elementWrapper) {
                // restore wrapper for tabs if they are overwritten in hook
                $this->elementWrapper = $this->elementWrapperForTabs;
            }
            // add document inline javascript
            $this->doc->JScode = $this->doc->wrapScriptTags('
				function goToalt_doc()	{	//
					' . $this->onClickEvent . '
				}

				Event.observe(window, \'load\', function() {
					if(top.refreshMenu) {
						top.refreshMenu();
					} else {
						top.TYPO3ModuleMenu.refreshMenu();
					}

					if(top.shortcutFrame) {
						top.shortcutFrame.refreshShortcuts();
					}
				});
			');
            // Traverse items for the wizard.
            // An item is either a header or an item rendered with a title/description and icon:
            $counter = 0;
            foreach ($wizardItems as $k => $wInfo) {
                if ($wInfo['header']) {
                    $menuItems[] = array('label' => htmlspecialchars($wInfo['header']), 'content' => $this->elementWrapper['section'][0]);
                    $key = count($menuItems) - 1;
                } else {
                    $content = '';
                    // href URI for icon/title:
                    $newRecordLink = 'index.php?' . $this->linkParams() . '&createNewRecord=' . rawurlencode($this->parentRecord) . $wInfo['params'];
                    // Icon:
                    $iInfo = @getimagesize($wInfo['icon']);
                    $content .= $this->elementWrapper['wizardPart'][0] . '<a href="' . htmlspecialchars($newRecordLink) . '">
						<img' . t3lib_iconWorks::skinImg($this->doc->backPath, $wInfo['icon'], '') . ' alt="" /></a>' . $this->elementWrapper['wizardPart'][1];
                    // Title + description:
                    $content .= $this->elementWrapper['wizardPart'][0] . '<a href="' . htmlspecialchars($newRecordLink) . '"><strong>' . htmlspecialchars($wInfo['title']) . '</strong><br />' . nl2br(htmlspecialchars(trim($wInfo['description']))) . '</a>' . $this->elementWrapper['wizardPart'][1];
                    // Finally, put it together in a container:
                    $menuItems[$key]['content'] .= $this->elementWrapper['wizard'][0] . $content . $this->elementWrapper['wizard'][1];
                }
            }
            // add closing section-tag
            foreach ($menuItems as $key => $val) {
                $menuItems[$key]['content'] .= $this->elementWrapper['section'][1];
            }
            // Add the wizard table to the content, wrapped in tabs:
            if ($this->config['renderMode'] == 'tabs') {
                $this->doc->inDocStylesArray[] = '
					.typo3-dyntabmenu-divs { background-color: #fafafa; border: 1px solid #000; width: 680px; }
					.typo3-dyntabmenu-divs table { margin: 15px; }
					.typo3-dyntabmenu-divs table td { padding: 3px; }
				';
                $code = $LANG->getLL('sel1', 1) . '<br /><br />' . $this->doc->getDynTabMenu($menuItems, 'new-content-element-wizard', false, false, 100);
            } else {
                $code = $LANG->getLL('sel1', 1) . '<br /><br />';
                foreach ($menuItems as $section) {
                    $code .= $this->elementWrapper['sectionHeader'][0] . $section['label'] . $this->elementWrapper['sectionHeader'][1] . $section['content'];
                }
            }
            $this->content .= $this->doc->section(!$this->onClickEvent ? $LANG->getLL('1_selectType') : '', $code, 0, 1);
        } else {
            // In case of no access:
            $this->content = $this->doc->header($LANG->getLL('newContentElement'));
        }
        $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause);
        $docHeaderButtons = $this->getDocHeaderButtons();
        $docContent = array('CSH' => $docHeaderButtons['csh'], 'CONTENT' => $this->content);
        $content = $this->doc->startPage($LANG->getLL('newContentElement'));
        $content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $docContent);
        $content .= $this->doc->endPage();
        // Replace content with templated content
        $this->content = $content;
    }
    /**
     * Main function of class
     *
     * @return	string		HTML output
     */
    function main()
    {
        global $LANG;
        $menu = t3lib_BEfunc::getFuncMenu($this->pObj->id, 'SET[tsconf_parts]', $this->pObj->MOD_SETTINGS['tsconf_parts'], $this->pObj->MOD_MENU['tsconf_parts']);
        $menu .= '<br /><label for="checkTsconf_alphaSort">' . $GLOBALS['LANG']->getLL('sort_alphabetic', true) . '</label> ' . t3lib_BEfunc::getFuncCheck($this->pObj->id, 'SET[tsconf_alphaSort]', $this->pObj->MOD_SETTINGS['tsconf_alphaSort'], '', '', 'id="checkTsconf_alphaSort"');
        $menu .= '<br /><br />';
        if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) {
            $TSparts = t3lib_BEfunc::getPagesTSconfig($this->pObj->id, '', 1);
            $lines = array();
            $pUids = array();
            foreach ($TSparts as $k => $v) {
                if ($k != 'uid_0') {
                    if ($k == 'defaultPageTSconfig') {
                        $pTitle = '<strong>' . $GLOBALS['LANG']->getLL('editTSconfig_default', 1) . '</strong>';
                        $editIcon = '';
                    } else {
                        $pUids[] = substr($k, 4);
                        $row = t3lib_BEfunc::getRecordWSOL('pages', substr($k, 4));
                        $pTitle = $this->pObj->doc->getHeader('pages', $row, '', 0);
                        $editIdList = substr($k, 4);
                        $params = '&edit[pages][' . $editIdList . ']=edit&columnsOnly=TSconfig';
                        $onclickUrl = t3lib_BEfunc::editOnClick($params, $GLOBALS['BACK_PATH'], '');
                        $editIcon = '<a href="#" onclick="' . htmlspecialchars($onclickUrl) . '" title="' . $GLOBALS['LANG']->getLL('editTSconfig', 1) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';
                    }
                    $TScontent = nl2br(htmlspecialchars(trim($v) . chr(10)));
                    $tsparser = t3lib_div::makeInstance('t3lib_TSparser');
                    $tsparser->lineNumberOffset = 0;
                    $TScontent = $tsparser->doSyntaxHighlight(trim($v) . LF, '', 0);
                    $lines[] = '
						<tr><td nowrap="nowrap" class="bgColor5">' . $pTitle . '</td></tr>
						<tr><td nowrap="nowrap" class="bgColor4">' . $TScontent . $editIcon . '</td></tr>
						<tr><td>&nbsp;</td></tr>
					';
                }
            }
            if (count($pUids)) {
                $params = '&edit[pages][' . implode(',', $pUids) . ']=edit&columnsOnly=TSconfig';
                $onclickUrl = t3lib_BEfunc::editOnClick($params, $GLOBALS['BACK_PATH'], '');
                $editIcon = '<a href="#" onclick="' . htmlspecialchars($onclickUrl) . '" title="' . $GLOBALS['LANG']->getLL('editTSconfig_all', 1) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '<strong>' . $GLOBALS['LANG']->getLL('editTSconfig_all', 1) . '</strong>' . '</a>';
            } else {
                $editIcon = '';
            }
            $theOutput .= $this->pObj->doc->section($LANG->getLL('tsconf_title'), t3lib_BEfunc::cshItem('_MOD_' . $GLOBALS['MCONF']['name'], 'tsconfig_edit', $GLOBALS['BACK_PATH'], '|<br />') . $menu . '
					<br /><br />

					<!-- Edit fields: -->
					<table border="0" cellpadding="0" cellspacing="1">' . implode('', $lines) . '</table><br />' . $editIcon, 0, 1);
        } else {
            $tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext');
            // Defined global here!
            $tmpl->tt_track = 0;
            // Do not log time-performance information
            $tmpl->fixedLgd = 0;
            $tmpl->linkObjects = 0;
            $tmpl->bType = '';
            $tmpl->ext_expandAllNotes = 1;
            $tmpl->ext_noPMicons = 1;
            switch ($this->pObj->MOD_SETTINGS['tsconf_parts']) {
                case '1':
                    $modTSconfig = t3lib_BEfunc::getModTSconfig($this->pObj->id, 'mod');
                    break;
                case '1a':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_layout', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                case '1b':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_view', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                case '1c':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_modules', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                case '1d':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_list', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                case '1e':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_info', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                case '1f':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_func', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                case '1g':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.web_ts', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                case '2':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                case '5':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('TCEFORM', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                case '6':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('TCEMAIN', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                case '3':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('TSFE', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                case '4':
                    $modTSconfig = $GLOBALS['BE_USER']->getTSConfig('user', t3lib_BEfunc::getPagesTSconfig($this->pObj->id));
                    break;
                default:
                    $modTSconfig['properties'] = t3lib_BEfunc::getPagesTSconfig($this->pObj->id);
                    break;
            }
            $modTSconfig = $modTSconfig['properties'];
            if (!is_array($modTSconfig)) {
                $modTSconfig = array();
            }
            $theOutput .= $this->pObj->doc->section($LANG->getLL('tsconf_title'), t3lib_BEfunc::cshItem('_MOD_' . $GLOBALS['MCONF']['name'], 'tsconfig_hierarchy', $GLOBALS['BACK_PATH'], '|<br />') . $menu . '

					<!-- Page TSconfig Tree: -->
					<table border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td nowrap="nowrap">' . $tmpl->ext_getObjTree($modTSconfig, '', '', '', '', $this->pObj->MOD_SETTINGS['tsconf_alphaSort']) . '</td>
						</tr>
					</table>', 0, 1);
        }
        // Return output:
        return $theOutput;
    }
Esempio n. 10
0
    /**
     * Links to stage change of a version
     *
     * @param	string		Table name
     * @param	array		Offline record (version)
     * @return	string		HTML content, mainly link tags and images.
     */
    function displayWorkspaceOverview_allStageCmd()
    {
        $table = t3lib_div::_GP('table');
        if ($table && $table != 'pages') {
            $uid = t3lib_div::_GP('uid');
            if ($rec_off = t3lib_BEfunc::getRecordWSOL($table, $uid)) {
                $uid = $rec_off['_ORIG_uid'];
            }
        } else {
            $table = '';
        }
        if ($table) {
            if ($uid && $this->recIndex[$table][$uid]) {
                $sId = $this->recIndex[$table][$uid];
                switch ($sId) {
                    case 1:
                        $label = $GLOBALS['LANG']->getLL('commentForReviewer');
                        break;
                    case 10:
                        $label = $GLOBALS['LANG']->getLL('commentForPublisher');
                        break;
                }
            } else {
                $sId = 0;
            }
        } else {
            if (count($this->stageIndex[1])) {
                // Review:
                $sId = 1;
                $color = '#666666';
                $label = $GLOBALS['LANG']->getLL('sendItemsToReview') . $GLOBALS['LANG']->getLL('commentForReviewer');
                $titleAttrib = $GLOBALS['LANG']->getLL('sendAllToReview');
            } elseif (count($this->stageIndex[10])) {
                // Publish:
                $sId = 10;
                $color = '#6666cc';
                $label = $GLOBALS['LANG']->getLL('approveToPublish') . $GLOBALS['LANG']->getLL('commentForPublisher');
                $titleAttrib = $GLOBALS['LANG']->getLL('approveAllToPublish');
            } else {
                $sId = 0;
            }
        }
        if ($sId > 0) {
            $issueCmd = '';
            $itemCount = 0;
            if ($table && $uid && $this->recIndex[$table][$uid]) {
                $issueCmd .= '&cmd[' . $table . '][' . $uid . '][version][action]=setStage';
                $issueCmd .= '&cmd[' . $table . '][' . $uid . '][version][stageId]=' . $this->recIndex[$table][$uid];
            } else {
                foreach ($this->stageIndex[$sId] as $table => $uidArray) {
                    $issueCmd .= '&cmd[' . $table . '][' . implode(',', $uidArray) . '][version][action]=setStage';
                    $issueCmd .= '&cmd[' . $table . '][' . implode(',', $uidArray) . '][version][stageId]=' . $sId;
                    $itemCount += count($uidArray);
                }
            }
            $onClick = 'var commentTxt=window.prompt("' . sprintf($label, $itemCount) . '","");
							if (commentTxt!=null) {window.location.href="' . $this->doc->issueCommand($issueCmd, $this->REQUEST_URI) . '&generalComment="+escape(commentTxt);}';
            if (t3lib_div::_GP('sendToReview')) {
                $onClick .= ' else {window.location.href = "' . $this->REQUEST_URI . '"}';
                $actionLinks .= $this->doc->wrapScriptTags($onClick);
            } else {
                $onClick .= ' return false;';
                $actionLinks .= '<input type="submit" name="_" value="' . htmlspecialchars($titleAttrib) . '" onclick="' . htmlspecialchars($onClick) . '" />';
            }
        } elseif (t3lib_div::_GP('sendToReview')) {
            $onClick = 'window.location.href = "' . $this->REQUEST_URI . '";';
            $actionLinks .= $this->doc->wrapScriptTags($onClick);
        } else {
            $actionLinks = '';
        }
        return $actionLinks;
    }
 /**
  * Extract the disallowed TCAFORM field values of $fieldName given field
  *
  * @param	integer		$parentPageId
  * @param	string		field name of TCAFORM
  * @access	private
  * @return	string		comma seperated list of integer
  */
 function getDisallowedTSconfigItemsByFieldName($positionPid, $fieldName)
 {
     $disallowPageTemplateItems = '';
     $disallowPageTemplateList = array();
     // Negative PID values is pointing to a page on the same level as the current.
     if ($positionPid < 0) {
         $pidRow = t3lib_BEfunc::getRecordWSOL('pages', abs($positionPid), 'pid');
         $parentPageId = $pidRow['pid'];
     } else {
         $parentPageId = $positionPid;
     }
     // Get PageTSconfig for reduce the output of selectded template structs
     $disallowPageTemplateStruct = t3lib_BEfunc::getModTSconfig(abs($parentPageId), 'TCEFORM.pages.' . $fieldName);
     if (isset($disallowPageTemplateStruct['properties']['removeItems'])) {
         $disallowedPageTemplateList = $disallowPageTemplateStruct['properties']['removeItems'];
     }
     $tmp_disallowedPageTemplateItems = array_unique(t3lib_div::intExplode(',', t3lib_div::expandList($disallowedPageTemplateList), TRUE));
     return count($tmp_disallowedPageTemplateItems) ? implode(',', $tmp_disallowedPageTemplateItems) : '0';
 }
Esempio n. 12
0
	/**
	 * Process editing of a TO for renderTO() function
	 *
	 * @param	array		Data Structure. Passed by reference; The sheets found inside will be resolved if found!
	 * @param	array		TO record row
	 * @param	string		Template file path (absolute)
	 * @param   integer		Process the headerPart instead of the bodyPart
	 * @return	array		Array with two keys (0/1) with a) content and b) currentMappingInfo which is retrieved inside (currentMappingInfo will be different based on whether "head" or "body" content is "mapped")
	 * @see renderTO()
	 */
	function renderTO_editProcessing(&$dataStruct,$row,$theFile, $headerPart = 0)	{
		$msg = array();

			// Converting GPvars into a "cmd" value:
		$cmd = '';
		if (t3lib_div::_GP('_reload_from'))	{	// Reverting to old values in TO
			$cmd = 'reload_from';
		} elseif (t3lib_div::_GP('_clear'))	{	// Resetting mapping
			$cmd = 'clear';
		} elseif (t3lib_div::_GP('_save_data_mapping'))	{	// Saving to Session
			$cmd = 'save_data_mapping';
		} elseif (t3lib_div::_GP('_save_to') || t3lib_div::_GP('_save_to_return'))	{	// Saving to Template Object
			$cmd = 'save_to';
		}

			// Getting data from tmplobj
		$templatemapping = unserialize($row['templatemapping']);
		if (!is_array($templatemapping))	$templatemapping=array();

			// If that array contains sheets, then traverse them:
		if (is_array($dataStruct['sheets']))	{
			$dSheets = t3lib_div::resolveAllSheetsInDS($dataStruct);
			$dataStruct=array(
				'ROOT' => array (
					'tx_templavoila' => array (
						'title' => $GLOBALS['LANG']->getLL('rootMultiTemplate_title'),
						'description' => $GLOBALS['LANG']->getLL('rootMultiTemplate_description'),
					),
					'type' => 'array',
					'el' => array()
				)
			);
			foreach($dSheets['sheets'] as $nKey => $lDS)	{
				if (is_array($lDS['ROOT']))	{
					$dataStruct['ROOT']['el'][$nKey] = $lDS['ROOT'];
				}
			}
		}

			// Get session data:
		$sesDat = $GLOBALS['BE_USER']->getSessionData($this->sessionKey);

			// Set current mapping info arrays:
		$currentMappingInfo_head = is_array($sesDat['currentMappingInfo_head']) ? $sesDat['currentMappingInfo_head'] : array();
		$currentMappingInfo = is_array($sesDat['currentMappingInfo']) ? $sesDat['currentMappingInfo'] : array();
		$this->cleanUpMappingInfoAccordingToDS($currentMappingInfo,$dataStruct);

		// Perform processing for head
			// GPvars, incoming data
		$checkboxElement = t3lib_div::_GP('checkboxElement',1);
		$addBodyTag = t3lib_div::_GP('addBodyTag');

			// Update session data:
		if ($cmd=='reload_from' || $cmd=='clear')	{
			$currentMappingInfo_head = is_array($templatemapping['MappingInfo_head'])&&$cmd!='clear' ? $templatemapping['MappingInfo_head'] : array();
			$sesDat['currentMappingInfo_head'] = $currentMappingInfo_head;
			$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
		} else {
			if ($cmd=='save_data_mapping' || $cmd=='save_to')	{
				$sesDat['currentMappingInfo_head'] = $currentMappingInfo_head = array(
					'headElementPaths' => $checkboxElement,
					'addBodyTag' => $addBodyTag?1:0
				);
				$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
			}
		}

		// Perform processing for  body
			// GPvars, incoming data
		$inputData = t3lib_div::_GP('dataMappingForm',1);

			// Update session data:
		if ($cmd=='reload_from' || $cmd=='clear')	{
			$currentMappingInfo = is_array($templatemapping['MappingInfo'])&&$cmd!='clear' ? $templatemapping['MappingInfo'] : array();
			$this->cleanUpMappingInfoAccordingToDS($currentMappingInfo,$dataStruct);
			$sesDat['currentMappingInfo'] = $currentMappingInfo;
			$sesDat['dataStruct'] = $dataStruct;
			$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
		} else {
			if ($cmd=='save_data_mapping' && is_array($inputData))	{
				$sesDat['currentMappingInfo'] = $currentMappingInfo = $this->array_merge_recursive_overrule($currentMappingInfo,$inputData);
				$sesDat['dataStruct'] = $dataStruct;		// Adding data structure to session data so that the PREVIEW window can access the DS easily...
				$GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat);
			}
		}

			// SAVE to template object
		if ($cmd=='save_to')	{
			$dataArr=array();

				// Set content, either for header or body:
			$templatemapping['MappingInfo_head'] = $currentMappingInfo_head;
			$templatemapping['MappingInfo'] = $currentMappingInfo;

				// Getting cached data:
			reset($dataStruct);
				// Init; read file, init objects:
			$fileContent = t3lib_div::getUrl($theFile);
			$htmlParse = t3lib_div::makeInstance('t3lib_parsehtml');
			$this->markupObj = t3lib_div::makeInstance('tx_templavoila_htmlmarkup');

				// Fix relative paths in source:
			$relPathFix=dirname(substr($theFile,strlen(PATH_site))).'/';
			$uniqueMarker = uniqid('###') . '###';
			$fileContent = $htmlParse->prefixResourcePath($relPathFix,$fileContent, array('A' => $uniqueMarker));
			$fileContent = $this->fixPrefixForLinks($relPathFix, $fileContent, $uniqueMarker);


				// Get BODY content for caching:
			$contentSplittedByMapping=$this->markupObj->splitContentToMappingInfo($fileContent,$currentMappingInfo);
			$templatemapping['MappingData_cached'] = $contentSplittedByMapping['sub']['ROOT'];

				// Get HEAD content for caching:
			list($html_header) =  $this->markupObj->htmlParse->getAllParts($htmlParse->splitIntoBlock('head',$fileContent),1,0);
			$this->markupObj->tags = $this->head_markUpTags;	// Set up the markupObject to process only header-section tags:

			$h_currentMappingInfo=array();
			if (is_array($currentMappingInfo_head['headElementPaths']))	{
				foreach($currentMappingInfo_head['headElementPaths'] as $kk => $vv)	{
					$h_currentMappingInfo['el_'.$kk]['MAP_EL'] = $vv;
				}
			}

			$contentSplittedByMapping = $this->markupObj->splitContentToMappingInfo($html_header,$h_currentMappingInfo);
			$templatemapping['MappingData_head_cached'] = $contentSplittedByMapping;

				// Get <body> tag:
			$reg='';
			preg_match('/<body[^>]*>/i',$fileContent,$reg);
			$templatemapping['BodyTag_cached'] = $currentMappingInfo_head['addBodyTag'] ? $reg[0] : '';

			$TOuid = t3lib_BEfunc::wsMapId('tx_templavoila_tmplobj',$row['uid']);
			$dataArr['tx_templavoila_tmplobj'][$TOuid]['templatemapping'] = serialize($templatemapping);
			$dataArr['tx_templavoila_tmplobj'][$TOuid]['fileref_mtime'] = @filemtime($theFile);
			$dataArr['tx_templavoila_tmplobj'][$TOuid]['fileref_md5'] = @md5_file($theFile);

			$tce = t3lib_div::makeInstance('t3lib_TCEmain');
			$tce->stripslashes_values=0;
			$tce->start($dataArr,array());
			$tce->process_datamap();
			unset($tce);
			$flashMessage = t3lib_div::makeInstance(
				't3lib_FlashMessage',
				$GLOBALS['LANG']->getLL('msgMappingSaved'),
				'',
				t3lib_FlashMessage::OK
			);
			$msg[] .= $flashMessage->render();
			$row = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj',$this->displayUid);
			$templatemapping = unserialize($row['templatemapping']);

			if (t3lib_div::_GP('_save_to_return'))	{
				header('Location: '.t3lib_div::locationHeaderUrl($this->returnUrl));
				exit;
			}
		}

			// Making the menu
		$menuItems=array();
		$menuItems[]='<input type="submit" name="_clear" value="' . $GLOBALS['LANG']->getLL('buttonClearAll') . '" title="' . $GLOBALS['LANG']->getLL('buttonClearAllMappingTitle') . '" />';

			// Make either "Preview" button (body) or "Set" button (header)
		if ($headerPart)	{	// Header:
			$menuItems[] = '<input type="submit" name="_save_data_mapping" value="' . $GLOBALS['LANG']->getLL('buttonSet') . '" title="' . $GLOBALS['LANG']->getLL('buttonSetTitle') . '" />';
		} else {	// Body:
			$menuItems[] = '<input type="submit" name="_preview" value="' . $GLOBALS['LANG']->getLL('buttonPreview') . '" title="' . $GLOBALS['LANG']->getLL('buttonPreviewMappingTitle') . '" />';
		}

		$menuItems[]='<input type="submit" name="_save_to" value="' . $GLOBALS['LANG']->getLL('buttonSave') . '" title="' . $GLOBALS['LANG']->getLL('buttonSaveTOTitle') . '" />';

		if ($this->returnUrl)	{
			$menuItems[]='<input type="submit" name="_save_to_return" value="' . $GLOBALS['LANG']->getLL('buttonSaveAndReturn') . '" title="' . $GLOBALS['LANG']->getLL('buttonSaveAndReturnTitle') . '" />';
		}

			// If a difference is detected...:
		if (
				(serialize($templatemapping['MappingInfo_head']) != serialize($currentMappingInfo_head))	||
				(serialize($templatemapping['MappingInfo']) != serialize($currentMappingInfo))
			)	{
			$menuItems[]='<input type="submit" name="_reload_from" value="' . $GLOBALS['LANG']->getLL('buttonRevert') . '" title="'.sprintf($GLOBALS['LANG']->getLL('buttonRevertTitle'), $headerPart ? 'HEAD' : 'BODY') . '" />';

			$flashMessage = t3lib_div::makeInstance(
				't3lib_FlashMessage',
				$GLOBALS['LANG']->getLL('msgMappingIsDifferent'),
				'',
				t3lib_FlashMessage::INFO
			);
			$msg[] .= $flashMessage->render();
		}

		$content = '

			<!--
				Menu for saving Template Objects
			-->
			<table border="0" cellpadding="2" cellspacing="2" id="c-toMenu">
				<tr class="bgColor5">
					<td>'.implode('</td>
					<td>',$menuItems).'</td>
				</tr>
			</table>
		';

			// @todo - replace with FlashMessage Queue
		$content .= implode('', $msg);
		return array($content, $headerPart ? $currentMappingInfo_head : $currentMappingInfo);
	}
Esempio n. 13
0
	/**
	 * Returns the code that the menu was mapped to in the HTML
	 *
	 * @param	string		"Field" from Data structure, either "field_menu" or "field_submenu"
	 * @return	string
	 */
	function getMenuDefaultCode($field)	{
			// Select template record and extract menu HTML content
		$toRec = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj',$this->wizardData['templateObjectId']);
		$tMapping = unserialize($toRec['templatemapping']);
		return $tMapping['MappingData_cached']['cArray'][$field];
	}
    /**
     * Renders Content Elements from the tt_content table from page id
     *
     * @param	integer		Page id
     * @return	string		HTML for the listing
     */
    function getTable_tt_content($id)
    {
        global $TCA;
        $this->initializeLanguages();
        // Initialize:
        $RTE = $GLOBALS['BE_USER']->isRTE();
        $lMarg = 1;
        $showHidden = $this->tt_contentConfig['showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content');
        $pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(t3lib_BEfunc::getRecordTitle('pages', t3lib_BEfunc::getRecordWSOL('pages', $id), TRUE));
        $GLOBALS['SOBE']->doc->getPageRenderer()->loadExtJs();
        $GLOBALS['SOBE']->doc->getPageRenderer()->addJsFile($GLOBALS['BACK_PATH'] . 'sysext/cms/layout/js/typo3pageModule.js');
        // Get labels for CTypes and tt_content element fields in general:
        $this->CType_labels = array();
        foreach ($TCA['tt_content']['columns']['CType']['config']['items'] as $val) {
            $this->CType_labels[$val[1]] = $GLOBALS['LANG']->sL($val[0]);
        }
        $this->itemLabels = array();
        foreach ($TCA['tt_content']['columns'] as $name => $val) {
            $this->itemLabels[$name] = $GLOBALS['LANG']->sL($val['label']);
        }
        // Select display mode:
        if (!$this->tt_contentConfig['single']) {
            // MULTIPLE column display mode, side by side:
            // Setting language list:
            $langList = $this->tt_contentConfig['sys_language_uid'];
            if ($this->tt_contentConfig['languageMode']) {
                if ($this->tt_contentConfig['languageColsPointer']) {
                    $langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
                } else {
                    $langList = implode(',', array_keys($this->tt_contentConfig['languageCols']));
                }
                $languageColumn = array();
            }
            $langListArr = explode(',', $langList);
            $defLanguageCount = array();
            $defLangBinding = array();
            // For EACH languages... :
            foreach ($langListArr as $lP) {
                // If NOT languageMode, then we'll only be through this once.
                $showLanguage = $this->defLangBinding && $lP == 0 ? ' AND sys_language_uid IN (0,-1)' : ' AND sys_language_uid=' . $lP;
                $cList = explode(',', $this->tt_contentConfig['cols']);
                $content = array();
                $head = array();
                // For EACH column, render the content into a variable:
                foreach ($cList as $key) {
                    if (!$lP) {
                        $defLanguageCount[$key] = array();
                    }
                    // Select content elements from this column/language:
                    $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos=' . intval($key) . $showHidden . $showLanguage);
                    $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
                    // If it turns out that there are not content elements in the column, then display a big button which links directly to the wizard script:
                    if ($this->doEdit && $this->option_showBigButtons && !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
                        $onClick = "window.location.href='db_new_content_el.php?id=" . $id . '&colPos=' . intval($key) . '&sys_language_uid=' . $lP . '&uid_pid=' . $id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "';";
                        $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick, $GLOBALS['LANG']->getLL('newPageContent'));
                        $content[$key] .= '<img src="clear.gif" width="1" height="5" alt="" /><br />' . $theNewButton;
                    }
                    // Traverse any selected elements and render their display code:
                    $rowArr = $this->getResult($result);
                    foreach ($rowArr as $rKey => $row) {
                        if (is_array($row) && (int) $row['t3ver_state'] != 2) {
                            $singleElementHTML = '';
                            if (!$lP) {
                                $defLanguageCount[$key][] = $row['uid'];
                            }
                            $editUidList .= $row['uid'] . ',';
                            $singleElementHTML .= $this->tt_content_drawHeader($row, $this->tt_contentConfig['showInfo'] ? 15 : 5, $this->defLangBinding && $lP > 0, TRUE);
                            $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
                            $singleElementHTML .= '<div ' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . '>' . $this->tt_content_drawItem($row, $isRTE) . '</div>';
                            // NOTE: this is the end tag for <div class="t3-page-ce-body">
                            // because of bad (historic) conception, starting tag has to be placed inside tt_content_drawHeader()
                            $singleElementHTML .= '</div>';
                            $statusHidden = $this->isDisabled('tt_content', $row) ? ' t3-page-ce-hidden' : '';
                            $singleElementHTML = '<div class="t3-page-ce' . $statusHidden . '">' . $singleElementHTML . '</div>';
                            if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) {
                                $defLangBinding[$key][$lP][$row[$lP ? 'l18n_parent' : 'uid']] = $singleElementHTML;
                            } else {
                                $content[$key] .= $singleElementHTML;
                            }
                        } else {
                            unset($rowArr[$rKey]);
                        }
                    }
                    // Add new-icon link, header:
                    $newP = $this->newContentElementOnClick($id, $key, $lP);
                    $head[$key] .= $this->tt_content_drawColHeader(t3lib_BEfunc::getProcessedValue('tt_content', 'colPos', $key), $this->doEdit && count($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : '', $newP);
                    $editUidList = '';
                }
                // For EACH column, fit the rendered content into a table cell:
                $out = '';
                foreach ($cList as $k => $key) {
                    if (!$k) {
                        $out .= '
							<td><img src="clear.gif" width="' . $lMarg . '" height="1" alt="" /></td>';
                    } else {
                        $out .= '
							<td><img src="clear.gif" width="4" height="1" alt="" /></td>
							<td bgcolor="#cfcfcf"><img src="clear.gif" width="1" height="1" alt="" /></td>
							<td><img src="clear.gif" width="4" height="1" alt="" /></td>';
                    }
                    $out .= '
							<td class="t3-page-column t3-page-column-' . $key . '">' . $head[$key] . $content[$key] . '</td>';
                    // Storing content for use if languageMode is set:
                    if ($this->tt_contentConfig['languageMode']) {
                        $languageColumn[$key][$lP] = $head[$key] . $content[$key];
                        if (!$this->defLangBinding) {
                            $languageColumn[$key][$lP] .= '<br /><br />' . $this->newLanguageButton($this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP), $lP);
                        }
                    }
                }
                // Wrap the cells into a table row:
                $out = '
					<table border="0" cellpadding="0" cellspacing="0" class="t3-page-columns">
						<tr>' . $out . '
						</tr>
					</table>';
                // CSH:
                $out .= t3lib_BEfunc::cshItem($this->descrTable, 'columns_multi', $GLOBALS['BACK_PATH']);
            }
            // If language mode, then make another presentation:
            // Notice that THIS presentation will override the value of $out! But it needs the code above to execute since $languageColumn is filled with content we need!
            if ($this->tt_contentConfig['languageMode']) {
                // Get language selector:
                $languageSelector = $this->languageSelector($id);
                // Reset out - we will make new content here:
                $out = '';
                // Separator between language columns (black thin line)
                $midSep = '
						<td><img src="clear.gif" width="4" height="1" alt="" /></td>
						<td bgcolor="black"><img src="clear.gif" width="1" height="1" alt="" /></td>
						<td><img src="clear.gif" width="4" height="1" alt="" /></td>';
                // Traverse languages found on the page and build up the table displaying them side by side:
                $cCont = array();
                $sCont = array();
                foreach ($langListArr as $lP) {
                    // Header:
                    $cCont[$lP] = '
						<td valign="top" align="center" class="bgColor6"><strong>' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '</strong></td>';
                    // "View page" icon is added:
                    $viewLink = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id, $this->backPath, t3lib_BEfunc::BEgetRootLine($this->id), '', '', '&L=' . $lP)) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-view') . '</a>';
                    // Language overlay page header:
                    if ($lP) {
                        list($lpRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . intval($lP));
                        t3lib_BEfunc::workspaceOL('pages_language_overlay', $lpRecord);
                        $params = '&edit[pages_language_overlay][' . $lpRecord['uid'] . ']=edit&overrideVals[pages_language_overlay][sys_language_uid]=' . $lP;
                        $lPLabel = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon(t3lib_iconWorks::getSpriteIconForRecord('pages_language_overlay', $lpRecord), $lpRecord['uid']) . $viewLink . ($GLOBALS['BE_USER']->check('tables_modify', 'pages_language_overlay') ? '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>' : '') . htmlspecialchars(t3lib_div::fixed_lgd_cs($lpRecord['title'], 20));
                    } else {
                        $lPLabel = $viewLink;
                    }
                    $sCont[$lP] = '
						<td nowrap="nowrap">' . $lPLabel . '</td>';
                }
                // Add headers:
                $out .= '
					<tr class="bgColor5">' . implode($midSep, $cCont) . '
					</tr>';
                $out .= '
					<tr class="bgColor5">' . implode($midSep, $sCont) . '
					</tr>';
                // Traverse previously built content for the columns:
                foreach ($languageColumn as $cKey => $cCont) {
                    $out .= '
					<tr>
						<td valign="top">' . implode('</td>' . $midSep . '
						<td valign="top">', $cCont) . '</td>
					</tr>';
                    if ($this->defLangBinding) {
                        // "defLangBinding" mode
                        foreach ($defLanguageCount[$cKey] as $defUid) {
                            $cCont = array();
                            foreach ($langListArr as $lP) {
                                $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . '<br/>' . $this->newLanguageButton($this->getNonTranslatedTTcontentUids(array($defUid), $id, $lP), $lP);
                            }
                            $out .= '
							<tr>
								<td valign="top">' . implode('</td>' . $midSep . '
								<td valign="top">', $cCont) . '</td>
							</tr>';
                        }
                        // Create spacer:
                        $cCont = array();
                        foreach ($langListArr as $lP) {
                            $cCont[] = '&nbsp;';
                        }
                        $out .= '
						<tr>
							<td valign="top">' . implode('</td>' . $midSep . '
							<td valign="top">', $cCont) . '</td>
						</tr>';
                    }
                }
                // Finally, wrap it all in a table and add the language selector on top of it:
                $out = $languageSelector . '
					<table border="0" cellpadding="0" cellspacing="0" width="480" class="typo3-page-langMode">
						' . $out . '
					</table>';
                // CSH:
                $out .= t3lib_BEfunc::cshItem($this->descrTable, 'language_list', $GLOBALS['BACK_PATH']);
            }
        } else {
            // SINGLE column mode (columns shown beneath each other):
            #debug('single column');
            if ($this->tt_contentConfig['sys_language_uid'] == 0 || !$this->defLangBinding) {
                // Initialize:
                if ($this->defLangBinding && $this->tt_contentConfig['sys_language_uid'] == 0) {
                    $showLanguage = ' AND sys_language_uid IN (0,-1)';
                    $lP = 0;
                } else {
                    $showLanguage = ' AND sys_language_uid=' . $this->tt_contentConfig['sys_language_uid'];
                    $lP = $this->tt_contentConfig['sys_language_uid'];
                }
                $cList = explode(',', $this->tt_contentConfig['showSingleCol']);
                $content = array();
                $out = '';
                // Expand the table to some preset dimensions:
                $out .= '
					<tr>
						<td><img src="clear.gif" width="' . $lMarg . '" height="1" alt="" /></td>
						<td valign="top"><img src="clear.gif" width="150" height="1" alt="" /></td>
						<td><img src="clear.gif" width="10" height="1" alt="" /></td>
						<td valign="top"><img src="clear.gif" width="300" height="1" alt="" /></td>
					</tr>';
                // Traverse columns to display top-on-top
                foreach ($cList as $counter => $key) {
                    // Select content elements:
                    $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos=' . intval($key) . $showHidden . $showLanguage);
                    $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
                    $c = 0;
                    $rowArr = $this->getResult($result);
                    $rowOut = '';
                    // If it turns out that there are not content elements in the column, then display a big button which links directly to the wizard script:
                    if ($this->doEdit && $this->option_showBigButtons && !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
                        $onClick = "window.location.href='db_new_content_el.php?id=" . $id . '&colPos=' . intval($key) . '&sys_language_uid=' . $lP . '&uid_pid=' . $id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "';";
                        $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick, $GLOBALS['LANG']->getLL('newPageContent'));
                        $theNewButton = '<img src="clear.gif" width="1" height="5" alt="" /><br />' . $theNewButton;
                    } else {
                        $theNewButton = '';
                    }
                    // Traverse any selected elements:
                    foreach ($rowArr as $rKey => $row) {
                        if (is_array($row) && (int) $row['t3ver_state'] != 2) {
                            $c++;
                            $editUidList .= $row['uid'] . ',';
                            $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
                            // Create row output:
                            $rowOut .= '
								<tr>
									<td></td>
									<td valign="top">' . $this->tt_content_drawHeader($row) . '</td>
									<td>&nbsp;</td>
									<td' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . ' valign="top">' . $this->tt_content_drawItem($row, $isRTE) . '</td>
								</tr>';
                            // If the element was not the last element, add a divider line:
                            if ($c != $GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
                                $rowOut .= '
								<tr>
									<td></td>
									<td colspan="3"><img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/stiblet_medium2.gif', 'width="468" height="1"') . ' class="c-divider" alt="" /></td>
								</tr>';
                            }
                        } else {
                            unset($rowArr[$rKey]);
                        }
                    }
                    // Add spacer between sections in the vertical list
                    if ($counter) {
                        $out .= '
							<tr>
								<td></td>
								<td colspan="3"><br /><br /><br /><br /></td>
							</tr>';
                    }
                    // Add section header:
                    $newP = $this->newContentElementOnClick($id, $key, $this->tt_contentConfig['sys_language_uid']);
                    $out .= '

						<!-- Column header: -->
						<tr>
							<td></td>
							<td valign="top" colspan="3">' . $this->tt_content_drawColHeader(t3lib_BEfunc::getProcessedValue('tt_content', 'colPos', $key), $this->doEdit && count($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : '', $newP) . $theNewButton . '<br /></td>
						</tr>';
                    // Finally, add the content from the records in this column:
                    $out .= $rowOut;
                }
                // Finally, wrap all table rows in one, big table:
                $out = '
					<table border="0" cellpadding="0" cellspacing="0" width="400" class="typo3-page-columnsMode">
						' . $out . '
					</table>';
                // CSH:
                $out .= t3lib_BEfunc::cshItem($this->descrTable, 'columns_single', $GLOBALS['BACK_PATH']);
            } else {
                $out = '<br/><br/>' . $GLOBALS['SOBE']->doc->icons(1) . 'Sorry, you cannot view a single language in this localization mode (Default Language Binding is enabled)<br/><br/>';
            }
        }
        // Add the big buttons to page:
        if ($this->option_showBigButtons) {
            $bArray = array();
            if (!$GLOBALS['SOBE']->current_sys_language) {
                if ($this->ext_CALC_PERMS & 2) {
                    $bArray[0] = $GLOBALS['SOBE']->doc->t3Button(t3lib_BEfunc::editOnClick('&edit[pages][' . $id . "]=edit", $this->backPath, ''), $GLOBALS['LANG']->getLL('editPageProperties'));
                }
            } else {
                if ($this->doEdit && $GLOBALS['BE_USER']->check('tables_modify', 'pages_language_overlay')) {
                    list($languageOverlayRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . intval($GLOBALS['SOBE']->current_sys_language));
                    $bArray[0] = $GLOBALS['SOBE']->doc->t3Button(t3lib_BEfunc::editOnClick('&edit[pages_language_overlay][' . $languageOverlayRecord['uid'] . "]=edit", $this->backPath, ''), $GLOBALS['LANG']->getLL('editPageProperties_curLang'));
                }
            }
            if ($this->ext_CALC_PERMS & 4 || $this->ext_CALC_PERMS & 2) {
                $bArray[1] = $GLOBALS['SOBE']->doc->t3Button("window.location.href='" . $this->backPath . "move_el.php?table=pages&uid=" . $id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "';", $GLOBALS['LANG']->getLL('move_page'));
            }
            if ($this->ext_CALC_PERMS & 8) {
                $bArray[2] = $GLOBALS['SOBE']->doc->t3Button("window.location.href='" . $this->backPath . "db_new.php?id=" . $id . '&pagesOnly=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "';", $GLOBALS['LANG']->getLL('newPage2'));
            }
            if ($this->doEdit && $this->ext_function == 1) {
                $bArray[3] = $GLOBALS['SOBE']->doc->t3Button("window.location.href='db_new_content_el.php?id=" . $id . '&sys_language_uid=' . $GLOBALS['SOBE']->current_sys_language . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "';", $GLOBALS['LANG']->getLL('newPageContent2'));
            }
            $out = '
				<table border="0" cellpadding="4" cellspacing="0" class="typo3-page-buttons">
					<tr>
						<td>' . implode('</td>
						<td>', $bArray) . '</td>
						<td>' . t3lib_BEfunc::cshItem($this->descrTable, 'button_panel', $GLOBALS['BACK_PATH']) . '</td>
					</tr>
				</table>
				<br />
				' . $out;
        }
        // Return content:
        return $out;
    }
 /**
  * Performs the neccessary steps to creates a new page
  *
  * @param	array		$pageArray: array containing the fields for the new page
  * @param	integer		$positionPid: location within the page tree (parent id)
  * @return	integer		uid of the new page record
  */
 function createPage($pageArray, $positionPid)
 {
     $dataArr = array();
     $dataArr['pages']['NEW'] = $pageArray;
     $dataArr['pages']['NEW']['pid'] = $positionPid;
     if (is_null($dataArr['pages']['NEW']['hidden'])) {
         $dataArr['pages']['NEW']['hidden'] = 0;
     }
     unset($dataArr['pages']['NEW']['uid']);
     // If no data structure is set, try to find one by using the template object
     if ($dataArr['pages']['NEW']['tx_templavoila_to'] && !$dataArr['pages']['NEW']['tx_templavoila_ds']) {
         $templateObjectRow = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj', $dataArr['pages']['NEW']['tx_templavoila_to'], 'uid,pid,datastructure');
         $dataArr['pages']['NEW']['tx_templavoila_ds'] = $templateObjectRow['datastructure'];
     }
     $tce = t3lib_div::makeInstance('t3lib_TCEmain');
     // set default TCA values specific for the user
     $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults');
     if (is_array($TCAdefaultOverride)) {
         $tce->setDefaultsFromUserTS($TCAdefaultOverride);
     }
     $tce->stripslashes_values = 0;
     $tce->start($dataArr, array());
     $tce->process_datamap();
     return $tce->substNEWwithIDs['NEW'];
 }
Esempio n. 16
0
    function renderList($pArray, $lines = array(), $c = 0)
    {
        if (is_array($pArray)) {
            reset($pArray);
            static $i;
            foreach ($pArray as $k => $v) {
                if (t3lib_div::testInt($k)) {
                    if (isset($pArray[$k . "_"])) {
                        $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
							<td nowrap><img src="clear.gif" width="1" height="1" hspace=' . $c * 10 . ' align="top">' . '<a href="' . t3lib_div::linkThisScript(array('id' => $k)) . '">' . t3lib_iconWorks::getSpriteIconForRecord('pages', t3lib_BEfunc::getRecordWSOL('pages', $k), array("title" => 'ID: ' . $k)) . t3lib_div::fixed_lgd_cs($pArray[$k], 30) . '</a></td>
							<td align="center">' . $pArray[$k . '_']['count'] . '</td>
							<td align="center" class="bgColor5">' . ($pArray[$k . '_']['root_max_val'] > 0 ? t3lib_iconWorks::getSpriteIcon('status-status-checked') : "&nbsp;") . '</td>
							<td align="center">' . ($pArray[$k . '_']['root_min_val'] == 0 ? t3lib_iconWorks::getSpriteIcon('status-status-checked') : "&nbsp;") . '</td>
							</tr>';
                    } else {
                        $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
							<td nowrap ><img src="clear.gif" width="1" height="1" hspace=' . $c * 10 . ' align=top>' . t3lib_iconWorks::getSpriteIconForRecord('pages', t3lib_BEfunc::getRecordWSOL('pages', $k)) . t3lib_div::fixed_lgd_cs($pArray[$k], 30) . '</td>
							<td align="center"></td>
							<td align="center" class="bgColor5"></td>
							<td align="center"></td>
							</tr>';
                    }
                    $lines = $this->renderList($pArray[$k . '.'], $lines, $c + 1);
                }
            }
        }
        return $lines;
    }
    /**
     * returns the recent documents list as an array
     *
     * @return	array	all recent documents as list-items
     */
    public function renderMenuEntry($document, $md5sum, $isRecentDoc = false, $isFirstDoc = false)
    {
        $table = $document[3]['table'];
        $uid = $document[3]['uid'];
        $record = t3lib_BEfunc::getRecordWSOL($table, $uid);
        if (!is_array($record)) {
            // record seems to be deleted
            return '';
        }
        $label = htmlspecialchars(strip_tags(t3lib_div::htmlspecialchars_decode($document[0])));
        $icon = t3lib_iconWorks::getSpriteIconForRecord($table, $record);
        $link = $GLOBALS['BACK_PATH'] . 'alt_doc.php?' . $document[2];
        $firstRow = '';
        if ($isFirstDoc) {
            $firstRow = ' first-row';
        }
        if (!$isRecentDoc) {
            $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.closeDoc', true);
            // open document
            $closeIcon = t3lib_iconWorks::getSpriteIcon('actions-document-close');
            $entry = '
				<tr class="opendoc' . $firstRow . '">
					<td class="icon">' . $icon . '</td>
					<td class="label"><a href="#" onclick="jump(unescape(\'' . htmlspecialchars($link) . '\'), \'web_list\', \'web\'); TYPO3BackendOpenDocs.toggleMenu(); return false;" target="content">' . $label . '</a></td>
					<td class="close" onclick="return TYPO3BackendOpenDocs.closeDocument(\'' . $md5sum . '\');">' . $closeIcon . '</td>
				</tr>';
        } else {
            // recently used document
            $entry = '
				<tr class="recentdoc' . $firstRow . '">
					<td class="icon">' . $icon . '</td>
					<td class="label" colspan="2"><a href="#" onclick="jump(unescape(\'' . htmlspecialchars($link) . '\'), \'web_list\', \'web\'); TYPO3BackendOpenDocs.toggleMenu(); return false;" target="content">' . $label . '</a></td>
				</tr>';
        }
        return $entry;
    }
 /**
  * Factory method to create AccumulatedInformations Object (e.g. build tree etc...) (Factorys should have all dependencies passed as parameter)
  *
  * @param int $sysLang sys_language_uid
  * @param mixed	$overrideStartingPoint		optional override startingpoint  TODO!
  * @return tx_l10nmgr_l10nAccumulatedInformations
  **/
 function getL10nAccumulatedInformationsObjectForLanguage($sysLang, $overrideStartingPoint = '')
 {
     $l10ncfg = $this->l10ncfg;
     // Showing the tree:
     // Initialize starting point of page tree:
     $treeStartingPoint = intval($l10ncfg['depth'] == -1 ? t3lib_div::_GET('srcPID') : $l10ncfg['pid']);
     $treeStartingRecord = t3lib_BEfunc::getRecordWSOL('pages', $treeStartingPoint);
     $depth = $l10ncfg['depth'];
     // Initialize tree object:
     /** @var $tree t3lib_pageTree */
     $tree = t3lib_div::makeInstance('t3lib_pageTree');
     $tree->init('AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
     $tree->addField('l18n_cfg');
     // Creating top icon; the current page
     $HTML = t3lib_iconWorks::getIconImage('pages', $treeStartingRecord, $GLOBALS['BACK_PATH'], 'align="top"');
     $tree->tree[] = array('row' => $treeStartingRecord, 'HTML' => $HTML);
     // Create the tree from starting point:
     if ($depth > 0) {
         $tree->getTree($treeStartingPoint, $depth, '');
     }
     //now create and init accum Info object:
     /** @var $accumObj tx_l10nmgr_l10nAccumulatedInformations */
     $accumObj = t3lib_div::makeInstance('tx_l10nmgr_l10nAccumulatedInformations', $tree, $l10ncfg, $sysLang);
     return $accumObj;
 }
 /** set internal _accumulatedInformations array. Is called from constructor and uses the given tree, lang and l10ncfg
  * @return void
  **/
 function _calculateInternalAccumulatedInformationsArray()
 {
     global $TCA;
     $tree = $this->tree;
     $l10ncfg = $this->l10ncfg;
     $accum = array();
     $sysLang = $this->sysLang;
     // FlexForm Diff data:
     $flexFormDiff = unserialize($l10ncfg['flexformdiff']);
     $flexFormDiff = $flexFormDiff[$sysLang];
     $excludeIndex = array_flip(t3lib_div::trimExplode(',', $l10ncfg['exclude'], 1));
     $tableUidConstraintIndex = array_flip(t3lib_div::trimExplode(',', $l10ncfg['tableUidConstraint'], 1));
     // Init:
     $t8Tools = t3lib_div::makeInstance('tx_l10nmgr_tools');
     $t8Tools->verbose = FALSE;
     // Otherwise it will show records which has fields but none editable.
     if ($l10ncfg['incfcewithdefaultlanguage'] == 1) {
         $t8Tools->includeFceWithDefaultLanguage = TRUE;
     }
     // Set preview language (only first one in list is supported):
     if ($this->forcedPreviewLanguage != '') {
         $previewLanguage = $this->forcedPreviewLanguage;
     } else {
         $previewLanguage = current(t3lib_div::intExplode(',', $GLOBALS['BE_USER']->getTSConfigVal('options.additionalPreviewLanguages')));
     }
     if ($previewLanguage) {
         $t8Tools->previewLanguages = array($previewLanguage);
     }
     // Traverse tree elements:
     foreach ($tree->tree as $treeElement) {
         $pageId = $treeElement['row']['uid'];
         if (!isset($excludeIndex['pages:' . $pageId]) && !in_array($treeElement['row']['doktype'], $this->disallowDoktypes)) {
             $accum[$pageId]['header']['title'] = $treeElement['row']['title'];
             $accum[$pageId]['header']['icon'] = $treeElement['HTML'];
             $accum[$pageId]['header']['prevLang'] = $previewLanguage;
             $accum[$pageId]['items'] = array();
             // Traverse tables:
             foreach ($TCA as $table => $cfg) {
                 // Only those tables we want to work on:
                 if (t3lib_div::inList($l10ncfg['tablelist'], $table)) {
                     if ($table === 'pages') {
                         $accum[$pageId]['items'][$table][$pageId] = $t8Tools->translationDetails('pages', t3lib_BEfunc::getRecordWSOL('pages', $pageId), $sysLang, $flexFormDiff);
                         $this->_increaseInternalCounters($accum[$pageId]['items'][$table][$pageId]['fields']);
                     } else {
                         $allRows = $t8Tools->getRecordsToTranslateFromTable($table, $pageId);
                         if (is_array($allRows)) {
                             if (count($allRows)) {
                                 // Now, for each record, look for localization:
                                 foreach ($allRows as $row) {
                                     t3lib_BEfunc::workspaceOL($table, $row);
                                     if (is_array($row) && count($tableUidConstraintIndex) > 0) {
                                         if (is_array($row) && isset($tableUidConstraintIndex[$table . ':' . $row['uid']])) {
                                             $accum[$pageId]['items'][$table][$row['uid']] = $t8Tools->translationDetails($table, $row, $sysLang, $flexFormDiff);
                                             $this->_increaseInternalCounters($accum[$pageId]['items'][$table][$row['uid']]['fields']);
                                         }
                                     } else {
                                         if (is_array($row) && !isset($excludeIndex[$table . ':' . $row['uid']])) {
                                             $accum[$pageId]['items'][$table][$row['uid']] = $t8Tools->translationDetails($table, $row, $sysLang, $flexFormDiff);
                                             $this->_increaseInternalCounters($accum[$pageId]['items'][$table][$row['uid']]['fields']);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $includeIndex = array_unique(t3lib_div::trimExplode(',', $l10ncfg['include'], 1));
     foreach ($includeIndex as $recId) {
         list($table, $uid) = explode(':', $recId);
         $row = t3lib_BEfunc::getRecordWSOL($table, $uid);
         if (count($row)) {
             $accum[-1]['items'][$table][$row['uid']] = $t8Tools->translationDetails($table, $row, $sysLang, $flexFormDiff);
             $this->_increaseInternalCounters($accum[-1]['items'][$table][$row['uid']]['fields']);
         }
     }
     #		debug($accum);
     $this->_accumulatedInformations = $accum;
 }
 /**
  * Returns the record for a uid.
  * For tables: Looks up the record in the database.
  * For arrays: Returns the fake record for uid id.
  *
  * @param	integer		UID to look up
  * @return	array		The record
  */
 function getRecord($uid)
 {
     if (is_array($this->data)) {
         return $this->dataLookup[$uid];
     } else {
         return t3lib_BEfunc::getRecordWSOL($this->table, $uid);
     }
 }
Esempio n. 21
0
    /**
     * Create configuration form
     *
     * @param	array		Form configurat data
     * @param	array		Table row accumulation variable. This is filled with table rows.
     * @return	void		Sets content in $this->content
     */
    function makeConfigurationForm($inData, &$row)
    {
        global $LANG;
        $nameSuggestion = '';
        // Page tree export options:
        if (isset($inData['pagetree']['id'])) {
            $nameSuggestion .= 'tree_PID' . $inData['pagetree']['id'] . '_L' . $inData['pagetree']['levels'];
            $row[] = '
				<tr class="tableheader bgColor5">
					<td colspan="2">' . $LANG->getLL('makeconfig_exportPagetreeConfiguration', 1) . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeCfg', $GLOBALS['BACK_PATH'], '') . '</td>
				</tr>';
            $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makeconfig_pageId', 1) . '</strong></td>
					<td>' . htmlspecialchars($inData['pagetree']['id']) . '<input type="hidden" value="' . htmlspecialchars($inData['pagetree']['id']) . '" name="tx_impexp[pagetree][id]" /></td>
				</tr>';
            $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makeconfig_tree', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeDisplay', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>' . ($this->treeHTML ? $this->treeHTML : $LANG->getLL('makeconfig_noTreeExportedOnly', 1)) . '</td>
				</tr>';
            $opt = array('-2' => $LANG->getLL('makeconfig_tablesOnThisPage'), '-1' => $LANG->getLL('makeconfig_expandedTree'), '0' => $LANG->getLL('makeconfig_onlyThisPage'), '1' => $LANG->getLL('makeconfig_1Level'), '2' => $LANG->getLL('makeconfig_2Levels'), '3' => $LANG->getLL('makeconfig_3Levels'), '4' => $LANG->getLL('makeconfig_4Levels'), '999' => $LANG->getLL('makeconfig_infinite'));
            $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makeconfig_levels', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeMode', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>' . $this->renderSelectBox('tx_impexp[pagetree][levels]', $inData['pagetree']['levels'], $opt) . '</td>
				</tr>';
            $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makeconfig_includeTables', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeRecordLimit', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>' . $this->tableSelector('tx_impexp[pagetree][tables]', $inData['pagetree']['tables'], 'pages') . '<br/>
						' . $LANG->getLL('makeconfig_maxNumberOfRecords', 1) . '<br/>
						<input type="text" name="tx_impexp[pagetree][maxNumber]" value="' . htmlspecialchars($inData['pagetree']['maxNumber']) . '"' . $this->doc->formWidth(10) . ' /><br/>
					</td>
				</tr>';
        }
        // Single record export:
        if (is_array($inData['record'])) {
            $row[] = '
				<tr class="tableheader bgColor5">
					<td colspan="2">' . $LANG->getLL('makeconfig_exportSingleRecord', 1) . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'singleRecord', $GLOBALS['BACK_PATH'], '') . '</td>
				</tr>';
            foreach ($inData['record'] as $ref) {
                $rParts = explode(':', $ref);
                $tName = $rParts[0];
                $rUid = $rParts[1];
                $nameSuggestion .= $tName . '_' . $rUid;
                $rec = t3lib_BEfunc::getRecordWSOL($tName, $rUid);
                $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makeconfig_record', 1) . '</strong></td>
					<td>' . t3lib_iconworks::getSpriteIconForRecord($tName, $rec) . t3lib_BEfunc::getRecordTitle($tName, $rec, TRUE) . '<input type="hidden" name="tx_impexp[record][]" value="' . htmlspecialchars($tName . ':' . $rUid) . '" /></td>
				</tr>';
            }
        }
        // Single tables/pids:
        if (is_array($inData['list'])) {
            $row[] = '
				<tr class="tableheader bgColor5">
					<td colspan="2">' . $LANG->getLL('makeconfig_exportTablesFromPages', 1) . '</td>
				</tr>';
            $tblList = '';
            foreach ($inData['list'] as $ref) {
                $rParts = explode(':', $ref);
                $tName = $rParts[0];
                if ($GLOBALS['BE_USER']->check('tables_select', $tName)) {
                    $rec = t3lib_BEfunc::getRecordWSOL('pages', $rParts[1]);
                    $tblList .= 'Table "' . $tName . '" from ' . t3lib_iconworks::getSpriteIconForRecord('pages', $rec) . t3lib_BEfunc::getRecordTitle('pages', $rec, TRUE) . '<input type="hidden" name="tx_impexp[list][]" value="' . htmlspecialchars($ref) . '" /><br/>';
                }
            }
            $row[] = '
			<tr class="bgColor4">
				<td><strong>' . $LANG->getLL('makeconfig_tablePids', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'tableList', $GLOBALS['BACK_PATH'], '') . '</td>
				<td>' . $tblList . '</td>
			</tr>';
            $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makeconfig_maxNumberOfRecords', 1) . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'tableListMaxNumber', $GLOBALS['BACK_PATH'], '') . '</strong></td>
					<td>
						<input type="text" name="tx_impexp[listCfg][maxNumber]" value="' . htmlspecialchars($inData['listCfg']['maxNumber']) . '"' . $this->doc->formWidth(10) . ' /><br/>
					</td>
				</tr>';
        }
        $row[] = '
			<tr class="tableheader bgColor5">
				<td colspan="2">' . $LANG->getLL('makeconfig_relationsAndExclusions', 1) . '</td>
			</tr>';
        // Add relation selector:
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makeconfig_includeRelationsToTables', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'inclRelations', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>' . $this->tableSelector('tx_impexp[external_ref][tables]', $inData['external_ref']['tables']) . '</td>
				</tr>';
        // Add static relation selector:
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makeconfig_useStaticRelationsFor', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'staticRelations', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>' . $this->tableSelector('tx_impexp[external_static][tables]', $inData['external_static']['tables']) . '<br/>
						<label for="checkShowStaticRelations">' . $LANG->getLL('makeconfig_showStaticRelations', 1) . '</label> <input type="checkbox" name="tx_impexp[showStaticRelations]" id="checkShowStaticRelations" value="1"' . ($inData['showStaticRelations'] ? ' checked="checked"' : '') . ' />
						</td>
				</tr>';
        // Exclude:
        $excludeHiddenFields = '';
        if (is_array($inData['exclude'])) {
            foreach ($inData['exclude'] as $key => $value) {
                $excludeHiddenFields .= '<input type="hidden" name="tx_impexp[exclude][' . $key . ']" value="1" />';
            }
        }
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makeconfig_excludeElements', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'excludedElements', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>' . $excludeHiddenFields . '
					' . (count($inData['exclude']) ? '<em>' . implode(', ', array_keys($inData['exclude'])) . '</em><hr/><label for="checkExclude">' . $LANG->getLL('makeconfig_clearAllExclusions', 1) . '</label> <input type="checkbox" name="tx_impexp[exclude]" id="checkExclude" value="1" />' : $LANG->getLL('makeconfig_noExcludedElementsYet', 1)) . '
					</td>
				</tr>';
        // Add buttons:
        $row[] = '
				<tr class="bgColor4">
					<td>&nbsp;</td>
					<td>
						<input type="submit" value="' . $LANG->getLL('makeadvanc_update', 1) . '" />
						<input type="hidden" name="tx_impexp[download_export_name]" value="' . substr($nameSuggestion, 0, 30) . '" />
					</td>
				</tr>';
    }
 /**
  * References all unreferenced elements with the specified
  * parent id (page uid)
  *
  * @param	integer		$pageUid: Parent id of the elements to reference
  * @return	void
  * @access	protected
  */
 function createReferencesForPage($pageUid)
 {
     $unreferencedElementRecordsArr = $this->getUnreferencedElementsRecords($pageUid);
     $langField = $GLOBALS['TCA']['tt_content']['ctrl']['languageField'];
     foreach ($unreferencedElementRecordsArr as $elementUid => $elementRecord) {
         $lDef = array();
         $vDef = array();
         if ($langField && $elementRecord[$langField]) {
             $pageRec = t3lib_BEfunc::getRecordWSOL('pages', $pageUid);
             $xml = t3lib_BEfunc::getFlexFormDS($GLOBALS['TCA']['pages']['columns']['tx_templavoila_flex']['config'], $pageRec, 'pages', 'tx_templavoila_ds');
             $langChildren = intval($xml['meta']['langChildren']);
             $langDisable = intval($xml['meta']['langDisable']);
             if ($elementRecord[$langField] == -1) {
                 $translatedLanguagesArr = $this->getAvailableLanguages($pageUid);
                 foreach ($translatedLanguagesArr as $lUid => $lArr) {
                     if ($lUid >= 0) {
                         $lDef[] = $langDisable ? 'lDEF' : ($langChildren ? 'lDEF' : 'l' . $lArr['ISOcode']);
                         $vDef[] = $langDisable ? 'vDEF' : ($langChildren ? 'v' . $lArr['ISOcode'] : 'vDEF');
                     }
                 }
             } elseif ($rLang = $this->allAvailableLanguages[$elementRecord[$langField]]) {
                 $lDef[] = $langDisable ? 'lDEF' : ($langChildren ? 'lDEF' : 'l' . $rLang['ISOcode']);
                 $vDef[] = $langDisable ? 'vDEF' : ($langChildren ? 'v' . $rLang['ISOcode'] : 'vDEF');
             } else {
                 $lDef[] = 'lDEF';
                 $vDef[] = 'vDEF';
             }
         } else {
             $lDef[] = 'lDEF';
             $vDef[] = 'vDEF';
         }
         $contentAreaFieldName = $this->templavoilaAPIObj->ds_getFieldNameByColumnPosition($pageUid, $elementRecord['colPos']);
         if ($contentAreaFieldName !== FALSE) {
             foreach ($lDef as $iKey => $lKey) {
                 $vKey = $vDef[$iKey];
                 $destinationPointer = array('table' => 'pages', 'uid' => $pageUid, 'sheet' => 'sDEF', 'sLang' => $lKey, 'field' => $contentAreaFieldName, 'vLang' => $vKey, 'position' => -1);
                 $this->templavoilaAPIObj->referenceElementByUid($elementUid, $destinationPointer);
             }
         }
     }
 }
Esempio n. 23
0
 /**
  * Creating the module output.
  *
  * @return	void
  */
 function main()
 {
     global $LANG, $BACK_PATH, $BE_USER;
     if ($this->page_id) {
         // Get record for element:
         $elRow = t3lib_BEfunc::getRecordWSOL($this->table, $this->moveUid);
         // Headerline: Icon, record title:
         $hline = t3lib_iconWorks::getSpriteIconForRecord($this->table, $elRow, array('id' => "c-recIcon", 'title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($elRow, $this->table))));
         $hline .= t3lib_BEfunc::getRecordTitle($this->table, $elRow, TRUE);
         // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently):
         $onClick = 'window.location.href=\'' . t3lib_div::linkThisScript(array('makeCopy' => !$this->makeCopy)) . '\';';
         $hline .= '<br /><input type="hidden" name="makeCopy" value="0" /><input type="checkbox" name="makeCopy" id="makeCopy" value="1"' . ($this->makeCopy ? ' checked="checked"' : '') . ' onclick="' . htmlspecialchars($onClick) . '" /> <label for="makeCopy">' . $LANG->getLL('makeCopy', 1) . '</label>';
         // Add the header-content to the module content:
         $this->content .= $this->doc->section($LANG->getLL('moveElement') . ':', $hline, 0, 1);
         $this->content .= $this->doc->spacer(20);
         // Reset variable to pick up the module content in:
         $code = '';
         // IF the table is "pages":
         if ((string) $this->table == 'pages') {
             // Get page record (if accessible):
             $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id, $this->perms_clause);
             if (is_array($pageinfo) && $BE_USER->isInWebMount($pageinfo['pid'], $this->perms_clause)) {
                 // Initialize the position map:
                 $posMap = t3lib_div::makeInstance('ext_posMap_pages');
                 $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move';
                 // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
                 if ($pageinfo['pid']) {
                     $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'], $this->perms_clause);
                     if (is_array($pidPageInfo)) {
                         if ($BE_USER->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
                             $code .= '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('uid' => intval($pageinfo['pid']), 'moveUid' => $this->moveUid))) . '">' . t3lib_iconWorks::getSpriteIcon('actions-view-go-up') . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE) . '</a><br />';
                         } else {
                             $code .= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo) . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE) . '<br />';
                         }
                     }
                 }
                 // Create the position tree:
                 $code .= $posMap->positionTree($this->page_id, $pageinfo, $this->perms_clause, $this->R_URI);
             }
         }
         // IF the table is "tt_content":
         if ((string) $this->table == 'tt_content') {
             // First, get the record:
             $tt_content_rec = t3lib_BEfunc::getRecord('tt_content', $this->moveUid);
             // ?
             if (!$this->input_moveUid) {
                 $this->page_id = $tt_content_rec['pid'];
             }
             // Checking if the parent page is readable:
             $pageinfo = t3lib_BEfunc::readPageAccess($this->page_id, $this->perms_clause);
             if (is_array($pageinfo) && $BE_USER->isInWebMount($pageinfo['pid'], $this->perms_clause)) {
                 // Initialize the position map:
                 $posMap = t3lib_div::makeInstance('ext_posMap_tt_content');
                 $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move';
                 $posMap->cur_sys_language = $this->sys_language;
                 // Headerline for the parent page: Icon, record title:
                 $hline = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageinfo, array('title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($pageinfo, 'pages'))));
                 $hline .= t3lib_BEfunc::getRecordTitle('pages', $pageinfo, TRUE);
                 // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable:
                 $modTSconfig_SHARED = t3lib_BEfunc::getModTSconfig($this->page_id, 'mod.SHARED');
                 // SHARED page-TSconfig settings.
                 $colPosList = strcmp(trim($modTSconfig_SHARED['properties']['colPos_list']), '') ? trim($modTSconfig_SHARED['properties']['colPos_list']) : '1,0,2,3';
                 $colPosList = implode(',', array_unique(t3lib_div::intExplode(',', $colPosList)));
                 // Removing duplicates, if any
                 // Adding parent page-header and the content element columns from position-map:
                 $code = $hline . '<br />';
                 $code .= $posMap->printContentElementColumns($this->page_id, $this->moveUid, $colPosList, 1, $this->R_URI);
                 // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
                 $code .= '<br />';
                 $code .= '<br />';
                 if ($pageinfo['pid']) {
                     $pidPageInfo = t3lib_BEfunc::readPageAccess($pageinfo['pid'], $this->perms_clause);
                     if (is_array($pidPageInfo)) {
                         if ($BE_USER->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
                             $code .= '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('uid' => intval($pageinfo['pid']), 'moveUid' => $this->moveUid))) . '">' . t3lib_iconWorks::getSpriteIcon('actions-view-go-up') . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE) . '</a><br />';
                         } else {
                             $code .= t3lib_iconWorks::getSpriteIconForRecord('pages', $pidPageInfo) . t3lib_BEfunc::getRecordTitle('pages', $pidPageInfo, TRUE) . '<br />';
                         }
                     }
                 }
                 // Create the position tree (for pages):
                 $code .= $posMap->positionTree($this->page_id, $pageinfo, $this->perms_clause, $this->R_URI);
             }
         }
         // Add the $code content as a new section to the module:
         $this->content .= $this->doc->section($LANG->getLL('selectPositionOfElement') . ':', $code, 0, 1);
     }
     // Setting up the buttons and markers for docheader
     $docHeaderButtons = $this->getButtons();
     $markers['CSH'] = $docHeaderButtons['csh'];
     $markers['CONTENT'] = $this->content;
     // Build the <body> for the module
     $this->content = $this->doc->startPage($LANG->getLL('movingElement'));
     $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
     $this->content .= $this->doc->endPage();
     $this->content = $this->doc->insertStylesAndJS($this->content);
 }
 /**
  * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
  *
  * @param	string		HREF value tp analyse
  * @param	string		The URL of the current website (frontend)
  * @return	array		Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
  */
 function parseCurUrl($href, $siteUrl)
 {
     $href = trim($href);
     if ($href) {
         $info = array();
         // Default is "url":
         $info['value'] = $href;
         $info['act'] = 'url';
         $specialParts = explode('#_SPECIAL', $href);
         if (count($specialParts) == 2) {
             // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
             $info['value'] = '#_SPECIAL' . $specialParts[1];
             $info['act'] = 'spec';
         } elseif (t3lib_div::isFirstPartOfStr($href, $siteUrl)) {
             // If URL is on the current frontend website:
             $rel = substr($href, strlen($siteUrl));
             if (file_exists(PATH_site . rawurldecode($rel))) {
                 // URL is a file, which exists:
                 $info['value'] = rawurldecode($rel);
                 if (@is_dir(PATH_site . $info['value'])) {
                     $info['act'] = 'folder';
                 } else {
                     $info['act'] = 'file';
                 }
             } else {
                 // URL is a page (id parameter)
                 $uP = parse_url($rel);
                 if (!trim($uP['path'])) {
                     $pp = preg_split('/^id=/', $uP['query']);
                     $pp[1] = preg_replace('/&id=[^&]*/', '', $pp[1]);
                     $parameters = explode('&', $pp[1]);
                     $id = array_shift($parameters);
                     if ($id) {
                         // Checking if the id-parameter is an alias.
                         if (!t3lib_div::testInt($id)) {
                             list($idPartR) = t3lib_BEfunc::getRecordsByField('pages', 'alias', $id);
                             $id = intval($idPartR['uid']);
                         }
                         $pageRow = t3lib_BEfunc::getRecordWSOL('pages', $id);
                         $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
                         $info['value'] = $GLOBALS['LANG']->getLL('page', 1) . " '" . htmlspecialchars(t3lib_div::fixed_lgd_cs($pageRow['title'], $titleLen)) . "' (ID:" . $id . ($uP['fragment'] ? ', #' . $uP['fragment'] : '') . ')';
                         $info['pageid'] = $id;
                         $info['cElement'] = $uP['fragment'];
                         $info['act'] = 'page';
                         $info['query'] = $parameters[0] ? '&' . implode('&', $parameters) : '';
                     }
                 }
             }
         } else {
             // Email link:
             if (strtolower(substr($href, 0, 7)) == 'mailto:') {
                 $info['value'] = trim(substr($href, 7));
                 $info['act'] = 'mail';
             }
         }
         $info['info'] = $info['value'];
     } else {
         // NO value inputted:
         $info = array();
         $info['info'] = $GLOBALS['LANG']->getLL('none');
         $info['value'] = '';
         $info['act'] = 'page';
     }
     // let the hook have a look
     foreach ($this->hookObjects as $hookObject) {
         $info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
     }
     return $info;
 }
 /**
  * If "editPage" value is sent to script and it points to an accessible page, the internal var $this->theEditRec is set to the page record which should be loaded.
  * Returns void
  *
  * @return	void
  */
 function editPageIdFunc()
 {
     global $BE_USER, $LANG;
     if (!t3lib_extMgm::isLoaded('cms')) {
         return;
     }
     // EDIT page:
     $this->editPage = trim($LANG->csConvObj->conv_case($LANG->charSet, $this->editPage, 'toLower'));
     $this->editError = '';
     $this->theEditRec = '';
     $this->searchFor = '';
     if ($this->editPage) {
         // First, test alternative value consisting of [table]:[uid] and if not found, proceed with traditional page ID resolve:
         $this->alternativeTableUid = explode(':', $this->editPage);
         if (!(count($this->alternativeTableUid) == 2 && $BE_USER->isAdmin())) {
             // We restrict it to admins only just because I'm not really sure if alt_doc.php properly checks permissions of passed records for editing. If alt_doc.php does that, then we can remove this.
             $where = ' AND (' . $BE_USER->getPagePermsClause(2) . ' OR ' . $BE_USER->getPagePermsClause(16) . ')';
             if (t3lib_div::testInt($this->editPage)) {
                 $this->theEditRec = t3lib_BEfunc::getRecordWSOL('pages', $this->editPage, '*', $where);
             } else {
                 $records = t3lib_BEfunc::getRecordsByField('pages', 'alias', $this->editPage, $where);
                 if (is_array($records)) {
                     reset($records);
                     $this->theEditRec = current($records);
                     t3lib_BEfunc::workspaceOL('pages', $this->theEditRec);
                 }
             }
             if (!is_array($this->theEditRec)) {
                 unset($this->theEditRec);
                 $this->searchFor = $this->editPage;
             } elseif (!$BE_USER->isInWebMount($this->theEditRec['uid'])) {
                 unset($this->theEditRec);
                 $this->editError = $LANG->getLL('shortcut_notEditable');
             } else {
                 // Visual path set:
                 $perms_clause = $BE_USER->getPagePermsClause(1);
                 $this->editPath = t3lib_BEfunc::getRecordPath($this->theEditRec['pid'], $perms_clause, 30);
                 if (!$BE_USER->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
                     // Expanding page tree:
                     t3lib_BEfunc::openPageTree($this->theEditRec['pid'], !$BE_USER->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
                 }
             }
         }
     }
 }
Esempio n. 26
0
    /**
     * [Describe function...]
     *
     * @param   [type]    $rec: ...
     * @return  [type]    ...
     */
    function makeTableRow($rec)
    {
        //Render information for base record:
        $baseRecord = t3lib_BEfunc::getRecordWSOL($rec['tablename'], $rec['recuid']);
        $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($rec['tablename'], $baseRecord);
        $title = t3lib_BEfunc::getRecordTitle($rec['tablename'], $baseRecord, 1);
        $baseRecordFlag = '<img src="' . htmlspecialchars($GLOBALS['BACK_PATH'] . $this->sysLanguages[$rec['sys_language_uid']]['flagIcon']) . '" alt="" title="" />';
        $tFlag = '<img src="' . htmlspecialchars($GLOBALS['BACK_PATH'] . $this->sysLanguages[$rec['translation_lang']]['flagIcon']) . '" alt="' . htmlspecialchars($this->sysLanguages[$rec['translation_lang']]['title']) . '" title="' . htmlspecialchars($this->sysLanguages[$rec['translation_lang']]['title']) . '" />';
        $baseRecordStr = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[' . $rec['tablename'] . '][' . $rec['recuid'] . ']=edit', $this->doc->backPath)) . '">' . $icon . $title . '</a>';
        // Render for translation if any:
        $translationRecord = false;
        if ($rec['translation_recuid']) {
            $translationTable = $this->l10nMgrTools->t8Tools->getTranslationTable($rec['tablename']);
            $translationRecord = t3lib_BEfunc::getRecordWSOL($translationTable, $rec['translation_recuid']);
            $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($translationTable, $translationRecord);
            $title = t3lib_BEfunc::getRecordTitle($translationTable, $translationRecord, 1);
            $translationRecStr = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[' . $translationTable . '][' . $translationRecord['uid'] . ']=edit', $this->doc->backPath)) . '">' . $icon . $title . '</a>';
        } else {
            $translationRecStr = '';
        }
        // Action:
        if (is_array($translationRecord)) {
            $action = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[' . $translationTable . '][' . $translationRecord['uid'] . ']=edit', $this->doc->backPath)) . '"><em>[Edit]</em></a>';
        } elseif ($rec['sys_language_uid'] == -1) {
            $action = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[' . $rec['tablename'] . '][' . $rec['recuid'] . ']=edit', $this->doc->backPath)) . '"><em>[Edit]</em></a>';
        } else {
            $action = '<a href="' . htmlspecialchars($this->doc->issueCommand('&cmd[' . $rec['tablename'] . '][' . $rec['recuid'] . '][localize]=' . $rec['translation_lang'])) . '"><em>[Localize]</em></a>';
        }
        return '<tr class="bgColor4-20">
			<td valign="top">' . $baseRecordFlag . '</td>
			<td valign="top" nowrap="nowrap">' . $baseRecordStr . '</td>
			<td valign="top">' . $tFlag . '</td>
			<td valign="top" nowrap="nowrap">' . $translationRecStr . '</td>
			<td valign="top">' . $action . '</td>
			<td align="center"' . ($rec['flag_new'] ? ' bgcolor="#91B5FF"' : '') . '>' . ($rec['flag_new'] ? $rec['flag_new'] : '') . '</td>
			<td align="center"' . ($rec['flag_unknown'] ? ' bgcolor="#FEFF5A"' : '') . '>' . ($rec['flag_unknown'] ? $rec['flag_unknown'] : '') . '</td>
			<td align="center"' . ($rec['flag_update'] ? ' bgcolor="#FF7161"' : '') . '>' . ($rec['flag_update'] ? $rec['flag_update'] : '') . '</td>
			<td align="center"' . ($rec['flag_noChange'] ? ' bgcolor="#78FF82"' : '') . '>' . ($rec['flag_noChange'] ? $rec['flag_noChange'] : '') . '</td>
			<td>' . implode('<br/>', unserialize($rec['serializedDiff'])) . '</td>
		</tr>';
    }
Esempio n. 27
0
	/**
	 * Main function, drawing marked up XML.
	 *
	 * @return	void
	 */
	function main()	{
		global $LANG,$BACK_PATH;

			// Check admin: If this is changed some day to other than admin users we HAVE to check if there is read access to the record being selected!
		if (!$GLOBALS['BE_USER']->isAdmin())	die('no access.');

		$this->returnUrl =  t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));

			// Draw the header.
		$this->doc = t3lib_div::makeInstance('template');
		$this->doc->docType = 'xhtml_trans';
		$this->doc->backPath = $BACK_PATH;
		$this->doc->setModuleTemplate('EXT:templavoila/resources/templates/cm2_default.html');
		$this->doc->bodyTagId = 'typo3-mod-php';
		$this->doc->divClass = '';

			// XML code:
		$this->viewTable = t3lib_div::_GP('viewRec');

		$record = t3lib_BEfunc::getRecordWSOL($this->viewTable['table'], $this->viewTable['uid']);	// Selecting record based on table/uid since adding the field might impose a SQL-injection problem; at least the field name would have to be checked first.
		if (is_array($record))	{

				// Set current XML data:
			$currentXML = $record[$this->viewTable['field_flex']];

				// Clean up XML:
			$cleanXML = '';
			if ($GLOBALS['BE_USER']->isAdmin())	{
				if ('tx_templavoila_flex' == $this->viewTable['field_flex'])	{
					$flexObj = t3lib_div::makeInstance('t3lib_flexformtools');
					if ($record['tx_templavoila_flex'])	{
						$cleanXML = $flexObj->cleanFlexFormXML($this->viewTable['table'],'tx_templavoila_flex',$record);

							// If the clean-button was pressed, save right away:
						if (t3lib_div::_POST('_CLEAN_XML'))	{
							$dataArr = array();
							$dataArr[$this->viewTable['table']][$this->viewTable['uid']]['tx_templavoila_flex'] = $cleanXML;

								// Init TCEmain object and store:
							$tce = t3lib_div::makeInstance('t3lib_TCEmain');
							$tce->stripslashes_values=0;
							$tce->start($dataArr,array());
							$tce->process_datamap();

								// Re-fetch record:
							$record = t3lib_BEfunc::getRecordWSOL($this->viewTable['table'], $this->viewTable['uid']);
							$currentXML = $record[$this->viewTable['field_flex']];
						}
					}
				}
			}

			if (md5($currentXML)!=md5($cleanXML))	{
					// Create diff-result:
				$t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
				$diffres = $t3lib_diff_Obj->makeDiffDisplay($currentXML,$cleanXML);

			$flashMessage = t3lib_div::makeInstance(
				't3lib_FlashMessage',
				$LANG->getLL('needsCleaning',1),
				'',
				t3lib_FlashMessage::INFO
			);
			$xmlContentMarkedUp = $flashMessage->render();

			$xmlContentMarkedUp .= '<table border="0">
					<tr class="bgColor5 tableheader">
						<td>'.$LANG->getLL('current',1).'</td>
					</tr>
					<tr>
						<td>'.$this->markUpXML($currentXML).'<br/><br/></td>
					</tr>
					<tr class="bgColor5 tableheader">
						<td>'.$LANG->getLL('clean',1).'</td>
					</tr>
					<tr>
						<td>'.$this->markUpXML($cleanXML).'</td>
					</tr>
					<tr class="bgColor5 tableheader">
						<td>'.$LANG->getLL('diff',1).'</td>
					</tr>
					<tr>
						<td>'.$diffres.'
						<br/><br/><br/>

						<form action="'.t3lib_div::getIndpEnv('REQUEST_URI').'" method="post">
							<input type="submit" value="'.$LANG->getLL('cleanUp',1).'" name="_CLEAN_XML" />
						</form>

						</td>
					</tr>
				</table>

				';
			} else {
				$xmlContentMarkedUp = '';
				if ($cleanXML)	{
					$flashMessage = t3lib_div::makeInstance(
						't3lib_FlashMessage',
						$LANG->getLL('XMLclean',1),
						'',
						t3lib_FlashMessage::OK
					);
					$xmlContentMarkedUp = $flashMessage->render();
				}
				$xmlContentMarkedUp.= $this->markUpXML($currentXML);
			}

			$this->content.=$this->doc->section('',$xmlContentMarkedUp,0,1);
		}

			// Add spacer:
		$this->content.=$this->doc->spacer(10);

		$docHeaderButtons = $this->getDocHeaderButtons();
		$docContent = array(
			'CSH' => $docHeaderButtons['csh'],
			'CONTENT' => $this->content
		);

		$content  = $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
		$content .= $this->doc->moduleBody(
			array(),
			$docHeaderButtons,
			$docContent
		);
		$content .= $this->doc->endPage();

			// Replace content with templated content
		$this->content = $content;
	}
 /**
  * Performs localization or synchronization of child records.
  *
  * @param	string		$table: The table of the localized parent record
  * @param	integer		$id: The uid of the localized parent record
  * @param	mixed		$command: Defines the type 'localize' or 'synchronize' (string) or a single uid to be localized (integer)
  * @return	void
  */
 protected function inlineLocalizeSynchronize($table, $id, $command)
 {
     // <field>, (localize | synchronize | <uid>):
     $parts = t3lib_div::trimExplode(',', $command);
     $field = $parts[0];
     $type = $parts[1];
     if ($field && (t3lib_div::inList('localize,synchronize', $type) || t3lib_div::testInt($type)) && isset($GLOBALS['TCA'][$table]['columns'][$field]['config'])) {
         $config = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
         $foreignTable = $config['foreign_table'];
         $localizationMode = t3lib_BEfunc::getInlineLocalizationMode($table, $config);
         if ($localizationMode == 'select') {
             $parentRecord = t3lib_BEfunc::getRecordWSOL($table, $id);
             $language = intval($parentRecord[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
             $transOrigPointer = intval($parentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]);
             $childTransOrigPointerField = $GLOBALS['TCA'][$foreignTable]['ctrl']['transOrigPointerField'];
             if ($parentRecord && is_array($parentRecord) && $language > 0 && $transOrigPointer) {
                 $inlineSubType = $this->getInlineFieldType($config);
                 $transOrigRecord = t3lib_BEfunc::getRecordWSOL($table, $transOrigPointer);
                 if ($inlineSubType !== FALSE) {
                     $removeArray = array();
                     // Fetch children from original language parent:
                     /** @var $dbAnalysisOriginal t3lib_loadDBGroup */
                     $dbAnalysisOriginal = t3lib_div::makeInstance('t3lib_loadDBGroup');
                     $dbAnalysisOriginal->start($transOrigRecord[$field], $foreignTable, '', $transOrigRecord['uid'], $table, $config);
                     $elementsOriginal = array();
                     foreach ($dbAnalysisOriginal->itemArray as $item) {
                         $elementsOriginal[$item['id']] = $item;
                     }
                     unset($dbAnalysisOriginal);
                     // Fetch children from current localized parent:
                     // @var $dbAnalysisCurrent t3lib_loadDBGroup
                     $dbAnalysisCurrent = t3lib_div::makeInstance('t3lib_loadDBGroup');
                     $dbAnalysisCurrent->start($parentRecord[$field], $foreignTable, '', $id, $table, $config);
                     // Perform synchronization: Possibly removal of already localized records:
                     if ($type == 'synchronize') {
                         foreach ($dbAnalysisCurrent->itemArray as $index => $item) {
                             $childRecord = t3lib_BEfunc::getRecordWSOL($item['table'], $item['id']);
                             if (isset($childRecord[$childTransOrigPointerField]) && $childRecord[$childTransOrigPointerField] > 0) {
                                 $childTransOrigPointer = $childRecord[$childTransOrigPointerField];
                                 // If snychronization is requested, child record was translated once, but original record does not exist anymore, remove it:
                                 if (!isset($elementsOriginal[$childTransOrigPointer])) {
                                     unset($dbAnalysisCurrent->itemArray[$index]);
                                     $removeArray[$item['table']][$item['id']]['delete'] = 1;
                                 }
                             }
                         }
                     }
                     // Perform synchronization/localization: Possibly add unlocalized records for original language:
                     if (t3lib_div::testInt($type) && isset($elementsOriginal[$type])) {
                         $item = $elementsOriginal[$type];
                         $item['id'] = $this->localize($item['table'], $item['id'], $language);
                         $item['id'] = $this->overlayAutoVersionId($item['table'], $item['id']);
                         $dbAnalysisCurrent->itemArray[] = $item;
                     } elseif (t3lib_div::inList('localize,synchronize', $type)) {
                         foreach ($elementsOriginal as $originalId => $item) {
                             $item['id'] = $this->localize($item['table'], $item['id'], $language);
                             $item['id'] = $this->overlayAutoVersionId($item['table'], $item['id']);
                             $dbAnalysisCurrent->itemArray[] = $item;
                         }
                     }
                     // Store the new values, we will set up the uids for the subtype later on (exception keep localization from original record):
                     $value = implode(',', $dbAnalysisCurrent->getValueArray());
                     $this->registerDBList[$table][$id][$field] = $value;
                     // Remove child records (if synchronization requested it):
                     if (is_array($removeArray) && count($removeArray)) {
                         $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                         $tce->stripslashes_values = FALSE;
                         $tce->start(array(), $removeArray);
                         $tce->process_cmdmap();
                         unset($tce);
                     }
                     // Handle, reorder and store relations:
                     if ($inlineSubType == 'list') {
                         $updateFields = array($field => $value);
                     } elseif ($inlineSubType == 'field') {
                         $dbAnalysisCurrent->writeForeignField($config, $id);
                         $updateFields = array($field => $dbAnalysisCurrent->countItems(FALSE));
                     }
                     // Update field referencing to child records of localized parent record:
                     if (is_array($updateFields) && count($updateFields)) {
                         $this->updateDB($table, $id, $updateFields);
                     }
                 }
             }
         }
     }
 }
 /**
  * Gets the page id by a record.
  *
  * @param	string		$table: Name of the table
  * @param	integer		$id: Id of the accordant record
  * @param	boolean		$ignoreTable: Whether to ignore the page, if true a positive
  *						id value is considered as page id without any further checks
  * @return	integer		Id of the page the record is persisted on
  */
 protected function getPageIdByRecord($table, $id, $ignoreTable = FALSE)
 {
     $pageId = 0;
     $id = (int) $id;
     if ($table && $id) {
         if (($ignoreTable || $table === 'pages') && $id >= 0) {
             $pageId = $id;
         } else {
             $record = t3lib_BEfunc::getRecordWSOL($table, abs($id), '*', '', FALSE);
             $pageId = $record['pid'];
         }
     }
     return $pageId;
 }
Esempio n. 30
0
    /**
     * Process editing of a TO for renderTO() function
     *
     * @param	array		Data Structure. Passed by reference; The sheets found inside will be resolved if found!
     * @param	array		TO record row
     * @param	string		Template file path (absolute)
     * @param   integer		Process the headerPart instead of the bodyPart
     * @return	array		Array with two keys (0/1) with a) content and b) currentMappingInfo which is retrieved inside (currentMappingInfo will be different based on whether "head" or "body" content is "mapped")
     * @see renderTO()
     */
    function renderTO_editProcessing(&$dataStruct, $row, $theFile, $headerPart = 0)
    {
        $msg = array();
        // Converting GPvars into a "cmd" value:
        $cmd = '';
        if (t3lib_div::GPvar('_reload_from')) {
            // Reverting to old values in TO
            $cmd = 'reload_from';
        } elseif (t3lib_div::GPvar('_clear')) {
            // Resetting mapping
            $cmd = 'clear';
        } elseif (t3lib_div::GPvar('_save_data_mapping')) {
            // Saving to Session
            $cmd = 'save_data_mapping';
        } elseif (t3lib_div::GPvar('_save_to') || t3lib_div::GPvar('_save_to_return')) {
            // Saving to Template Object
            $cmd = 'save_to';
        }
        // Getting data from tmplobj
        $templatemapping = unserialize($row['templatemapping']);
        if (!is_array($templatemapping)) {
            $templatemapping = array();
        }
        // If that array contains sheets, then traverse them:
        if (is_array($dataStruct['sheets'])) {
            $dSheets = t3lib_div::resolveAllSheetsInDS($dataStruct);
            $dataStruct = array('ROOT' => array('tx_templavoila' => array('title' => 'ROOT of MultiTemplate', 'description' => 'Select the ROOT container for this template project. Probably just select a body-tag or some other HTML element which encapsulates ALL sub templates!'), 'type' => 'array', 'el' => array()));
            foreach ($dSheets['sheets'] as $nKey => $lDS) {
                if (is_array($lDS['ROOT'])) {
                    $dataStruct['ROOT']['el'][$nKey] = $lDS['ROOT'];
                }
            }
        }
        // Get session data:
        $sesDat = $GLOBALS['BE_USER']->getSessionData($this->MCONF['name'] . '_mappingInfo');
        // Set current mapping info arrays:
        $currentMappingInfo_head = is_array($sesDat['currentMappingInfo_head']) ? $sesDat['currentMappingInfo_head'] : array();
        $currentMappingInfo = is_array($sesDat['currentMappingInfo']) ? $sesDat['currentMappingInfo'] : array();
        $this->cleanUpMappingInfoAccordingToDS($currentMappingInfo, $dataStruct);
        // Perform processing for head
        // GPvars, incoming data
        $checkboxElement = t3lib_div::GPvar('checkboxElement', 1);
        $addBodyTag = t3lib_div::GPvar('addBodyTag');
        // Update session data:
        if ($cmd == 'reload_from' || $cmd == 'clear') {
            $currentMappingInfo_head = is_array($templatemapping['MappingInfo_head']) && $cmd != 'clear' ? $templatemapping['MappingInfo_head'] : array();
            $sesDat['currentMappingInfo_head'] = $currentMappingInfo_head;
            $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'] . '_mappingInfo', $sesDat);
        } else {
            if ($cmd == 'save_data_mapping' || $cmd == 'save_to') {
                $sesDat['currentMappingInfo_head'] = $currentMappingInfo_head = array('headElementPaths' => $checkboxElement, 'addBodyTag' => $addBodyTag ? 1 : 0);
                $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'] . '_mappingInfo', $sesDat);
            }
        }
        // Perform processing for  body
        // GPvars, incoming data
        $inputData = t3lib_div::GPvar('dataMappingForm', 1);
        // Update session data:
        if ($cmd == 'reload_from' || $cmd == 'clear') {
            $currentMappingInfo = is_array($templatemapping['MappingInfo']) && $cmd != 'clear' ? $templatemapping['MappingInfo'] : array();
            $this->cleanUpMappingInfoAccordingToDS($currentMappingInfo, $dataStruct);
            $sesDat['currentMappingInfo'] = $currentMappingInfo;
            $sesDat['dataStruct'] = $dataStruct;
            $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'] . '_mappingInfo', $sesDat);
        } else {
            if ($cmd == 'save_data_mapping' && is_array($inputData)) {
                $sesDat['currentMappingInfo'] = $currentMappingInfo = t3lib_div::array_merge_recursive_overrule($currentMappingInfo, $inputData);
                $sesDat['dataStruct'] = $dataStruct;
                // Adding data structure to session data so that the PREVIEW window can access the DS easily...
                $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'] . '_mappingInfo', $sesDat);
            }
        }
        // SAVE to template object
        if ($cmd == 'save_to') {
            $dataArr = array();
            // Set content, either for header or body:
            $templatemapping['MappingInfo_head'] = $currentMappingInfo_head;
            $templatemapping['MappingInfo'] = $currentMappingInfo;
            // Getting cached data:
            reset($dataStruct);
            // Init; read file, init objects:
            $fileContent = t3lib_div::getUrl($theFile);
            $htmlParse = t3lib_div::makeInstance('t3lib_parsehtml');
            $this->markupObj = t3lib_div::makeInstance('tx_templavoila_htmlmarkup');
            // Fix relative paths in source:
            $relPathFix = dirname(substr($theFile, strlen(PATH_site))) . '/';
            $uniqueMarker = uniqid('###') . '###';
            $fileContent = $htmlParse->prefixResourcePath($relPathFix, $fileContent, array('A' => $uniqueMarker));
            $fileContent = $this->fixPrefixForLinks($relPathFix, $fileContent, $uniqueMarker);
            // Get BODY content for caching:
            $contentSplittedByMapping = $this->markupObj->splitContentToMappingInfo($fileContent, $currentMappingInfo);
            $templatemapping['MappingData_cached'] = $contentSplittedByMapping['sub']['ROOT'];
            // Get HEAD content for caching:
            list($html_header) = $this->markupObj->htmlParse->getAllParts($htmlParse->splitIntoBlock('head', $fileContent), 1, 0);
            $this->markupObj->tags = $this->head_markUpTags;
            // Set up the markupObject to process only header-section tags:
            $h_currentMappingInfo = array();
            if (is_array($currentMappingInfo_head['headElementPaths'])) {
                foreach ($currentMappingInfo_head['headElementPaths'] as $kk => $vv) {
                    $h_currentMappingInfo['el_' . $kk]['MAP_EL'] = $vv;
                }
            }
            $contentSplittedByMapping = $this->markupObj->splitContentToMappingInfo($html_header, $h_currentMappingInfo);
            $templatemapping['MappingData_head_cached'] = $contentSplittedByMapping;
            // Get <body> tag:
            $reg = '';
            //#
            //### Mansoor Ahmad - change because of PHP5.3
            //#
            //eregi('<body[^>]*>',$fileContent,$reg);
            preg_match('/<body[^>]*>/i', $fileContent, $reg);
            $templatemapping['BodyTag_cached'] = $currentMappingInfo_head['addBodyTag'] ? $reg[0] : '';
            $TOuid = t3lib_BEfunc::wsMapId('tx_templavoila_tmplobj', $row['uid']);
            $dataArr['tx_templavoila_tmplobj'][$TOuid]['templatemapping'] = serialize($templatemapping);
            $dataArr['tx_templavoila_tmplobj'][$TOuid]['fileref_mtime'] = @filemtime($theFile);
            $dataArr['tx_templavoila_tmplobj'][$TOuid]['fileref_md5'] = @md5_file($theFile);
            $tce = t3lib_div::makeInstance('t3lib_TCEmain');
            $tce->stripslashes_values = 0;
            $tce->start($dataArr, array());
            $tce->process_datamap();
            unset($tce);
            $msg[] = $GLOBALS['LANG']->getLL('msgMappingSaved');
            $row = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj', $this->displayUid);
            $templatemapping = unserialize($row['templatemapping']);
            if (t3lib_div::GPvar('_save_to_return')) {
                header('Location: ' . t3lib_div::locationHeaderUrl($this->returnUrl));
                exit;
            }
        }
        // Making the menu
        $menuItems = array();
        $menuItems[] = '<input type="submit" name="_clear" value="Clear all" title="Clears all mapping information currently set." />';
        // Make either "Preview" button (body) or "Set" button (header)
        if ($headerPart) {
            // Header:
            $menuItems[] = '<input type="submit" name="_save_data_mapping" value="Set" title="Will update session data with current settings." />';
        } else {
            // Body:
            $menuItems[] = '<input type="submit" name="_preview" value="Preview" title="Will merge sample content into the template according to the current mapping information." />';
        }
        $menuItems[] = '<input type="submit" name="_save_to" value="Save" title="Saving all mapping data into the Template Object." />';
        if ($this->returnUrl) {
            $menuItems[] = '<input type="submit" name="_save_to_return" value="Save and Return" title="Saving all mapping data into the Template Object and return." />';
        }
        // If a difference is detected...:
        if (serialize($templatemapping['MappingInfo_head']) != serialize($currentMappingInfo_head) || serialize($templatemapping['MappingInfo']) != serialize($currentMappingInfo)) {
            $menuItems[] = '<input type="submit" name="_reload_from" value="Revert" title="' . sprintf('Reverting %s mapping data to original data in the Template Object.', $headerPart ? 'HEAD' : 'BODY') . '" />';
            $msg[] = 'The current mapping information is different from the mapping information in the Template Object';
        }
        $content = '

			<!--
				Menu for saving Template Objects
			-->
			<table border="0" cellpadding="2" cellspacing="2" id="c-toMenu">
				<tr class="bgColor5">
					<td>' . implode('</td>
					<td>', $menuItems) . '</td>
				</tr>
			</table>
		';
        // Making messages:
        foreach ($msg as $msgStr) {
            $content .= '
			<p><img src="' . $GLOBALS['BACK_PATH'] . 'gfx/icon_note.gif" width="18" height="16" border="0" align="top" class="absmiddle" alt="" /><strong>' . htmlspecialchars($msgStr) . '</strong></p>';
        }
        return array($content, $headerPart ? $currentMappingInfo_head : $currentMappingInfo);
    }