Ejemplo n.º 1
0
 /**
  * Return a page tree
  *
  * @param integer $pageUid page to start with
  * @param integer $treeLevel count of levels
  * @return \TYPO3\CMS\Backend\Tree\View\PageTreeView
  * @throws Exception
  */
 public static function pageTree($pageUid, $treeLevel)
 {
     if (TYPO3_MODE !== 'BE') {
         throw new Exception('Page::pageTree does only work in the backend!');
     }
     /* @var $tree \TYPO3\CMS\Backend\Tree\View\PageTreeView */
     $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
     $tree->init('AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
     $treeStartingRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $pageUid);
     \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL('pages', $treeStartingRecord);
     // Creating top icon; the current page
     $tree->tree[] = array('row' => $treeStartingRecord, 'HTML' => \TYPO3\CMS\Backend\Utility\IconUtility::getIconImage('pages', $treeStartingRecord, $GLOBALS['BACK_PATH'], 'align="top"'));
     $tree->getTree($pageUid, $treeLevel, '');
     return $tree;
 }
Ejemplo n.º 2
0
 /**
  *
  * Generates an icon leading to a record editing page using TYPO3-internal
  * functions. Used for example to provide icons allowing to edit fe_user
  * records.
  *
  * @param  string $table The table from which a record is to be edited.
  * @param  array $row The record to be edited as associative array.
  * @return string        An icon linked to the editing form
  *
  */
 function getItemFromRecord($table, $row)
 {
     global $BACK_PATH, $BE_USER;
     $iconAltText = BackendUtility::getRecordIconAltText($row, $table);
     //$elementTitle = BackendUtility::getRecordPath($row['uid'], '1=1', 0);
     //$elementTitle = GeneralUtility::fixed_lgd_cs($elementTitle, -($BE_USER->uc['titleLen']));
     $elementIcon = IconUtility::getIconImage($table, $row, $BACK_PATH, 'class="c-recicon" title="' . $iconAltText . '"');
     $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
     $editOnClick = BackendUtility::editOnClick($params, $BACK_PATH);
     return '<a href="#" onclick="' . htmlspecialchars($editOnClick) . '">' . $elementIcon . '</a>';
 }
Ejemplo n.º 3
0
 /**
  * For RTE: This displays all content elements on a page and lets you create a link to the element.
  *
  * @return	string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
  */
 protected function expandPageRecords()
 {
     $out = '';
     if ($this->expandPage >= 0 && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->expandPage) && $GLOBALS['BE_USER']->isInWebMount($this->expandPage)) {
         $tables = '*';
         if (isset($this->configuration['listTables'])) {
             $tables = $this->configuration['listTables'];
         }
         // Set array with table names to list:
         if (!strcmp(trim($tables), '*')) {
             $tablesArr = array_keys($GLOBALS['TCA']);
         } else {
             $tablesArr = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $tables, 1);
         }
         reset($tablesArr);
         // Headline for selecting records:
         $out .= $this->browseLinksObj->barheader($GLOBALS['LANG']->getLL('selectRecords') . ':');
         // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
         $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
         $mainPageRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $this->expandPage);
         $aTag = '';
         $aTagEnd = '';
         $aTag2 = '';
         if (in_array('pages', $tablesArr)) {
             $ficon = \TYPO3\CMS\Backend\Utility\IconUtility::getIcon('pages', $mainPageRec);
             $aTag = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] . "', 'db', " . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($mainPageRec['title']) . ", '', '', '" . $ficon . "', '',1);\">";
             $aTag2 = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] . "', 'db', " . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($mainPageRec['title']) . ", '', '', '" . $ficon . "', '',0);\">";
             $aTagEnd = '</a>';
         }
         $picon = \TYPO3\CMS\Backend\Utility\IconUtility::getIconImage('pages', $mainPageRec, $GLOBALS['BACK_PATH'], '');
         $pBicon = $aTag2 ? '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' alt="" />' : '';
         $pText = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($mainPageRec['title'], $titleLen));
         $out .= $picon . $aTag2 . $pBicon . $aTagEnd . $aTag . $pText . $aTagEnd . '<br />';
         // Initialize the record listing:
         $id = $this->expandPage;
         $pointer = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
         $pagePermsClause = $GLOBALS['BE_USER']->getPagePermsClause(1);
         $pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($id, $pagePermsClause);
         // Generate the record list:
         // unfortunately we have to set weird dependencies.
         /** @var \AOE\Linkhandler\Record\ElementBrowserRecordList $dblist */
         $dblist = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('AOE\\Linkhandler\\Record\\ElementBrowserRecordList');
         $dblist->setAddPassOnParameters($this->addPassOnParams);
         $dblist->browselistObj = $this->browseLinksObj;
         $dblist->backPath = $GLOBALS['BACK_PATH'];
         $dblist->thumbs = 0;
         $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
         $dblist->noControlPanels = 1;
         $dblist->clickMenuEnabled = 0;
         $dblist->tableList = implode(',', $tablesArr);
         if (array_key_exists('overwriteHandler', $this->configuration)) {
             $dblist->setOverwriteLinkHandler($this->configuration['overwriteHandler']);
         }
         $dblist->start($id, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('table'), $pointer, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('search_field'), \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('search_levels'), \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('showLimit'));
         $dblist->setDispFields();
         $dblist->generateList();
         $dblist->writeBottom();
         //	Add the HTML for the record list to output variable:
         $out .= $dblist->HTMLcode;
         $out .= $dblist->getSearchBox();
     }
     return $out;
 }
Ejemplo n.º 4
0
    /**
     * Shows the copy wizard
     *
     * @param int $uidClip Uid of the clipped item
     * @param int $uidTarget Uid of target
     * @param string $command Command
     *
     * @return void
     */
    protected function showCopyWizard($uidClip, $uidTarget, $command)
    {
        $language = $this->getLanguageService();
        $str = '';
        $this->pageinfo = Tx_Commerce_Utility_BackendUtility::readCategoryAccess($uidTarget, Tx_Commerce_Utility_BackendUtility::getCategoryPermsClause(1));
        $str .= $this->doc->header($language->getLL('Copy'));
        $str .= $this->doc->spacer(5);
        // flag if neither sorting nor localizations
        // are existing and we can immediately copy
        $noActionReq = FALSE;
        // First prepare user defined objects (if any)
        // for hooks which extend this function:
        $hookObjectsArr = array();
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/mod_cce/class.tx_commerce_cce_db.php']['copyWizardClass'])) {
            \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('
				hook
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/mod_cce/class.tx_commerce_cce_db.php\'][\'copyWizardClass\']
				is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Utility/DataHandlerUtility.php\'][\'copyWizard\']
			');
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/mod_cce/class.tx_commerce_cce_db.php']['copyWizardClass'] as $classRef) {
                $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
            }
        }
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Utility/DataHandlerUtility.php']['copyWizard'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Utility/DataHandlerUtility.php']['copyWizard'] as $classRef) {
                $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
            }
        }
        switch ($command) {
            case 'overwrite':
                // pass through
            // pass through
            case 'pasteProduct':
                // chose local to copy from product
                /**
                 * Product
                 *
                 * @var Tx_Commerce_Domain_Model_Product $product
                 */
                $product = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Product', $uidClip);
                $product->loadData();
                $prods = $product->getL18nProducts();
                if (count($prods)) {
                    $str .= '<h1>' . $language->getLL('copy.head.l18n') . '</h1>
						<h2>' . $language->getLL('copy.product') . ': ' . $product->getTitle() . '</h2>
						<ul>';
                    // walk the l18n and get the selector box
                    $l = count($prods);
                    for ($i = 0; $i < $l; $i++) {
                        $tmpProd = $prods[$i];
                        $flag = $tmpProd['flag'] != '' ? '<img src="' . $this->doc->backPath . 'gfx/flags/' . $tmpProd['flag'] . '" alt="Flag" />' : '';
                        $str .= '<li><input type="checkbox" name="locale[]" id="loc_' . $tmpProd['uid'] . '" value="' . $tmpProd['sys_language'] . '" /><label for="loc_' . $tmpProd['uid'] . '">' . $flag . $tmpProd['title'] . '</label></li>';
                    }
                    $str .= '</ul>';
                }
                $records = array();
                // chose sorting position
                if ($command != 'overwrite') {
                    // Initialize tree object:
                    /**
                     * Product data
                     *
                     * @var Tx_Commerce_Tree_Leaf_ProductData $treedb
                     */
                    $treedb = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_ProductData');
                    $treedb->init();
                    $records = $treedb->getRecordsDbList($uidTarget);
                }
                $l = count($records['pid'][$uidTarget]);
                // Hook: beforeFormClose
                $userIgnoreClose = FALSE;
                foreach ($hookObjectsArr as $hookObj) {
                    if (method_exists($hookObj, 'beforeFormClose')) {
                        // set $user_ignoreClose to true if you want to
                        // force the script to print out the execute button
                        $str .= $hookObj->beforeFormClose($uidClip, $uidTarget, $command, $userIgnoreClose);
                    }
                }
                if (0 >= $l && (0 != count($prods) || $userIgnoreClose)) {
                    // no child object - sorting position is irrelevant - just print a submit button
                    // and notify users that there are not products in the category yet
                    $str .= '<input type="submit" value="' . $language->getLL('copy.submit') . '" />';
                } elseif (0 < $l) {
                    // at least 1 item - offer choice
                    $icon = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/newrecord_marker_d.gif', 'width="281" height="8"') . ' alt="" title="Insert the category" />';
                    $prodIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getIconImage('tx_commerce_products', array('uid' => $uidTarget), $this->doc->backPath, 'align="top" class="c-recIcon"');
                    $str .= '<h1>' . $language->getLL('copy.position') . '</h1>';
                    $onClickAction = 'onclick="submitForm(' . $records['pid'][$uidTarget][0]['uid'] . ')"';
                    $str .= '<span class="nobr"><a href="javascript:void(0)" ' . $onClickAction . '>' . $icon . '</a></span><br />';
                    for ($i = 0; $i < $l; $i++) {
                        $record = $records['pid'][$uidTarget][$i];
                        $onClickAction = 'onclick="submitForm(-' . $record['uid'] . ')"';
                        $str .= '<span class="nobr">' . $prodIcon . $record['title'] . '</span><br />';
                        $str .= '<span class="nobr"><a href="javascript:void(0)" ' . $onClickAction . '>' . $icon . '</a></span><br />';
                    }
                } else {
                    $noActionReq = TRUE;
                }
                break;
            case 'pasteCategory':
                // chose locale to copy from category
                /**
                 * Category
                 *
                 * @var Tx_Commerce_Domain_Model_Category $category
                 */
                $category = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Category', $uidClip);
                $category->loadData();
                $cats = $category->getL18nCategories();
                if (0 != count($cats)) {
                    $str .= '<h1>' . $language->getLL('copy.head.l18n') . '</h1>
						<h2>' . $language->getLL('copy.category') . ': ' . $category->getTitle() . '</h2>
						<ul>';
                    // walk the l18n and get the selector box
                    $l = count($cats);
                    for ($i = 0; $i < $l; $i++) {
                        $tmpCat = $cats[$i];
                        $flag = $tmpCat['flag'] != '' ? '<img src="' . $this->doc->backPath . 'gfx/flags/' . $tmpCat['flag'] . '" alt="Flag" />' : '';
                        $str .= '<li><input type="checkbox" name="locale[]" id="loc_' . $tmpCat['uid'] . '" value="' . $tmpCat['sys_language'] . '" /><label for="loc_' . $tmpCat['uid'] . '">' . $flag . $tmpCat['title'] . '</label></li>';
                    }
                    $str .= '</ul>';
                }
                // chose sorting position
                // Initialize tree object:
                /**
                 * Category data
                 *
                 * @var Tx_Commerce_Tree_Leaf_CategoryData $treedb
                 */
                $treedb = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_CategoryData');
                $treedb->init();
                $records = $treedb->getRecordsDbList($uidTarget);
                $l = count($records['pid'][$uidTarget]);
                // Hook: beforeFormClose
                $userIgnoreClose = FALSE;
                foreach ($hookObjectsArr as $hookObj) {
                    if (method_exists($hookObj, 'beforeFormClose')) {
                        $str .= $hookObj->beforeFormClose($uidClip, $uidTarget, $command, $userIgnoreClose);
                    }
                }
                if (0 == $l && (0 != count($cats) || $userIgnoreClose)) {
                    // no child object - sorting position is irrelevant - just print a submit button
                    $str .= '<input type="submit" value="' . $language->getLL('copy.submit') . '" />';
                } elseif (0 < $l) {
                    // at least 1 item - offer choice
                    $icon = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/newrecord_marker_d.gif', 'width="281" height="8"') . ' alt="" title="Insert the category" />';
                    $catIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getIconImage('tx_commerce_categories', array('uid' => $uidTarget), $this->doc->backPath, 'align="top" class="c-recIcon"');
                    $str .= '<h1>' . $language->getLL('copy.position') . '</h1>';
                    $onClickAction = 'onclick="submitForm(' . $records['pid'][$uidTarget][0]['uid'] . ')"';
                    $str .= '<span class="nobr"><a href="javascript:void(0)" ' . $onClickAction . '>' . $icon . '</a></span><br />';
                    for ($i = 0; $i < $l; $i++) {
                        $record = $records['pid'][$uidTarget][$i];
                        $onClickAction = 'onclick="submitForm(-' . $record['uid'] . ')"';
                        $str .= '<span class="nobr">' . $catIcon . $record['title'] . '</span><br />
							<span class="nobr"><a href="javascript:void(0)" ' . $onClickAction . '>' . $icon . '</a></span><br />';
                    }
                } else {
                    $noActionReq = TRUE;
                }
                break;
            default:
                die('unknown command');
        }
        // skip transforming and execute the command
        // if there are no locales and no positions
        if ($noActionReq) {
            $this->commitCommand($uidClip, $uidTarget, $command);
            return;
        }
        // Hook: beforeTransform
        foreach ($hookObjectsArr as $hookObj) {
            if (method_exists($hookObj, 'beforeTransform')) {
                $str .= $hookObj->beforeTransform($uidClip, $uidTarget, $command);
            }
        }
        $this->content .= $str;
        $markers = array('CSH' => '', 'CONTENT' => $this->content, 'CATINFO' => '', 'CATPATH' => '');
        $markers['FUNC_MENU'] = $this->doc->funcMenu('', \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[mode]', $this->MOD_SETTINGS['mode'], $this->MOD_MENU['mode']));
        $this->content = $this->doc->startPage($language->getLL('Copy'));
        $this->content .= $this->doc->moduleBody($this->pageinfo, array(), $markers);
        $this->content .= $this->doc->endPage();
    }