Parse error: syntax error, unexpected else (T ELSE), expecting function (T FUNCTION)
Hallo,
ich habe oben genannte Fehler, komme aber in PHP nicht sooo gut zurecht. Es waren noch einige andere Fehler drin, welche ich aber schon reparieren konnte. Ich habe mit PHPDesigner 8 mir betreffende Datei angeschau und bekomme diesen Code
Betreffende Zeile ist hierbei die Zeile 55 mit dem Wort else. Ich komme nicht damit klar was hier noch falsch sein sollte. Kann mir dabei bitte jemand helfen?
LG Kepala
ich habe oben genannte Fehler, komme aber in PHP nicht sooo gut zurecht. Es waren noch einige andere Fehler drin, welche ich aber schon reparieren konnte. Ich habe mit PHPDesigner 8 mir betreffende Datei angeschau und bekomme diesen Code
<?php
/**
* @version $Id: select.php 20640 2011-02-10 06:26:40Z infograf768 $
* @package Joomla.Framework
* @subpackage HTML
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* Utility class for creating HTML select lists
*
* @static
* @package Joomla.Framework
* @subpackage HTML
* @since 1.5
*/
abstract class JHtmlSelect
{
/**
* Default values for options. Organized by option group.
*
* @var array
*/
static protected $_optionDefaults = array(
'option' => array(
'option.attr' => null,
'option.disable' => 'disable',
'option.id' => null,
'option.key' => 'value',
'option.key.toHtml' => true,
'option.label' => null,
'option.label.toHtml' => true,
'option.text' => 'text',
'option.text.toHtml' => true,
),
);
/**
* Generates a yes/no radio list.
*
* @param string The value of the HTML name attribute
* @param string Additional HTML attributes for the <select> tag
* @param mixed The key that is selected
* @return string HTML for the radio list
*/
public static function booleanlist(
$name, $attribs = null, $selected = null, $yes = 'JYES', $no = 'JNO', $id = false
) {
$arr = array(
JHtml::_('select.option', '0', JText::_($no)),
JHtml::_('select.option', '1', JText::_($yes))
);
return JHtml::_('serray_merge($options, $optKey)')
} else {
// Get options from the parameters
$options['option.key'] = $optKey;
$options['option.text'] = $optText;
$options['disable'] = $disable;
}
$obj = new JObject;
$obj->$options['option.key'] = $value;
$obj->$options['option.text'] = trim($text) ? $text : $value;
/*
* If a label is provided, save it. If no label is provided and there is
* a label name, initialise to an empty string.
*/
$hasProperty = $options['option.label'] !== null;
if (isset($options['label'])) {
$labelProperty = $hasProperty ? $options['option.label'] : 'label';
$obj->$labelProperty = $options['label'];
} elseif ($hasProperty) {
$obj->$options['option.label'] = '';
}
// Set attributes only if there is a property and a value
if ($options['attr'] !== null) {
$obj->$options['option.attr'] = $options['attr'];
}
// Set disable only if it has a property and a value
if ($options['disable'] !== null) {
$obj->$options['option.disable'] = $options['disable'];
}
return $obj;
}
/**
* Generates the option tags for an HTML select list (with no select tag
* surrounding the options).
*
* @param array An array of objects, arrays, or values.
* @param mixed If a string, this is the name of the object variable for
* the option value. If null, the index of the array of objects is used. If
* an array, this is a set of options, as key/value pairs. Valid options
* are:
* <ul><li>Format options, {@see JHtml::$formatOptions}.
* </li><li>groups: Boolean. If set, looks for keys with the value
* "<optgroup>" and synthesizes groups from them. Deprecated. Defaults
* true for backwards compatibility.
* </li><li>list.select: either the value of one selected option or an array
* of selected options. Default: none.
* </li><li>list.translate: Boolean. If set, text and labels are translated via
* JText::_(). Default is false.
* </li><li>option.id: The property in each option array to use as the
* selection id attribute. Defaults to none.
* </li><li>option.key: The property in each option array to use as the
* selection value. Defaults to "value". If set to null, the index of the
* option array is used.
* </li><li>option.label: The property in each option array to use as the
* selection label attribute. Defaults to null (none).
* </li><li>option.text: The property in each option array to use as the
* displayed text. Defaults to "text". If set to null, the option array is
* assumed to be a list of displayable scalars.
* </li><li>option.attr: The property in each option array to use for
* additional selection attributes. Defaults to none.
* </li><li>option.disable: The property that will hold the disabled state.
* Defaults to "disable".
* </li><li>option.key: The property that will hold the selection value.
* Defaults to "value".
* </li><li>option.text: The property that will hold the the displayed text.
* Defaults to "text". If set to null, the option array is assumed to be a
* list of displayable scalars.
* </li></ul>
* @param string The name of the object variable for the option text.
* @param mixed The key that is selected (accepts an array or a string)
* @return string HTML for the select list
*/
public static function options(
$arr, $optKey = 'value', $optText = 'text', $selected = null, $translate = false
) {
$options = array_merge(
JHtml::$formatOptions,
self::$_optionDefaults['option'],
array(
'format.depth' => 0,
'groups' => true,
'list.select' => null,
'list.translate' => false,
)
);
if (is_array($optKey)) {
// Set default options and overwrite with anything passed in
$options = array_merge($options, $optKey);
} else {
// Get options from the parameters
$options['option.key'] = $optKey;
$options['option.text'] = $optText;
$options['list.select'] = $selected;
$options['list.translate'] = $translate;
}
$html = '';
$baseIndent = str_repeat($options['format.indent'], $options['format.depth']);
foreach ($arr as $elementKey => &$element)
{
$attr = '';
$extra = '';
$label = '';
$id = '';
if (is_array($element))
{
$key = $options['option.key'] === null
? $elementKey : $element[$options['option.key']];
$text = $element[$options['option.text']];
if (isset($element[$options['option.attr']])) {
$attr = $element[$options['option.attr']];
}
if (isset($element[$options['option.id']])) {
$id = $element[$options['option.id']];
}
if (isset($element[$options['option.label']])) {
$label = $element[$options['option.label']];
}
if (isset($element[$options['option.disable']]) && $element[$options['option.disable']]) {
$extra .= ' disabled="disabled"';
}
} elseif (is_object($element)) {
$key = $options['option.key'] === null
? $elementKey : $element->$options['option.key'];
$text = $element->$options['option.text'];
if (isset($element->$options['option.attr'])) {
$attr = $element->$options['option.attr'];
}
if (isset($element->$options['option.id'])) {
$id = $element->$options['option.id'];
}
if (isset($element->$options['option.label'])) {
$label = $element->$options['option.label'];
}
if (isset($element->$options['option.disable']) && $element->$options['option.disable']) {
$extra .= ' disabled="disabled"';
}
} else {
// This is a simple associative array
$key = $elementKey;
$text = $element;
}
/*
* The use of options that contain optgroup HTML elements was
* somewhat hacked for J1.5. J1.6 introduces the grouplist() method
* to handle this better. The old solution is retained through the
* "groups" option, which defaults true in J1.6, but should be
* deprecated at some point in the future.
*/
$key = (string) $key;
if ($options['groups'] && $key == '<OPTGROUP>') {
$html .= $baseIndent . '<optgroup label="'
. ($options['list.translate'] ? JText::_($text) : $text)
. '">' . $options['format.eol'];
$baseIndent = str_repeat($options['format.indent'], ++$options['format.depth']);
} else if ($options['groups'] && $key == '</OPTGROUP>') {
$baseIndent = str_repeat($options['format.indent'], --$options['format.depth']);
$html .= $baseIndent . '</optgroup>' . $options['format.eol'];
} else {
// if no string after hypen - take hypen out
$splitText = explode(' - ', $text, 2);
$text = $splitText;
if (isset($splitText[1])) {
$text .= ' - ' . $splitText[1];
}
if ($options['list.translate'] && !empty($label)) {
$label = JText::_($label);
}
if ($options['option.label.toHtml']) {
$label = htmlentities($label);
}
if (is_array($attr)) {
$attr = JArrayHelper::toString($attr);
} else {
$attr = trim($attr);
}
$extra = ($id ? ' id="' . $id . '"' : '')
. ($label ? ' label="' . $label . '"' : '')
. ($attr ? ' ' . $attr : '')
. $extra
;
if (is_array($options['list.select']))
{
foreach ($options['list.select'] as $val)
{
$key2 = is_object($val) ? $val->$options['option.key'] : $val;
if ($key == $key2) {
$extra .= ' selected="selected"';
break;
}
}
} elseif ((string)$key == (string)$options['list.select']) {
$extra .= ' selected="selected"';
}
if ($options['list.translate']) {
$text = JText::_($text);
}
// Generate the option, encoding as required
$html .= $baseIndent . '<option value="'
. ($options['option.key.toHtml'] ? htmlspecialchars($key, ENT_COMPAT, 'UTF-8') : $key) . '"'
. $extra . '>'
. ($options['option.text.toHtml'] ? htmlentities(html_entity_decode($text), ENT_COMPAT, 'UTF-8') : $text)
. '</option>'
. $options['format.eol']
;
}
}
return $html;
}
/**
* Generates an HTML radio list.
*
* @param array An array of objects
* @param string The value of the HTML name attribute
* @param string Additional HTML attributes for the <select> tag
* @param mixed The key that is selected
* @param string The name of the object variable for the option value
* @param string The name of the object variable for the option text
* @return string HTML for the select list
*/
public static function radiolist(
$data, $name, $attribs = null, $optKey = 'value', $optText = 'text',
$selected = null, $idtag = false, $translate = false
) {
reset($data);
$html = '';
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
$id_text = $idtag ? $idtag : $name;
foreach ($data as $ind => $obj)
{
$k = $obj->$optKey;
$t = $translate ? JText::_($obj->$optText) : $obj->$optText;
$id = (isset($obj->id) ? $obj->id : null);
$extra = '';
$extra .= $id ? ' id="' . $obj->id . '"' : '';
if (is_array($selected))
{
foreach ($selected as $val)
{
$k2 = is_object($val) ? $val->$optKey : $val;
if ($k == $k2)
{
$extra .= ' selected="selected"';
break;
}
}
} else {
$extra .= ((string)$k == (string)$selected ? ' checked="checked"' : '');
}
$html .= "\n\t" .'<input type="radio" name="' . $name . '"'
. ' id="' . $id_text . $k . '" value="' . $k .'"'
. ' ' . $extra . ' ' . $attribs . '/>'
. "\n\t" . '<label for="' . $id_text . $k . '"'
. ' id="' . $id_text . $k . '-lbl" class="radiobtn">'.$t.'</label>';
}
$html .= "\n";
return $html;
}
}
Betreffende Zeile ist hierbei die Zeile 55 mit dem Wort else. Ich komme nicht damit klar was hier noch falsch sein sollte. Kann mir dabei bitte jemand helfen?
LG Kepala
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 220876
Url: https://administrator.de/contentid/220876
Ausgedruckt am: 23.11.2024 um 01:11 Uhr
7 Kommentare
Neuester Kommentar
Ich hab das Ding nicht geschrieben ! woher soll ich dann wissen welche Bedingung drin stehen soll:
Die hast du wahrscheinlich irgendwie rausgelöscht...hol dir die Original-Datei aus den Joomla-Repos fertig ....
Grüße Uwe
Die hast du wahrscheinlich irgendwie rausgelöscht...hol dir die Original-Datei aus den Joomla-Repos fertig ....
if (BEDINGUNG DIE ICH NICHT KENNE){
//MACH hier was
} else {
// Get options from the parameters
$options['option.key'] = $optKey;
$options['option.text'] = $optText;
$options['disable'] = $disable;
}
Grüße Uwe
Dann bitte noch den Beitrag auf gelöst setzen. Merci.