Exemplo n.º 1
0
 /**
  * Hooks to the felogin extension to provide additional code for FE login
  *
  * @return array 0 => onSubmit function, 1 => extra fields and required files
  */
 public function loginFormHook()
 {
     $result = array(0 => '', 1 => '');
     if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['loginSecurityLevel']) === 'rsa') {
         $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
         if ($backend) {
             $result[0] = 'tx_rsaauth_feencrypt(this);';
             $javascriptPath = \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('rsaauth') . 'resources/';
             $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js', 'rsaauth_min.js');
             foreach ($files as $file) {
                 $result[1] .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>';
             }
             // Generate a new key pair
             $keyPair = $backend->createNewKeyPair();
             // Save private key
             $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage();
             /** @var $storage \TYPO3\CMS\Rsaauth\Storage\AbstractStorage */
             $storage->put($keyPair->getPrivateKey());
             // Add RSA hidden fields
             $result[1] .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />';
             $result[1] .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />';
         }
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Provides form code and javascript for the user setup.
  *
  * @param array $parameters Parameters to the script
  * @param \TYPO3\CMS\Backend\Controller\LoginController $userSetupObject Calling object: user setup module
  * @return string The code for the user setup
  */
 public function getLoginScripts(array $parameters, \TYPO3\CMS\Setup\Controller\SetupModuleController $userSetupObject)
 {
     $content = '';
     if ($this->isRsaAvailable()) {
         // If we can get the backend, we can proceed
         $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
         $javascriptPath = \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('rsaauth') . 'resources/';
         $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js', 'rsaauth_min.js');
         $content = '';
         foreach ($files as $file) {
             $content .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>';
         }
         // Generate a new key pair
         $keyPair = $backend->createNewKeyPair();
         // Save private key
         $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage();
         /** @var $storage \TYPO3\CMS\Rsaauth\Storage\AbstractStorage */
         $storage->put($keyPair->getPrivateKey());
         // Add form tag
         $form = '<form action="' . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('user_setup') . '" method="post" name="usersetup" enctype="application/x-www-form-urlencoded" onsubmit="tx_rsaauth_encryptUserSetup();">';
         // Add RSA hidden fields
         $form .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />';
         $form .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />';
         $userSetupObject->doc->form = $form;
     }
     return $content;
 }
Exemplo n.º 3
0
 /**
  * Initializes the Module
  *
  * @return void
  */
 public function __construct()
 {
     parent::init();
     // Initialize document
     $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
     $this->doc->setModuleTemplate(\TYPO3\CMS\Core\Extension\ExtensionManager::extPath('taskcenter') . 'res/mod_template.html');
     $this->doc->backPath = $GLOBALS['BACK_PATH'];
     $this->doc->getPageRenderer()->loadScriptaculous('effects,dragdrop');
     $this->doc->addStyleSheet('tx_taskcenter', '../' . \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('taskcenter') . 'res/mod_styles.css');
 }
Exemplo n.º 4
0
 /**
  * Provides form code for the superchallenged authentication.
  *
  * @param array $params Parameters to the script
  * @param \TYPO3\CMS\Backend\Controller\LoginController $pObj Calling object
  * @return string The code for the login form
  */
 public function getLoginScripts(array $params, \TYPO3\CMS\Backend\Controller\LoginController &$pObj)
 {
     $content = '';
     if ($pObj->loginSecurityLevel == 'rsa') {
         $javascriptPath = \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('rsaauth') . 'resources/';
         $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js', 'rsaauth_min.js');
         $content = '';
         foreach ($files as $file) {
             $content .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>';
         }
     }
     return $content;
 }
Exemplo n.º 5
0
 /**
  * Returns the HTML code for the locking symbol.
  * NOTICE: Requires a call to ->getPathFromPageId() first in order to work (done in ->makeInfo() by calling that first)
  *
  * @param 	integer		Page id for which to find answer
  * @return 	string		<img> tag if access is limited.
  * @todo Define visibility
  */
 public function makeAccessIndication($id)
 {
     if (is_array($this->fe_groups_required[$id]) && count($this->fe_groups_required[$id])) {
         return '<img src="' . \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('indexed_search') . 'pi/res/locked.gif" width="12" height="15" vspace="5" title="' . sprintf($this->pi_getLL('res_memberGroups', '', 1), implode(',', array_unique($this->fe_groups_required[$id]))) . '" alt="" />';
     }
 }
Exemplo n.º 6
0
 /**
  * Returns the reference to a 'resource' in TypoScript.
  * This could be from the filesystem if '/' is found in the value $fileFromSetup, else from the resource-list
  *
  * @param string $fileFromSetup TypoScript "resource" data type value.
  * @return string Resulting filename, if any.
  * @todo Define visibility
  */
 public function getFileName($fileFromSetup)
 {
     $file = trim($fileFromSetup);
     if (!$file) {
         return;
     } elseif (strstr($file, '../')) {
         if ($this->tt_track) {
             $GLOBALS['TT']->setTSlogMessage('File path "' . $file . '" contained illegal string "../"!', 3);
         }
         return;
     }
     // Cache
     $hash = md5($file);
     if (isset($this->fileCache[$hash])) {
         return $this->fileCache[$hash];
     }
     if (!strcmp(substr($file, 0, 4), 'EXT:')) {
         $newFile = '';
         list($extKey, $script) = explode('/', substr($file, 4), 2);
         if ($extKey && \TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded($extKey)) {
             $extPath = \TYPO3\CMS\Core\Extension\ExtensionManager::extPath($extKey);
             $newFile = substr($extPath, strlen(PATH_site)) . $script;
         }
         if (!@is_file(PATH_site . $newFile)) {
             if ($this->tt_track) {
                 $GLOBALS['TT']->setTSlogMessage('Extension media file "' . $newFile . '" was not found!', 3);
             }
             return;
         } else {
             $file = $newFile;
         }
     }
     if (parse_url($file) !== FALSE) {
         return $file;
     }
     // Find
     if (strpos($file, '/') !== FALSE) {
         // If the file is in the media/ folder but it doesn't exist,
         // it is assumed that it's in the tslib folder
         if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($file, 'media/') && !is_file($this->getFileName_backPath . $file)) {
             $file = \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('cms') . 'tslib/' . $file;
         }
         if (is_file($this->getFileName_backPath . $file)) {
             $outFile = $file;
             $fileInfo = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($outFile);
             $OK = 0;
             foreach ($this->allowedPaths as $val) {
                 if (substr($fileInfo['path'], 0, strlen($val)) == $val) {
                     $OK = 1;
                     break;
                 }
             }
             if ($OK) {
                 $this->fileCache[$hash] = $outFile;
                 return $outFile;
             } elseif ($this->tt_track) {
                 $GLOBALS['TT']->setTSlogMessage('"' . $file . '" was not located in the allowed paths: (' . implode(',', $this->allowedPaths) . ')', 3);
             }
         } elseif ($this->tt_track) {
             $GLOBALS['TT']->setTSlogMessage('"' . $this->getFileName_backPath . $file . '" is not a file (non-uploads/.. resource, did not exist).', 3);
         }
     }
 }
Exemplo n.º 7
0
    /**
     * Putting things together, in particular the JavaScript code needed for the DHTML menu.
     *
     * @return string Empty string! (Since $GLOBALS['TSFE']->divSection is set with the <div>-sections used in the menu)
     * @todo Define visibility
     */
    public function extProc_finish()
    {
        $bHeight = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['bottomHeight'] ? $this->mconf['bottomHeight'] : 100, 0, 3000);
        $bottomContent = $this->mconf['bottomContent'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($this->mconf['bottomContent'], $this->mconf['bottomContent.'], '/GMENU_FOLDOUT/.bottomContent') : '';
        $adjustTopHeights = intval($this->mconf['adjustItemsH']);
        $adjustSubHeights = intval($this->mconf['adjustSubItemsH']);
        $mWidth = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['menuWidth'] ? $this->mconf['menuWidth'] : 170, 0, 3000);
        $mHeight = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['menuHeight'] ? $this->mconf['menuHeight'] : 400, 0, 3000);
        $insertmColor = $this->mconf['menuBackColor'] ? 'BACKGROUND-COLOR: ' . $this->mconf['menuBackColor'] . '; layer-background-color: ' . $this->mconf['menuBackColor'] : '';
        $insertBottomColor = $this->mconf['bottomBackColor'] ? 'BACKGROUND-COLOR: ' . $this->mconf['bottomBackColor'] . '; layer-background-color: ' . $this->mconf['bottomBackColor'] : '';
        $menuOffset = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->mconf['menuOffset'] . ',');
        $subOffset = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->mconf['subMenuOffset'] . ',');
        $GLOBALS['TSFE']->additionalHeaderData['gmenu_layer_shared'] = '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('statictemplates') . 'media/scripts/jsfunc.layermenu.js"></script>';
        $GLOBALS['TSFE']->additionalHeaderData['gmenu_foldout'] = '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('statictemplates') . 'media/scripts/jsfunc.foldout.js"></script>';
        $GLOBALS['TSFE']->additionalHeaderData[] .= '
<style type="text/css">
	/*<![CDATA[*/
#divCont {
	Z-INDEX: 1; LEFT: ' . $menuOffset[0] . 'px; VISIBILITY: hidden; WIDTH: ' . $mWidth . 'px; POSITION: absolute; TOP: ' . $menuOffset[1] . 'px; HEIGHT: ' . $mHeight . 'px
}
.clTop {
	Z-INDEX: 1; WIDTH: ' . $mWidth . 'px; POSITION: absolute; ' . $insertmColor . '
}
.clSub {
	Z-INDEX: 1; LEFT: ' . $subOffset[0] . 'px; WIDTH: ' . $mWidth . 'px; POSITION: absolute; TOP: ' . $subOffset[1] . 'px
}
.bottomLayer {
	Z-INDEX: 1; WIDTH: ' . $mWidth . 'px; CLIP: rect(0px ' . $mWidth . 'px ' . $bHeight . 'px 0px); POSITION: absolute; HEIGHT: ' . $bHeight . 'px; ' . $insertBottomColor . '
}
	/*]]>*/
</style>
<script type="text/javascript">
/*<![CDATA[*/
<!--
GFV_foldNumber=' . $this->WMmenuItems . ';          //How many toplinks do you have?
GFV_foldTimer=' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['foldTimer'] ? $this->mconf['foldTimer'] : 40, 1, 3000) . ';          //The timeout in the animation, these are milliseconds.
GFV_foldSpeed=' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['foldSpeed'], 1, 100) . ';           //How many steps in an animation?
GFV_stayFolded=' . ($this->mconf['stayFolded'] ? 'true' : 'false') . ';      //Stay open when you click a new toplink?
GFV_foldImg=' . $this->WMimagesFlag . ';             //Do you want images (if not set to 0 and remove the images from the body)?
GFV_currentFold=null;
GFV_foldStep1=null;
GFV_foldStep2=null;
GFV_step=0;
GFV_active=false;	 //Don\'t change this one.
GFV_adjustTopHeights = ' . $adjustTopHeights . ';
GFV_adjustSubHeights = ' . $adjustSubHeights . ';
if (bw.opera) {
	GFV_scrX= innerWidth;
	GFV_scrY= innerHeight;
}

//This is the default image.
//Remember to change the actual images in the page as well, but remember to keep the name of the image.
var GFV_unImg=new Image();
GFV_unImg.src="' . $GLOBALS['TSFE']->absRefPrefix . $this->WMarrowNO[3] . '";

var GFV_exImg=new Image();          //Making an image variable...
GFV_exImg.src="' . $GLOBALS['TSFE']->absRefPrefix . $this->WMarrowACT[3] . '";   //...this is the source of the image that it changes to when the menu expands.

//-->
/*]]>*/
</script>
';
        $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']['GF_resizeForOpera()'] = 'GF_resizeForOpera();';
        $GLOBALS['TSFE']->JSeventFuncCalls['onload']['GMENU_FOLDOUT'] = 'if(bw.bw) {GF_initFoldout();' . $this->WM_activeOnLoad . '}';
        $GLOBALS['TSFE']->divSection .= '
<div id="divCont"><!-- These are the contents of the foldoutmenu. -->
		' . $this->tmpl->wrap($this->WMresult, $this->mconf['wrap']) . '
<div class="bottomLayer" id="divTop' . ($this->WMmenuItems + 1) . '">
	<div class="clSub" id="divSub' . ($this->WMmenuItems + 1) . '"><!-- This is a cover layer, it should always be the last one, and does NOT count in your number of toplinks! --><!-- So if this one is divTop7, the GFV_foldNumber variable should be set to 6 --><!-- This layer covers up the last sub, so if the last sub gets too big, increase this layers size in the stylesheet. --><!-- There are tables with width="100%" around the toplinks, to force NS4 to use the real width specified for the toplinks in the stylesheet. -->
	</div>' . $this->tmpl->wrap($bottomContent, $this->WMtableWrap) . '
</div>
</div><!-- Here ends the foldoutmenu. -->
		';
        return '';
    }
Exemplo n.º 8
0
 /**
  * Returns the path to the plugin directory, if any
  *
  * @return 	string		the full path to the plugin directory
  */
 public function getPathToPluginDirectory()
 {
     return $this->relativePathToPluginDirectory ? $this->htmlAreaRTE->httpTypo3Path . \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath($this->extensionKey) . $this->relativePathToPluginDirectory : '';
 }
Exemplo n.º 9
0
 public function getFullFileName($filename)
 {
     if (substr($filename, 0, 4) == 'EXT:') {
         // extension
         list($extKey, $local) = explode('/', substr($filename, 4), 2);
         $newFilename = '';
         if (strcmp($extKey, '') && \TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded($extKey) && strcmp($local, '')) {
             $newFilename = ($this->is_FE() || $this->isFrontendEditActive() ? \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath($extKey) : $this->backPath . \TYPO3\CMS\Core\Extension\ExtensionManager::extRelPath($extKey)) . $local;
         }
     } elseif (substr($filename, 0, 1) != '/') {
         $newFilename = ($this->is_FE() || $this->isFrontendEditActive() ? '' : $this->backPath . '../') . $filename;
     } else {
         $newFilename = ($this->is_FE() || $this->isFrontendEditActive() ? '' : $this->backPath . '../') . substr($filename, 1);
     }
     return \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath($newFilename);
 }
Exemplo n.º 10
0
    /**
     * Putting things together, in particular the JavaScript code needed
     * for the DHTML menu.
     *
     * @return mixed Returns the value of a call to the parent function, parent::extProc_finish();
     * @todo Define visibility
     */
    public function extProc_finish()
    {
        $dirL = $this->mconf['directionLeft'] ? '-GL_getObj(id).width' : '';
        $dirU = $this->mconf['directionUp'] ? '-GL_getObj(id).height' : '';
        $parentLayerId = end($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']);
        $DoTop = array();
        $GLV_menuOn = array();
        $relCode = array();
        $relFlag = 0;
        if ($this->mconf['relativeToParentLayer'] && $parentLayerId) {
            $relCode['X'] .= 'GLV_curLayerX["' . $parentLayerId . '"]+';
            $relCode['Y'] .= 'GLV_curLayerY["' . $parentLayerId . '"]+';
            if ($this->mconf['relativeToParentLayer.']['addWidth']) {
                $relCode['X'] .= 'GLV_curLayerWidth["' . $parentLayerId . '"]+';
            }
            if ($this->mconf['relativeToParentLayer.']['addHeight']) {
                $relCode['Y'] .= 'GLV_curLayerHeight["' . $parentLayerId . '"]+';
            }
        }
        if ($this->mconf['relativeToTriggerItem']) {
            $DoTop[] = '
		var parentObject = GL_getObj(GLV_menuXY[WMid][id][2]);
		var TI_width = parentObject.width;
		var TI_height = parentObject.height;
		var anchorObj = GL_getObj(GLV_menuXY[WMid][id][3]);
		var TI_x = anchorObj.x;
		var TI_y = anchorObj.y;
			';
            $relCode['X'] .= 'TI_x+';
            $relCode['Y'] .= 'TI_y+';
            if ($this->mconf['relativeToTriggerItem.']['addWidth']) {
                $relCode['X'] .= 'TI_width+';
            }
            if ($this->mconf['relativeToTriggerItem.']['addHeight']) {
                $relCode['Y'] .= 'TI_height+';
            }
            $relFlag = 1;
        }
        if ($relFlag) {
            $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . intval($this->mconf['leftOffset']) . $dirL . ')+"px";';
            $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top =  (' . $relCode['Y'] . intval($this->mconf['topOffset']) . $dirU . ')+"px";';
        } else {
            // X position (y is fixed)
            if (!strcmp($this->mconf['lockPosition'], 'x')) {
                $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . 'GLV_menuXY["' . $this->WMid . '"][id][0]-(' . intval($this->mconf['xPosOffset']) . ')' . $dirL . ')+"px";';
                if ($this->isSetIntval($this->mconf['topOffset'])) {
                    $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (' . $relCode['Y'] . intval($this->mconf['topOffset']) . $dirU . ')+"px";';
                }
            } elseif ($this->isSetIntval($this->mconf['xPosOffset'])) {
                $GLV_menuOn[] = $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (GLV_x-(' . intval($this->mconf['xPosOffset']) . ')' . $dirL . ')+"px";';
                if ($this->isSetIntval($this->mconf['topOffset'])) {
                    $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (' . $relCode['Y'] . intval($this->mconf['topOffset']) . $dirU . ')+"px";';
                }
            }
            // Y position	(x is fixed)
            if (!strcmp($this->mconf['lockPosition'], 'y')) {
                $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (' . $relCode['Y'] . 'GLV_menuXY["' . $this->WMid . '"][id][1]-(' . intval($this->mconf['yPosOffset']) . ')' . $dirU . ')+"px";';
                if ($this->isSetIntval($this->mconf['leftOffset'])) {
                    $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . intval($this->mconf['leftOffset']) . $dirL . ')+"px";';
                }
            } elseif ($this->isSetIntval($this->mconf['yPosOffset'])) {
                $GLV_menuOn[] = $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].top = (GLV_y-(' . intval($this->mconf['yPosOffset']) . ')' . $dirU . ')+"px";';
                if ($this->isSetIntval($this->mconf['leftOffset'])) {
                    $DoTop[] = 'GLV_menuOn["' . $this->WMid . '"].left = (' . $relCode['X'] . intval($this->mconf['leftOffset']) . $dirL . ')+"px";';
                }
            }
        }
        // BordersWithIn:
        $DoTop[] = $this->extCalcBorderWithin('left', $this->WMbordersWithin[0]);
        $DoTop[] = $this->extCalcBorderWithin('top', $this->WMbordersWithin[1]);
        $DoTop[] = $this->extCalcBorderWithin('right', $this->WMbordersWithin[2]);
        $DoTop[] = $this->extCalcBorderWithin('bottom', $this->WMbordersWithin[3]);
        $DoTop[] = $this->extCalcBorderWithin('left', $this->WMbordersWithin[4]);
        $DoTop[] = $this->extCalcBorderWithin('top', $this->WMbordersWithin[5]);
        if ($this->mconf['freezeMouseover'] && !$this->mconf['freezeMouseover.']['alwaysKeep']) {
            $this->WMhideCode .= '
GL' . $this->WMid . '_out("");';
        }
        $TEST = '';
        if (count($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'])) {
            foreach ($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] as $mIdStr) {
                $this->WMhideCode .= '
GL_hideAll("' . $mIdStr . '");';
                $this->WMrestoreScript .= '
GL_restoreMenu("' . $mIdStr . '");';
                $this->WMresetSubMenus .= '
if (!GLV_doReset["' . $mIdStr . '"] && GLV_currentLayer["' . $mIdStr . '"]!=null)	resetSubMenu=0;';
            }
        }
        // IESelectFix - Adds IFRAME tag to HTML, Hides IFRAME layer below menu
        if ($this->mconf['ieSelectFix']) {
            $this->WMhideCode .= '
	GL_iframer(\'' . $this->WMid . '\',\'\',false);';
            $this->divLayers['iframe'] = '<iframe id="Iframe' . $this->WMid . '" scrolling="no" frameborder="0" style="position:absolute; top:0px; left:0px; background-color:transparent; layer-background-color:transparent; display:none;"></iframe>';
        }
        $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array_merge($this->WMtempStore, $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']);
        $GLOBALS['TSFE']->additionalHeaderData['gmenu_layer_shared'] = '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('statictemplates') . 'media/scripts/jsfunc.layermenu.js"></script>';
        $GLOBALS['TSFE']->JSCode .= '

GLV_curLayerWidth["' . $this->WMid . '"]=0;
GLV_curLayerHeight["' . $this->WMid . '"]=0;
GLV_curLayerX["' . $this->WMid . '"]=0;
GLV_curLayerY["' . $this->WMid . '"]=0;
GLV_menuOn["' . $this->WMid . '"] = null;
GLV_gap["' . $this->WMid . '"]=' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['hideMenuWhenNotOver'], 0, 600) . ';
GLV_currentLayer["' . $this->WMid . '"] = null;
GLV_currentROitem["' . $this->WMid . '"] = null;
GLV_hasBeenOver["' . $this->WMid . '"]=0;
GLV_doReset["' . $this->WMid . '"]=false;
GLV_lastKey["' . $this->WMid . '"] = "' . $this->WMlastKey . '";
GLV_onlyOnLoad["' . $this->WMid . '"] = ' . ($this->WMonlyOnLoad ? 1 : 0) . ';
GLV_dontHideOnMouseUp["' . $this->WMid . '"] = ' . ($this->mconf['dontHideOnMouseUp'] ? 1 : 0) . ';
GLV_dontFollowMouse["' . $this->WMid . '"] = ' . ($this->mconf['dontFollowMouse'] ? 1 : 0) . ';
GLV_date = new Date();
GLV_timeout["' . $this->WMid . '"] = GLV_date.getTime();
GLV_timeoutRef["' . $this->WMid . '"] = ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['hideMenuTimer'], 0, 20000) . ';
GLV_menuXY["' . $this->WMid . '"] = new Array();
' . implode(LF, $this->WMxyArray) . '
' . $this->WMrestoreVars;
        if ($this->mconf['freezeMouseover']) {
            $GLOBALS['TSFE']->JSCode .= '
// Alternative rollover/out functions for use with GMENU_LAYER
function GL' . $this->WMid . '_over(mitm_id) {
	GL' . $this->WMid . '_out("");	// removes any old roll over state of an item. Needed for alwaysKeep and Opera browsers.
	switch(mitm_id) {
' . implode(LF, $this->VMmouseoverActions) . '
	}
	GLV_currentROitem["' . $this->WMid . '"]=mitm_id;
}
function GL' . $this->WMid . '_out(mitm_id) {
	if (!mitm_id)	mitm_id=GLV_currentROitem["' . $this->WMid . '"];
	switch(mitm_id) {
' . implode(LF, $this->VMmouseoutActions) . '
	}
}
';
        }
        $GLOBALS['TSFE']->JSCode .= '
function GL' . $this->WMid . '_getMouse(e) {
	if (GLV_menuOn["' . $this->WMid . '"]!=null && !GLV_dontFollowMouse["' . $this->WMid . '"]){
' . implode(LF, $GLV_menuOn) . '
	}
	GL_mouseMoveEvaluate("' . $this->WMid . '");
}
function GL' . $this->WMid . '_hideCode() {
' . $this->WMhideCode . '
}
function GL' . $this->WMid . '_doTop(WMid,id) {
' . trim(implode(LF, $DoTop)) . '
}
function GL' . $this->WMid . '_restoreMenu() {
' . $this->WMrestoreScript . '
}
function GL' . $this->WMid . '_resetSubMenus() {
	var resetSubMenu=1;
' . $this->WMresetSubMenus . '
	return resetSubMenu;
}

GLV_timeout_pointers[GLV_timeout_count] = "' . $this->WMid . '";
GLV_timeout_count++;

';
        $GLOBALS['TSFE']->JSeventFuncCalls['onload']['GL_initLayers()'] = 'GL_initLayers();';
        $GLOBALS['TSFE']->JSeventFuncCalls['onload'][$this->WMid] = 'GL_restoreMenu("' . $this->WMid . '");';
        // Should be called BEFORE any of the 'local' getMouse functions!
        // is put inside in a try catch block to avoid JS errors in IE
        $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']['GL_getMouse(e)'] = 'try{GL_getMouse(e);}catch(ex){};';
        $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove'][$this->WMid] = 'try{GL' . $this->WMid . '_getMouse(e);}catch(ex){};';
        $GLOBALS['TSFE']->JSeventFuncCalls['onmouseup'][$this->WMid] = 'GL_mouseUp(\'' . $this->WMid . '\',e);';
        $GLOBALS['TSFE']->divSection .= implode($this->divLayers, LF) . LF;
        return parent::extProc_finish();
    }
Exemplo n.º 11
0
 /**
  * Calculates the path to the TYPO3 directory from the current directory
  *
  * @return string
  */
 protected function getBackPath()
 {
     $extPath = \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('openid');
     $segmentCount = count(explode('/', $extPath));
     $path = str_pad('', $segmentCount * 3, '../') . TYPO3_mainDir;
     return $path;
 }
    /**
     * Main class of Spell Checker plugin for Typo3 CMS
     *
     * @return 	string		content produced by the plugin
     * @todo Define visibility
     */
    public function main()
    {
        $this->csConvObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter');
        // Setting start time
        $time_start = microtime(TRUE);
        $this->pspell_is_available = in_array('pspell', get_loaded_extensions());
        $this->AspellDirectory = trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['AspellDirectory']) ? trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['AspellDirectory']) : '/usr/bin/aspell';
        // Setting command mode if requested and available
        $this->forceCommandMode = trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['forceCommandMode']) ? trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['forceCommandMode']) : 0;
        if (!$this->pspell_is_available || $this->forceCommandMode) {
            $AspellVersionString = explode('Aspell', shell_exec($this->AspellDirectory . ' -v'));
            $AspellVersion = substr($AspellVersionString[1], 0, 4);
            if (doubleval($AspellVersion) < doubleval('0.5') && (!$this->pspell_is_available || $this->forceCommandMode)) {
                echo 'Configuration problem: Aspell version ' . $AspellVersion . ' too old. Spell checking cannot be performed in command mode.';
            }
            $this->defaultAspellEncoding = trim(shell_exec($this->AspellDirectory . ' config encoding'));
        }
        // Setting the list of dictionaries
        $dictionaryList = shell_exec($this->AspellDirectory . ' dump dicts');
        $dictionaryList = implode(',', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $dictionaryList, 1));
        $dictionaryArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $dictionaryList, 1);
        $restrictToDictionaries = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('restrictToDictionaries');
        if ($restrictToDictionaries) {
            $dictionaryArray = array_intersect($dictionaryArray, \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $restrictToDictionaries, 1));
        }
        if (!count($dictionaryArray)) {
            $dictionaryArray[] = 'en';
        }
        $this->dictionary = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('dictionary');
        $defaultDictionary = $this->dictionary;
        if (!$defaultDictionary || !in_array($defaultDictionary, $dictionaryArray)) {
            $defaultDictionary = 'en';
        }
        uasort($dictionaryArray, 'strcoll');
        $dictionaryList = implode(',', $dictionaryArray);
        // Setting the dictionary
        if (empty($this->dictionary) || !in_array($this->dictionary, $dictionaryArray)) {
            $this->dictionary = 'en';
        }
        // Setting the pspell suggestion mode
        $this->pspellMode = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('pspell_mode') ? \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('pspell_mode') : $this->pspellMode;
        // Now sanitize $this->pspellMode
        $this->pspellMode = \TYPO3\CMS\Core\Utility\GeneralUtility::inList('ultra,fast,normal,bad-spellers', $this->pspellMode) ? $this->pspellMode : 'normal';
        switch ($this->pspellMode) {
            case 'ultra':
            case 'fast':
                $pspellModeFlag = PSPELL_FAST;
                break;
            case 'bad-spellers':
                $pspellModeFlag = PSPELL_BAD_SPELLERS;
                break;
            case 'normal':
            default:
                $pspellModeFlag = PSPELL_NORMAL;
                break;
        }
        // Setting the charset
        if (\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('pspell_charset')) {
            $this->charset = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('pspell_charset'));
        }
        if (strtolower($this->charset) == 'iso-8859-1') {
            $this->parserCharset = strtolower($this->charset);
        }
        // In some configurations, Aspell uses 'iso8859-1' instead of 'iso-8859-1'
        $this->aspellEncoding = $this->parserCharset;
        if ($this->parserCharset == 'iso-8859-1' && strstr($this->defaultAspellEncoding, '8859-1')) {
            $this->aspellEncoding = $this->defaultAspellEncoding;
        }
        // However, we are going to work only in the parser charset
        if ($this->pspell_is_available && !$this->forceCommandMode) {
            $this->pspell_link = pspell_new($this->dictionary, '', '', $this->parserCharset, $pspellModeFlag);
        }
        // Setting the path to main dictionary
        $this->setMainDictionaryPath();
        // Setting the path to user personal dictionary, if any
        $this->setPersonalDictionaryPath();
        $this->fixPersonalDictionaryCharacterSet();
        $cmd = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('cmd');
        if ($cmd == 'learn') {
            // Only availble for BE_USERS, die silently if someone has gotten here by accident
            if (TYPO3_MODE !== 'BE' || !is_object($GLOBALS['BE_USER'])) {
                die('');
            }
            // Updating the personal word list
            $to_p_dict = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('to_p_dict');
            $to_p_dict = $to_p_dict ? $to_p_dict : array();
            $to_r_list = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('to_r_list');
            $to_r_list = $to_r_list ? $to_r_list : array();
            header('Content-Type: text/plain; charset=' . strtoupper($this->parserCharset));
            header('Pragma: no-cache');
            if ($to_p_dict || $to_r_list) {
                $tmpFileName = \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam($this->filePrefix);
                $filehandle = fopen($tmpFileName, 'wb');
                if ($filehandle) {
                    // Get the character set of the main dictionary
                    // We need to convert the input into the character set of the main dictionary
                    $mainDictionaryCharacterSet = $this->getMainDictionaryCharacterSet();
                    // Write the personal words addition commands to the temporary file
                    foreach ($to_p_dict as $personal_word) {
                        $cmd = '&' . $this->csConvObj->conv($personal_word, $this->parserCharset, $mainDictionaryCharacterSet) . LF;
                        fwrite($filehandle, $cmd, strlen($cmd));
                    }
                    // Write the replacent pairs addition commands to the temporary file
                    foreach ($to_r_list as $replace_pair) {
                        $cmd = '$$ra ' . $this->csConvObj->conv($replace_pair[0], $this->parserCharset, $mainDictionaryCharacterSet) . ' , ' . $this->csConvObj->conv($replace_pair[1], $this->parserCharset, $mainDictionaryCharacterSet) . LF;
                        fwrite($filehandle, $cmd, strlen($cmd));
                    }
                    $cmd = '#' . LF;
                    fwrite($filehandle, $cmd, strlen($cmd));
                    // Assemble the Aspell command
                    $AspellCommand = (TYPO3_OS === 'WIN' ? 'type ' : 'cat ') . escapeshellarg($tmpFileName) . ' | ' . $this->AspellDirectory . ' -a --mode=none' . ($this->personalDictionaryPath ? ' --home-dir=' . escapeshellarg($this->personalDictionaryPath) : '') . ' --lang=' . escapeshellarg($this->dictionary) . ' --encoding=' . escapeshellarg($mainDictionaryCharacterSet) . ' 2>&1';
                    $AspellAnswer = shell_exec($AspellCommand);
                    // Close and delete the temporary file
                    fclose($filehandle);
                    \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($tmpFileName);
                    echo 'Personal word list was updated.';
                } else {
                    \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog('SpellChecker tempfile open error: ' . $tmpFileName, $this->extKey, \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR);
                    echo 'SpellChecker tempfile open error.';
                }
            } else {
                echo 'Nothing to add to the personal word list.';
            }
            flush();
            die;
        } else {
            // Check spelling content
            // Initialize output
            $this->result = '<?xml version="1.0" encoding="' . $this->parserCharset . '"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . substr($this->dictionary, 0, 2) . '" lang="' . substr($this->dictionary, 0, 2) . '">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=' . $this->parserCharset . '" />
<link rel="stylesheet" type="text/css" media="all" href="' . (TYPO3_MODE == 'BE' ? '../' : '') . \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath($this->extKey) . '/htmlarea/plugins/SpellChecker/spell-check-style.css" />
<script type="text/javascript">
/*<![CDATA[*/
<!--
';
            // Getting the input content
            $content = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('content');
            // Parsing the input HTML
            $parser = xml_parser_create(strtoupper($this->parserCharset));
            xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
            xml_set_object($parser, $this);
            if (!xml_set_element_handler($parser, 'startHandler', 'endHandler')) {
                echo 'Bad xml handler setting';
            }
            if (!xml_set_character_data_handler($parser, 'collectDataHandler')) {
                echo 'Bad xml handler setting';
            }
            if (!xml_set_default_handler($parser, 'defaultHandler')) {
                echo 'Bad xml handler setting';
            }
            if (!xml_parse($parser, '<?xml version="1.0" encoding="' . $this->parserCharset . '"?><spellchecker> ' . preg_replace('/&nbsp;/' . ($this->parserCharset == 'utf-8' ? 'u' : ''), ' ', $content) . ' </spellchecker>')) {
                echo 'Bad parsing';
            }
            if (xml_get_error_code($parser)) {
                throw new \UnexpectedException('Line ' . xml_get_current_line_number($parser) . ': ' . xml_error_string(xml_get_error_code($parser)), 1294585788);
            }
            xml_parser_free($parser);
            if ($this->pspell_is_available && !$this->forceCommandMode) {
                pspell_clear_session($this->pspell_link);
            }
            $this->result .= 'var suggestedWords = {' . $this->suggestedWords . '};
var dictionaries = "' . $dictionaryList . '";
var selectedDictionary = "' . $this->dictionary . '";
';
            // Calculating parsing and spell checkting time
            $time = number_format(microtime(TRUE) - $time_start, 2, ',', ' ');
            // Insert spellcheck info
            $this->result .= 'var spellcheckInfo = { "Total words":"' . $this->wordCount . '","Misspelled words":"' . sizeof($this->misspelled) . '","Total suggestions":"' . $this->suggestionCount . '","Total words suggested":"' . $this->suggestedWordCount . '","Spelling checked in":"' . $time . '" };
// -->
/*]]>*/
</script>
</head>
';
            $this->result .= '<body onload="window.parent.RTEarea[\'' . \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('editorId') . '\'].editor.getPlugin(\'SpellChecker\').spellCheckComplete();">';
            $this->result .= preg_replace('/' . preg_quote('<?xml') . '.*' . preg_quote('?>') . '[' . preg_quote(LF . CR . chr(32)) . ']*/' . ($this->parserCharset == 'utf-8' ? 'u' : ''), '', $this->text);
            $this->result .= '<div style="display: none;">' . $dictionaries . '</div>';
            // Closing
            $this->result .= '
</body></html>';
            // Outputting
            header('Content-Type: text/html; charset=' . strtoupper($this->parserCharset));
            echo $this->result;
        }
    }
Exemplo n.º 13
0
 /**
  * This prints a single result row, including a recursive call for subrows.
  *
  * @param array $row Search result row
  * @param integer $headerOnly 1=Display only header (for sub-rows!), 2=nothing at all
  * @return string HTML code
  */
 protected function compileSingleResultRow($row, $headerOnly = 0)
 {
     $specRowConf = $this->getSpecialConfigForResultRow($row);
     $resultData = $row;
     $resultData['headerOnly'] = $headerOnly;
     $resultData['CSSsuffix'] = $specRowConf['CSSsuffix'] ? '-' . $specRowConf['CSSsuffix'] : '';
     if ($this->multiplePagesType($row['item_type'])) {
         $dat = unserialize($row['cHashParams']);
         $pp = explode('-', $dat['key']);
         if ($pp[0] != $pp[1]) {
             $resultData['titleaddition'] = ', ' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.page', 'indexed_search') . ' ' . $dat['key'];
         } else {
             $resultData['titleaddition'] = ', ' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.pages', 'indexed_search') . ' ' . $pp[0];
         }
     }
     $title = $resultData['item_title'] . $resultData['titleaddition'];
     $title = htmlspecialchars($title);
     // If external media, link to the media-file instead.
     if ($row['item_type']) {
         if ($row['show_resume']) {
             // Can link directly.
             $targetAttribute = '';
             if ($GLOBALS['TSFE']->config['config']['fileTarget']) {
                 $targetAttribute = ' target="' . htmlspecialchars($GLOBALS['TSFE']->config['config']['fileTarget']) . '"';
             }
             $title = '<a href="' . htmlspecialchars($row['data_filename']) . '"' . $targetAttribute . '>' . $title . '</a>';
         } else {
             // Suspicious, so linking to page instead...
             $copiedRow = $row;
             unset($copiedRow['cHashParams']);
             $title = $this->linkPage($row['page_id'], $title, $copiedRow);
         }
     } else {
         // Else the page:
         // Prepare search words for markup in content:
         if ($this->settings['forwardSearchWordsInResultLink']) {
             $markUpSwParams = array('no_cache' => 1);
             foreach ($this->sWArr as $d) {
                 $markUpSwParams['sword_list'][] = $d['sword'];
             }
         } else {
             $markUpSwParams = array();
         }
         $title = $this->linkPage($row['data_page_id'], $title, $row, $markUpSwParams);
     }
     $resultData['title'] = $title;
     $resultData['icon'] = $this->makeItemTypeIcon($row['item_type'], '', $specRowConf);
     $resultData['rating'] = $this->makeRating($row);
     $resultData['description'] = $this->makeDescription($row, $this->searchData['extResume'] && !$headerOnly ? 0 : 1);
     $resultData['language'] = $this->makeLanguageIndication($row);
     $resultData['size'] = \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($row['item_size']);
     $resultData['created'] = $row['item_crdate'];
     $resultData['modified'] = $row['item_mtime'];
     $pI = parse_url($row['data_filename']);
     if ($pI['scheme']) {
         $targetAttribute = '';
         if ($GLOBALS['TSFE']->config['config']['fileTarget']) {
             $targetAttribute = ' target="' . htmlspecialchars($GLOBALS['TSFE']->config['config']['fileTarget']) . '"';
         }
         $resultData['path'] = '<a href="' . htmlspecialchars($row['data_filename']) . '"' . $targetAttribute . '>' . htmlspecialchars($row['data_filename']) . '</a>';
     } else {
         $pathId = $row['data_page_id'] ? $row['data_page_id'] : $row['page_id'];
         $pathMP = $row['data_page_id'] ? $row['data_page_mp'] : '';
         $pathStr = htmlspecialchars($this->getPathFromPageId($pathId, $pathMP));
         $resultData['path'] = $this->linkPage($pathId, $pathStr, array('cHashParams' => $row['cHashParams'], 'data_page_type' => $row['data_page_type'], 'data_page_mp' => $pathMP, 'sys_language_uid' => $row['sys_language_uid']));
         // check if the access is restricted
         if (is_array($this->requiredFrontendUsergroups[$id]) && count($this->requiredFrontendUsergroups[$id])) {
             $resultData['access'] = '<img src="' . \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('indexed_search') . 'pi/res/locked.gif" width="12" height="15" vspace="5" title="' . sprintf(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.memberGroups', 'indexed_search'), implode(',', array_unique($this->requiredFrontendUsergroups[$id]))) . '" alt="" />';
         }
     }
     // If there are subrows (eg. subpages in a PDF-file or if a duplicate page
     // is selected due to user-login (phash_grouping))
     if (is_array($row['_sub'])) {
         $resultData['subresults'] = array();
         if ($this->multiplePagesType($row['item_type'])) {
             $resultData['subresults']['header'] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.otherMatching', 'indexed_search');
             foreach ($row['_sub'] as $subRow) {
                 $resultData['subresults']['items'][] = $this->compileSingleResultRow($subRow, 1);
             }
         } else {
             $resultData['subresults']['header'] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.otherMatching', 'indexed_search');
             $resultData['subresults']['info'] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('result.otherPageAsWell', 'indexed_search');
         }
     }
     return $resultData;
 }
Exemplo n.º 14
0
    /**
     * Draws the RTE as an iframe
     *
     * @param 	object		Reference to parent object, which is an instance of the TCEforms.
     * @param 	string		The table name
     * @param 	string		The field name
     * @param 	array		The current row from which field is being rendered
     * @param 	array		Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
     * @param 	array		"special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
     * @param 	array		Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
     * @param 	string		Record "type" field value.
     * @param 	string		Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
     * @param 	integer		PID value of record (true parent page id)
     * @return 	string		HTML code for RTE!
     * @todo Define visibility
     */
    public function drawRTE(&$parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
    {
        global $TSFE, $TYPO3_CONF_VARS, $TYPO3_DB;
        $this->TCEform = $parentObject;
        $this->client = $this->clientInfo();
        $this->typoVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
        /* =======================================
         * INIT THE EDITOR-SETTINGS
         * =======================================
         */
        // Get the path to this extension:
        $this->extHttpPath = \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath($this->ID);
        // Get the site URL
        $this->siteURL = $GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '';
        // Get the host URL
        $this->hostURL = '';
        // Element ID + pid
        $this->elementId = $PA['itemFormElName'];
        $this->elementParts[0] = $table;
        $this->elementParts[1] = $row['uid'];
        $this->tscPID = $thePidValue;
        $this->thePid = $thePidValue;
        // Record "type" field value:
        $this->typeVal = $RTEtypeVal;
        // TCA "type" value for record
        // RTE configuration
        $pageTSConfig = $TSFE->getPagesTSconfig();
        if (is_array($pageTSConfig) && is_array($pageTSConfig['RTE.'])) {
            $this->RTEsetup = $pageTSConfig['RTE.'];
        }
        if (is_array($thisConfig) && !empty($thisConfig)) {
            $this->thisConfig = $thisConfig;
        } elseif (is_array($this->RTEsetup['default.']) && is_array($this->RTEsetup['default.']['FE.'])) {
            $this->thisConfig = $this->RTEsetup['default.']['FE.'];
        }
        // Special configuration (line) and default extras:
        $this->specConf = $specConf;
        if ($this->thisConfig['forceHTTPS']) {
            $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
            $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
            $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
        }
        // Register RTE windows:
        $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
        $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
        $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId)) . '_' . strval($this->TCEform->RTEcounter);
        /* =======================================
         * LANGUAGES & CHARACTER SETS
         * =======================================
         */
        // Language
        $TSFE->initLLvars();
        $this->language = $TSFE->lang;
        $this->LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile('EXT:' . $this->ID . '/locallang.xml', $this->language);
        if ($this->language == 'default' || !$this->language) {
            $this->language = 'en';
        }
        $this->contentLanguageUid = $row['sys_language_uid'] > 0 ? $row['sys_language_uid'] : 0;
        if (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('static_info_tables')) {
            if ($this->contentLanguageUid) {
                $tableA = 'sys_language';
                $tableB = 'static_languages';
                $languagesUidsList = $this->contentLanguageUid;
                $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
                $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
                $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
                $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableA);
                $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableA);
                $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                    $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
                    $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                }
            } else {
                $this->contentISOLanguage = $GLOBALS['TSFE']->sys_language_isocode ? $GLOBALS['TSFE']->sys_language_isocode : 'en';
                $selectFields = 'lg_iso_2, lg_typo3';
                $tableAB = 'static_languages';
                $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
                $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                    $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                }
            }
        }
        $this->contentISOLanguage = $this->contentISOLanguage ? $this->contentISOLanguage : ($GLOBALS['TSFE']->sys_language_isocode ? $GLOBALS['TSFE']->sys_language_isocode : 'en');
        $this->contentTypo3Language = $this->contentTypo3Language ? $this->contentTypo3Language : $GLOBALS['TSFE']->lang;
        if ($this->contentTypo3Language == 'default') {
            $this->contentTypo3Language = 'en';
        }
        // Character set
        $this->charset = $TSFE->renderCharset;
        $this->OutputCharset = $TSFE->metaCharset ? $TSFE->metaCharset : $TSFE->renderCharset;
        // Set the charset of the content
        $this->contentCharset = $TSFE->csConvObj->charSetArray[$this->contentTypo3Language];
        $this->contentCharset = $this->contentCharset ? $this->contentCharset : 'utf-8';
        $this->contentCharset = trim($TSFE->config['config']['metaCharset']) ? trim($TSFE->config['config']['metaCharset']) : $this->contentCharset;
        /* =======================================
         * TOOLBAR CONFIGURATION
         * =======================================
         */
        $this->initializeToolbarConfiguration();
        /* =======================================
         * SET STYLES
         * =======================================
         */
        $width = 460 + ($this->TCEform->docLarge ? 150 : 0);
        if (isset($this->thisConfig['RTEWidthOverride'])) {
            if (strstr($this->thisConfig['RTEWidthOverride'], '%')) {
                if ($this->client['browser'] != 'msie') {
                    $width = intval($this->thisConfig['RTEWidthOverride']) > 0 ? $this->thisConfig['RTEWidthOverride'] : '100%';
                }
            } else {
                $width = intval($this->thisConfig['RTEWidthOverride']) > 0 ? intval($this->thisConfig['RTEWidthOverride']) : $width;
            }
        }
        $RTEWidth = strstr($width, '%') ? $width : $width . 'px';
        $editorWrapWidth = strstr($width, '%') ? $width : $width + 2 . 'px';
        $height = 380;
        $RTEHeightOverride = intval($this->thisConfig['RTEHeightOverride']);
        $height = $RTEHeightOverride > 0 ? $RTEHeightOverride : $height;
        $RTEHeight = $height . 'px';
        $editorWrapHeight = $height + 2 . 'px';
        $this->RTEWrapStyle = $this->RTEWrapStyle ? $this->RTEWrapStyle : ($this->RTEdivStyle ? $this->RTEdivStyle : 'height:' . $editorWrapHeight . '; width:' . $editorWrapWidth . ';');
        $this->RTEdivStyle = $this->RTEdivStyle ? $this->RTEdivStyle : 'position:relative; left:0px; top:0px; height:' . $RTEHeight . '; width:' . $RTEWidth . '; border: 1px solid black;';
        /* =======================================
         * LOAD JS, CSS and more
         * =======================================
         */
        $this->pageRenderer = $this->getPageRenderer();
        // Preloading the pageStyle and including RTE skin stylesheets
        $this->addPageStyle();
        $this->addSkin();
        // Register RTE in JS
        $this->TCEform->additionalJS_post[] = $this->wrapCDATA($this->registerRTEinJS($this->TCEform->RTEcounter, '', '', '', $textAreaId));
        // Set the save option for the RTE:
        $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
        // Loading ExtJs JavaScript files and inline code, if not configured in TS setup
        if (!$GLOBALS['TSFE']->isINTincScript() || !is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.'])) {
            $this->pageRenderer->loadExtJs();
            $this->pageRenderer->enableExtJSQuickTips();
        }
        $this->pageRenderer->addCssFile($this->siteURL . 't3lib/js/extjs/ux/resize.css');
        $this->pageRenderer->addJsFile($this->getFullFileName('t3lib/js/extjs/ux/ext.resizable.js'));
        $this->pageRenderer->addJsFile($this->getFullFileName('t3lib/js/extjs/notifications.js'));
        // Add RTE JavaScript
        $this->addRteJsFiles($this->TCEform->RTEcounter);
        $this->pageRenderer->addJsFile($this->buildJSMainLangFile($this->TCEform->RTEcounter));
        $this->pageRenderer->addJsInlineCode('HTMLArea-init', $this->getRteInitJsCode(), TRUE);
        if ($GLOBALS['TSFE']->isINTincScript()) {
            $GLOBALS['TSFE']->additionalHeaderData['rtehtmlarea'] = $this->pageRenderer->render();
        }
        /* =======================================
         * DRAW THE EDITOR
         * =======================================
         */
        // Transform value:
        $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
        // Further content transformation by registered plugins
        foreach ($this->registeredPlugins as $pluginId => $plugin) {
            if ($this->isPluginEnabled($pluginId) && method_exists($plugin, 'transformContent')) {
                $value = $plugin->transformContent($value);
            }
        }
        // draw the textarea
        $item = $this->triggerField($PA['itemFormElName']) . '
			<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $TSFE->csConvObj->conv($TSFE->getLLL('Please wait', $this->LOCAL_LANG), $this->charset, $TSFE->renderCharset) . '</div>
			<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; ' . htmlspecialchars($this->RTEWrapStyle) . '">
			<textarea id="RTEarea' . $textAreaId . '" name="' . htmlspecialchars($PA['itemFormElName']) . '" rows="0" cols="0" style="' . htmlspecialchars($this->RTEdivStyle) . '">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($value) . '</textarea>
			</div>' . LF;
        return $item;
    }
Exemplo n.º 15
0
 /**
  * Load the necessarry css
  *
  * This will only be done when the referenced record is available
  *
  * @return void
  */
 protected function loadCss()
 {
     // TODO Set to TRUE when finished
     $compress = FALSE;
     $baseUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath('../../../../../' . \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('form') . 'Resources/Public/CSS/');
     $cssFiles = array('Wizard/Form.css', 'Wizard/Wizard.css');
     // Load the wizards css
     foreach ($cssFiles as $cssFile) {
         $this->pageRenderer->addCssFile($baseUrl . $cssFile, 'stylesheet', 'all', '', $compress, FALSE);
     }
 }
Exemplo n.º 16
0
    // Default navigation frame width
    $TBE_STYLES['dims']['navFrameWidth'] = 280;
    // Setting roll-over background color for click menus:
    // Notice, this line uses the the 'scriptIDindex' feature to override another value in this array (namely $TBE_STYLES['mainColors']['bgColor5']), for a specific script "typo3/alt_clickmenu.php"
    $TBE_STYLES['scriptIDindex']['typo3/alt_clickmenu.php']['mainColors']['bgColor5'] = '#dedede';
    // Setting up auto detection of alternative icons:
    $TBE_STYLES['skinImgAutoCfg'] = array('absDir' => \TYPO3\CMS\Core\Extension\ExtensionManager::extPath($_EXTKEY) . 'icons/', 'relDir' => \TYPO3\CMS\Core\Extension\ExtensionManager::extRelPath($_EXTKEY) . 'icons/', 'forceFileExtension' => 'gif', 'iconSizeWidth' => 16, 'iconSizeHeight' => 16);
    // Changing icon for filemounts, needs to be done here as overwriting the original icon would also change the filelist tree's root icon
    $TCA['sys_filemounts']['ctrl']['iconfile'] = '_icon_ftp_2.gif';
    // Adding flags to sys_language
    \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('sys_language');
    $TCA['sys_language']['ctrl']['typeicon_column'] = 'flag';
    $TCA['sys_language']['ctrl']['typeicon_classes'] = array('default' => 'mimetypes-x-sys_language', 'mask' => 'flags-###TYPE###');
    $flagNames = array('multiple', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'catalonia', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cs', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'england', 'er', 'es', 'et', 'europeanunion', 'fam', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'in', 'io', 'iq', 'ir', 'is', 'it', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 'qc', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'scotland', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wales', 'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw');
    foreach ($flagNames as $flagName) {
        $TCA['sys_language']['columns']['flag']['config']['items'][] = array($flagName, $flagName, 'EXT:t3skin/images/flags/' . $flagName . '.png');
    }
    // Manual setting up of alternative icons. This is mainly for module icons which has a special prefix:
    $TBE_STYLES['skinImg'] = array_merge($presetSkinImgs, array('gfx/ol/blank.gif' => array('clear.gif', 'width="18" height="16"'), 'MOD:web/website.gif' => array($temp_eP . 'icons/module_web.gif', 'width="24" height="24"'), 'MOD:web_layout/layout.gif' => array($temp_eP . 'icons/module_web_layout.gif', 'width="24" height="24"'), 'MOD:web_view/view.gif' => array($temp_eP . 'icons/module_web_view.png', 'width="24" height="24"'), 'MOD:web_list/list.gif' => array($temp_eP . 'icons/module_web_list.gif', 'width="24" height="24"'), 'MOD:web_info/info.gif' => array($temp_eP . 'icons/module_web_info.png', 'width="24" height="24"'), 'MOD:web_perm/perm.gif' => array($temp_eP . 'icons/module_web_perms.png', 'width="24" height="24"'), 'MOD:web_func/func.gif' => array($temp_eP . 'icons/module_web_func.png', 'width="24" height="24"'), 'MOD:web_ts/ts1.gif' => array($temp_eP . 'icons/module_web_ts.gif', 'width="24" height="24"'), 'MOD:web_modules/modules.gif' => array($temp_eP . 'icons/module_web_modules.gif', 'width="24" height="24"'), 'MOD:web_txversionM1/cm_icon.gif' => array($temp_eP . 'icons/module_web_version.gif', 'width="24" height="24"'), 'MOD:file/file.gif' => array($temp_eP . 'icons/module_file.gif', 'width="22" height="24"'), 'MOD:file_list/list.gif' => array($temp_eP . 'icons/module_file_list.gif', 'width="22" height="24"'), 'MOD:file_images/images.gif' => array($temp_eP . 'icons/module_file_images.gif', 'width="22" height="22"'), 'MOD:user/user.gif' => array($temp_eP . 'icons/module_user.gif', 'width="22" height="22"'), 'MOD:user_task/task.gif' => array($temp_eP . 'icons/module_user_taskcenter.gif', 'width="22" height="22"'), 'MOD:user_setup/setup.gif' => array($temp_eP . 'icons/module_user_setup.gif', 'width="22" height="22"'), 'MOD:user_doc/document.gif' => array($temp_eP . 'icons/module_doc.gif', 'width="22" height="22"'), 'MOD:user_ws/sys_workspace.gif' => array($temp_eP . 'icons/module_user_ws.gif', 'width="22" height="22"'), 'MOD:tools/tool.gif' => array($temp_eP . 'icons/module_tools.gif', 'width="25" height="24"'), 'MOD:tools_beuser/beuser.gif' => array($temp_eP . 'icons/module_tools_user.gif', 'width="24" height="24"'), 'MOD:tools_em/em.gif' => array($temp_eP . 'icons/module_tools_em.png', 'width="24" height="24"'), 'MOD:tools_em/install.gif' => array($temp_eP . 'icons/module_tools_em.gif', 'width="24" height="24"'), 'MOD:tools_dbint/db.gif' => array($temp_eP . 'icons/module_tools_dbint.gif', 'width="25" height="24"'), 'MOD:tools_config/config.gif' => array($temp_eP . 'icons/module_tools_config.gif', 'width="24" height="24"'), 'MOD:tools_install/install.gif' => array($temp_eP . 'icons/module_tools_install.gif', 'width="24" height="24"'), 'MOD:tools_log/log.gif' => array($temp_eP . 'icons/module_tools_log.gif', 'width="24" height="24"'), 'MOD:tools_txphpmyadmin/thirdparty_db.gif' => array($temp_eP . 'icons/module_tools_phpmyadmin.gif', 'width="24" height="24"'), 'MOD:tools_isearch/isearch.gif' => array($temp_eP . 'icons/module_tools_isearch.gif', 'width="24" height="24"'), 'MOD:help/help.gif' => array($temp_eP . 'icons/module_help.gif', 'width="23" height="24"'), 'MOD:help_about/info.gif' => array($temp_eP . 'icons/module_help_about.gif', 'width="25" height="24"'), 'MOD:help_aboutmodules/aboutmodules.gif' => array($temp_eP . 'icons/module_help_aboutmodules.gif', 'width="24" height="24"'), 'MOD:help_cshmanual/about.gif' => array($temp_eP . 'icons/module_help_cshmanual.gif', 'width="25" height="24"'), 'MOD:help_txtsconfighelpM1/moduleicon.gif' => array($temp_eP . 'icons/module_help_ts.gif', 'width="25" height="24"')));
    // Logo at login screen
    $TBE_STYLES['logo_login'] = $temp_eP . 'images/login/typo3logo-white-greyback.gif';
    // extJS theme
    $TBE_STYLES['extJS']['theme'] = $temp_eP . 'extjs/xtheme-t3skin.css';
    // Adding HTML template for login screen
    $TBE_STYLES['htmlTemplates']['templates/login.html'] = 'sysext/t3skin/templates/login.html';
    $GLOBALS['TBE_STYLES']['stylesheets']['admPanel'] = \TYPO3\CMS\Core\Extension\ExtensionManager::siteRelPath('t3skin') . 'stylesheets/standalone/admin_panel.css';
    foreach ($flagNames as $flagName) {
        \TYPO3\CMS\Backend\Sprite\SpriteManager::addIconSprite(array('flags-' . $flagName, 'flags-' . $flagName . '-overlay'));
    }
    unset($flagNames, $flagName);
}