/**
  * [Describe function...]
  *
  * @param	[type]		$cmd: ...
  * @return	[type]		...
  */
 function renderCatTree($calledFromAjax = false)
 {
     // 		$tStart = microtime(true);
     // 		$this->debug['start'] = time();
     if (substr($this->table, 0, 3) != 'be_') {
         // ignore useStoragePid if table is be_user/groups.
         if ($this->confArr['useStoragePid']) {
             if ($this->storagePidFromAjax) {
                 $this->storagePid = $this->storagePidFromAjax;
             } else {
                 $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($this->table, $this->row);
                 $this->storagePid = $TSconfig['_STORAGE_PID'] ? $TSconfig['_STORAGE_PID'] : intval($this->row['pid']);
             }
             $SPaddWhere = ' AND tt_news_cat.pid IN (' . $this->storagePid . ')';
             if ($this->table == 'tt_news_cat' && intval($this->row['pid']) > 0 && $this->row['pid'] != $this->storagePid) {
                 $msg = $this->printMsg('notInGRSP', 'warning2');
                 $notInGRSP = true;
             }
         }
         $catlistWhere = tx_ttnews_div::getCatlistWhere();
         if ($catlistWhere) {
             $this->getNotAllowedItems($SPaddWhere);
         }
     }
     $treeOrderBy = $this->confArr['treeOrderBy'] ? $this->confArr['treeOrderBy'] : 'uid';
     // instantiate tree object
     $treeViewObj = t3lib_div::makeInstance('tx_ttnews_tceforms_categorytree');
     $treeViewObj->treeName = $this->table . '_tree';
     $treeViewObj->table = 'tt_news_cat';
     $treeViewObj->tceFormsTable = $this->table;
     $treeViewObj->tceFormsRecID = $this->recID;
     $treeViewObj->storagePid = $this->storagePid;
     $treeViewObj->useStoragePid = $this->confArr['useStoragePid'];
     $treeViewObj->init($SPaddWhere . $catlistWhere, $treeOrderBy);
     $treeViewObj->backPath = $GLOBALS['BACK_PATH'];
     $treeViewObj->thisScript = 'class.tx_ttnews_tceformsSelectTree.php';
     $treeViewObj->fieldArray = array('uid', 'title', 'description', 'hidden', 'starttime', 'endtime', 'fe_group');
     // those fields will be filled to the array $treeViewObj->tree
     $treeViewObj->parentField = 'parent_category';
     $treeViewObj->expandable = $this->useAjax;
     $treeViewObj->expandAll = !$this->useAjax;
     $treeViewObj->useAjax = $this->useAjax;
     $treeViewObj->titleLen = 60;
     $treeViewObj->disableAll = $notInGRSP;
     $treeViewObj->ext_IconMode = '1';
     // no context menu on icons
     $treeViewObj->title = $GLOBALS['LANG']->sL('LLL:EXT:tt_news/locallang_tca.xml:tt_news.treeSelect.treeTitle');
     $treeViewObj->TCEforms_itemFormElName = $this->PA['itemFormElName'];
     if ($this->table == 'tt_news_cat') {
         $treeViewObj->TCEforms_nonSelectableItemsArray[] = $this->row['uid'];
     }
     /**
      * FIXME
      * making categories not-selectable with tt_newsPerms.tt_news_cat.allowedItems doesn't work anymore
      */
     //		if (tx_ttnews_div::useAllowedCategories() && !tx_ttnews_div::allowedItemsFromTreeSelector) {
     //			// 'options.useListOfAllowedItems' is set but no category is selected --> check the 'allowedItems' list
     //			$notAllowedItems = $this->getNotAllowedItems($SPaddWhere);
     //		}
     //		if (is_array($notAllowedItems) && $notAllowedItems[0]) {
     //			foreach ($notAllowedItems as $k) {
     //				$treeViewObj->TCEforms_nonSelectableItemsArray[] = $k;
     //			}
     //		}
     $sPageIcon = '';
     // mark selected categories
     $treeViewObj->TCEforms_selectedItemsArray = $this->selectedItems;
     $treeViewObj->selectedItemsArrayParents = $this->getCatRootline($SPaddWhere);
     if (substr($this->table, 0, 3) == 'be_') {
         // if table is 'be_users' or 'be_groups' group the categories by folder. 'useStoragePid' is ignored
         $cf = $this->getCategoryFolders($SPaddWhere . $catlistWhere);
         /**
          * FIXME:
          * currently 'expandFirst' is required to prevent js errors when expanding/collapsing the tree
          * the problems are caused by multiple "root" records with uid=0
          */
         $treeViewObj->expandFirst = 1;
         $treeViewObj->MOUNTS = $cf;
         $groupByPages = TRUE;
     } else {
         if ($this->storagePid > 0) {
             $addWhere = ' AND pid=' . $this->storagePid;
         } else {
             // useStoragePid=0 and table != beusers/groups
             $addWhere = '';
         }
         // get selected categories from be user/group without subcategories
         $tmpsc = tx_ttnews_div::getBeUserCatMounts(FALSE);
         $beUserSelCatArr = t3lib_div::intExplode(',', $tmpsc);
         $includeListArr = tx_ttnews_div::getIncludeCatArray();
         $subcatArr = array_diff($includeListArr, $beUserSelCatArr);
         // get all selected category records from the current storagePid which are not 'root' categories
         // and add them as tree mounts. Subcategories of selected categories will be excluded.
         $cMounts = array();
         $nonRootMounts = FALSE;
         foreach ($beUserSelCatArr as $catID) {
             $tmpR = t3lib_BEfunc::getRecord('tt_news_cat', $catID, 'parent_category,hidden', $addWhere);
             if (is_array($tmpR) && !in_array($catID, $subcatArr)) {
                 if ($tmpR['parent_category'] > 0) {
                     $nonRootMounts = TRUE;
                     if (!$calledFromAjax) {
                         $sPageIcon = $this->getStoragePageIcon($treeViewObj);
                     }
                 }
                 $cMounts[] = $catID;
             }
         }
         if ($nonRootMounts) {
             $treeViewObj->MOUNTS = $cMounts;
         }
     }
     // render tree html
     $treeContent = $sPageIcon . $treeViewObj->getBrowsableTree($groupByPages);
     $this->treeObj_ajaxStatus = $treeViewObj->ajaxStatus;
     //		if (count($treeViewObj->ids) == 0) {
     //			$msg .= str_replace('###PID###',$this->storagePid,$this->printMsg('emptyTree','note'));
     //			$treeContent = '';
     //		}
     return $msg . $treeContent;
 }
Пример #2
0
 /**
  * [Describe function...]
  *
  * @return	[type]		...
  */
 function getTreeObj()
 {
     $addWhere = '';
     if ($this->confArr['useStoragePid']) {
         $addWhere .= ' AND tt_news_cat.pid=' . $this->storagePid;
     }
     if (!$this->mData['showHiddenCategories']) {
         $addWhere .= ' AND tt_news_cat.hidden=0';
     }
     $treeOrderBy = $this->confArr['treeOrderBy'] ? $this->confArr['treeOrderBy'] : 'uid';
     if (!is_object($this->treeObj)) {
         $this->treeObj = t3lib_div::makeInstance('tx_ttnewscatmanager_treeView');
     }
     $urlparams = array('id' => $this->id);
     $this->treeObj->table = 'tt_news_cat';
     $this->treeObj->init($this->catlistWhere . $addWhere, $treeOrderBy);
     $this->treeObj->parentField = 'parent_category';
     $this->treeObj->thisScript = $this->script . '&id=' . $this->id;
     $this->treeObj->returnUrl = t3lib_BEfunc::getModuleUrl('web_txttnewsM1', $urlparams);
     $this->treeObj->fieldArray = array('uid', 'title', 'description', 'hidden', 'starttime', 'endtime', 'fe_group');
     // those fields will be filled to the array $this->treeObj->tree
     $this->treeObj->mayUserEditCategories = $this->mayUserEditCategories;
     $this->treeObj->title = $GLOBALS['LANG']->getLL('treeTitle');
     $this->treeObj->pageID = $this->id;
     $this->treeObj->storagePid = $this->storagePid;
     $this->treeObj->useStoragePid = $this->confArr['useStoragePid'];
     $this->treeObj->expandAll = $GLOBALS['SOBE']->MOD_SETTINGS['expandAll'];
     $this->treeObj->expandable = true;
     $this->treeObj->expandFirst = $this->TSprop['catmenu.']['expandFirst'];
     $this->treeObj->titleLen = 60;
     $this->treeObj->useAjax = true;
     $this->treeObj->showEditIcons = $this->mData['showEditIcons'];
     $this->treeObj->showHiddenCategories = $this->mData['showHiddenCategories'];
     $this->treeObj->category = $this->category;
     $this->treeObj->current_sys_language = $this->current_sys_language;
     // get selected categories from be user/group without subcategories
     $tmpsc = tx_ttnews_div::getBeUserCatMounts(FALSE);
     $beUserSelCatArr = t3lib_div::intExplode(',', $tmpsc);
     $includeListArr = tx_ttnews_div::getIncludeCatArray();
     $subcatArr = array_diff($includeListArr, $beUserSelCatArr);
     /**
      * TODO:
      * filter out double mounts
      */
     // get all selected category records from the current storagePid which are not 'root' categories
     // and add them as tree mounts. Subcategories of selected categories will be excluded.
     $cMounts = array();
     $nonRootMounts = FALSE;
     foreach ($beUserSelCatArr as $catID) {
         $tmpR = t3lib_BEfunc::getRecord('tt_news_cat', $catID, 'parent_category,hidden', $addWhere);
         if (is_array($tmpR) && !in_array($catID, $subcatArr)) {
             if ($tmpR['parent_category'] > 0) {
                 $nonRootMounts = TRUE;
                 $this->sPageIcon = $this->getStoragePageIcon();
             }
             if ($this->mData['showHiddenCategories']) {
                 $cMounts[] = $catID;
             } else {
                 if ($tmpR['hidden'] == 0) {
                     $cMounts[] = $catID;
                 }
             }
         }
     }
     if ($nonRootMounts) {
         $this->treeObj->MOUNTS = $cMounts;
     }
 }
 /**
  * [Describe function...]
  *
  * @return	[type]		...
  */
 function getIncludeCatArray()
 {
     $includeList = $GLOBALS['BE_USER']->getTSConfigVal('tt_newsPerms.tt_news_cat.includeList');
     $catmounts = tx_ttnews_div::getBeUserCatMounts();
     if ($catmounts) {
         $includeList = $catmounts;
     }
     return t3lib_div::intExplode(',', $includeList, 1);
 }
Пример #4
0
 /**
  * Get categories to include for the current user
  *
  * @return array ids of categories to include
  */
 public static function getIncludeCatArray()
 {
     $includeList = $GLOBALS['BE_USER']->getTSConfigVal('tt_newsPerms.tt_news_cat.includeList');
     $catmounts = tx_ttnews_div::getBeUserCatMounts();
     if ($catmounts) {
         $includeList = $catmounts;
     }
     return \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $includeList, 1);
 }