/**
  * Returns true if the action is of the wanted type
  *
  * @param	string		$type Action type
  * @param	array		$itemInfo Item info array. Eg pathInfo, meta data array
  * @param	array		$env Environment array. Can be set with setEnv() too.
  * @return	boolean
  */
 function isValid($type, $itemInfo = NULL, $env = NULL)
 {
     $valid = ($this->isTypeValid($type, $itemInfo, $env) and $itemInfo['file_status'] != TXDAM_status_file_missing);
     if ($valid) {
         // more simpler access check is needed
         if ($this->itemInfo['file_path_absolute']) {
             $valid = t3lib_div::isFirstPartOfStr($this->itemInfo['file_path_absolute'], PATH_site);
         } else {
             $this->itemInfo['file_path_absolute'] = tx_dam::path_makeAbsolute($this->itemInfo['file_path']);
             $valid = t3lib_div::isFirstPartOfStr($this->itemInfo['file_path_absolute'], PATH_site);
         }
     }
     return $valid;
 }
    /**
     * Create the folder navigation tree in HTML
     *
     * @param	mixed		Input tree array. If not array, then $this->tree is used.
     * @return	string		HTML output of the tree.
     */
    function eb_printTree($treeArr = '')
    {
        global $BE_USER;
        if (!is_array($treeArr)) {
            $treeArr = $this->tree;
        }
        $out = '';
        $c = 0;
        $cmpItem = '';
        $cmpPath = '';
        $selection = $GLOBALS['SOBE']->browser->damSC->selection->sl->sel;
        if (is_array($selection['SELECT'][$this->treeName])) {
            $cmpItem = key($selection['SELECT'][$this->treeName]);
            $cmpPath = tx_dam::path_makeAbsolute($cmpItem);
        }
        // Traverse rows for the tree and print them into table rows:
        foreach ($treeArr as $k => $v) {
            $c++;
            $bgColorClass = ($c + 1) % 2 ? 'bgColor' : 'bgColor-10';
            // Creating blinking arrow, if applicable:
            if ($cmpPath && ($GLOBALS['SOBE']->act === 'file' || $GLOBALS['SOBE']->act === 'upload') && $cmpPath == $v['row']['path']) {
                $arrCol = '<td><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_right.gif', 'width="5" height="9"') . ' class="c-blinkArrowR" alt="" /></td>';
                $bgColorClass = 'bgColor4';
            } else {
                $arrCol = '<td></td>';
            }
            // Create arrow-bullet for file listing (if folder path is linkable):
            $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->act . '&mode=' . $GLOBALS['SOBE']->mode . '&bparams=' . $GLOBALS['SOBE']->bparams . $this->getJumpToParam($v['row']) . '\');';
            $cEbullet = $this->ext_isLinkable($v['row']) ? '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/arrowbullet.gif', 'width="18" height="16"') . ' alt="" /></a>' : '';
            // Put table row with folder together:
            $out .= '
				<tr class="' . $bgColorClass . '">
					<td nowrap="nowrap">' . $v['HTML'] . $this->wrapTitle(t3lib_div::fixed_lgd_cs($v['row']['title'], $BE_USER->uc['titleLen']), $v['row']) . '</td>
					' . $arrCol . '
					<td width="1%">' . $cEbullet . '</td>
				</tr>';
        }
        $out = '

			<!--
				Folder tree:
			-->
			<table border="0" cellpadding="0" cellspacing="0" class="typo3-browsetree" style="width:100%">
				' . $out . '
			</table>';
        return $out;
    }
    /**
     * Rendering the upload file form fields
     *
     * @return	string		HTML content
     */
    function renderForm()
    {
        global $BACK_PATH, $LANG;
        $id = $this->meta['uid'];
        $path = tx_dam::path_makeAbsolute($this->meta['file_path']);
        $content = '';
        $msg = array();
        $this->pObj->markers['FOLDER_INFO'] = '[' . $this->file['file_path'] . ']:' . $this->file['file_name'];
        $msg[] = tx_dam_guiFunc::getRecordInfoHeaderExtra($this->meta);
        $msg[] = '&nbsp;';
        $msg[] = '
				<input type="file" name="upload_' . $id . '"' . $this->pObj->doc->formWidth(35) . ' size="45" />
				<input type="hidden" name="data[upload][' . $id . '][target]" value="' . htmlspecialchars($path) . '" />
				<input type="hidden" name="data[upload][' . $id . '][data]" value="' . $id . '" />';
        if (tx_dam::config_checkValueEnabled('mod.txdamM1_SHARED.displayExtraButtons', 1)) {
            $buttons = '
				<input type="submit" value="' . $LANG->sL('LLL:EXT:lang/locallang_core.xml:file_upload.php.submit', 1) . '" />
				<input type="submit" value="' . $LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.cancel', 1) . '" onclick="jumpBack(); return false;" />';
        }
        $this->pObj->docHeaderButtons['SAVE'] = '<input class="c-inputButton" name="_savedok"' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/savedok.gif') . ' title="' . $LANG->sL('LLL:EXT:lang/locallang_core.xml:file_upload.php.submit', 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>';
        $content .= $GLOBALS['SOBE']->getMessageBox($GLOBALS['SOBE']->pageTitle, $msg, $buttons, 1);
        return $content;
    }
예제 #4
0
 /**
  * Search for a file and walk up the path if not found in current dir.
  *
  * @param 	string 		$fileName File name to search for
  * @param 	string 		$path Path to search for file
  * @param 	boolean 	$walkUp If set it will be searched for the file in folders above the given
  * @param 	string 		$basePath This absolute path is the limit for searching with $walkUp
  * @return	string 		file content
  */
 function tools_findFileInPath($fileName, $path, $walkUp = true, $basePath = '')
 {
     $basePath = $basePath ? $basePath : PATH_site;
     $path = tx_dam::path_makeAbsolute($path);
     if (is_file($path . $fileName) and is_readable($path . $fileName)) {
         $setup = t3lib_div::getUrl($path . $fileName);
         return $setup;
     }
     if (!$walkUp or $path == $basePath) {
         return false;
     }
     if (tx_dam::path_makeRelative($path) == '') {
         return false;
     }
     if (!($path = dirname($path))) {
         return false;
     }
     return tx_dam::tools_findFileInPath($fileName, $path, $walkUp, $basePath);
 }
    /**
     * 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;
    }
 function enhanceItemArray($row, $mode)
 {
     $row['file_title'] = $row['title'] ? $row['title'] : $row['file_name'];
     $row['file_path_absolute'] = tx_dam::path_makeAbsolute($row['file_path']);
     $row['file_name_absolute'] = $row['file_path_absolute'] . $row['file_name'];
     $row['__exists'] = @is_file($row['file_name_absolute']);
     if ($mode === 'db') {
         $row['_ref_table'] = 'tx_dam';
         $row['_ref_id'] = $row['uid'];
         $row['_ref_file_path'] = '';
     } else {
         $row['_ref_table'] = '';
         $row['_ref_id'] = t3lib_div::shortMD5($row['file_name_absolute']);
         $row['_ref_file_path'] = $row['file_name_absolute'];
     }
     return $row;
 }
 /**
  * Renders the item icon
  *
  * @param	array		$item item array
  * @return	string
  */
 function getItemIcon($item)
 {
     static $titleNotIndexed;
     static $iconNotIndexed;
     if (!$iconNotIndexed) {
         $titleNotIndexed = 'title="' . $GLOBALS['LANG']->getLL('fileNotIndexed') . '"';
         $iconNotIndexed = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/required_h.gif', 'width="10" height="10"') . ' ' . $titleNotIndexed . ' alt="" />';
     }
     $type = $item['__type'];
     if ($type == 'file') {
         $titleAttr = '';
         $attachToIcon = '';
         if (!$item['__isIndexed'] and !($uid = tx_dam::file_isIndexed($item))) {
             $attachToIcon = $iconNotIndexed;
             $titleAttr = $titleNotIndexed;
         }
         $iconTag = tx_dam::icon_getFileTypeImgTag($item, $titleAttr);
         if ($this->enableContextMenus) {
             $iconTag = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconTag, tx_dam::file_absolutePath($item));
         }
         $iconTag .= $attachToIcon;
     } else {
         $titleAttr = 'title="' . htmlspecialchars($item[$type . '_title']) . '"';
         $iconTag = tx_dam::icon_getFileTypeImgTag($item, $titleAttr);
         if ($this->enableContextMenus) {
             $iconTag = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconTag, tx_dam::path_makeAbsolute($item));
         }
     }
     return $iconTag;
 }
    /**
     * 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;
    }
 /**
  * Init the object by a passed meta data record array.
  * It is assumed that the data is really from the index and therefore the file "isIndexed".
  *
  * @param	array		$uid $meta Array of a meta data record
  * @return	void
  */
 function setMetaData($meta)
 {
     if (is_array($meta)) {
         $this->meta = $meta;
         $this->isIndexed = is_array($meta);
         $this->filename = $this->meta['file_name'];
         $this->pathNormalized = $this->meta['file_path'];
         $this->pathAbsolute = tx_dam::path_makeAbsolute($this->meta['file_path']);
         $this->filepath = $this->pathAbsolute . $this->filename;
         if ($this->isAvailable == NULL) {
             $this->fetchFileInfo();
         }
     }
 }
 /**
  * Index uploaded files
  *
  * @param	array		$fileList: ...
  * @return	array		Data
  */
 function indexUploadedFiles($fileList)
 {
     global $BACK_PATH, $LANG, $TYPO3_CONF_VARS;
     $files = array();
     $errors = array();
     require_once PATH_txdam . 'lib/class.tx_dam_indexing.php';
     $index = t3lib_div::makeInstance('tx_dam_indexing');
     $index->init();
     $index->setDefaultSetup(tx_dam::path_makeAbsolute($this->pObj->path));
     $index->enableReindexing(2);
     $index->initEnabledRules();
     $index->setRunType('auto');
     $index->enableMetaCollect();
     $index->indexFiles($fileList, $this->pObj->defaultPid);
     foreach ($index->meta as $data) {
         if ($data['failure']) {
             $meta = $data['file'];
         } else {
             $meta = $data['fields'];
         }
         $files[] = array('uid' => $meta['uid'], 'meta' => $meta, 'errors' => $data['failure'], 'isIndexed' => $data['isIndexed']);
         if ($data['failure']) {
             $errors[] = $data['failure'];
         }
     }
     return array('files' => $files, 'errors' => $errors);
 }
    /**
     * Generates the module content
     *
     * @return	string		HTML content
     */
    function moduleContent($header = '', $description = '', $lastStep = 4)
    {
        global $BE_USER, $LANG, $BACK_PATH, $FILEMOUNTS;
        $content = '';
        switch ($this->getCurrentFunc()) {
            case 'index':
            case 'index1':
                // TODO make it possible to read preset if present in current folder
                $content .= parent::moduleContent($LANG->getLL('tx_dam_tools_indexsetup.start_point'), '<p style="margin:0.8em 0 1.2em 0">' . $LANG->getLL('tx_dam_tools_indexsetup.desc', true) . '</p>');
                break;
                //
                // setup summary
                //
            //
            // setup summary
            //
            case 'index4':
                $step = 4;
                $content .= $this->pObj->getPathInfoHeaderBar($this->pObj->pathInfo, FALSE, $this->cmdIcons);
                $content .= $this->pObj->doc->spacer(10);
                $header = $LANG->getLL('tx_damindex_index.setup_summary');
                $stepsBar = $this->getStepsBar($step, $lastStep, '', '', '', $LANG->getLL('tx_dam_tools_indexsetup.finish'));
                $content .= $this->pObj->doc->section($header, $stepsBar, 0, 1);
                $content .= '<strong>Set Options:</strong><table border="0" cellspacing="0" cellpadding="4" width="100%">' . $this->index->getIndexingOptionsInfo() . '</table>';
                $content .= $this->pObj->doc->spacer(10);
                $rec = array_merge($this->index->dataPreset, $this->index->dataPostset);
                $fixedFields = array_keys($this->index->dataPostset);
                $content .= '<strong>Meta data preset:</strong><br /><table border="0" cellpadding="4" width="100%"><tr><td bgcolor="' . $this->pObj->doc->bgColor3dim . '">' . $this->showPresetData($rec, $fixedFields) . '</td></tr></table>';
                $content .= $this->pObj->doc->spacer(10);
                break;
            case 'indexStart':
                $content .= $this->pObj->doc->section('Indexing default setup', '', 0, 1);
                $filename = '.indexing.setup.xml';
                $path = tx_dam::path_makeAbsolute($this->pObj->path);
                $content .= '</form>';
                $content .= $this->pObj->getFormTag();
                if (is_file($path . $filename) and is_readable($path . $filename)) {
                    $content .= '<br /><strong>Overwrite existing default indexer setup to this folder:</strong><br />' . htmlspecialchars($this->pObj->path) . '<br />';
                    $content .= '<br /><input type="submit" name="indexSave" value="Overwrite" />';
                } else {
                    $content .= '<br /><strong>Save default indexer setup for this folder:</strong><br />' . htmlspecialchars($this->pObj->path) . '<br />';
                    $content .= '<br /><input type="submit" name="indexSave" value="Save" />';
                }
                $content .= '<input type="hidden" name="setuptype" value="folder">';
                $content .= $this->pObj->doc->spacer(10);
                if (t3lib_extMgm::isLoaded('dam_cron')) {
                    $content .= $this->pObj->doc->section('CRON', '', 0, 1);
                    $path = $this->cronUploadsFolder;
                    $filename = $this->makeSetupfilenameForPath($this->pObj->path);
                    $content .= '</form>';
                    $content .= $this->pObj->getFormTag();
                    $content .= '<input type="hidden" name="setuptype" value="cron">';
                    $content .= '<br /><strong>Save setup as cron indexer setup:</strong><br />' . htmlspecialchars($path) . '<br />
								<input type="text" size="25" maxlength="25" name="filename" value="' . htmlspecialchars($filename) . '"> .xml';
                    $content .= '<br /><input type="submit" name="indexSave" value="Save" />';
                    $files = t3lib_div::getFilesInDir($path, 'xml', 0, 1);
                    $out = '';
                    foreach ($files as $file) {
                        $out .= htmlspecialchars($file) . '<br />';
                    }
                    if ($out) {
                        $content .= '<br /><br /><strong>Existing cron setups:</strong><div style="border-top:1px solid grey;border-bottom:1px solid grey;">' . $out . '</div><br />';
                    }
                }
                $extraSetup = '';
                $this->index->setPath($this->pObj->path);
                $this->index->setOptionsFromRules();
                $this->index->setPID($this->pObj->defaultPid);
                $this->index->enableMetaCollect(TRUE);
                $setup = $this->index->serializeSetup($extraSetup, false);
                $content .= $this->pObj->doc->section('Set Options', t3lib_div::view_array($setup), 0, 1);
                $content .= '<br /><textarea style="width:100%" rows="15">' . htmlspecialchars(str_replace('{', "{\n", $this->index->serializeSetup($extraSetup))) . '</textarea>';
                break;
            case 'indexSave':
                $content .= $this->pObj->getPathInfoHeaderBar($this->pObj->pathInfo, FALSE, $this->cmdIcons);
                $content .= $this->pObj->doc->spacer(10);
                $content .= '<div style="width:100%;text-align:right;">' . $this->pObj->btn_back() . '</div>';
                if (t3lib_div::_GP('setuptype') === 'folder') {
                    $path = tx_dam::path_makeAbsolute($this->pObj->path);
                    $filename = $path . '.indexing.setup.xml';
                } else {
                    $path = $this->cronUploadsFolder;
                    $filename = t3lib_div::_GP('filename');
                    $filename = $filename ? $filename : $this->makeSetupfilenameForPath($this->pObj->path);
                    $filename = $path . $filename . '.xml';
                }
                $this->index->setPath($this->pObj->path);
                $this->index->setOptionsFromRules();
                $this->index->setPID($this->pObj->defaultPid);
                $this->index->enableMetaCollect(TRUE);
                $setup = $this->index->serializeSetup($extraSetup);
                if ($handle = fopen($filename, 'wb')) {
                    if (fwrite($handle, $setup)) {
                        $content .= 'Setup written to file<br />' . htmlspecialchars($filename);
                    } else {
                        $content .= 'Can\'t write to file ' . htmlspecialchars($filename);
                    }
                    fclose($handle);
                    t3lib_div::fixPermissions($filename);
                } else {
                    $content .= 'Can\'t open file ' . htmlspecialchars($filename);
                }
                break;
            case 'cron_info':
                $content .= $this->pObj->getHeaderBar('', implode('&nbsp;', $this->cmdIcons));
                $content .= $this->pObj->doc->spacer(10);
                $files = t3lib_div::getFilesInDir($this->cronUploadsFolder, 'xml', 1, 1);
                $out = '';
                foreach ($files as $file) {
                    if ($file == $filename) {
                        $out .= '<strong>' . htmlspecialchars($file) . '</strong><br />';
                    } else {
                        $out .= htmlspecialchars($file) . '<br />';
                    }
                }
                $filename = $filename ? $filename : $file;
                if ($out) {
                    $content .= '<br /><br /><strong>Existing setups:</strong><div style="border-top:1px solid grey;border-bottom:1px solid grey;">' . $out . '</div><br />';
                } else {
                    $content .= '<br /><br /><strong>No setups available.</strong><br />';
                }
                if ($out) {
                    $cronscript = t3lib_extMgm::extPath('dam_cron') . 'cron/dam_indexer.php';
                    $content .= '<br /><strong>Call indexer script example:</strong><br />';
                    $content .= '<span style="font-family: monaco,courier,monospace;">/usr/bin/php ' . htmlspecialchars($cronscript) . ' --setup=' . htmlspecialchars($filename) . '</span>';
                }
                break;
            case 'doIndexing':
                break;
            default:
                $content .= parent::moduleContent($header, $description, $lastStep);
        }
        return $content;
    }
 /**
  * Returns a new tab for the browse links wizard
  * Returns the 'media' tab to the RTE link browser
  *
  * @param	string		current link selector action
  * @return	string		a tab for the selected link action
  */
 public function getTab($linkSelectorAction)
 {
     $content = '';
     if ($this->isEnabled) {
         switch ($linkSelectorAction) {
             case 'media':
                 $this->initMediaBrowser();
                 $content .= $this->addAttributesForm();
                 $content .= $this->browserRenderObj->part_rte_linkfile();
                 $this->addDAMStylesAndJSArrays();
                 break;
             case 'media_upload':
                 $this->initMediaBrowser();
                 $content .= $this->browserRenderObj->dam_upload($this->allowedFileTypes);
                 $content .= $this->browserRenderObj->damSC->getOptions();
                 $content .= '<br /><br />';
                 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
                     $path = tx_dam::path_makeAbsolute($this->browserRenderObj->damSC->path);
                     if (!$path or !@is_dir($path)) {
                         $path = $this->fileProcessor->findTempFolder() . '/';
                         // The closest TEMP-path is found
                     }
                     $content .= $this->browserRenderObj->createFolder($path);
                     $content .= '<br />';
                 }
                 $this->addDAMStylesAndJSArrays();
                 break;
         }
     }
     return $content;
 }
 /**
  * Returns a new tab to the RTE media browser
  *
  * @param	string		current action
  * @return	string		a tab for the selected action
  */
 public function getTab($act)
 {
     global $BE_USER, $LANG;
     $content = '';
     switch ($act) {
         case 'media_magic':
             $this->initMediaBrowser();
             $this->browserRenderObj->addDisplayOptions();
             $content .= $this->browserRenderObj->dam_select($this->allowedFileTypes);
             $content .= $this->browserRenderObj->damSC->getOptions();
             $content .= $this->invokingObject->getMsgBox($this->invokingObject->getHelpMessage('magic'));
             $this->addDAMStylesAndJSArrays();
             break;
         case 'media_plain':
             $this->initMediaBrowser();
             $this->browserRenderObj->addDisplayOptions();
             $content .= $this->browserRenderObj->dam_select($this->allowedFileTypes);
             $content .= $this->browserRenderObj->damSC->getOptions();
             $content .= $this->invokingObject->getMsgBox($this->invokingObject->getHelpMessage('plain'));
             $this->addDAMStylesAndJSArrays();
             break;
         case 'media_dragdrop':
             $this->initMediaBrowser();
             $this->browserRenderObj->addDisplayOptions();
             $content .= $this->browserRenderObj->dam_select($this->allowedFileTypes);
             $content .= $this->browserRenderObj->damSC->getOptions();
             $content .= $this->invokingObject->getMsgBox($LANG->getLL('findDragDrop'));
             $this->addDAMStylesAndJSArrays();
             break;
         case 'media_upload':
             $this->initMediaBrowser();
             $content .= $this->browserRenderObj->dam_upload($this->allowedFileTypes);
             $content .= $this->browserRenderObj->damSC->getOptions();
             $content .= '<br /><br />';
             if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
                 $path = tx_dam::path_makeAbsolute($this->browserRenderObj->damSC->path);
                 if (!$path or !@is_dir($path)) {
                     $path = $this->fileProcessor->findTempFolder() . '/';
                     // The closest TEMP-path is found
                 }
                 $content .= $this->browserRenderObj->createFolder($path);
                 $content .= '<br />';
             }
             $this->addDAMStylesAndJSArrays();
             break;
     }
     return $content;
 }
    /**
     * 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;
    }
 /**
  * tx_dam::path_makeXXX()
  */
 public function test_path_makeXXX()
 {
     $GLOBALS['T3_VAR']['ext']['dam']['pathInfoCache'] = array();
     $filepath = $this->getFixtureFilename();
     $filename = tx_dam::file_basename($filepath);
     $testpath = tx_dam::file_dirname($filepath);
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     self::assertEquals($path, $testpath, 'File path differs: ' . $path . ' (' . $testpath . ')');
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     self::assertEquals($path, $testpath, 'Path differs: ' . $path . ' (' . $testpath . ')');
     $testpath = '/aaa/../bbb/./ccc//ddd';
     $testpathClean = '/bbb/ccc/ddd/';
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     self::assertEquals($path, $testpathClean, 'Path differs: ' . $path . ' (' . $testpathClean . ')');
     $testpath = PATH_site . '/aaa/../bbb/./ccc//ddd';
     $testpathClean = 'bbb/ccc/ddd/';
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     self::assertEquals($path, $testpathClean, 'Path differs: ' . $path . ' (' . $testpathClean . ')');
 }
 /**
  * Creates a browsable file/folder list
  *
  * @param	string		$path Path
  * @param	string		$folderParam Parameter name to be used for folder browsing
  * @return	string		Output
  */
 function getBrowseableFolderList($path, $folderParam = 'SET[tx_dam_folder]')
 {
     global $TYPO3_CONF_VARS;
     $content = '';
     require_once PATH_txdam . 'lib/class.tx_dam_filebrowser.php';
     $filelist = t3lib_div::makeInstance('tx_dam_filebrowser');
     $filelist->SOBE =& $this;
     $filelist->paramName['setFolder'] = $folderParam;
     $content .= $filelist->getBrowseableFolderList(tx_dam::path_makeAbsolute($path));
     return $content;
 }
예제 #17
0
    function addFlashUploader()
    {
        $this->doc->JScodeArray['flashUploader'] = '
			if (top.TYPO3.FileUploadWindow.isFlashAvailable()) {
				document.observe("dom:loaded", function() {
						// monitor the button
					$("button-upload").observe("click", initFlashUploader);

					function initFlashUploader(event) {
							// set the page specific options for the flashUploader
						var flashUploadOptions = {
							uploadURL:           top.TS.PATH_typo3 + "ajax.php",
							uploadFileSizeLimit: "' . t3lib_div::getMaxUploadFileSize() . '",
							uploadFileTypes: {
								allow:  "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow'] . '",
								deny: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny'] . '"
							},
							uploadFilePostName:  "upload_1",
							uploadPostParams: {
								"file[upload][1][target]": "' . tx_dam::path_makeAbsolute($this->path) . '",
								"file[upload][1][data]": 1,
								"file[upload][1][charset]": "utf-8",
								"ajaxID": "TYPO3_tcefile::process"
							}
						};

							// get the flashUploaderWindow instance from the parent frame
						var flashUploader = top.TYPO3.FileUploadWindow.getInstance(flashUploadOptions);
						// add an additional function inside the container to show the checkbox option
						var infoComponent = new top.Ext.Panel({
							autoEl: { tag: "div" },
							height: "auto",
							bodyBorder: false,
							border: false,
							hideBorders: true,
							cls: "t3-upload-window-infopanel",
							id: "t3-upload-window-infopanel-addition",
							html: \'<label for="overrideExistingFilesCheckbox"><input id="overrideExistingFilesCheckbox" type="checkbox" onclick="setFlashPostOptionOverwriteExistingFiles(this);" />\' + top.String.format(top.TYPO3.LLL.fileUpload.infoComponentOverrideFiles) + \'</label>\'
						});
						flashUploader.add(infoComponent);

							// do a reload of this frame once all uploads are done
						flashUploader.on("totalcomplete", function() {
							window.location.reload();
						});

							// this is the callback function that delivers the additional post parameter to the flash application
						top.setFlashPostOptionOverwriteExistingFiles = function(checkbox) {
							var uploader = top.TYPO3.getInstance("FileUploadWindow");
							if (uploader.isVisible()) {
								uploader.swf.addPostParam("overwriteExistingFiles", (checkbox.checked == true ? 1 : 0));
							}
						};

						event.stop();
					};
				});
			}
		';
    }
 static function createThumbnails10($damFiles, $size, $addAttr)
 {
     require_once tx_rnbase_util_Extensions::extPath('dam') . 'lib/class.tx_dam.php';
     $files = $damFiles['rows'];
     $ret = array();
     foreach ($files as $key => $info) {
         $thumbScript = $GLOBALS['BACK_PATH'] . 'thumbs.php';
         $filepath = tx_dam::path_makeAbsolute($info['file_path']);
         $ret[] = Tx_Rnbase_Backend_Utility::getThumbNail($thumbScript, $filepath . $info['file_name'], $addAttr, $size);
     }
     return $ret;
 }
 /**
  * Returns an array with file/dir items + an array with the sorted items
  *
  * @param	string		Path (absolute) to read
  * @param	mixed		$allowTypes List or array of allow directory entry types: file, dir, link. Empty is all kinds of stuff.
  * @return	void
  */
 function read($path, $allowTypes = 'file')
 {
     $allowTypes = is_array($allowTypes) ? $allowTypes : t3lib_div::trimExplode(',', $allowTypes, true);
     if ($path) {
         $tempArray = array();
         $path = tx_dam::path_makeAbsolute($path);
         if (is_object($d = @dir($path))) {
             while ($entry = $d->read()) {
                 $filepath = $path . $entry;
                 // check for allow file types: eg. file, dir, link
                 if (@file_exists($filepath) && (!$allowTypes || in_array($type = filetype($filepath), $allowTypes))) {
                     // if filename matches exclude list this file is skipped
                     foreach ($this->excludeRegex as $expr) {
                         if (preg_match($expr, $entry)) {
                             continue 2;
                         }
                     }
                     // if filename don't matches allow list this file is skipped
                     foreach ($this->allowRegex as $expr) {
                         if (!preg_match($expr, $entry)) {
                             continue 2;
                         }
                     }
                     if ($type === 'file') {
                         $fileInfo = tx_dam::file_compileInfo($filepath);
                         if (is_array($meta = tx_dam::meta_getDataForFile($fileInfo))) {
                             // the newer stat data will be merged over the stored meta data
                             $fileInfo = array_merge($meta, $fileInfo);
                         } else {
                             $mimeType = tx_dam::file_getType($filepath);
                             $fileInfo = array_merge($fileInfo, $mimeType);
                         }
                         if (count($this->excludeFileTypes) and in_array($fileInfo['file_type'], $this->excludeFileTypes)) {
                             continue;
                         }
                         if (count($this->allowFileTypes) and !in_array($fileInfo['file_type'], $this->allowFileTypes)) {
                             continue;
                         }
                         if ($this->enableAutoIndexing) {
                             $this->autoIndex($fileInfo);
                         }
                     } elseif ($type === 'dir' or $type === 'link') {
                         $fileInfo = tx_dam::path_compileInfo($filepath);
                     }
                     // the file is valid so we add it to the list
                     $this->entries[] = $fileInfo;
                     $this->countBytes += $fileInfo['file_size'];
                 }
             }
             $d->close();
             $this->sort();
             $this->rewind();
         }
     }
 }
 /**
  * Returns an array with the names of files in a specific path
  *
  * @param	string		Path to start to collect files
  * @param	boolean		Go recursive into subfolder?
  * @param	array		Array of file paths
  * @param	integer		$maxDirs limit the read directories
  * @return	array		Array of file paths
  */
 function getFilesInDir($path, $recursive = FALSE, $filearray = array(), $maxDirs = 999)
 {
     if ($path) {
         $path = preg_replace('#/$#', '', $path);
         $absPath = tx_dam::path_makeAbsolute($path);
         $d = @dir($absPath);
         if (is_object($d)) {
             while ($entry = $d->read()) {
                 if (@is_file($absPath . '/' . $entry)) {
                     if (!preg_match('/^\\./', $entry) && !preg_match('/~$/', $entry)) {
                         $key = md5($absPath . '/' . $entry);
                         $filearray[$key] = $absPath . '/' . $entry;
                     }
                 } elseif ($recursive && $maxDirs > 0 && @is_dir($absPath . '/' . $entry) && !preg_match('/^\\./', $entry) && $entry != 'CVS') {
                     $filearray = $this->getFilesInDir($path . '/' . $entry, true, $filearray, $maxDirs - 1);
                 }
             }
             $d->close();
         }
     }
     return $filearray;
 }
 /**
  * Wraps filenames in links which opens them in a window IF they are in web-path.
  *
  * @param	string		$title String to be wrapped in link
  * @param	string		$pathInfo
  * @return	string		A tag
  */
 function linkWrapFile($title, $pathInfo)
 {
     if (!$this->enableFilePopup) {
         return htmlspecialchars($title);
     }
     if (!isset($pathInfo['file_path_absolute'])) {
         $pathInfo['file_path_absolute'] = tx_dam::path_makeAbsolute($pathInfo['file_path']);
     }
     if (t3lib_div::isFirstPartOfStr($pathInfo['file_path_absolute'], PATH_site)) {
         $href = tx_dam::file_relativeSitePath($pathInfo['file_path_absolute'] . $pathInfo['file_name']);
         $aOnClick = "return top.openUrlInWindow('" . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $href . "','WebFile');";
         if (!strcmp($title, strip_tags($title))) {
             return '<a href="' . htmlspecialchars($href) . '" onclick="' . htmlspecialchars($aOnClick) . '" title="' . htmlspecialchars($title) . '">' . htmlspecialchars($title) . '</a>';
         } else {
             return '<a href="' . htmlspecialchars($href) . '" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
         }
     }
     return $title;
 }