/**
  * constructor
  *
  * @return	void
  */
 function tx_dam_selectionCategory()
 {
     global $LANG, $BACK_PATH;
     $this->title = $LANG->sL('LLL:EXT:dam/lib/locallang.xml:categories');
     $this->treeName = 'txdamCat';
     $this->domIdPrefix = $this->treeName;
     $this->table = 'tx_dam_cat';
     $this->parentField = $GLOBALS['TCA'][$this->table]['ctrl']['treeParentField'];
     $this->typeField = $GLOBALS['TCA'][$this->table]['ctrl']['type'];
     $this->iconName = 'cat.gif';
     $this->iconPath = PATH_txdam_rel . 'i/';
     $this->rootIcon = PATH_txdam_rel . 'i/catfolder.gif';
     $this->fieldArray = array('uid', 'pid', 'title', 'sys_language_uid');
     if ($this->parentField) {
         $this->fieldArray[] = $this->parentField;
     }
     if ($this->typeField) {
         $this->fieldArray[] = $this->typeField;
     }
     $this->defaultList = 'uid,pid,tstamp,sorting';
     $this->clause = tx_dam_db::enableFields($this->table, 'AND');
     $this->clause .= ' AND sys_language_uid IN (0,-1)';
     // default_sortby might be not set
     $defaultSortby = $GLOBALS['TCA'][$this->table]['ctrl']['default_sortby'] ? $GLOBALS['TYPO3_DB']->stripOrderBy($GLOBALS['TCA'][$this->table]['ctrl']['default_sortby']) : '';
     // sortby might be not set or unset
     $sortby = $GLOBALS['TCA'][$this->table]['ctrl']['sortby'] ? $GLOBALS['TCA'][$this->table]['ctrl']['sortby'] : '';
     // if we have default_sortby it shall win
     $this->orderByFields = $defaultSortby ? $defaultSortby : $sortby;
     // get the right sys_language_uid for the BE users language
     if (is_object($GLOBALS['BE_USER']) and t3lib_extMgm::isLoaded('static_info_tables')) {
         // Hooray - it's so simple to develop with TYPO3
         $lang = $GLOBALS['BE_USER']->user['lang'];
         $lang = $lang ? $lang : 'en';
         // TYPO3 specific: Array with the iso names used for each system language in TYPO3:
         // Missing keys means: same as Typo3
         $isoArray = array('ba' => 'bs', 'br' => 'pt_BR', 'ch' => 'zh_CN', 'cz' => 'cs', 'dk' => 'da', 'si' => 'sl', 'se' => 'sv', 'gl' => 'kl', 'gr' => 'el', 'hk' => 'zh_HK', 'kr' => 'ko', 'ua' => 'uk', 'jp' => 'ja', 'vn' => 'vi');
         $iso = $isoArray[$lang] ? $isoArray[$lang] : $lang;
         // Finding the ISO code:
         if ($rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('sys_language.uid', 'sys_language LEFT JOIN static_languages ON static_languages.uid=sys_language.static_lang_isocode', 'static_languages.lg_iso_2=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($iso), 'static_languages') . tx_dam_db::enableFields('static_languages', 'AND') . tx_dam_db::enableFields('sys_language', 'AND'))) {
             $row = current($rows);
             $this->langOvlUid = intval($row['uid']);
         }
     }
     $this->TSconfig = tx_dam::config_getValue('setup.selections.' . $this->treeName, true);
 }
Пример #2
0
 /**
  * Fetches the meta data from the index by a given file hash.
  * The field list to be fetched can be passed.
  * This function returns an array of meta data arrays because it's possible to match more than one index entry!
  * To get meta data for a file use meta_getDataForFile() instead.
  *
  * @param	string		$hash Hash value for the file
  * @param	string		$fields A list of fields to be fetched. Default is a list of fields generated by tx_dam_db::getMetaInfoFieldList().
  * @param	string		$mode TYPO3_MODE to be used: 'FE', 'BE'. Constant TYPO3_MODE is default.
  * @return	array		Array of Meta data arrays or false.
  */
 function meta_getDataByHash($hash, $fields = '', $mode = TYPO3_MODE)
 {
     $rows = false;
     if ($hash) {
         $where = array();
         $where['file_hash'] = 'file_hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'tx_dam');
         $where['enableFields'] = tx_dam_db::enableFields('tx_dam', '', $mode);
         $rows = tx_dam_db::getDataWhere($fields, $where);
     }
     return $rows;
 }
 /**
  * Returns a part of a WHERE clause which will filter out records with start/end times or hidden/fe_groups fields set to values that should de-select them according to the current time, preview settings or user login. Definitely a frontend function.
  * THIS IS A VERY IMPORTANT FUNCTION: Basically you must add the output from this function for EVERY select query you create for selecting records of tables in your own applications - thus they will always be filtered according to the "enablefields" configured in TCA
  * Simply calls t3lib_pageSelect::enableFields() BUT will send the show_hidden flag along! This means this function will work in conjunction with the preview facilities of the frontend engine/Admin Panel.
  *
  * @param	string		The table for which to get the where clause
  * @return	string		The part of the where clause on the form " AND NOT [fieldname] AND ...". Eg. " AND hidden=0 AND starttime < 123345567"
  * @see t3lib_pageSelect::enableFields()
  */
 function enableFields($table = '')
 {
     $table = $table ? $table : $this->table;
     return tx_dam_db::enableFields($table, 'AND', $this->mode);
 }
Пример #4
0
 /**
  * Returns the result of a db query on a soft ref table
  *
  *
  * @param 	string 		$local_table Eg tx_dam
  * @param 	string 		$local_uid Uid list of tx_dam records the references shall be fetched for
  * @param	string		$foreign_table Table name to get references for. Eg tt_content
  * @param	integer		$foreign_uid The uid of the referenced record
  * @param	mixed		$softRef_ident Array of field/value pairs that should match in soft references table. If it is a string, it will be used as value for the field 'softref_key'.
  * @param	string		$softRef_table The soft referneces table to use. Default: sys_refindex
  * @param	string		$fields The fields to select. Needs to be prepended with table name: tx_dam.uid, tx_dam.title
  * @param	array		$whereClauses WHERE clauses as array with associative keys (which can be used to overwrite 'enableFields') or a single one as string.
  * @param	string		$groupBy: ...
  * @param	string		$orderBy: ...
  * @param	string		$limit: Default: 1000
  * @return	mixed		db result pointer
  */
 function softRefIndexQuery($local_table, $local_uid, $foreign_table, $foreign_uid, $softRef_ident = '', $softRef_table = 'sys_refindex', $fields = '', $whereClauses = array(), $groupBy = '', $orderBy = '', $limit = 1000)
 {
     if (!is_array($whereClauses)) {
         $whereClauses = array('where' => preg_replace('/^AND /', '', trim($whereClauses)));
     }
     $softRef_table = $softRef_table ? $softRef_table : 'sys_refindex';
     $where = array();
     if (!isset($whereClauses['deleted']) && !isset($whereClauses['enableFields'])) {
         $where['enableFields'] = tx_dam_db::enableFields($local_table);
         // soft references table has no TCA
         $where['deleted'] = $softRef_table . '.deleted=0';
         if ($foreign_table) {
             $where['enableFields'] .= ' AND ' . tx_dam_db::enableFields($foreign_table);
         }
     }
     $where['ref'] = $local_table . '.uid=' . $softRef_table . '.ref_uid';
     $where['ref'] .= $foreign_table ? ' AND ' . $foreign_table . '.uid=' . $softRef_table . '.recuid' : '';
     $where['refTable'] = $softRef_table . '.ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('tx_dam', $softRef_table);
     $where = array_merge($where, $whereClauses);
     if ($foreign_table) {
         $where[] = $softRef_table . '.tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($foreign_table, $softRef_table);
     }
     if ($foreign_uid = $GLOBALS['TYPO3_DB']->cleanIntList($foreign_uid)) {
         $where[] = $softRef_table . '.recuid IN (' . $foreign_uid . ')';
     }
     if ($local_uid = $GLOBALS['TYPO3_DB']->cleanIntList($local_uid)) {
         $where[] = $softRef_table . '.ref_uid IN (' . $local_uid . ')';
     }
     $where[] = 'NOT ' . $softRef_table . '.softref_key=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('', $softRef_table);
     if ($softRef_ident) {
         if (!is_array($softRef_ident)) {
             $softRef_ident = array('softref_key' => $softRef_ident);
         }
         foreach ($softRef_ident as $field => $value) {
             if ($value) {
                 $where[] = $softRef_table . '.' . $field . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, $softRef_table);
             }
         }
     }
     if (!$orderBy) {
         $orderBy = $softRef_table . '.sorting';
     }
     while ($key = array_search('', $where)) {
         unset($where[$key]);
     }
     $where = implode(' AND ', $where);
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $local_table . ',' . $softRef_table . ($foreign_table ? ',' . $foreign_table : ''), $where, $groupBy, $orderBy, $limit);
     return $res;
 }