/**
  * Get the stored settings from MOD_SETTINGS and set them in $this->storedSettings
  *
  * @return	void
  */
 function initStorage($uidList = '', $pidList = '')
 {
     $pidList = $pidList ? $GLOBALS['TYPO3_DB']->cleanIntList($pidList) : '';
     $pidList = $pidList ? $pidList : tx_dam_db::getPid();
     $pidList = $this->table . '.pid IN (' . $pidList . ')';
     $uidList = $uidList ? $GLOBALS['TYPO3_DB']->cleanIntList($uidList) : '';
     $uidList = $uidList ? ' AND ' . $this->table . '.uid IN (' . $uidList . ')' : '';
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->table, $pidList . $uidList . ' AND ' . tx_dam_db::deleteClause($this->table), '', $this->table . '.title');
     $this->storedSettings = array();
     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         #$row['definition'] = t3lib_div::xml2array($row['definition']);
         $this->storedSettings[$row['uid']] = $row;
     }
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     $this->storedSettings = $this->cleanupStorageArray($this->storedSettings);
 }
Пример #2
0
    /**
     * Main function of the module. Write the content to $this->content
     *
     * @return	void
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TYPO3_CONF_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS;
        $this->extObjCmdInit();
        //
        // Initialize the template object
        //
        if (!is_object($this->doc)) {
            $this->doc = t3lib_div::makeInstance('template');
            $this->doc->backPath = $BACK_PATH;
            $this->doc->setModuleTemplate(t3lib_extMgm::extRelPath('dam') . 'res/templates/mod_cmd.html');
            $this->doc->styleSheetFile2 = t3lib_extMgm::extRelPath('dam') . 'res/css/stylesheet.css';
            $this->doc->docType = 'xhtml_trans';
        }
        //
        // check access
        //
        $access = false;
        $this->actionAccess = $this->extObjAccess();
        if ($this->actionAccess) {
            $this->accessDenied = array();
            if ($this->file) {
                foreach ($this->file as $key => $filename) {
                    if (!tx_dam::access_checkFile($filename, $this->extObj->passthroughMissingFiles)) {
                        $this->accessDenied['file'][] = tx_dam::file_normalizePath($filename);
                        unset($this->file[$key]);
                    }
                }
                if ($this->file) {
                    $access = true;
                }
            } elseif ($this->folder) {
                foreach ($this->folder as $key => $path) {
                    if (!tx_dam::access_checkPath($path)) {
                        $this->accessDenied['folder'][] = tx_dam::path_makeRelative($path);
                        unset($this->folder[$key]);
                    }
                }
                if ($this->folder) {
                    $access = true;
                }
            } elseif ($this->record and $this->defaultPid) {
                foreach ($this->record as $table => $uidList) {
                    $where = array();
                    $where['enableFields'] = tx_dam_db::deleteClause($table);
                    $where['pidList'] = $table . '.pid IN (' . $this->defaultPid . ')';
                    $where['uid'] = $table . '.uid IN (' . implode(',', $uidList) . ')';
                    $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $table, implode(' AND ', $where), '', '', '', 'uid');
                    if ($rows) {
                        $this->record[$table] = array_keys($rows);
                    } else {
                        $this->accessDenied['record'][$table] = $uidList;
                        unset($this->record[$table]);
                    }
                }
                if ($this->record) {
                    $access = true;
                }
            }
        }
        //
        // Main
        //
        if ($access) {
            //
            // Output page header
            //
            $this->actionTarget = $this->actionTarget ? $this->actionTarget : t3lib_div::linkThisScript(array('returnUrl' => $this->returnUrl, 'redirect' => $this->redirect));
            if ($this->CMD == 'tx_dam_cmd_foldernew') {
                $this->actionTarget = $BACK_PATH . 'tce_file.php';
            }
            $this->doc->form = '<form action="' . htmlspecialchars($this->actionTarget) . '" method="post" name="editform" enctype="' . $TYPO3_CONF_VARS['SYS']['form_enctype'] . '">';
            // JavaScript
            $this->doc->JScodeArray['jumpToUrl'] = '
				var script_ended = 0;
				var changed = 0;

				function jumpToUrl(URL)	{
					document.location.href = URL;
				}

				function jumpBack()	{
					document.location.href = "' . htmlspecialchars($this->redirect) . '";
				}

				function navFrameReload() {
					if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav)	{
						// top.content.nav_frame.refresh_nav();
					}
				}
				';
            $this->doc->postCode .= $this->doc->wrapScriptTags('
				script_ended = 1;');
            $this->makePageHeader();
            //
            // Call submodule function
            //
            $this->extObjContent();
            $this->markers['CONTENT'] = $this->content;
        } else {
            // If no access
            $this->makePageHeader();
            $accessDeniedInfo = array();
            if ($this->actionAccess) {
                foreach ($this->accessDenied as $type => $items) {
                    if ($items) {
                        $accessDeniedInfo[] = '<h4>' . $LANG->getLL($type, 1) . '</h4>';
                        foreach ($items as $item) {
                            $accessDeniedInfo[] = '<p>' . htmlspecialchars($item) . '</p>';
                        }
                    }
                }
            } else {
                $accessDeniedInfo[] = '<p>' . sprintf($LANG->getLL('messageCmdDenied', 1), $this->pageTitle) . '</p>';
            }
            // file do not exist ...
            $this->content .= $this->accessDeniedMessageBox(implode('', $accessDeniedInfo));
        }
    }
Пример #3
0
 /**
  * Returns a part of a WHERE clause which will filter out records with start/end times or hidden/fe_groups fields set to values that should de-select them according to the current time, preview settings or user login. Definitely a frontend function.
  * THIS IS A VERY IMPORTANT FUNCTION: Basically you must add the output from this function for EVERY select query you create for selecting records of tables in your own applications - thus they will always be filtered according to the "enablefields" configured in TCA
  * Simply calls t3lib_pageSelect::enableFields() BUT will send the show_hidden flag along! This means this function will work in conjunction with the preview facilities of the frontend engine/Admin Panel.
  *
  * In comparison to t3lib_pageSelect::enableFields() this function don't prepend with ' AND '.
  *
  * @param	string		$table The table for which to get the where clause
  * @param	string		$addOperator The table for which to get the where clause
  * @param	string		$mode TYPO3_MODE to be used: 'FE', 'BE'. Constant TYPO3_MODE is default. Special mode 'NONE' returns nothing, to not restrict queries.
  * @return	string		The part of the where clause on the form " AND NOT [fieldname] AND ...". Eg. " AND hidden=0 AND starttime < 123345567"
  * @see t3lib_pageSelect::enableFields()
  */
 function enableFields($table, $addOperator = '', $mode = TYPO3_MODE)
 {
     $enableFields = '';
     if ($mode === 'NONE') {
         return '';
     } elseif ($mode === 'FE' and is_object($GLOBALS['TSFE'])) {
         $enableFields = preg_replace('#^ AND #', '', $GLOBALS['TSFE']->sys_page->enableFields($table));
     } else {
         $enableFields = tx_dam_db::deleteClause($table);
     }
     return ($enableFields and $addOperator) ? ' ' . $addOperator . ' ' . $enableFields : $enableFields;
 }
Пример #4
0
    /**
     * Main function of the module. Write the content to $this->content
     *
     * @return	void
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TYPO3_CONF_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS;
        $access = false;
        $this->errorMessages = array();
        $this->media = NULL;
        $editorList = array();
        $this->actionTarget = $this->actionTarget ? $this->actionTarget : t3lib_div::linkThisScript(array('returnUrl' => $this->returnUrl, 'redirect' => $this->redirect));
        //
        // get media that should be edited
        //
        if ($this->file) {
            foreach ($this->file as $key => $filename) {
                if (!tx_dam::access_checkFile($filename)) {
                    $this->errorMessages['file'][] = tx_dam::file_normalizePath($filename);
                    unset($this->file[$key]);
                }
            }
            if ($this->file) {
                $this->media = tx_dam::media_getForFile($this->file[0]);
                if (!$this->media->isAvailable) {
                    $this->errorMessages['file'][] = $this->media->filename;
                    unset($this->media);
                }
            }
        } elseif ($this->record and $this->defaultPid) {
            foreach ($this->record as $table => $uidList) {
                $where = array();
                $where['enableFields'] = tx_dam_db::deleteClause($table);
                $where['pidList'] = $table . '.pid IN (' . $this->defaultPid . ')';
                $where['uid'] = $table . '.uid IN (' . implode(',', $uidList) . ')';
                $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $table, implode(' AND ', $where), '', '', '', 'uid');
                if ($rows) {
                    $this->record[$table] = array_keys($rows);
                } else {
                    $this->errorMessages['record'][$table] = $uidList;
                    unset($this->record[$table]);
                }
            }
            if ($this->record['tx_dam']) {
                // reduce passed files/records to just one item
                // it will be done here because later editors might want to get multiple resources (eg. blending images) so we keep the infrastructure
                reset($this->record['tx_dam']);
                // just one uid
                $uid = current($this->record['tx_dam']);
                $this->media = tx_dam::media_getByUid($uid);
                if (!$this->media->isAvailable) {
                    $this->errorMessages['file'][] = $this->media->filename;
                    unset($this->media);
                }
            }
        }
        $access = ($this->hasExtObjDefined() or is_object($this->media));
        //
        // Main
        //
        // a valid file is selected
        if ($access) {
            $success = false;
            // an editor is not already defined by CMD
            if (!$this->hasExtObjDefined() and is_object($this->media)) {
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['editorClasses'])) {
                    foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['editorClasses'] as $idName => $classRessource) {
                        if (is_object($editorList[$idName] = t3lib_div::getUserObj($classRessource))) {
                            if (!$editorList[$idName]->isValid($this->media)) {
                                unset($editorList[$idName]);
                            }
                        }
                    }
                }
                if (!count($editorList)) {
                    // error message no valid editor found for file
                    $this->errorMessages['error'][] = sprintf($LANG->getLL('messageNoEditorFound', 1), $this->media->filename);
                } elseif (count($editorList) == 1) {
                    // activate extObj
                    $this->errorMessages['error'][] = 'TODO: activate extObj';
                    if (!$this->CMD) {
                        $this->CMD = key($editorList);
                    }
                    $this->handleExternalFunctionValue('function', $this->CMD);
                }
                // selection of multiple editors is below
            }
            // an editor is selected
            if ($this->hasExtObjDefined()) {
                $this->checkExtObj();
                // Checking for first level external objects
                $this->checkSubExtObj();
                // Checking second level external objects
            }
            if (is_object($this->extObj)) {
                $this->extObjCmdInit();
                //
                // Initialize the template object
                //
                if (!is_object($this->doc)) {
                    $this->doc = t3lib_div::makeInstance('template');
                    $this->doc->backPath = $BACK_PATH;
                    $this->doc->setModuleTemplate(t3lib_extMgm::extRelPath('dam') . 'res/templates/mod_edit.html');
                    $this->doc->styleSheetFile2 = t3lib_extMgm::extRelPath('dam') . 'res/css/stylesheet.css';
                    $this->doc->docType = 'xhtml_trans';
                }
                //
                // check access
                //
                $this->actionAccess = $this->extObjAccess();
                if ($access and $this->actionAccess) {
                    $success = true;
                    //
                    // Output page header
                    //
                    $this->doc->form = '<form action="' . htmlspecialchars($this->actionTarget) . '" method="post" name="editform" enctype="' . $TYPO3_CONF_VARS['SYS']['form_enctype'] . '">';
                    $this->doc->form .= '<input type="hidden" name="CMD" value="' . $this->CMD . '" />';
                    // JavaScript
                    $this->doc->JScodeArray['jumpToUrl'] = '
						var script_ended = 0;
						var changed = 0;
		
						function jumpToUrl(URL)	{
							document.location.href = URL;
						}
		
						function jumpBack()	{
							document.location.href = "' . htmlspecialchars($this->redirect) . '";
						}
		
						function navFrameReload() {
							if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav)	{
								// top.content.nav_frame.refresh_nav();
							}
						}
						';
                    $this->doc->postCode .= $this->doc->wrapScriptTags('
						script_ended = 1;');
                    $this->makePageHeader();
                    //
                    // Call submodule function
                    //
                    $this->extObjContent();
                    $this->markers['CONTENT'] = $this->content;
                } else {
                    $access = false;
                    $this->errorMessages['error'][] = sprintf($LANG->getLL('messageCmdDenied', true), $this->pageTitle);
                }
            }
        }
        if (!is_object($this->doc)) {
            $this->doc = t3lib_div::makeInstance('template');
            $this->doc->backPath = $BACK_PATH;
            $this->doc->setModuleTemplate(t3lib_extMgm::extRelPath('dam') . 'res/templates/mod_edit.html');
            $this->doc->styleSheetFile2 = t3lib_extMgm::extRelPath('dam') . 'res/css/stylesheet.css';
            $this->doc->docType = 'xhtml_trans';
        }
        // provide a selector when multiple editors are available
        if ($access and count($editorList) > 1) {
            $this->makePageHeader();
            $messages = array();
            $messages[] = '<div style="margin: 1em 3em 2em 3em;">' . sprintf($LANG->getLL('messageAvailableEditors', true), $this->media->filename) . '</div>';
            $messages[] = '<div style="padding-left:3em; display:table-cell">';
            foreach ($editorList as $idName => $editorObj) {
                $button = $this->button($editorObj->getIcon(), $editorObj->getLabel(), $editorObj->getDescription(), $this->actionTarget . '&CMD=' . $idName, '', ' style="display:block;"');
                $messages[] = '<div style="margin-bottom:0.8em">' . $button . '</div>';
            }
            $messages[] = '</div>';
            $this->content .= $GLOBALS['SOBE']->getMessageBox($this->pageTitle, $messages, $this->buttonBack(0), 2);
            $success = true;
        }
        if (!$access or !$success) {
            // If no access
            $this->makePageHeader();
            $messages = array();
            foreach ($this->errorMessages as $type => $items) {
                if ($items) {
                    if ($type !== 'error' and $headerText = $LANG->getLL($type, 1)) {
                        $messages[] = '<h4>' . $LANG->getLL($type, true) . '</h4>';
                    }
                    foreach ($items as $item) {
                        $messages[] = '<p>' . htmlspecialchars($item) . '</p>';
                    }
                }
            }
            // file do not exist ...
            if (!$access) {
                $this->content .= $this->accessDeniedMessageBox(implode('', $messages));
            } else {
                $this->content .= $this->errorMessageBox(implode('', $messages));
            }
        }
    }