Esempio n. 1
0
 /**
  * Checks the array for elements which might contain unallowed default values and will unset them!
  * Looks for the "tt_content_defValues" key in each element and if found it will traverse that array as fieldname / value pairs and check. The values will be added to the "params" key of the array (which should probably be unset or empty by default).
  *
  * @param	array		Wizard items, passed by reference
  * @return	void
  */
 function removeInvalidElements(&$wizardItems)
 {
     global $TCA;
     // Load full table definition:
     t3lib_div::loadTCA('tt_content');
     // Get TCEFORM from TSconfig of current page
     $TCEFORM_TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig('tt_content', array('pid' => $this->id));
     $removeItems = t3lib_div::trimExplode(',', $TCEFORM_TSconfig['CType']['removeItems'], 1);
     $headersUsed = array();
     // Traverse wizard items:
     foreach ($wizardItems as $key => $cfg) {
         // Exploding parameter string, if any (old style)
         if ($wizardItems[$key]['params']) {
             // Explode GET vars recursively
             $tempGetVars = t3lib_div::explodeUrl2Array($wizardItems[$key]['params'], TRUE);
             // If tt_content values are set, merge them into the tt_content_defValues array, unset them from $tempGetVars and re-implode $tempGetVars into the param string (in case remaining parameters are around).
             if (is_array($tempGetVars['defVals']['tt_content'])) {
                 $wizardItems[$key]['tt_content_defValues'] = array_merge(is_array($wizardItems[$key]['tt_content_defValues']) ? $wizardItems[$key]['tt_content_defValues'] : array(), $tempGetVars['defVals']['tt_content']);
                 unset($tempGetVars['defVals']['tt_content']);
                 $wizardItems[$key]['params'] = t3lib_div::implodeArrayForUrl('', $tempGetVars);
             }
         }
         // If tt_content_defValues are defined...:
         if (is_array($wizardItems[$key]['tt_content_defValues'])) {
             // Traverse field values:
             foreach ($wizardItems[$key]['tt_content_defValues'] as $fN => $fV) {
                 if (is_array($TCA['tt_content']['columns'][$fN])) {
                     // Get information about if the field value is OK:
                     $config =& $TCA['tt_content']['columns'][$fN]['config'];
                     $authModeDeny = $config['type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode('tt_content', $fN, $fV, $config['authMode']);
                     if ($authModeDeny || in_array($fV, $removeItems)) {
                         // Remove element all together:
                         unset($wizardItems[$key]);
                         break;
                     } else {
                         // Add the parameter:
                         $wizardItems[$key]['params'] .= '&defVals[tt_content][' . $fN . ']=' . rawurlencode($fV);
                         $tmp = explode('_', $key);
                         $headersUsed[$tmp[0]] = $tmp[0];
                     }
                 }
             }
         }
     }
     // Remove headers without elements
     foreach ($wizardItems as $key => $cfg) {
         list($itemCategory, $dummy) = explode('_', $key);
         if (!isset($headersUsed[$itemCategory])) {
             unset($wizardItems[$key]);
         }
     }
 }
 /**
  * This function performs processing on the input $row array and stores internally a corresponding array which contains processed values, ready to pass on to the TCEforms rendering in the frontend!
  * The objective with this function is to prepare the content for handling in TCEforms.
  * Default values from outside/TSconfig is added by fetchRecord(). In this function default values from TCA is used if a field is NOT defined in $row.
  * The resulting, processed row is stored in $this->regTableItems_data[$uniqueItemRef], where $uniqueItemRef is "[tablename]_[id-value]"
  *
  * @param	string		The table name
  * @param	string		The uid value of the record (integer). Can also be a string (NEW-something) if the record is a NEW record.
  * @param	integer		The pid integer. For existing records this is of course the row's "pid" field. For new records it can be either a page id (positive) or a pointer to another record from the SAME table (negative) after which the record should be inserted (or on same page)
  * @param	array		The row of the current record. If NEW record, then it may be loaded with default values (by eg. fetchRecord()).
  * @return	void
  * @see fetchRecord()
  */
 function renderRecord($table, $id, $pid, $row)
 {
     global $TCA;
     // Init:
     $uniqueItemRef = $table . '_' . $id;
     t3lib_div::loadTCA($table);
     // Fetches the true PAGE TSconfig pid to use later, if needed. (Until now, only for the RTE, but later..., who knows?)
     list($tscPID) = t3lib_BEfunc::getTSCpid($table, $id, $pid);
     $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($table, array_merge($row, array('uid' => $id, 'pid' => $pid)));
     // If the record has not already been loaded (in which case we DON'T do it again)...
     if (!$this->regTableItems[$uniqueItemRef]) {
         $this->regTableItems[$uniqueItemRef] = 1;
         // set "loaded" flag.
         // If the table is pages, set the previous page id internally.
         if ($table == 'pages') {
             $this->prevPageID = $id;
         }
         $this->regTableItems_data[$uniqueItemRef] = $this->renderRecordRaw($table, $id, $pid, $row, $TSconfig, $tscPID);
         // Merges the processed array on-top of the raw one - this is done because some things in TCEforms may need access to other fields than those in the columns configuration!
         if ($this->addRawData && is_array($row) && is_array($this->regTableItems_data[$uniqueItemRef])) {
             $this->regTableItems_data[$uniqueItemRef] = array_merge($row, $this->regTableItems_data[$uniqueItemRef]);
         }
     }
 }
 function renderTree()
 {
     t3lib_div::loadTCA($this->fieldConfig['foreign_table']);
     $orderBy = $GLOBALS['TCA'][$this->fieldConfig['foreign_table']]['ctrl']['sortby'] ? $this->fieldConfig['foreign_table'] . '.' . $GLOBALS['TCA'][$this->fieldConfig['foreign_table']]['ctrl']['sortby'] : substr($GLOBALS['TCA'][$this->fieldConfig['foreign_table']]['ctrl']['default_sortby'], 9);
     $treeViewObj = t3lib_div::makeInstance('tx_cpstcatree_treeview');
     $treeViewObj->thisScript = 'class.tx_cpstcatree.php';
     $treeViewObj->title = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->fieldConfig['foreign_table']]['ctrl']['title']);
     $treeViewObj->treeName = $this->table . '_' . $this->field . '_tree';
     $treeViewObj->table = $this->fieldConfig['foreign_table'];
     // Set parent field of table
     if (isset($this->fieldConfig['treeViewParentField'])) {
         $this->parentField = $this->fieldConfig['treeViewParentField'];
     } else {
         $this->parentField = $GLOBALS['TCA'][$this->fieldConfig['foreign_table']]['ctrl']['treeParentField'];
     }
     if (!$this->parentField) {
         $this->parentField = 'pid';
     }
     $treeViewObj->parentField = $this->parentField;
     $treeViewObj->parentField = $this->parentField;
     // Set select fields
     $treeViewObj->fieldArray = array('uid');
     $treeViewObj->addField($GLOBALS['TCA'][$treeViewObj->table]['ctrl']['label']);
     if (isset($GLOBALS['TCA'][$treeViewObj->table]['ctrl']['label_alt'])) {
         $treeViewObj->addField($GLOBALS['TCA'][$treeViewObj->table]['ctrl']['label_alt']);
     }
     $treeViewObj->tceFormsTable = $this->table;
     if ($this->table == 'tt_content') {
         $treeViewObj->tceFormsField = $this->field . ',' . $this->fieldConfig['piFlexFormSheet'] . ',' . $this->fieldConfig['piFlexFormLang'] . ',' . $this->fieldConfig['piFlexFormValue'] . ',' . $this->row['CType'] . ',' . $this->row['list_type'];
     } else {
         $treeViewObj->tceFormsField = $this->field;
     }
     $treeViewObj->tceFormsRecID = $this->row['uid'];
     $treeViewObj->ext_IconMode = '0';
     $treeViewObj->treeView = $this->fieldConfig['treeView'];
     $treeViewObj->expandable = $this->fieldConfig['expandable'];
     $treeViewObj->expandFirst = $this->fieldConfig['expandFirst'];
     $treeViewObj->expandAll = $this->fieldConfig['expandAll'];
     $treeViewObj->ignorePermsClause = $this->fieldConfig['ignorePermsClause'];
     // Get TSconfig
     $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($this->table, $this->row);
     // Get TSconfig for field
     if ($this->table == 'tt_content') {
         $fieldTSconfig = t3lib_TCEforms::setTSconfig($this->table, $this->row);
         $fieldTSconfig = $fieldTSconfig['pi_flexform'][$this->row['list_type'] . '.'][$this->field . '.'];
     } else {
         $fieldTSconfig = t3lib_TCEforms::setTSconfig($this->table, $this->row, $this->field);
     }
     $clause = '';
     // removeItems
     if (isset($fieldTSconfig['removeItems'])) {
         $this->removeItems = tx_cpsdevlib_div::toListArray(tx_cpsdevlib_db::getRootLineDownwards($treeViewObj->table, $treeViewObj->parentField, $fieldTSconfig['removeItems']), '', 1, 1, 1);
     }
     // keepItems
     if (isset($fieldTSconfig['keepItems'])) {
         $this->keepItems = tx_cpsdevlib_div::toListArray($fieldTSconfig['keepItems']);
         if (count($this->removeItems)) {
             // If items were removed from list check keepItems to add back
             foreach ($this->keepItems as $value) {
                 if (($key = array_search($value, $this->removeItems)) !== false) {
                     unset($this->removeItems[$key]);
                     // Get rootline upwards to restore parent items
                     $rL = tx_cpsdevlib_div::toListArray(tx_cpsdevlib_db::getRootLineUpwards($treeViewObj->table, 'pid', $value), '', 1, 1, 1);
                     foreach ($rL as $v) {
                         if (($k = array_search($v, $this->removeItems)) !== false) {
                             $treeViewObj->TCEforms_nonSelectableItemsArray[] = $v;
                             unset($this->removeItems[$k]);
                         }
                     }
                 }
             }
         } else {
             // If just keepItems is set only show selected
             if (count($this->keepItems)) {
                 $clause = ' AND ' . $treeViewObj->table . '.uid IN (' . implode(',', $this->keepItems) . ')';
             }
         }
     }
     if (count($this->removeItems)) {
         $clause = ' AND ' . $treeViewObj->table . '.uid NOT IN (' . implode(',', $this->removeItems) . ')';
     }
     // hideItems
     if (isset($fieldTSconfig['hideItems'])) {
         $this->hideItems = tx_cpsdevlib_div::toListArray($fieldTSconfig['hideItems']);
         $treeViewObj->TCEforms_nonSelectableItemsArray = array_merge($treeViewObj->TCEforms_nonSelectableItemsArray, $this->hideItems);
     }
     // Add foreign_table_where
     if ($this->fieldConfig['foreign_table_where']) {
         // Remove ORDER BY part if present
         if (strpos(strtolower($this->fieldConfig['foreign_table_where']), 'order by') !== false) {
             $ftWhere = substr($this->fieldConfig['foreign_table_where'], 0, strpos(strtolower($this->fieldConfig['foreign_table_where']), 'order by'));
         } else {
             $ftWhere = $this->fieldConfig['foreign_table_where'];
         }
         // Replace record maker in foreign_table_where
         if (strstr($ftWhere, '###REC_FIELD_')) {
             $ftWhereParts = explode('###REC_FIELD_', $ftWhere);
             foreach ($ftWhereParts as $key => $value) {
                 if ($key) {
                     $ftWhereSubpart = explode('###', $value, 2);
                     if (substr($ftWhereParts[0], -1) === '\'' && $ftWhereSubpart[1][0] === '\'') {
                         $ftWhereParts[$key] = $GLOBALS['TYPO3_DB']->quoteStr($TSconfig['_THIS_ROW'][$ftWhereSubpart[0]], $treeViewObj->table) . $ftWhereSubpart[1];
                     } else {
                         $ftWhereParts[$key] = $GLOBALS['TYPO3_DB']->fullQuoteStr($TSconfig['_THIS_ROW'][$ftWhereSubpart[0]], $treeViewObj->table) . $ftWhereSubpart[1];
                     }
                 }
             }
             $ftWhere = implode('', $ftWhereParts);
         }
         // Replace special marker in foreign_table_where
         $ftWhere = str_replace('###CURRENT_PID###', intval($TSconfig['_CURRENT_PID']), $ftWhere);
         $ftWhere = str_replace('###THIS_UID###', intval($TSconfig['_THIS_UID']), $ftWhere);
         $ftWhere = str_replace('###THIS_CID###', intval($TSconfig['_THIS_CID']), $ftWhere);
         $ftWhere = str_replace('###STORAGE_PID###', intval($TSconfig['_STORAGE_PID']), $ftWhere);
         $ftWhere = str_replace('###SITEROOT###', intval($TSconfig['_SITEROOT']), $ftWhere);
         $ftWhere = str_replace('###PAGE_TSCONFIG_ID###', intval($TSconfig[$this->field]['PAGE_TSCONFIG_ID']), $ftWhere);
         $ftWhere = str_replace('###PAGE_TSCONFIG_IDLIST###', $GLOBALS['TYPO3_DB']->cleanIntList($TSconfig[$this->field]['PAGE_TSCONFIG_IDLIST']), $ftWhere);
         $ftWhere = str_replace('###PAGE_TSCONFIG_STR###', $GLOBALS['TYPO3_DB']->quoteStr($TSconfig[$this->field]['PAGE_TSCONFIG_STR'], $this->fieldConfig['foreign_table']), $ftWhere);
         $clause .= ' ' . trim($ftWhere);
     }
     // Hook to manipulate clause
     $parameter = array('clause' => &$clause, 'treeViewObj' => &$treeViewObj);
     tx_cpsdevlib_div::callHookObjects('cps_tcatree', 'changeClauseHook', $parameter, $this);
     $treeViewObj->init($clause, $orderBy);
     $treeViewObj->TCEforms_itemFormElName = $this->itemFormElName;
     if ($this->table == $this->fieldConfig['foreign_table']) {
         $treeViewObj->TCEforms_nonSelectableItemsArray[] = $this->row['uid'];
     }
     $treeViewObj->TCEforms_selectedItemsArray = $this->selectedItems;
     $treeViewObj->selectedItemsArrayParents = $this->getItemRootline($this->selectedItems);
     $treeContent = $treeViewObj->getBrowsableTree();
     return $treeContent;
 }
 /**
  * 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']);
 }
 /**
  * [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;
 }
Esempio n. 6
0
 /**
  * Initializes the Module
  *
  * @return	void
  */
 function init()
 {
     //		$s = microtime(TRUE);
     if (!$this->MCONF['name']) {
         $this->MCONF = $GLOBALS['MCONF'];
         if (!$this->MCONF['name']) {
             $MCONF = '';
             require 'conf.php';
             $this->MCONF = $MCONF;
         }
     }
     $this->isAdmin = $GLOBALS['BE_USER']->isAdmin();
     $this->id = intval(t3lib_div::_GP('id'));
     //		$this->CMD = t3lib_div::_GP('CMD');
     $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
     $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->id, 'mod.' . $this->MCONF['name']);
     $this->TSprop = $this->modTSconfig['properties'];
     $this->confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['tt_news']);
     $tceTSC = array();
     if ($this->confArr['useStoragePid']) {
         $tceTSC = t3lib_BEfunc::getTCEFORM_TSconfig('tt_news_cat', array('pid' => $this->id));
     }
     $this->storagePid = $tceTSC['_STORAGE_PID'] ? $tceTSC['_STORAGE_PID'] : $this->id;
     $newArticlePid = intval($this->TSprop['list.']['pidForNewArticles']);
     $this->newArticlePid = $newArticlePid ? $newArticlePid : $this->id;
     $this->script = 'mod.php?M=web_txttnewsM1';
     if ($fieldList = $this->TSprop['list.']['fList']) {
         $this->fieldList = $fieldList;
     }
     // get pageinfo array for the current page
     $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause);
     $this->localCalcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
     // get pageinfo array for the GRSP
     $grspPI = t3lib_BEfunc::readPageAccess($this->storagePid, $this->perms_clause);
     $this->grspCalcPerms = $GLOBALS['BE_USER']->calcPerms($grspPI);
     $this->mayUserEditCategories = $this->grspCalcPerms & 16;
     // get pageinfo array for newArticlePid
     $newArticlePidPI = t3lib_BEfunc::readPageAccess($this->newArticlePid, $this->perms_clause);
     $this->newArticleCalcPerms = $GLOBALS['BE_USER']->calcPerms($newArticlePidPI);
     $this->mayUserEditArticles = $this->newArticleCalcPerms & 16;
     $pagesTSC = t3lib_BEfunc::getPagesTSconfig($this->id);
     if ($pagesTSC['tx_ttnews.']['singlePid']) {
         $this->singlePid = intval($pagesTSC['tx_ttnews.']['singlePid']);
     }
     $this->initCategories();
     $this->setPidList();
     $this->initPermsCache();
     if ($this->pidList) {
         $this->setEditablePages($this->pidList);
     }
     $this->menuConfig();
     $this->mData = $GLOBALS['BE_USER']->uc['moduleData']['web_txttnewsM1'];
     $this->current_sys_language = intval($this->MOD_SETTINGS['language']);
     $this->searchLevels = intval($this->MOD_SETTINGS['searchLevels']);
     $this->thumbs = intval($this->MOD_SETTINGS['showThumbs']);
     $limit = intval($this->MOD_SETTINGS['showLimit']);
     if ($limit) {
         $this->showLimit = $limit;
     } else {
         $this->showLimit = intval($this->TSprop['list.']['limit']);
     }
     $this->initGPvars();
     //		debug((microtime(TRUE)-$s), 'time ('.__CLASS__.'::'.__FUNCTION__.')', __LINE__, __FILE__, 3);
 }
	/**
	 * Replaces any dynamic markers in a SQL statement.
	 *
	 * @param	string		The SQL statement with dynamic markers.
	 * @param	string		Name of the table.
	 * @param	array		row from table.
	 * @return	string		SQL query with dynamic markers subsituted.
	 */
	function replaceMarkersInSQL ($sql, $table, $row)	{

		$TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($table, $row);

		/* Replace references to specific fields with value of that field */
		if (strstr($sql,'###REC_FIELD_'))	{
			$sql_parts = explode('###REC_FIELD_',$sql);
			while(list($kk,$vv)=each($sql_parts))	{
				if ($kk)	{
					$sql_subpart = explode('###',$vv,2);
					$sql_parts[$kk]=$TSconfig['_THIS_ROW'][$sql_subpart[0]].$sql_subpart[1];
				}
			}
			$sql = implode('',$sql_parts);
		}

		/* Replace markers with TSConfig values */
		$sql = str_replace('###THIS_UID###',intval($TSconfig['_THIS_UID']),$sql);
		$sql = str_replace('###THIS_CID###',intval($TSconfig['_THIS_CID']),$sql);
		$sql = str_replace('###SITEROOT###',intval($TSconfig['_SITEROOT']),$sql);
		$sql = str_replace('###PAGE_TSCONFIG_ID###',intval($TSconfig[$field]['PAGE_TSCONFIG_ID']),$sql);
		$sql = str_replace('###PAGE_TSCONFIG_IDLIST###',$GLOBALS['TYPO3_DB']->cleanIntList($TSconfig[$field]['PAGE_TSCONFIG_IDLIST']),$sql);
		$sql = str_replace('###PAGE_TSCONFIG_STR###',$GLOBALS['TYPO3_DB']->quoteStr($TSconfig[$field]['PAGE_TSCONFIG_STR'], $table),$sql);

		return $sql;
	}
Esempio n. 8
0
 /**
  * Initialization of the class.
  *
  * @return	void
  */
 function init()
 {
     // Init GPvars:
     $this->P = t3lib_div::_GP('P');
     $this->returnEditConf = t3lib_div::_GP('returnEditConf');
     // Get this record
     $origRow = t3lib_BEfunc::getRecord($this->P['table'], $this->P['uid']);
     // Set table:
     $this->table = $this->P['params']['table'];
     // Get TSconfig for it.
     $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($this->P['table'], is_array($origRow) ? $origRow : array('pid' => $this->P['pid']));
     // Set [params][pid]
     if (substr($this->P['params']['pid'], 0, 3) == '###' && substr($this->P['params']['pid'], -3) == '###') {
         $this->pid = intval($TSconfig['_' . substr($this->P['params']['pid'], 3, -3)]);
     } else {
         $this->pid = intval($this->P['params']['pid']);
     }
     // Return if new record as parent (not possibly/allowed)
     if (!strcmp($this->pid, '')) {
         t3lib_utility_Http::redirect(t3lib_div::sanitizeLocalUrl($this->P['returnUrl']));
     }
     // Else proceed:
     if ($this->returnEditConf) {
         // If a new id has returned from a newly created record...
         $eC = unserialize($this->returnEditConf);
         if (is_array($eC[$this->table]) && t3lib_div::testInt($this->P['uid'])) {
             // Getting id and cmd from returning editConf array.
             reset($eC[$this->table]);
             $this->id = intval(key($eC[$this->table]));
             $cmd = current($eC[$this->table]);
             // ... and if everything seems OK we will register some classes for inclusion and instruct the object to perform processing later.
             if ($this->P['params']['setValue'] && $cmd == 'edit' && $this->id && $this->P['table'] && $this->P['field'] && $this->P['uid']) {
                 if ($LiveRec = t3lib_BEfunc::getLiveVersionOfRecord($this->table, $this->id, 'uid')) {
                     $this->id = $LiveRec['uid'];
                 }
                 $this->include_once[] = PATH_t3lib . 'class.t3lib_loaddbgroup.php';
                 $this->include_once[] = PATH_t3lib . 'class.t3lib_transferdata.php';
                 $this->include_once[] = PATH_t3lib . 'class.t3lib_tcemain.php';
                 $this->processDataFlag = 1;
             }
         }
     }
 }
 /**
  * Returns TSconfig for table/row
  * Multiple requests to this function will return cached content so there is no performance loss in calling this many times since the information is looked up only once.
  *
  * @param	string		The table name
  * @param	array		The table row (Should at least contain the "uid" value, even if "NEW..." string. The "pid" field is important as well, and negative values will be intepreted as pointing to a record from the same table.)
  * @param	string		Optionally you can specify the field name as well. In that case the TSconfig for the field is returned.
  * @return	mixed		The TSconfig values (probably in an array)
  * @see t3lib_BEfunc::getTCEFORM_TSconfig()
  */
 function setTSconfig($table, $row, $field = '')
 {
     $mainKey = $table . ':' . $row['uid'];
     if (!isset($this->cachedTSconfig[$mainKey])) {
         $this->cachedTSconfig[$mainKey] = t3lib_BEfunc::getTCEFORM_TSconfig($table, $row);
     }
     if ($field) {
         return $this->cachedTSconfig[$mainKey][$field];
     } else {
         return $this->cachedTSconfig[$mainKey];
     }
 }
Esempio n. 10
0
 /**
  * Main function
  * Will issue a location-header, redirecting either BACK or to a new alt_doc.php instance...
  *
  * @return	void
  */
 function main()
 {
     // Get this record
     $origRow = t3lib_BEfunc::getRecord($this->P['table'], $this->P['uid']);
     // Get TSconfig for it.
     $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($this->table, is_array($origRow) ? $origRow : array('pid' => $this->P['pid']));
     // Set [params][pid]
     if (substr($this->P['params']['pid'], 0, 3) == '###' && substr($this->P['params']['pid'], -3) == '###') {
         $this->pid = intval($TSconfig['_' . substr($this->P['params']['pid'], 3, -3)]);
     } else {
         $this->pid = intval($this->P['params']['pid']);
     }
     // Make redirect:
     if (!strcmp($this->pid, '') || strcmp($this->id, '')) {
         // If pid is blank OR if id is set, then return...
         $redirectUrl = $this->P['returnUrl'];
     } else {
         // Otherwise, show the list:
         $redirectUrl = 'db_list.php?id=' . $this->pid . '&table=' . $this->P['params']['table'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
     }
     t3lib_utility_Http::redirect($redirectUrl);
 }
Esempio n. 11
0
 /**
  * Main function
  * Will issue a location-header, redirecting either BACK or to a new alt_doc.php instance...
  *
  * @return	void
  */
 function main()
 {
     // Get this record
     $origRow = t3lib_BEfunc::getRecord($this->P['table'], $this->P['uid']);
     // Get TSconfig for it.
     $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig($this->table, is_array($origRow) ? $origRow : array('pid' => $this->P['pid']));
     // Set [params][pid]
     if (substr($this->P['params']['pid'], 0, 3) == '###' && substr($this->P['params']['pid'], -3) == '###') {
         $this->pid = intval($TSconfig['_' . substr($this->P['params']['pid'], 3, -3)]);
     } else {
         $this->pid = intval($this->P['params']['pid']);
     }
     // Make redirect:
     if (!strcmp($this->pid, '') || strcmp($this->id, '')) {
         // If pid is blank OR if id is set, then return...
         $redirectUrl = t3lib_div::sanitizeLocalUrl($this->P['returnUrl']);
     } else {
         // Otherwise, show the list:
         $urlParameters = array();
         $urlParameters['id'] = $this->pid;
         $urlParameters['table'] = $this->P['params']['table'];
         $urlParameters['returnUrl'] = t3lib_div::getIndpEnv('REQUEST_URI');
         $redirectUrl = t3lib_BEfunc::getModuleUrl('web_list', $urlParameters);
     }
     t3lib_utility_Http::redirect($redirectUrl);
 }
Esempio n. 12
0
 /**
  * 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);
     $storagePid = intval($TSconfig['_STORAGE_PID']);
     // Check for alternative storage folder
     $modTSConfig = t3lib_BEfunc::getModTSconfig($pageUid, 'tx_templavoila.storagePid');
     if (is_array($modTSConfig) && tx_templavoila_div::canBeInterpretedAsInteger($modTSConfig['value'])) {
         $storagePid = intval($modTSConfig['value']);
     }
     return $storagePid;
 }