/**
  * Check if this object should render
  *
  * @param	string		Type: "file"
  * @param	object		Parent object.
  * @return	boolean
  */
 function isValid($type, &$pObj)
 {
     $isValid = false;
     if ($type === 'file' && is_array($this->meta = tx_dam::meta_getDataForFile($pObj->file, '*'))) {
         $isValid = true;
     }
     return $isValid;
 }
 /**
  * tx_dam::config_setValue()
  */
 public function test_config_setValue()
 {
     tx_dam::config_init();
     tx_dam::config_setValue('setup.indexing.auto', true);
     $value = tx_dam::config_getValue('setup.indexing.auto');
     self::assertEquals($value, true);
     tx_dam::config_setValue('setup.indexing.auto', false);
     $value = tx_dam::config_getValue('setup.indexing.auto');
     self::assertEquals($value, false);
 }
 /**
  * tx_dam::access_checkFile()
  */
 public function test_access_checkFile()
 {
     $GLOBALS['T3_VAR']['ext']['dam']['pathInfoCache'] = array();
     $filepath = $this->getFixtureFilename();
     $this->addFixturePathToFilemount();
     $access = tx_dam::access_checkFile($filepath);
     self::assertTrue($access, 'File not accessable: ' . $filepath);
     $access = tx_dam::access_checkFile($filepath . 'xyz');
     self::assertFalse($access, 'File accessable: ' . $filepath . 'xyz');
     $this->removeFixturePathFromFilemount();
 }
 /**
  * Update the media types table for browsing
  * Will be called when a meta data record was inserted.
  *
  * @param	array		$meta meta data. $meta['media_type'] and $meta['file_type'] have to be set
  * @return	void
  */
 function insertMetaTrigger($meta)
 {
     $TX_DAM = $GLOBALS['T3_VAR']['ext']['dam'];
     $mediaType = intval($meta['media_type']);
     // check if media type exists
     if ($typeStr = tx_dam::convert_mediaType($mediaType)) {
         // get the id of the media type record
         $media_id = false;
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tx_dam_metypes_avail', 'type=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($mediaType, 'tx_dam_metypes_avail'));
         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $media_id = $row['uid'];
         }
         // no record - then create one
         if (!$media_id) {
             $sorting = $TX_DAM['code2sorting'][$mediaType];
             $sorting = $sorting ? $sorting : 10000;
             $fields_values = array();
             $fields_values['pid'] = tx_dam_db::getPid();
             $fields_values['parent_id'] = 0;
             $fields_values['tstamp'] = time();
             $fields_values['title'] = $typeStr;
             $fields_values['type'] = $mediaType;
             $fields_values['sorting'] = $sorting;
             $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_dam_metypes_avail', $fields_values);
             $media_id = $GLOBALS['TYPO3_DB']->sql_insert_id();
         }
         // get file type record
         $type_id = false;
         if ($media_id) {
             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tx_dam_metypes_avail', 'title=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($meta['file_type'], 'tx_dam_metypes_avail') . ' AND parent_id=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($media_id, 'tx_dam_metypes_avail'));
             if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 $type_id = $row['uid'];
             }
         }
         // no record - then create one
         if (!$type_id) {
             $fields_values = array();
             $fields_values['pid'] = tx_dam_db::getPid();
             $fields_values['parent_id'] = $media_id;
             $fields_values['tstamp'] = time();
             $fields_values['title'] = $meta['file_type'] ? $meta['file_type'] : 'n/a';
             $fields_values['type'] = $mediaType;
             $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_dam_metypes_avail', $fields_values);
         }
     }
 }
 /**
  * Transformation handler: 'ts_links' / direction: "db"
  * Processing linked images inserted in the RTE.
  * This is used when content goes from the RTE to the database.
  * Images inserted in the RTE has an absolute URL applied to the src attribute. This URL is converted to a media uid
  *
  * @param	string		The content from RTE going to Database
  * @return	string		Processed content
  */
 function transform_db($value, &$pObj)
 {
     // Split content into <a> tag blocks and process:
     $blockSplit = $pObj->splitIntoBlock('A', $value);
     foreach ($blockSplit as $k => $v) {
         if ($k % 2) {
             // If an A-tag was found:
             $attribArray = $pObj->get_tag_attributes_classic($pObj->getFirstTag($v), 1);
             $info = $pObj->urlInfoForLinkTags($attribArray['href']);
             $uid = false;
             if (isset($attribArray['txdam'])) {
                 $uid = intval($attribArray['txdam']);
             }
             if (!$uid and $info['relUrl']) {
                 $info['relUrl'] = rawurldecode($info['relUrl']);
                 $uid = tx_dam::file_isIndexed($info['relUrl']);
             }
             // found an id, so convert the a tag to a media tag
             if ($uid) {
                 if ($attribArray['usedamcolumn'] == 'true') {
                     unset($attribArray['title']);
                 }
                 unset($attribArray['usedamcolumn']);
                 if (is_array($pObj->procOptions['HTMLparser_db.']['tags.']['media.'])) {
                     $tags = array();
                     $tags['a'] = $pObj->procOptions['HTMLparser_db.']['tags.']['media.'];
                     $blockSplit[$k] = $pObj->HTMLcleaner($blockSplit[$k], $tags, true);
                 }
                 $bTag = '<media ' . $uid . ($attribArray['target'] ? ' ' . $attribArray['target'] : ($attribArray['class'] || $attribArray['title'] ? ' -' : '')) . ($attribArray['class'] ? ' ' . $attribArray['class'] : ($attribArray['title'] ? ' -' : '')) . ($attribArray['title'] ? ' "' . $attribArray['title'] . '"' : '') . '>';
                 $eTag = '</media>';
                 $blockSplit[$k] = $bTag . $this->transform_db($pObj->removeFirstAndLastTag($blockSplit[$k]), $pObj) . $eTag;
             } else {
                 // just rebuild the tag so it can be processed by t3lib_parsehtml_proc::TS_links_db
                 unset($attribArray['usedamcolumn']);
                 $bTag = '<a ' . t3lib_div::implodeAttributes($attribArray, 1) . '>';
                 $eTag = '</a>';
                 $blockSplit[$k] = $bTag . $this->transform_db($pObj->removeFirstAndLastTag($blockSplit[$k]), $pObj) . $eTag;
             }
         }
     }
     $value = implode('', $blockSplit);
     $value = $pObj->TS_links_db($value);
     return $value;
 }
 /**
  * Returns a <img> tag with the image file defined by $file and processed according to the properties in the TypoScript array.
  * Mostly this function is a sub-function to the IMAGE function which renders the IMAGE cObject in TypoScript. This function is called by "$this->cImage($conf['file'],$conf);" from IMAGE().
  *
  * @param	string		File TypoScript resource
  * @param	array		TypoScript configuration properties
  * @return	string		<img> tag, (possibly wrapped in links and other HTML) if any image found.
  * @access private
  * @see IMAGE()
  */
 function cImage($file, $conf)
 {
     $info = $this->getImgResource($file, $conf['file.']);
     //print_r($info);
     // added by Caspar Stuebs @ Gosign media.
     if (is_array($info) && (!empty($this->data['tx_goimageeditbe_croped_image']) || false)) {
         $editConfig = unserialize($this->data['tx_goimageeditbe_croped_image']);
         // render image with info from db
         $newFile = $this->renderGoImageEdit($info['origFile'], $editConfig ? $editConfig : array(), $conf);
         // create new image info
         $info = $this->getImgResource($newFile, $conf['file.']);
     }
     // end of add
     $GLOBALS['TSFE']->lastImageInfo = $info;
     if (is_array($info)) {
         $info[3] = t3lib_div::png_to_gif_by_imagemagick($info[3]);
         $GLOBALS['TSFE']->imagesOnPage[] = $info[3];
         // This array is used to collect the image-refs on the page...
         if (!strlen($conf['altText']) && !is_array($conf['altText.'])) {
             // Backwards compatible:
             $conf['altText'] = $conf['alttext'];
             $conf['altText.'] = $conf['alttext.'];
         }
         //$altParam = $this->getAltParam($conf);
         if (empty($conf['altText']) && empty($conf['altText.'])) {
             // by ELIO@GOSIGN 19-01-2011: ALT-TEXT for all cImages
             $altParam = empty($this->data['altText']) ? tx_dam::media_getForFile($conf['file'])->meta['alt_text'] : $this->data['altText'];
             $altParam = ' alt="' . $altParam . '"';
         } else {
             $altParam = $this->getAltParam($conf);
         }
         $theValue = '<img src="' . htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . t3lib_div::rawUrlEncodeFP($info[3])) . '" width="' . $info[0] . '" height="' . $info[1] . '"' . $this->getBorderAttr(' border="' . intval($conf['border']) . '"') . ($conf['params'] || is_array($conf['params.']) ? ' ' . $this->stdwrap($conf['params'], $conf['params.']) : '') . $altParam . ' />';
         //print_r($theValue);
         if ($conf['linkWrap']) {
             $theValue = $this->linkWrap($theValue, $conf['linkWrap']);
         } elseif ($conf['imageLinkWrap']) {
             $theValue = $this->imageLinkWrap($theValue, $info['origFile'], $conf['imageLinkWrap.']);
         }
         return $this->wrap($theValue, $conf['wrap']);
     }
 }
 /**
  * Transformation handler: 'txdam_media' / direction: "rte"
  * Processing linked images from database content going into the RTE.
  * Processing includes converting the src attribute to an absolute URL.
  *
  * @param	string		Content input
  * @return	string		Content output
  */
 function transform_rte($value, &$pObj)
 {
     // Split content by the TYPO3 pseudo tag "<media>":
     $blockSplit = $pObj->splitIntoBlock('media', $value, 1);
     foreach ($blockSplit as $k => $v) {
         $error = '';
         if ($k % 2) {
             // block:
             $tagCode = t3lib_div::unQuoteFilenames(trim(substr($pObj->getFirstTag($v), 0, -1)), true);
             $link_param = $tagCode[1];
             $href = '';
             $useDAMColumn = FALSE;
             // Checking if the id-parameter is int and get meta data
             if (t3lib_div::testInt($link_param)) {
                 $meta = tx_dam::meta_getDataByUid($link_param);
             }
             if (is_array($meta)) {
                 $href = tx_dam::file_url($meta);
                 if (!$tagCode[4]) {
                     require_once PATH_txdam . 'lib/class.tx_dam_guifunc.php';
                     $displayItems = '';
                     if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes'], 'usedamcolumn') && $pObj->thisConfig['buttons.']['link.']['media.']['properties.']['title.']['useDAMColumn']) {
                         $displayItems = $pObj->thisConfig['buttons.']['link.']['media.']['properties.']['title.']['useDAMColumn.']['displayItems'] ? $pObj->thisConfig['buttons.']['link.']['media.']['properties.']['title.']['useDAMColumn.']['displayItems'] : '';
                         $useDAMColumn = TRUE;
                     }
                     $tagCode[4] = tx_dam_guiFunc::meta_compileHoverText($meta, $displayItems, ', ');
                 }
             } else {
                 $href = $link_param;
                 $error = 'No media file found: ' . $link_param;
             }
             // Setting the A-tag:
             $bTag = '<a href="' . htmlspecialchars($href) . '" txdam="' . htmlspecialchars($link_param) . '"' . ($tagCode[2] && $tagCode[2] != '-' ? ' target="' . htmlspecialchars($tagCode[2]) . '"' : '') . ($tagCode[3] && $tagCode[3] != '-' ? ' class="' . htmlspecialchars($tagCode[3]) . '"' : '') . ($tagCode[4] ? ' title="' . htmlspecialchars($tagCode[4]) . '"' : '') . ($useDAMColumn ? ' usedamcolumn="true"' : '') . ($error ? ' rteerror="' . htmlspecialchars($error) . '" style="background-color: yellow; border:2px red solid; color: black;"' : '') . '>';
             $eTag = '</a>';
             $blockSplit[$k] = $bTag . $this->transform_rte($pObj->removeFirstAndLastTag($blockSplit[$k]), $pObj) . $eTag;
         }
     }
     $value = implode('', $blockSplit);
     return $value;
 }
 /**
  * delete file when record is deleted
  */
 function processCmdmap_preProcess($command, $table, $id, $value, $tce)
 {
     global $FILEMOUNTS, $BE_USER, $TYPO3_CONF_VARS;
     if ($table === 'tx_dam') {
         if ($rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_dam', 'uid=' . $id, '', '', 1, 'uid')) {
             $row = $rows[$id];
             switch ($command) {
                 // delete the file when the record is deleted
                 case 'delete':
                     require_once PATH_t3lib . 'class.t3lib_basicfilefunc.php';
                     require_once PATH_t3lib . 'class.t3lib_extfilefunc.php';
                     $filepath = tx_dam::file_absolutePath($row);
                     if (@is_file($filepath)) {
                         $cmd = array();
                         $cmd['delete'][0]['data'] = $filepath;
                         // Initializing:
                         $tce->fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
                         $tce->fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
                         $tce->fileProcessor->init_actionPerms(tx_dam::getFileoperationPermissions());
                         $tce->fileProcessor->dontCheckForUnique = $tce->overwriteExistingFiles ? 1 : 0;
                         // Checking referer / executing:
                         $refInfo = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
                         $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
                         if ($httpHost != $refInfo['host'] && $tce->vC != $BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) {
                             $tce->fileProcessor->writeLog(0, 2, 1, 'Referer host "%s" and server host "%s" did not match!', array($refInfo['host'], $httpHost));
                         } else {
                             $tce->fileProcessor->start($cmd);
                             $tce->fileProcessor->processData();
                         }
                     }
                     break;
                 default:
                     break;
             }
         }
     }
 }
 /**
  * Initializes the action objects.
  *
  * @param	boolean		$checkForPossiblyValid If set invalid will be done with isPossiblyValid().
  * @param	boolean		$keepInvalid If set invalid actions will not removed
  * @return	void
  */
 function initObjects($checkForPossiblyValid = false, $keepInvalid = false)
 {
     $setupAllowDeny = tx_dam::config_getValue('mod.txdamM1_SHARED.actions', true);
     $setupAllowDeny = isset($setupAllowDeny[$this->type . '.']) ? $setupAllowDeny[$this->type . '.'] : $setupAllowDeny['shared.'];
     $setupAllowDenyShared = tx_dam_allowdeny_list::transformSimpleSetup($setupAllowDeny);
     list($modName, $modFuncName) = explode('.', $this->moduleName);
     $setupAllowDeny = tx_dam::config_getValue('mod.' . $modName . '.actions', true);
     $setupAllowDeny = isset($setupAllowDeny[$this->type . '.']) ? $setupAllowDeny[$this->type . '.'] : $setupAllowDeny['shared.'];
     $setupAllowDenyMod = tx_dam_allowdeny_list::transformSimpleSetup($setupAllowDeny);
     if ($modFuncName) {
         $setupAllowDeny = tx_dam::config_getValue('mod.' . $modName . '.modfunc.' . $modFuncName . '.actions', true);
         $setupAllowDeny = isset($setupAllowDeny[$this->type . '.']) ? $setupAllowDeny[$this->type . '.'] : $setupAllowDeny['shared.'];
         $setupAllowDenyModfunc = tx_dam_allowdeny_list::transformSimpleSetup($setupAllowDeny);
     }
     $allowDeny = new tx_dam_allowdeny_list(array_keys($this->classes), $setupAllowDenyModfunc, $setupAllowDenyMod, $setupAllowDenyShared);
     foreach ($this->classes as $idName => $classRef) {
         if ($allowDeny->isAllowed($idName) and $this->makeObject($idName)) {
             $this->objects[$idName]->setItemInfo($this->itemInfo);
             $this->objects[$idName]->setEnv($this->env);
             $this->objects[$idName]->getIdName();
             if ($checkForPossiblyValid) {
                 $valid = $this->objects[$idName]->isPossiblyValid($this->type);
             } else {
                 $valid = $this->objects[$idName]->isValid($this->type);
             }
             if (!$keepInvalid and !$valid) {
                 unset($this->objects[$idName]);
             }
         }
     }
 }
    /**
     * Creates the listing of records from a single table
     *
     * @param	string		Table name
     * @param	integer		Page id
     * @param	string		List of fields to show in the listing. Pseudo fields will be added including the record header.
     * @return	string		HTML table with the listing for the record.
     */
    function getTable($table, $rowlist)
    {
        global $TCA, $BACK_PATH, $LANG;
        // Loading all TCA details for this table:
        t3lib_div::loadTCA($table);
        // Init
        $addWhere = '';
        $titleCol = $TCA[$table]['ctrl']['label'];
        $thumbsCol = $TCA[$table]['ctrl']['thumbnail'];
        $l10nEnabled = $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'] && !$TCA[$table]['ctrl']['transOrigPointerTable'];
        $selFieldList = $this->getSelFieldList($table, $rowlist);
        $dbCount = 0;
        if ($this->pointer->countTotal and $this->res) {
            $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($this->res);
        }
        $shEl = $this->showElements;
        $out = '';
        if ($dbCount) {
            // half line is drawn
            $theData = array();
            if (!$this->table && !$rowlist) {
                $theData[$titleCol] = '<img src="clear.gif" width="' . ($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel'] ? '230' : '350') . '" height="1">';
                if (in_array('_CONTROL_', $this->fieldArray)) {
                    $theData['_CONTROL_'] = '';
                }
            }
            #			$out.=$this->addelement('', $theData);
            // Header line is drawn
            $theData = array();
            #			$theData[$titleCol] = '<b>'.$GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'],1).'</b> ('.$this->resCount.')';
            $theUpIcon = '&nbsp;';
            // todo csh
            #			$theData[$titleCol].= t3lib_BEfunc::cshItem($table,'',$this->backPath,'',FALSE,'margin-bottom:0px; white-space: normal;');
            #			$out.=$this->addelement($theUpIcon, $theData, '', '', 'background-color:'.$this->headLineCol.'; border-bottom:1px solid #000');
            // Fixing a order table for sortby tables
            $this->currentTable = array();
            $currentIdList = array();
            $doSort = $TCA[$table]['ctrl']['sortby'] && !$this->sortField;
            $prevUid = 0;
            $prevPrevUid = 0;
            $accRows = array();
            // Accumulate rows here
            while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($this->res)) {
                $accRows[] = $row;
                $currentIdList[] = $row['uid'];
                if ($doSort) {
                    if ($prevUid) {
                        $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
                        $this->currentTable['next'][$prevUid] = '-' . $row['uid'];
                        $this->currentTable['prevUid'][$row['uid']] = $prevUid;
                    }
                    $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
                    $prevUid = $row['uid'];
                }
            }
            $GLOBALS['TYPO3_DB']->sql_free_result($this->res);
            // items
            $itemContentTRows = '';
            $this->duplicateStack = array();
            $this->eCounter = $this->pointer->firstItemNum;
            $cc = 0;
            $itemContentTRows .= $this->fwd_rwd_nav('rwd');
            foreach ($accRows as $row) {
                $this->alternateBgColors = false;
                $cc++;
                $row_bgColor = $this->alternateBgColors ? $cc % 2 ? ' class="item"' : ' class="item" bgColor="' . t3lib_div::modifyHTMLColor($GLOBALS['SOBE']->doc->bgColor4, +10, +10, +10) . '"' : ' class="item"';
                // Initialization
                $iconfile = t3lib_iconWorks::getIcon($table, $row);
                $alttext = t3lib_BEfunc::getRecordIconAltText($row, $table);
                $recTitle = t3lib_BEfunc::getRecordTitle($table, $row, 1);
                // The icon with link
                $theIcon = '<img src="' . $this->backPath . $iconfile . '" width="18" height="16" border="0" title="' . $alttext . '" />';
                $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon, $table, $row['uid']);
                $thumbImg = '';
                if ($this->thumbs) {
                    $thumbImg = '<div style="margin:2px 0 2px 0;">' . $this->getThumbNail(tx_dam::path_makeAbsolute($row['file_path']) . $row['file_name']) . '</div>';
                }
                // 	Preparing and getting the data-array
                $theData = array();
                reset($this->fieldArray);
                while (list(, $fCol) = each($this->fieldArray)) {
                    if ($fCol == $titleCol) {
                        $theData[$fCol] = $this->linkWrapItems($table, $row['uid'], $recTitle, $row) . $thumbImg;
                    } elseif ($fCol == 'pid') {
                        $theData[$fCol] = $row[$fCol];
                    } elseif ($fCol == '_CONTROL_') {
                        $theData[$fCol] = $this->makeControl($table, $row);
                    } else {
                        $theData[$fCol] = t3lib_BEfunc::getProcessedValueExtra($table, $fCol, $row[$fCol], 100);
                    }
                }
                $actionIcon = '';
                $itemContentTRows .= $this->addElement($theIcon, $theData, $actionIcon, $row_bgColor, '', true);
                // Thumbsnails?
                //				if ($this->thumbs && trim($row[$thumbsCol]))	{
                //					$itemContentTRows.=$this->addelement('', Array($titleCol=>$this->thumbCode($row,$table,$thumbsCol)), '', $row_bgColor);
                //				}
                $this->eCounter++;
            }
            if ($this->eCounter > $this->pointer->firstItemNum) {
                $itemContentTRows .= $this->fwd_rwd_nav('fwd');
            }
            // field header line is drawn:
            $theData = array();
            foreach ($this->fieldArray as $fCol) {
                $permsEdit = $this->calcPerms & ($table == 'pages' ? 2 : 16);
                if ($fCol == '_CONTROL_') {
                    if (!$TCA[$table]['ctrl']['readOnly']) {
                        if ($permsEdit && $this->table && is_array($currentIdList) && in_array('editRec', $shEl)) {
                            $editIdList = implode(',', $currentIdList);
                            $params = '&edit[' . $table . '][' . $editIdList . ']=edit&columnsOnly=' . implode(',', $this->fieldArray) . '&disHelp=1';
                            $content = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/edit2.gif', 'width="11" height="12"') . ' vspace="2" border="0" align="top" title="' . $GLOBALS['LANG']->getLL('editShownColumns') . '" />';
                            $theData[$fCol] .= $this->wrapEditLink($content, $params);
                        }
                    }
                } else {
                    $theData[$fCol] = '';
                    #					$theData[$fCol].='&nbsp;';
                    if ($this->table && is_array($currentIdList) && in_array('editRec', $shEl)) {
                        if (!$TCA[$table]['ctrl']['readOnly'] && $permsEdit && $TCA[$table]['columns'][$fCol]) {
                            $editIdList = implode(',', $currentIdList);
                            $params = '&edit[' . $table . '][' . $editIdList . ']=edit&columnsOnly=' . $fCol . '&disHelp=1';
                            $content = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/edit2.gif', 'width="11" height="12"') . ' vspace="2" border="0" align="top" title="' . sprintf($GLOBALS['LANG']->getLL('editThisColumn'), preg_replace("/:\$/", '', trim($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($table, $fCol))))) . '" />';
                            $theData[$fCol] .= $this->wrapEditLink($content, $params);
                        }
                    } else {
                        #						$theData[$fCol].='&nbsp;';
                    }
                    $theData[$fCol] .= $this->addSortLink($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($table, $fCol, '&nbsp;<i>[|]</i>&nbsp;')), $fCol, $table);
                }
            }
            $out .= $this->addelement($theUpIcon, $theData, '', ' class="c-headLine"', 'border-bottom:1px solid #888');
            // The list of records is added after the header:
            $out .= $itemContentTRows;
            $out .= $this->addelement('', array(), '', '', 'border-top:1px solid #888');
            #TODO
            $LOISmode = false;
            // ... and it is all wrapped in a table:
            $out = '

			<!--
				DB listing of elements:	"' . htmlspecialchars($table) . '"
			-->
				<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist' . ($LOISmode ? ' typo3-dblist-overview' : '') . '">
					' . $out . '
				</table>';
        }
        // Return content:
        return $out;
    }
    /**
     * Renders the EB for rte mode
     *
     * @return	string HTML
     */
    function main_rte()
    {
        global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
        // Excluding items based on Page TSConfig
        $this->allowedItems = array_diff($this->allowedItems, t3lib_div::trimExplode(',', $this->modPageConfig['properties']['removeTabs'], 1));
        // Excluding upload into readOnly folders
        $path = tx_dam::path_makeAbsolute($this->damSC->path);
        if ($this->isReadOnlyFolder($path)) {
            $this->allowedItems = array_diff($this->allowedItems, array('upload'));
        }
        if (!$path or !@is_dir($path)) {
            $path = $this->fileProcessor->findTempFolder() . '/';
            // The closest TEMP-path is found
        }
        $this->damSC->path = tx_dam::path_makeRelative($path);
        // mabe not needed
        // Starting content:
        $content = $this->doc->startPage($LANG->getLL('Insert Image', 1));
        $this->reinitParams();
        // Making menu in top:
        $menuDef = array();
        if (in_array('image', $this->allowedItems) && ($this->act == 'image' || t3lib_div::_GP('cWidth'))) {
            $menuDef['page']['isActive'] = $this->act == 'image';
            $menuDef['page']['label'] = $LANG->getLL('currentImage', 1);
            $menuDef['page']['url'] = '#';
            $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\'' . htmlspecialchars($this->thisScript . '?act=image&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('magic', $this->allowedItems)) {
            $menuDef['file']['isActive'] = $this->act == 'magic';
            $menuDef['file']['label'] = $LANG->getLL('magicImage', 1);
            $menuDef['file']['url'] = '#';
            $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\'' . htmlspecialchars($this->thisScript . '?act=magic&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('plain', $this->allowedItems)) {
            $menuDef['url']['isActive'] = $this->act == 'plain';
            $menuDef['url']['label'] = $LANG->getLL('plainImage', 1);
            $menuDef['url']['url'] = '#';
            $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\'' . htmlspecialchars($this->thisScript . '?act=plain&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('dragdrop', $this->allowedItems)) {
            $menuDef['mail']['isActive'] = $this->act == 'dragdrop';
            $menuDef['mail']['label'] = $LANG->getLL('dragDropImage', 1);
            $menuDef['mail']['url'] = '#';
            $menuDef['mail']['addParams'] = 'onClick="jumpToUrl(\'' . htmlspecialchars($this->thisScript . '?act=dragdrop&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('upload', $this->allowedItems)) {
            $menuDef['upload']['isActive'] = $this->act == 'upload';
            $menuDef['upload']['label'] = $LANG->getLL('tx_dam_file_upload.title', 1);
            $menuDef['upload']['url'] = '#';
            $menuDef['upload']['addParams'] = 'onclick="jumpToUrl(\'' . htmlspecialchars($this->thisScript . '?act=upload&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        $content .= $this->doc->getTabMenuRaw($menuDef);
        $pArr = explode('|', $this->bparams);
        switch ($this->act) {
            case 'image':
                $JScode = '
				document.write(printCurrentImageOptions());
				insertImagePropertiesInForm();';
                $content .= '<br />' . $this->doc->wrapScriptTags($JScode);
                break;
            case 'upload':
                $content .= $this->dam_upload($this->allowedFileTypes, $this->disallowedFileTypes);
                $content .= $this->damSC->getOptions();
                $content .= '<br /><br />';
                if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
                    $content .= $this->createFolder($path);
                    $content .= '<br />';
                }
                break;
            case 'dragdrop':
                $this->allowedFileTypes = t3lib_div::trimExplode(',', $pArr[3], true);
                $this->addDisplayOptions();
                $content .= $this->dam_select($this->allowedFileTypes, $this->disallowedFileTypes);
                $content .= $this->damSC->getOptions();
                break;
            case 'plain':
                $this->allowedFileTypes = t3lib_div::trimExplode(',', $pArr[3], true);
                $this->addDisplayOptions();
                $content .= $this->dam_select($this->allowedFileTypes, $this->disallowedFileTypes);
                $content .= $this->damSC->getOptions();
                $content .= $this->getMsgBox($this->RTESelectImageObj->getHelpMessage($this->act));
                break;
            case 'magic':
                $this->addDisplayOptions();
                $content .= $this->dam_select($this->allowedFileTypes, $this->disallowedFileTypes);
                $content .= $this->damSC->getOptions();
                $content .= $this->getMsgBox($this->RTESelectImageObj->getHelpMessage($this->act));
                break;
            default:
                break;
        }
        // Ending page, returning content:
        $content .= $this->doc->endPage();
        $this->doc->JScodeArray['rtehtmlarea'] = $this->RTESelectImageObj->getJSCode($this->act, $this->editorNo, $this->sys_language_content);
        $this->doc->JScodeArray['rtehtmlarea-dam'] = $this->getAdditionalJSCode();
        $content = $this->damSC->doc->insertStylesAndJS($content);
        return $content;
    }
 /**
  * Creates a tab menu from an array definition
  *
  * Returns a tab menu for a module
  * Requires the JS function jumpToUrl() to be available
  *
  * @param	mixed		$id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
  * @param	string		$elementName it the form elements name, probably something like "SET[...]"
  * @param	string		$currentValue is the value to be selected currently.
  * @param	array		$menuItems is an array with the menu items for the selector box
  * @param	string		$script is the script to send the &id to, if empty it's automatically found
  * @param	string		$addParams is additional parameters to pass to the script.
  * @return	string		HTML code for tab menu
  */
 function getTabMenu($mainParams, $elementName, $currentValue, $menuItems, $script = '', $addparams = '')
 {
     // read page TSconfig
     $useTabs = tx_dam::config_checkValueEnabled('mod.txdamM1_SHARED.useTabs');
     if ($useTabs && is_array($menuItems)) {
         if (!is_array($mainParams)) {
             $mainParams = array('id' => $mainParams);
         }
         $mainParams = t3lib_div::implodeArrayForUrl('', $mainParams);
         if (!$script) {
             $script = basename(PATH_thisScript);
         }
         $menuDef = array();
         foreach ($menuItems as $value => $label) {
             $menuDef[$value]['isActive'] = !strcmp($currentValue, $value);
             $menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label));
             // original: $menuDef[$value]['url'] = htmlspecialchars($script.'?'.$mainParams.$addparams.'&'.$elementName.'='.$value);
             $menuDef[$value]['url'] = $script . '?' . $mainParams . $addparams . '&' . $elementName . '=' . $value;
         }
         $this->content .= $this->doc->getTabMenuRaw($menuDef);
         return '';
     } else {
         return t3lib_BEfunc::getFuncMenu($this->id, $elementName, $currentValue, $menuItems);
     }
 }
 /**
  * Renaming files or foldes (action=5)
  *
  * @param	array		$cmds['data'] is the new name. $cmds['target'] is the target (file or dir).
  * @param	string		$id: ID of the item
  * @return	string		Returns the new filename upon success
  */
 function func_rename($cmds, $id)
 {
     if (!$this->isInit) {
         return FALSE;
     }
     $theNewName = tx_dam::file_makeCleanName($cmds['data'], true);
     #		$theNewName = $this->cleanFileName($cmds['data']);
     if (empty($theNewName)) {
         return;
     }
     // main log entry
     $this->log['cmd']['rename'][$id] = array('errors' => array(), 'orig_filename' => $cmds['target'], 'target_file' => $theNewName);
     if (!$this->checkFileNameLen($theNewName)) {
         $this->writelog(5, 1, 124, 'New name "%s" was too long (max %s characters)', array($theNewName, $this->maxInputNameLen), 'rename', $id);
         return;
     }
     $theTarget = $cmds['target'];
     $type = filetype($theTarget);
     // $type MUST BE file or dir
     if (!($type == 'file' || $type == 'dir')) {
         $this->writelog(5, 2, 123, 'Target "%s" was neither a directory nor a file!', array($theTarget), 'rename', $id);
         return;
     }
     // Fetches info about path, name, extention of $theTarget
     $fileInfo = t3lib_div::split_fileref($theTarget);
     // The name should be different from the current. And the filetype must be allowed
     if ($fileInfo['file'] == $theNewName) {
         $this->writelog(5, 1, 122, 'Old and new name is the same (%s)', array($theNewName), 'rename', $id);
         return;
     }
     $theRenameName = $fileInfo['path'] . $theNewName;
     // check mountpoints
     if (!$this->checkPathAgainstMounts($fileInfo['path'])) {
         $this->writelog(5, 1, 121, 'Destination path "%s" was not within your mountpoints!', array($fileInfo['path']), 'rename', $id);
         return;
     }
     // check if dest exists
     if (@file_exists($theRenameName)) {
         $this->writelog(5, 1, 120, 'Destination "%s" existed already!', array($theRenameName), 'rename', $id);
         return;
     }
     if ($type == 'file') {
         // user have permissions for action
         if (!$this->actionPerms['renameFile']) {
             $this->writelog(5, 1, 102, 'You are not allowed to rename files!', '', 'rename', $id);
             return;
         }
         $fI = t3lib_div::split_fileref($theRenameName);
         if (!$this->checkIfAllowed($fI['fileext'], $fileInfo['path'], $fI['file'])) {
             $this->writelog(5, 1, 101, 'Fileextension "%s" was not allowed!', array($fI['fileext']), 'rename', $id);
             return;
         }
         if (!@rename($theTarget, $theRenameName)) {
             $this->writelog(5, 1, 100, 'File "%s" was not renamed! Write-permission problem in "%s"?', array($theTarget, $fileInfo['path']), 'rename', $id);
             return;
         }
         $this->writelog(5, 0, 1, 'File renamed from "%s" to "%s"', array($fileInfo['file'], $theNewName), 'rename', $id);
         // update meta data
         if ($this->processMetaUpdate) {
             tx_dam::notify_fileMoved($theTarget, $theRenameName);
         }
     } elseif ($type == 'dir') {
         // user have permissions for action
         if (!$this->actionPerms['renameFolder']) {
             $this->writelog(5, 1, 111, 'You are not allowed to rename directories!', '', 'rename', $id);
             return;
         }
         if (!@rename($theTarget, $theRenameName)) {
             $this->writelog(5, 1, 110, 'Directory "%s" was not renamed! Write-permission problem in "%s"?', array($theTarget, $fileInfo['path']), 'rename', $id);
             return;
         }
         $this->writelog(5, 0, 2, 'Directory renamed from "%s" to "%s"', array($fileInfo['file'], $theNewName), 'rename', $id);
         // update meta data
         if ($this->processMetaUpdate) {
             tx_dam::notify_fileMoved($theTarget, $theRenameName);
         }
     } else {
         return;
     }
     // add file to log entry
     $this->log['cmd']['rename'][$id]['target_' . $type] = $theRenameName;
     return $theRenameName;
 }
    /**
     * 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;
    }
Example #15
0
tx_dam::register_indexingRule('tx_damindex_rule_doReindexing', 'EXT:dam/components/class.tx_dam_index_rules.php:&tx_dam_index_rule_doReindexing');
tx_dam::register_indexingRule('tx_damindex_rule_titleFromFilename', 'EXT:dam/components/class.tx_dam_index_rules.php:&tx_dam_index_rule_titleFromFilename');
tx_dam::register_indexingRule('tx_damindex_rule_dryRun', 'EXT:dam/components/class.tx_dam_index_rules.php:&tx_dam_index_rule_dryRun');
if ($TYPO3_CONF_VARS['EXTCONF']['dam']['setup']['devel']) {
    tx_dam::register_indexingRule('tx_damindex_rule_devel', 'EXT:dam/components/class.tx_dam_index_rules.php:&tx_dam_index_rule_devel');
}
// register navigation tree and select rule for nav tree.
tx_dam::register_selection('txdamFolder', 'EXT:dam/components/class.tx_dam_selectionFolder.php:&tx_dam_selectionFolder');
tx_dam::register_selection('txdamCat', 'EXT:dam/components/class.tx_dam_selectionCategory.php:&tx_dam_selectionCategory');
tx_dam::register_selection('txdamMedia', 'EXT:dam/components/class.tx_dam_selectionMeTypes.php:&tx_dam_selectionMeTypes');
tx_dam::register_selection('txdamStatus', 'EXT:dam/components/class.tx_dam_selectionStatus.php:&tx_dam_selectionStatus');
tx_dam::register_selection('txdamIndexRun', 'EXT:dam/components/class.tx_dam_selectionIndexRun.php:&tx_dam_selectionIndexRun');
tx_dam::register_selection('txdamStrSearch', 'EXT:dam/components/class.tx_dam_selectionStringSearch.php:&tx_dam_selectionStringSearch');
tx_dam::register_selection('txdamRecords', 'EXT:dam/components/class.tx_dam_selectionRecords.php:&tx_dam_selectionRecords');
// register DAM internal db change trigger
tx_dam::register_dbTrigger('tx_dam_dbTriggerMediaTypes', 'EXT:dam/components/class.tx_dam_dbTriggerMediaTypes.php:&tx_dam_dbTriggerMediaTypes');
// register special TCE tx_dam processing
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = 'EXT:dam/binding/tce/class.tx_dam_tce_process.php:&tx_dam_tce_process';
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:dam/binding/tce/class.tx_dam_tce_process.php:&tx_dam_tce_process';
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:dam/binding/tce/class.tx_dam_tce_filetracking.php:&tx_dam_tce_filetracking';
// <media> tag for BE and FE
if ($TYPO3_CONF_VARS['EXTCONF']['dam']['setup']['mediatag']) {
    require_once PATH_txdam . 'binding/mediatag/ext_localconf.php';
}
// user-defined soft reference parsers
require_once PATH_txdam . 'binding/softref/ext_localconf.php';
// txdam attribute on img tag for FE
require_once PATH_txdam . 'binding/imgtag/ext_localconf.php';
// FE stuff
$pluginContent = t3lib_div::getUrl(PATH_txdam . 'pi/setup.txt');
t3lib_extMgm::addTypoScript('dam', 'setup', '
 public function formatValue($mValue)
 {
     if (t3lib_extmgm::isLoaded("dam")) {
         if (is_numeric($mValue)) {
             $oMedia = tx_dam::media_getByUid($mValue);
             return $oMedia->meta['file_name'];
         }
     }
     return $mValue;
 }
    /**
     * Call gui item functions and return the output
     *
     * @param	string		Type name: header, footer
     * @param	string		List of item function which should be called instead of the default defined
     * @return	string		Items output
     */
    function getOutput($type = 'footer', $itemList = '')
    {
        if (is_null($itemList)) {
            return;
        }
        if ($itemList) {
            $itemListArr = t3lib_div::trimExplode(',', $itemList, 1);
        } else {
            $type = 'items_' . $type;
            if (!is_array($this->{$type})) {
                return;
            }
            $itemListArr = array_keys($this->{$type});
        }
        $elementList =& $this->{$type};
        $out = '';
        foreach ($itemListArr as $item) {
            $content = $this->items_callFunc($elementList[$item]);
            $out .= '
				<!-- GUI element section: ' . htmlspecialchars($item) . ' -->
					' . $content . '
				<!-- GUI element section end -->';
        }
        if ($type === 'items_footer' and is_array($GLOBALS['SOBE']->debugContent) and tx_dam::config_getValue('setup.devel')) {
            $content = '<div class="itemsFooter">' . '<h4>GUI Elements</h4>' . t3lib_div::view_array($GLOBALS['SOBE']->develAvailableGuiItems) . '</div>';
            $content .= '<div class="itemsFooter">' . '<h4>Options</h4>' . t3lib_div::view_array($GLOBALS['SOBE']->develAvailableOptions) . '</div>';
            $content .= '<div class="itemsFooter">' . '<h4>Registered actions (all)</h4>' . t3lib_div::view_array(array_keys($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['actionClasses'])) . '</div>';
            $out .= $GLOBALS['SOBE']->buttonToggleDisplay('devel', 'Module Info', $content);
            $content = '<div class="itemsFooter">' . implode('', $GLOBALS['SOBE']->debugContent) . '</div>';
            $out .= $GLOBALS['SOBE']->buttonToggleDisplay('debug', 'Debug output', $content);
        }
        return $out;
    }
 function main(&$backRef, $menuItems, $file, $uid)
 {
     // Returns directly, because the clicked item was not a file
     if ($backRef->cmLevel == 0 && $uid != '') {
         return $menuItems;
     }
     // Returns directly, because the clicked item was not the second level menu from DAM records
     if ($backRef->cmLevel == 1 && t3lib_div::_GP('subname') != 'tx_dam_cm_file') {
         return $menuItems;
     }
     $this->backRef =& $backRef;
     // this is second level menu from DAM records
     $fileDAM = t3lib_div::_GP('txdamFile');
     $file = $fileDAM ? $fileDAM : $file;
     if (@is_file($file)) {
         $item = tx_dam::file_compileInfo($file);
         $permsEdit = tx_dam::access_checkFile($item) && tx_dam::access_checkFileOperation('editFile');
         $permsDelete = tx_dam::access_checkFile($item) && tx_dam::access_checkFileOperation('deleteFile');
     } elseif (@is_dir($file)) {
         $item = tx_dam::path_compileInfo($file);
         $permsEdit = tx_dam::access_checkPath($item) && tx_dam::access_checkFileOperation('renameFolder');
         $permsDelete = tx_dam::access_checkPath($item) && tx_dam::access_checkFileOperation('deleteFolder');
     } else {
         return $menuItems;
     }
     // clear the existing menu now and fill it with DAM specific things
     $damMenuItems = array();
     // see typo3/alt_clickmenu.php:clickmenu::enableDisableItems() for iParts[3]
     // which is called after this function
     $backRef->iParts[3] = '';
     $actionCall = t3lib_div::makeInstance('tx_dam_actionCall');
     if (is_array($backRef->disabledItems)) {
         foreach ($backRef->disabledItems as $idName) {
             $actionCall->removeAction($idName);
         }
     }
     $actionCall->setRequest('context', $item);
     $actionCall->setEnv('returnUrl', t3lib_div::_GP('returnUrl'));
     $actionCall->setEnv('backPath', $backRef->PH_backPath);
     $actionCall->setEnv('defaultCmdScript', PATH_txdam_rel . 'mod_cmd/index.php');
     $actionCall->setEnv('defaultEditScript', PATH_txdam_rel . 'mod_edit/index.php');
     $actionCall->setEnv('actionPerms', tx_dam::access_checkFileOperation());
     $actionCall->setEnv('permsEdit', $permsEdit);
     $actionCall->setEnv('permsDelete', $permsDelete);
     $actionCall->setEnv('cmLevel', $backRef->cmLevel);
     $actionCall->setEnv('cmParent', t3lib_div::_GP('parentname'));
     $actionCall->initActions(true);
     $actions = $actionCall->renderActionsContextMenu(true);
     foreach ($actions as $id => $action) {
         if ($action['isDivider']) {
             $damMenuItems[$id] = 'spacer';
         } else {
             $onclick = $action['onclick'] ? $action['onclick'] : $this->createOnClick($action['url'], $action['dontHide']);
             $damMenuItems[$id] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($action['label']), $backRef->excludeIcon($action['icon']), $onclick, $action['onlyCM'], $action['dontHide']);
         }
     }
     // clear the file context menu, allow additional items from extensions,
     // like TemplaVoila, and the display constraints
     // once a DAM file is found
     foreach ($menuItems as $key => $var) {
         if (!t3lib_div::inList('edit,rename,info,copy,cut,delete', $key) && !array_key_exists($key, $damMenuItems)) {
             $damMenuItems[$key] = $var;
         }
     }
     return $damMenuItems;
 }
    /**
     * Rich Text Editor (RTE) link selector (MAIN function)
     * Generates the link selector for the Rich Text Editor.
     * Can also be used to select links for the TCEforms (see $wiz)
     *
     * @param	boolean		If set, the "remove link" is not shown in the menu: Used for the "Select link" wizard which is used by the TCEforms
     * @return	string		Modified content variable.
     */
    function main_rte($wiz = 0)
    {
        global $LANG, $BE_USER, $BACK_PATH;
        // Starting content:
        $content = $this->doc->startPage($LANG->getLL('Insert/Modify Link', 1));
        $this->reinitParams();
        // Initializing the action value, possibly removing blinded values etc:
        $this->allowedItems = explode(',', 'page,file,url,mail,spec,upload');
        // Remove upload tab if filemount is readonly
        if ($this->isReadOnlyFolder(tx_dam::path_makeAbsolute($this->damSC->path))) {
            $this->allowedItems = array_diff($this->allowedItems, array('upload'));
        }
        //call hook for extra options
        foreach ($this->hookObjects as $hookObject) {
            $this->allowedItems = $hookObject->addAllowedItems($this->allowedItems);
        }
        if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
            $this->allowedItems = array_diff($this->allowedItems, t3lib_div::trimExplode(',', $this->buttonConfig['options.']['removeItems'], 1));
        } else {
            $this->allowedItems = array_diff($this->allowedItems, t3lib_div::trimExplode(',', $this->thisConfig['blindLinkOptions'], 1));
        }
        reset($this->allowedItems);
        if (!in_array($this->act, $this->allowedItems)) {
            $this->act = current($this->allowedItems);
        }
        // Making menu in top:
        $menuDef = array();
        if (!$wiz && $this->curUrlArray['href']) {
            $menuDef['removeLink']['isActive'] = $this->act == 'removeLink';
            $menuDef['removeLink']['label'] = $LANG->getLL('removeLink', 1);
            $menuDef['removeLink']['url'] = '#';
            $menuDef['removeLink']['addParams'] = 'onclick="plugin.unLink();return false;"';
        }
        if (in_array('page', $this->allowedItems)) {
            $menuDef['page']['isActive'] = $this->act == 'page';
            $menuDef['page']['label'] = $LANG->getLL('page', 1);
            $menuDef['page']['url'] = '#';
            $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'' . htmlspecialchars('?act=page&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('file', $this->allowedItems)) {
            $menuDef['file']['isActive'] = $this->act == 'file';
            $menuDef['file']['label'] = $LANG->sL('LLL:EXT:dam/mod_main/locallang_mod.xml:mlang_tabs_tab', 1);
            $menuDef['file']['url'] = '#';
            $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'' . htmlspecialchars('?act=file&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('url', $this->allowedItems)) {
            $menuDef['url']['isActive'] = $this->act == 'url';
            $menuDef['url']['label'] = $LANG->getLL('extUrl', 1);
            $menuDef['url']['url'] = '#';
            $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'' . htmlspecialchars('?act=url&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('mail', $this->allowedItems)) {
            $menuDef['mail']['isActive'] = $this->act == 'mail';
            $menuDef['mail']['label'] = $LANG->getLL('email', 1);
            $menuDef['mail']['url'] = '#';
            $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'' . htmlspecialchars('?act=mail&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (is_array($this->thisConfig['userLinks.']) && in_array('spec', $this->allowedItems)) {
            $menuDef['spec']['isActive'] = $this->act == 'spec';
            $menuDef['spec']['label'] = $LANG->getLL('special', 1);
            $menuDef['spec']['url'] = '#';
            $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'' . htmlspecialchars('?act=spec&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        if (in_array('upload', $this->allowedItems)) {
            $menuDef['upload']['isActive'] = $this->act === 'upload';
            $menuDef['upload']['label'] = $LANG->getLL('tx_dam_file_upload.title', 1);
            $menuDef['upload']['url'] = '#';
            $menuDef['upload']['addParams'] = 'onclick="jumpToUrl(\'' . htmlspecialchars('?act=upload&mode=' . $this->mode . '&bparams=' . $this->bparams) . '\');return false;"';
        }
        // call hook for extra options
        foreach ($this->hookObjects as $hookObject) {
            $menuDef = $hookObject->modifyMenuDefinition($menuDef);
        }
        $content .= $this->doc->getTabMenuRaw($menuDef);
        // Adding the menu and header to the top of page:
        $content .= $this->printCurrentUrl($this->curUrlInfo['info']) . '<br />';
        // Depending on the current action we will create the actual module content for selecting a link:
        switch ($this->act) {
            case 'mail':
                $extUrl = '
			<!--
				Enter mail address:
			-->
					<form action="" name="lurlform" id="lurlform">
						<table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
							<tr>
								<td>' . $LANG->getLL('emailAddress', 1) . ':</td>
								<td><input type="text" name="lemail"' . $this->doc->formWidth(20) . ' value="' . htmlspecialchars($this->curUrlInfo['act'] == 'mail' ? $this->curUrlInfo['info'] : '') . '" /> ' . '<input type="submit" value="' . $LANG->getLL('setLink', 1) . '" onclick="setTarget(\'\');setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
							</tr>
						</table>
					</form>';
                $content .= $extUrl;
                $content .= $this->addAttributesForm();
                break;
            case 'url':
                $extUrl = '
			<!--
				Enter External URL:
			-->
					<form action="" name="lurlform" id="lurlform">
						<table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
							<tr>
								<td>URL:</td>
								<td><input type="text" name="lurl"' . $this->doc->formWidth(20) . ' value="' . htmlspecialchars($this->curUrlInfo['act'] == 'url' ? $this->curUrlInfo['info'] : 'http://') . '" /> ' . '<input type="submit" value="' . $LANG->getLL('setLink', 1) . '" onclick="if (/^[A-Za-z0-9_+]{1,8}:/i.test(document.lurlform.lurl.value)) { setValue(document.lurlform.lurl.value); } else { setValue(\'http://\'+document.lurlform.lurl.value); }; return link_current();" /></td>
							</tr>
						</table>
					</form>';
                $content .= $extUrl;
                $content .= $this->addAttributesForm();
                break;
            case 'file':
                $this->addDisplayOptions();
                $content .= $this->addAttributesForm();
                $content .= $this->dam_select($this->allowedFileTypes, $this->disallowedFileTypes);
                $content .= $this->damSC->getOptions();
                break;
            case 'spec':
                if (is_array($this->thisConfig['userLinks.'])) {
                    $subcats = array();
                    $v = $this->thisConfig['userLinks.'];
                    foreach ($v as $k2 => $dummyValue) {
                        $k2i = intval($k2);
                        if (substr($k2, -1) == '.' && is_array($v[$k2i . '.'])) {
                            // Title:
                            $title = trim($v[$k2i]);
                            if (!$title) {
                                $title = $v[$k2i . '.']['url'];
                            } else {
                                $title = $LANG->sL($title);
                            }
                            // Description:
                            $description = $v[$k2i . '.']['description'] ? $LANG->sL($v[$k2i . '.']['description'], 1) . '<br />' : '';
                            // URL + onclick event:
                            $onClickEvent = '';
                            if (isset($v[$k2i . '.']['target'])) {
                                $onClickEvent .= "setTarget('" . $v[$k2i . '.']['target'] . "');";
                            }
                            $v[$k2i . '.']['url'] = str_replace('###_URL###', $this->siteURL, $v[$k2i . '.']['url']);
                            if (substr($v[$k2i . '.']['url'], 0, 7) == "http://" || substr($v[$k2i . '.']['url'], 0, 7) == 'mailto:') {
                                $onClickEvent .= "cur_href=unescape('" . rawurlencode($v[$k2i . '.']['url']) . "');link_current();";
                            } else {
                                $onClickEvent .= "link_spec(unescape('" . $this->siteURL . rawurlencode($v[$k2i . '.']['url']) . "'));";
                            }
                            // Link:
                            $A = array('<a href="#" onclick="' . htmlspecialchars($onClickEvent) . 'return false;">', '</a>');
                            // Adding link to menu of user defined links:
                            $subcats[$k2i] = '
								<tr>
									<td class="bgColor4">' . $A[0] . '<strong>' . htmlspecialchars($title) . ($this->curUrlInfo['info'] == $v[$k2i . '.']['url'] ? '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/blinkarrow_right.gif', 'width="5" height="9"') . ' class="c-blinkArrowR" alt="" />' : '') . '</strong><br />' . $description . $A[1] . '</td>
								</tr>';
                        }
                    }
                    // Sort by keys:
                    ksort($subcats);
                    // Add menu to content:
                    $content .= '
			<!--
				Special userdefined menu:
			-->
						<table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
							<tr>
								<td class="bgColor5" class="c-wCell" valign="top"><strong>' . $LANG->getLL('special', 1) . '</strong></td>
							</tr>
							' . implode('', $subcats) . '
						</table>
						';
                }
                break;
            case 'page':
                $content .= $this->addAttributesForm();
                $pagetree = t3lib_div::makeInstance('tx_rtehtmlarea_pageTree');
                $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
                $pagetree->addField('nav_title');
                $tree = $pagetree->getBrowsableTree();
                $cElements = $this->expandPage();
                $content .= '
			<!--
				Wrapper table for page tree / record list:
			-->
					<table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
						<tr>
							<td class="c-wCell" valign="top">' . $this->barheader($LANG->getLL('pageTree') . ':') . $tree . '</td>
							<td class="c-wCell" valign="top">' . $cElements . '</td>
						</tr>
					</table>
					';
                break;
            case 'upload':
                $content .= $this->dam_upload($this->allowedFileTypes, $this->disallowedFileTypes);
                $content .= $this->damSC->getOptions();
                $content .= '<br /><br />';
                if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
                    $content .= $this->createFolder(tx_dam::path_makeAbsolute($this->damSC->path));
                }
                break;
            default:
                // call hook
                foreach ($this->hookObjects as $hookObject) {
                    $content .= $hookObject->getTab($this->act);
                }
                break;
        }
        // End page, return content:
        $content .= $this->doc->endPage();
        $this->getJSCode();
        $content = $this->damSC->doc->insertStylesAndJS($content);
        return $content;
    }
 /**
  * Implements the "typolink" property of stdWrap (and others)
  * Basically the input string, $linktext, is (typically) wrapped in a <a>-tag linking to some page, email address, file or URL based on a parameter defined by the configuration array $conf.
  * This function is best used from internal functions as is. There are some API functions defined after this function which is more suited for general usage in external applications.
  * Generally the concept "typolink" should be used in your own applications as an API for making links to pages with parameters and more. The reason for this is that you will then automatically make links compatible with all the centralized functions for URL simulation and manipulation of parameters into hashes and more.
  * For many more details on the parameters and how they are intepreted, please see the link to TSref below.
  *
  * @param string $linktxt The string (text) to link
  * @param array $conf TypoScript configuration (see link below)
  * @param tslib_cObj $cObj
  * @return	string		A link-wrapped string.
  * @see stdWrap(), tslib_pibase::pi_linkTP()
  * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=321&cHash=59bd727a5e
  */
 function typoLink($linktxt, $conf, $cObj = NULL)
 {
     $finalTagParts = array();
     // If called from media link handler, use the reference of the passed cObj
     if (!is_object($this->cObj)) {
         $this->cObj = $cObj;
     }
     $link_param = trim($this->cObj->stdWrap($conf['parameter'], $conf['parameter.']));
     $initP = '?id=' . $GLOBALS['TSFE']->id . '&type=' . $GLOBALS['TSFE']->type;
     $this->cObj->lastTypoLinkUrl = '';
     $this->cObj->lastTypoLinkTarget = '';
     if ($link_param) {
         $link_paramA = t3lib_div::unQuoteFilenames($link_param, TRUE);
         $link_param = trim($link_paramA[0]);
         // Link parameter value
         $linkClass = trim($link_paramA[2]);
         // Link class
         if ($linkClass === '-') {
             $linkClass = '';
         }
         // The '-' character means 'no class'. Necessary in order to specify a title as fourth parameter without setting the target or class!
         $forceTarget = trim($link_paramA[1]);
         // Target value
         $forceTitle = trim($link_paramA[3]);
         // Title value
         if ($forceTarget === '-') {
             $forceTarget = '';
         }
         // The '-' character means 'no target'. Necessary in order to specify a class as third parameter without setting the target!
         // Check, if the target is coded as a JS open window link:
         $JSwindowParts = array();
         $JSwindowParams = '';
         $onClick = '';
         if ($forceTarget && preg_match('/^([0-9]+)x([0-9]+)(:(.*)|.*)$/', $forceTarget, $JSwindowParts)) {
             // Take all pre-configured and inserted parameters and compile parameter list, including width+height:
             $JSwindow_tempParamsArr = t3lib_div::trimExplode(',', strtolower($conf['JSwindow_params'] . ',' . $JSwindowParts[4]), TRUE);
             $JSwindow_paramsArr = array();
             foreach ($JSwindow_tempParamsArr as $JSv) {
                 list($JSp, $JSv) = explode('=', $JSv);
                 $JSwindow_paramsArr[$JSp] = $JSp . '=' . $JSv;
             }
             // Add width/height:
             $JSwindow_paramsArr['width'] = 'width=' . $JSwindowParts[1];
             $JSwindow_paramsArr['height'] = 'height=' . $JSwindowParts[2];
             // Imploding into string:
             $JSwindowParams = implode(',', $JSwindow_paramsArr);
             $forceTarget = '';
             // Resetting the target since we will use onClick.
         }
         // Internal target:
         $target = isset($conf['target']) ? $conf['target'] : $GLOBALS['TSFE']->intTarget;
         if ($conf['target.']) {
             $target = $this->cObj->stdWrap($target, $conf['target.']);
         }
         // Checking if the id-parameter is an alias.
         if (version_compare(TYPO3_version, '4.6.0', '>=')) {
             $isInteger = t3lib_utility_Math::canBeInterpretedAsInteger($link_param);
         } else {
             $isInteger = t3lib_div::testInt($link_param);
         }
         if (!$isInteger) {
             $GLOBALS['TT']->setTSlogMessage("tx_dam_tsfemediatag->typolink(): File id '" . $link_param . "' is not an integer, so '" . $linktxt . "' was not linked.", 1);
             return $linktxt;
         }
         if (!is_object($media = tx_dam::media_getByUid($link_param))) {
             $GLOBALS['TT']->setTSlogMessage("tx_dam_tsfemediatag->typolink(): File id '" . $link_param . "' was not found, so '" . $linktxt . "' was not linked.", 1);
             return $linktxt;
         }
         if (!$media->isAvailable) {
             $GLOBALS['TT']->setTSlogMessage("tx_dam_tsfemediatag->typolink(): File '" . $media->getPathForSite() . "' (" . $link_param . ") did not exist, so '" . $linktxt . "' was not linked.", 1);
             return $linktxt;
         }
         $meta = $media->getMetaArray();
         if (is_array($this->conf['procFields.'])) {
             foreach ($this->conf['procFields.'] as $field => $fieldConf) {
                 if (substr($field, -1, 1) === '.') {
                     $fN = substr($field, 0, -1);
                 } else {
                     $fN = $field;
                     $fieldConf = array();
                 }
                 $meta[$fN] = $media->getContent($fN, $fieldConf);
             }
         }
         $this->addMetaToData($meta);
         // Title tag
         $title = $conf['title'];
         if ($conf['title.']) {
             $title = $this->cObj->stdWrap($title, $conf['title.']);
         }
         // Setting title if blank value to link:
         if ($linktxt === '') {
             $linktxt = $media->getContent('title');
         }
         if ($GLOBALS['TSFE']->config['config']['jumpurl_enable']) {
             $this->cObj->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix . $GLOBALS['TSFE']->config['mainScript'] . $initP . '&jumpurl=' . rawurlencode($media->getPathForSite()) . $GLOBALS['TSFE']->getMethodUrlIdToken;
         } else {
             $this->cObj->lastTypoLinkUrl = $media->getURL();
         }
         if ($forceTarget) {
             $target = $forceTarget;
         }
         $this->cObj->lastTypoLinkTarget = $target;
         $finalTagParts['url'] = $this->cObj->lastTypoLinkUrl;
         $finalTagParts['targetParams'] = $target ? ' target="' . $target . '"' : '';
         $finalTagParts['aTagParams'] = $this->cObj->getATagParams($conf);
         $finalTagParts['TYPE'] = 'file';
         if ($forceTitle) {
             $title = $forceTitle;
         }
         if ($JSwindowParams) {
             // Create TARGET-attribute only if the right doctype is used
             if (!t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype)) {
                 $target = ' target="FEopenLink"';
             } else {
                 $target = '';
             }
             $onClick = "vHWin=window.open('" . $GLOBALS['TSFE']->baseUrlWrap($finalTagParts['url']) . "','FEopenLink','" . $JSwindowParams . "');vHWin.focus();return false;";
             $res = '<a href="' . htmlspecialchars($finalTagParts['url']) . '"' . $target . ' onclick="' . htmlspecialchars($onClick) . '"' . ($title ? ' title="' . $title . '"' : '') . ($linkClass ? ' class="' . $linkClass . '"' : '') . $finalTagParts['aTagParams'] . '>';
         } else {
             $res = '<a href="' . htmlspecialchars($finalTagParts['url']) . '"' . ($title ? ' title="' . $title . '"' : '') . $finalTagParts['targetParams'] . ($linkClass ? ' class="' . $linkClass . '"' : '') . $finalTagParts['aTagParams'] . '>';
         }
         // Call userFunc
         if ($conf['userFunc']) {
             $finalTagParts['TAG'] = $res;
             $res = $this->cObj->callUserFunction($conf['userFunc'], $conf['userFunc.'], $finalTagParts);
         }
         // If flag "returnLastTypoLinkUrl" set, then just return the latest URL made:
         if ($conf['returnLast']) {
             switch ($conf['returnLast']) {
                 case 'url':
                     return $this->cObj->lastTypoLinkUrl;
                     break;
                 case 'target':
                     return $this->cObj->lastTypoLinkTarget;
                     break;
             }
         }
         if ($conf['postUserFunc']) {
             $linktxt = $this->cObj->callUserFunction($conf['postUserFunc'], $conf['postUserFunc.'], $linktxt);
         }
         if ($conf['ATagBeforeWrap']) {
             return $res . $this->cObj->wrap($linktxt, $conf['wrap']) . '</a>';
         } else {
             return $this->cObj->wrap($res . $linktxt . '</a>', $conf['wrap']);
         }
     } else {
         return $linktxt;
     }
 }
 /**
  * tx_dam::index_process()
  */
 public function test_index_process()
 {
     $this->removeIndexSetup();
     $this->removeFixturesFromIndex();
     $this->addFixturePathToFilemount();
     $filepath = $this->getFixtureFilename('iptc');
     $uid = tx_dam::file_isIndexed($filepath);
     self::assertFalse($uid, 'File index found, but shouldn\'t');
     $indexed = tx_dam::index_process($filepath);
     $indexed = current($indexed);
     self::assertTrue(isset($indexed['uid']), 'File not indexed');
     $meta = tx_dam::meta_getDataByUid($indexed['uid'], '*');
     $date = date('d.m.Y', $meta['date_cr']);
     self::assertEquals($date, '04.07.2006', 'Wrong date: ' . $date);
     self::assertEquals($meta['title'], 'Hummelflug', 'Wrong title: ' . $meta['title']);
     self::assertEquals($meta['file_hash'], '184e454250f6f606a1dba14b5c7b38c5', 'Wrong file_hash: ' . $meta['file_hash']);
     self::assertEquals(intval($meta['media_type']), TXDAM_mtype_image, 'Wrong media_type: ' . $meta['media_type']);
     self::assertEquals($meta['file_type'], 'jpg', 'Wrong file_type: ' . $meta['file_type']);
     self::assertEquals($meta['file_mime_type'], 'image', 'Wrong file_mime_type: ' . $meta['file_mime_type']);
     self::assertEquals($meta['file_mime_subtype'], 'jpeg', 'Wrong file_mime_subtype: ' . $meta['file_mime_subtype']);
     self::assertTrue((bool) $meta['hpixels'], 'Missing value');
     self::assertTrue((bool) $meta['vpixels'], 'Missing value');
     self::assertTrue((bool) $meta['hres'], 'Missing value');
     self::assertTrue((bool) $meta['vres'], 'Missing value');
     self::assertTrue((bool) $meta['width'], 'Missing value');
     self::assertTrue((bool) $meta['height'], 'Missing value');
     self::assertTrue((bool) $meta['height_unit'], 'Missing value');
     $this->removeFixturePathFromFilemount();
     $this->removeFixturesFromIndex();
 }
    /**
     *
     */
    function indexing_getProgessTable()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TYPO3_CONF_VARS;
        // JavaScript
        $this->pObj->doc->JScode = $this->pObj->doc->wrapScriptTags('
			function progress_bar_update(intCurrentPercent) {
				document.getElementById("progress_bar_left").style.width = intCurrentPercent+"%";
				document.getElementById("progress_bar_left").innerHTML = intCurrentPercent+"&nbsp;%";

				document.getElementById("progress_bar_left").style.background = "#448e44";
				if(intCurrentPercent >= 100) {
					document.getElementById("progress_bar_right").style.background = "#448e44";
				}
			}


			function addTableRow(cells) {

				document.getElementById("progressTable").style.visibility = "visible";

				var tbody = document.getElementById("progressTable").getElementsByTagName("tbody")[0];
				var row = document.createElement("TR");

				row.style.backgroundColor = "#D9D5C9";

				for (var cellId in cells) {
					var tdCell = document.createElement("TD");
					tdCell.innerHTML = cells[cellId];
					row.appendChild(tdCell);
				}
				var header = document.getElementById("progressTableheader");
				var headerParent = header.parentNode;
				headerParent.insertBefore(row,header.nextSibling);

				// tbody.appendChild(row);
				// tbody.insertBefore(row,document.getElementById("progressTableheader"));
			}

			function setMessage(msg) {
				var messageCnt = document.getElementById("message");
				messageCnt.innerHTML = msg;
			}

			function finished() {
				progress_bar_update(100);
				document.getElementById("progress_bar_left").innerHTML = "' . $LANG->getLL('tx_dam_tools_indexupdate.finished', 1) . '";
				// document.getElementById("btn_back").style.visibility = "visible";
			}
		');
        if (tx_dam::config_getValue('setup.devel')) {
            $iframeSize = 'width="100%" height="300" border="1" scrolling="yes" frameborder="1"';
        } else {
            $iframeSize = 'width="0" height="0" border="0" scrolling="no" frameborder="0"';
        }
        $code = '';
        $code .= '
			<table width="300px" border="0" cellpadding="0" cellspacing="0" id="progress_bar" summary="progress_bar" align="center" style="border:1px solid #888">
			<tbody>
			<tr>
			<td id="progress_bar_left" width="0%" align="center" style="background:#eee; color:#fff">&nbsp;</td>
			<td id="progress_bar_right" style="background:#eee;">&nbsp;</td>
			</tr>
			</tbody>
			</table>

			<iframe src="' . htmlspecialchars(t3lib_div::linkThisScript($this->pObj->addParams)) . '" name="indexiframe" ' . $iframeSize . '>
			Error!
			</iframe>
			<br />
		';
        $code .= '
			 <div id="message"></div>
			 <table id="progressTable" style="visibility:hidden" cellpadding="1" cellspacing="1" border="0" width="100%">
			 <tr id="progressTableheader" bgcolor="' . $this->pObj->doc->bgColor5 . '">
				 <th></th>
				 <th>' . $LANG->sL('LLL:EXT:dam/locallang_db.xml:tx_dam_item.file_name', 1) . '</th>
				 <th>' . $LANG->sL('LLL:EXT:dam/locallang_db.xml:tx_dam_item.file_path', 1) . '</th>
			</tr>
			</table>
		';
        return $code;
    }
 /**
  * Additional access check
  *
  * @return	boolean Return true if access is granted
  */
 function accessCheck()
 {
     return tx_dam::access_checkFileOperation('moveFile');
 }
 /**
  * Indiziert eine Datei mit DAM.
  *
  * ACHTUNG: wenn die Feld Collation der DB-Felder file_name und file_path
  *     in der tx_dam Tabelle auf *_ci (utf8_general_ci) stehen,
  *     wird bei der Prüfung Gruß-/Kleinschreibung ignoriert,
  *     was bei unix-Systemen zu Fehlern führt!
  *     Die einfache Lösung ist, die Collation der beiden Felder
  *     auf *_bin (utf8_bin) zu setzen!
  *
  * @param string $file
  * @param int $beUserId
  * @return uid
  */
 public static function indexProcess($file, $beUserId)
 {
     if (!tx_rnbase_util_Extensions::isLoaded('dam')) {
         return 0;
     }
     require_once tx_rnbase_util_Extensions::extPath('dam', 'lib/class.tx_dam.php');
     $mediaUid = tx_dam::file_isIndexed($file);
     if (!$mediaUid) {
         // process file indexing
         self::initBE4DAM($beUserId);
         $damData = tx_dam::index_process($file);
         $mediaUid = $damData[0]['uid'];
     }
     return $mediaUid;
 }
    /**
     * Returns rendered previewer
     * used player:
     * http://aktuell.de.selfhtml.org/artikel/grafik/flashmusik/
     * http://loudblog.de/index.php?s=download
     *
     * @param	array		$row Meta data array
     * @param	integer		$size The maximum size of the previewer
     * @param	string		$type The wanted previewer type
     * @param	array		$conf Additional configuration values. Might be empty.
     * @return	array		True if this is the right previewer for the file
     */
    function render($row, $size, $type, $conf = array())
    {
        $outArr = array('htmlCode' => '', 'headerCode' => '');
        $absFile = tx_dam::file_absolutePath($row['file_path'] . $row['file_name']);
        $siteUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
        $fileRelPath = tx_dam::file_relativeSitePath($row['file_path'] . $row['file_name']);
        $playerRelPath = str_replace(PATH_site, '', PATH_txdam);
        #$size = 'width="200" height="55"';
        #$playerRelPath .= 'res/emff_lila.swf';
        $size = 'width="120" height="37"';
        $playerRelPath .= 'res/emff_inx.swf';
        $outArr['htmlCode'] = '<div class="previewMP3">
			<object type="application/x-shockwave-flash" data="' . htmlspecialchars($siteUrl . $playerRelPath) . '?streaming=yes&src=' . htmlspecialchars($siteUrl . t3lib_div::rawUrlEncodeFP($fileRelPath)) . '" ' . $size . '>
			<param name="movie" value="' . htmlspecialchars($siteUrl . $playerRelPath) . '?streaming=yes&src=' . htmlspecialchars($siteUrl . t3lib_div::rawUrlEncodeFP($fileRelPath)) . '" />
			<param name="quality" value="high" />
			</object>
			</div>';
        return $outArr;
    }
 /**
  * Fetches the current element
  *
  * @return	boolean
  */
 function _fetchCurrent()
 {
     if (isset($this->res[$this->currentPointer])) {
         $uid = intval($this->res[$this->currentPointer]);
         unset($this->media);
         $this->media = tx_dam::media_getByUid($uid);
         $this->currentData = $this->media->getMetaInfoArray();
         if ($this->media->isAvailable) {
             // TODO use tx_dam_media
             if (!is_null($this->currentData) and $this->table and $this->mode === 'FE') {
                 $this->currentData = tx_dam_db::getRecordOverlay($this->table, $this->currentData, array(), $this->mode);
             }
         }
         if ($this->conf['callbackFunc_currentData'] and is_callable($this->conf['callbackFunc_currentData'])) {
             call_user_func($this->conf['callbackFunc_currentData'], $this);
         }
     } else {
         unset($this->media);
         $this->currentData = NULL;
     }
 }
 /**
  * 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);
 }
 /**
  * media->filepath
  */
 public function test_getPathAbsolute()
 {
     $fixture = $this->getFixtureMedia();
     $filename = $fixture['filename'];
     $meta = $fixture['meta'];
     $media = $fixture['media'];
     $filepath = tx_dam::file_absolutePath($filename);
     $path = $media->filepath;
     self::assertEquals($path, $filepath, 'File path differs: ' . $path . ' (' . $filepath . ')');
 }
    /**
     * Making the form for create file
     *
     * @return	string		HTML content
     */
    function renderForm($fileContent = '')
    {
        global $BE_USER, $LANG, $TYPO3_CONF_VARS;
        $content = '';
        $msg = array();
        $this->pObj->markers['FOLDER_INFO'] = tx_dam_guiFunc::getFolderInfoBar(tx_dam::path_compileInfo($this->pObj->media->pathAbsolute));
        $msg[] = '&nbsp;';
        $this->pObj->markers['FILE_INFO'] = $GLOBALS['LANG']->sL('LLL:EXT:dam/locallang_db.xml:tx_dam_item.file_name', 1) . ' <strong>' . htmlspecialchars($this->pObj->media->filename) . '</strong>';
        $msg[] = '&nbsp;';
        $msg[] = $GLOBALS['LANG']->getLL('tx_dam_cmd_filenew.text_content', 1);
        $msg[] = '<textarea rows="30" name="data[file_content]" wrap="off"' . $this->pObj->doc->formWidthText(48, 'width:99%;height:65%', 'off') . ' class="fixed-font enable-tab">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>';
        $this->pObj->docHeaderButtons['SAVE'] = '<input class="c-inputButton" name="_savedok"' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/savedok.gif') . ' title="' . $GLOBALS['LANG']->getLL('labelCmdSave', 1) . '" height="16" type="image" width="16">';
        $this->pObj->docHeaderButtons['SAVE_CLOSE'] = '<input class="c-inputButton" name="_saveandclosedok"' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/saveandclosedok.gif') . ' title="' . $GLOBALS['LANG']->getLL('labelCmdSaveClose', 1) . '" height="16" type="image" width="16">';
        $this->pObj->docHeaderButtons['CLOSE'] = '<a href="#" onclick="jumpBack(); return false;"><img' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/closedok.gif') . ' class="c-inputButton" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.cancel', 1) . '" alt="" height="16" width="16"></a>';
        if (tx_dam::config_checkValueEnabled('mod.txdamM1_SHARED.displayExtraButtons', 1)) {
            $buttons = '
				<input type="submit" name="save" value="' . $GLOBALS['LANG']->getLL('labelCmdSave', 1) . '" />
				<input type="submit" name="_saveandclosedok_x" value="' . $GLOBALS['LANG']->getLL('labelCmdSaveClose', 1) . '" />
				<input type="submit" value="' . $LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.cancel', 1) . '" onclick="jumpBack(); return false;" />';
        }
        $content .= $GLOBALS['SOBE']->getMessageBox($GLOBALS['SOBE']->pageTitle, $msg, $buttons, 1);
        return $content;
    }
    /**
     * List media types, along with options to edit & delete
     *
     * @return	string		HTML table of all the mimetypes
     */
    function listMimeTypes()
    {
        global $LANG, $BACK_PATH, $BE_USER;
        // Load template
        $content = t3lib_parsehtml::getSubpart(t3lib_div::getURL($BACK_PATH . t3lib_extMgm::extRelPath('dam') . 'modfunc_tools_mimetypes/template.html'), '###MOD_TEMPLATE###');
        $rowTemplate[1] = t3lib_parsehtml::getSubpart($content, '###ROW_1###');
        $rowTemplate[2] = t3lib_parsehtml::getSubpart($content, '###ROW_2###');
        // Add some JS
        $this->pObj->doc->JScode .= $this->pObj->doc->wrapScriptTags('
				function deleteRecord(id)	{	//
					if (confirm(' . $LANG->JScharCode($LANG->getLL('deleteWarning')) . '))	{
						window.location.href = "' . $BACK_PATH . 'tce_db.php?cmd[tx_dam_media_types]["+id+"][delete]=1&redirect=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) . '&id=' . tx_dam_db::getPid() . '&vC=' . $BE_USER->veriCode() . '&prErr=1&uPT=1";
					}
					return false;
				}
		');
        // Get content
        $alternate = 1;
        $rows = '';
        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_dam_media_types', '', '', 'ext ASC');
        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
            $editURL = $BACK_PATH . 'alt_doc.php?returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) . '&id=' . tx_dam_db::getPid() . '&edit[tx_dam_media_types][' . $row['uid'] . ']=edit';
            //$deleteURL = $BACK_PATH . 'alt_doc.php?returnUrl=' . rawurlencode( t3lib_div::getIndpEnv('TYPO3_REQUEST_URL') ) . '&id=' . tx_dam_db::getPid() . '&edit[tx_dam_media_types][' . $row['uid'] . '][delete]=1';
            $rowMarkers['EDIT'] = '<a href="#" onclick="window.location.href=\'' . $editURL . '\'; return false;"><img' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/edit2.gif', 'width="11" height="12"') . ' title="Edit this type" alt="" height="16" width="16"></a>';
            $rowMarkers['DELETE'] = '<a href="#" onclick="deleteRecord(' . $row['uid'] . ')"><img' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/deletedok.gif', 'width="11" height="12"') . ' title="Delete this type" alt="" height="16" width="16"></a>';
            $rowMarkers['EXTENSION'] = $row['ext'];
            $rowMarkers['MIME'] = $row['mime'];
            $rowMarkers['ICON'] = '<img src="' . $BACK_PATH . tx_dam::icon_getFileType(array('file_type' => $row['ext'], 'media_type' => $row['type'])) . '" />';
            $rows .= t3lib_parsehtml::substituteMarkerArray($rowTemplate[$alternate], $rowMarkers, '###|###');
            // Cycle the alternating rows
            if ($alternate == 2) {
                $alternate = 1;
            } else {
                $alternate = 2;
            }
        }
        $content = t3lib_parsehtml::substituteSubpart($content, '###ROWS###', $rows);
        $GLOBALS['TYPO3_DB']->sql_free_result($res);
        return $content;
    }