"syntax error, unexpected T_STRING"

Résolu/Fermé
bxl - 13 avril 2009 à 13:44
 bxl - 14 avril 2009 à 02:09
Bonjour,

J'ai un problème récurent lorsque je veux éditer des articles sur mon site créé en joomla.

Code erreur:

Parse error: syntax error, unexpected T_STRING in /homez.110/apresgen/www/libraries/joomla/html/editor.php on line 65

Je ne m'y connais pas du tout en "code" c'est d'ailleurs pourquoi j'ai choisi de travailler avec Joomla...

Sans possibilité de modifier les articles, je reste coincé dans une impasse...

Merci de me donner qq pistes

je copie le code ci-dessous, peut être que l'erreur sautera aux yeux pour des pros?


if(class_exists($className)) { $plugin = new $className($this,
(array)$plugin); } // Try to authenticate //$result[] =
$plugin->onDisplay($editor); } return $result; } /** * Load the
editor * * @access private * @param array Associative array of
editor config paramaters * @since 1.5 */ function
_loadEditor($config = array()) { //check if editor is already loaded
if(!is_null(($this->_editor))) { return; }
jimport('joomla.filesystem.file'); // Build the path to the needed
editor plugin $name = JFilterInput::clean($this->_name, 'cmd');
$path = JPATH_SITE.DS.'plugins'.DS.'editors'.DS.$name.'.php'; if (
! JFile::exists($path) ) { $message = JText::_('Cannot load the
editor'); JError::raiseWarning( 500, $message ); return false; } //
A voir également:

7 réponses

penegal Messages postés 318 Date d'inscription lundi 22 décembre 2008 Statut Membre Dernière intervention 31 janvier 2014 27
13 avril 2009 à 14:08
bijour....
Il faudrait peut-être formater le code ( sur notepad++ ==> couleurs et mettre des "a la ligne" pour que l'on s'y retrouve ...)

Sinon, cette erreur vient d'un code non souhaité.
Je m'explique:
ceci dit syntax error, unexpected T_STRING

<?
echo 'pomme d'api';
?>

par contre ceci dit pomme d'api:
<?
echo 'pomme d\'api';
?>


Donc ==> recherche les guillemets et mettre un antislash devant \
0
Merci pour la rapidité de la réponse...

Donc selon toi je dois faire précéder les guillemets d'un antislash dans le code.

Et ensuite remplacer le fichier editor.php sur mon site.

Dois je le faire pour tous les guillemets? simples et doubles?

Le code n'est pas très long (79 lignes) c'est juste que je n'y connais vraiment rien et je n'ai sais pas exactement ce qui pose problème.

Ce qui m'intrigue c'est que la ligne du message d'erreur (65) ne comporte pas de guillemets.

A la ligne 71/72 il est écrit "Cannot load the editor" peut être est ce un problème de plugin?

Je pense que je vais contacter un "pro du code" afin de le réécrire.

61> if(class_exists($className)) { $plugin = new $className($this,

62> (array)$plugin); } // Try to authenticate //$result[] =

63> $plugin->onDisplay($editor); } return $result; } /** * Load the

64> editor * * @access private * @param array Associative array of

65> editor config paramaters * @since 1.5 */ function

66> _loadEditor($config = array()) { //check if editor is already loaded

67> if(!is_null(($this->_editor))) { return; }

68> jimport('joomla.filesystem.file'); // Build the path to the needed

69> editor plugin $name = JFilterInput::clean($this->_name, 'cmd');

70> $path = JPATH_SITE.DS.'plugins'.DS.'editors'.DS.$name.'.php'; if (

71> ! JFile::exists($path) ) { $message = JText::_('Cannot load the

72> editor'); JError::raiseWarning( 500, $message ); return false; } //
0
Smoking bird Messages postés 870 Date d'inscription mardi 11 mars 2008 Statut Membre Dernière intervention 10 juillet 2011 58
13 avril 2009 à 14:55
slash les guillemets simples dans d'autres guillemets simples:

' l\'artiste';

les guillemets doubles dans d'autres guillemets doubles:

" l'artiste " (ici pas besoin)

ceci est correct:

' l"artiste' (en matière de code seulement -_- ;) )

ton code n'est pas 'mis en forme', y'a pas d'indentation ni rien, c'est dur à lire. Tu l'ouvre avec quoi chez toi?
0
A vrai dire je ne touche jamais au code :(

Avec Joomla ce n'est pas vraiment nécessaire pour créer des articles, des galeries photos, etc

Comme je viens de mettre mon site en ligne chez un hébergeur je me suis rendu compte du bug
lors de l'édition des articles
(uniquement pour le backend, en frontend pas de problème)


Pour ouvrir un fichier en php j'utilise une version démo de dreamweaver...

Je ne sais pas à quoi doit ressembler un code mis en forme...
0
penegal Messages postés 318 Date d'inscription lundi 22 décembre 2008 Statut Membre Dernière intervention 31 janvier 2014 27
13 avril 2009 à 15:41
Bon je vais faire la remise en forme ^^

                        if(class_exists($className)) 
                         { 
                          $plugin = new $className($this,(array)$plugin);
                          } 

                          // Try to authenticate //

                      $result[] = $plugin->onDisplay($editor);
                      }
                  return $result;
                  } 

/** * Load the editor * * @access private * @param array Associative array of editor config paramaters * @since 1.5 */ 

              function_loadEditor($config = array()) 
              { 

//check if editor is already loaded

                  if(!is_null(($this->_editor)))
                  {
                  return;
                  }
             jimport('joomla.filesystem.file');

// Build the path to the needed

             editor plugin $name = JFilterInput::clean($this->_name, 'cmd');
             $path = JPATH_SITE.DS.'plugins'.DS.'editors'.DS.$name.'.php';
                  if (! JFile::exists($path) )
                  {
                   $message = JText::_('Cannot load the editor');
                  JError::raiseWarning( 500, $message );
                  return false;
                   } 
//Encore une indication... que l'on a pas ici ^^
0
penegal Messages postés 318 Date d'inscription lundi 22 décembre 2008 Statut Membre Dernière intervention 31 janvier 2014 27
13 avril 2009 à 15:44
Je croit que l'erreur pourrait venir de la ligne

$path = JPATH_SITE.DS.'plugins'.DS.'editors'.DS.$name.'.php';


qui deviendrais

$path = JPATH_SITE . DS . 'plugins'.DS.'editors' . DS . . $name . '.php';


Mais je ne suis pas un "PRO" donc ... voila ce que je pense ^^

A+
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Non, ce code est correct.

Plutôt ici :

function_loadEditor($config = array()) 
              { 


Vire l'underscore (en laissant un espace entre fonction et loadEditor).
0
Smoking bird Messages postés 870 Date d'inscription mardi 11 mars 2008 Statut Membre Dernière intervention 10 juillet 2011 58
13 avril 2009 à 16:08
Hum je ne suis pas d'accord avec toi Penegal, l'erreur ne se situe pas après la ligne 65, et en général ça se situe plus haut si sur la ligne incriminée il n'y a pas de chaîne. Je pense donc qu'il nous faut remonter plus loin^^
0
penegal Messages postés 318 Date d'inscription lundi 22 décembre 2008 Statut Membre Dernière intervention 31 janvier 2014 27
13 avril 2009 à 16:18
C'est vrai patachon c'est une bonne idée...

Mais poste TOUT le document ... sinon on ne sais pas voir si l'erreur est plus haute ^^
0
Merci du coup de main en tout cas!

pour moi c'est vraiment du chinois (et encore je me débrouille en mandarin)

J'ai repris le code en entier, avec en gras la ligne qui pose problème...

Je comprend pas, il n'y a pas de module d'édition?

<?php
/**
* @version $Id: editor.php 10707 2008-08-21 09:52:47Z eddieajau $
* @package Joomla.Framework
* @subpackage HTML
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();

jimport('joomla.event.dispatcher');

/**
* JEditor class to handle WYSIWYG editors
*
* @package Joomla.Framework
* @subpackage HTML
* @since 1.5
*/
class JEditor extends JObservable
{
/**
* Editor Plugin object
*
* @var object
*/
var $_editor = null;

/**
* Editor Plugin name
*
* @var string
*/
var $_name = null;

/**
* constructor
*
* @access protected
* @param string The editor name
*/
function __construct($editor = 'none')
{
$this->_name = $editor;
}

/**
* Returns a reference to a global Editor object, only creating it
* if it doesn't already exist.
*
* This method must be invoked as:
* pre> $editor = &JEditor::getInstance([$editor);</pre>
*
* @access public
* @param string $editor The editor to use.
* @return JEditor The Editor object.
*/
function &getInstance($editor = 'none')
{
static $instances;

if (!isset ($instances)) {
$instances = array ();
}

$signature = serialize($editor);

if (empty ($instances[$signature])) {
$instances[$signature] = new JEditor($editor);
}

return $instances[$signature];
}

/**
* Initialize the editor
*/
function initialise()
{
//check if editor is already loaded
if(is_null(($this->_editor))) {
return;
}

$args['event'] = 'onInit';

$return = '';
$results[] = $this->_editor->update($args);
foreach ($results as $result) {
if (trim($result)) {
//$return .= $result;
$return = $result;
}
}

$document =& JFactory::getDocument();
$document->addCustomTag($return);
}

/**
* Present a text area
*
* @param string The control name
* @param string The contents of the text area
* @param string The width of the text area (px or %)
* @param string The height of the text area (px or %)
* @param int The number of columns for the textarea
* @param int The number of rows for the textarea
* @param boolean True and the editor buttons will be displayed
* @param array Associative array of editor parameters
*/
function display($name, $html, $width, $height, $col, $row, $buttons = true, $params = array())
{
$this->_loadEditor($params);

//check if editor is already loaded
if(is_null(($this->_editor))) {
return;
}

// Backwards compatibility. Width and height should be passed without a semicolon from now on.
// If editor plugins need a unit like "px" for CSS styling, they need to take care of that
$width = str_replace( ';', '', $width );
$height = str_replace( ';', '', $height );

// Initialize variables
$return = null;

$args['name'] = $name;
$args['content'] = $html;
$args['width'] = $width;
$args['height'] = $height;
$args['col'] = $col;
$args['row'] = $row;
$args['buttons'] = $buttons;
$args['event'] = 'onDisplay';

$results[] = $this->_editor->update($args);

foreach ($results as $result)
{
if (trim($result)) {
$return .= $result;
}
}
return $return;
}

/**
* Save the editor content
*
* @param string The name of the editor control
*/
function save( $editor )
{
$this->_loadEditor();

//check if editor is already loaded
if(is_null(($this->_editor))) {
return;
}

$args[] = $editor;
$args['event'] = 'onSave';

$return = '';
$results[] = $this->_editor->update($args);
foreach ($results as $result) {
if (trim($result)) {
$return .= $result;
}
}
return $return;
}

/**
* Get the editor contents
*
* @param string The name of the editor control
*/
function getContent( $editor )
{
$this->_loadEditor();

$args['name'] = $editor;
$args['event'] = 'onGetContent';

$return = '';
$results[] = $this->_editor->update($args);
foreach ($results as $result) {
if (trim($result)) {
$return .= $result;
}
}
return $return;
}

/**
* Set the editor contents
*
* @param string The name of the editor control
* @param string The contents of the text area
*/
function setContent( $editor, $html )
{
$this->_loadEditor();

$args['name'] = $editor;
$args['html'] = $html;
$args['event'] = 'onSetContent';

$return = '';
$results[] = $this->_editor->update($args);
foreach ($results as $result) {
if (trim($result)) {
$return .= $result;
}
}
return $return;
}

/**
* Get the editor buttons
*
* @param mixed $buttons Can be boolean or array, if boolean defines if the buttons are displayed, if array defines a list of buttons not to show.
* @access public
* @since 1.5
*/
function getButtons($editor, $buttons = true)
{
$result = array();

if(is_bool($buttons) && !$buttons) {
return $result;
}

// Get plugins
$plugins = JPluginHelper::getPlugin('editors-xtd');

foreach($plugins as $plugin)
{
if(is_array($buttons) && in_array($plugin->name, $buttons)) {
continue;
}

$isLoaded = JPluginHelper::importPlugin('editors-xtd', $plugin->name, false);

$className = 'plgButton'.$plugin->name;
if(class_exists($className)) {
$plugin = new $className($this, (array)$plugin);
}

// Try to authenticate
$result[] = $plugin->onDisplay($editor);
}

return $result;
}

/**
* Load the editor
*
* @access private
* @param array Associative array of editor config paramaters
* @since 1.5
*/
function _loadEditor($config = array())
{
//check if editor is already loaded
if(!is_null(($this->_editor))) {
return;
}

jimport('joomla.filesystem.file');

// Build the path to the needed editor plugin
$name = JFilterInput::clean($this->_name, 'cmd');
$path = JPATH_SITE.DS.'plugins'.DS.'editors'.DS.$name.'.php';

if ( ! JFile::exists($path) )
{
$message = JText::_('Cannot load the editor');
JError::raiseWarning( 500, $message );
return false;
}

// Require plugin file
require_once $path;

// Get the plugin
$plugin =& JPluginHelper::getPlugin('editors', $this->_name);
$params = new JParameter($plugin->params);
$params->loadArray($config);
$plugin->params = $params;

// Build editor plugin classname
$name = 'plgEditor'.$this->_name;
if($this->_editor = new $name ($this, (array)$plugin))
{
// load plugin parameters
$this->initialise();
JPluginHelper::importPlugin('editors-xtd');
}
}
}
0
...problème résolu :)


> Comme vous me l'aviez conseillé, j'ai supprimé plusieurs "underscore" devant la fonction: loadEditor


Et à présent tout roule normalement...


Merci beaucoup pour le coup de main!
0