Generate XML declaration

@param bool $called_from_macro for error checking: unbuffered output doesn't support that
433329
public function doXmlDeclaration($called_from_macro = false)
    {
        if ($this->_xmldeclaration && $this->getOutputMode() !== PHPTAL::HTML5) {
            $code = '$ctx->setXmlDeclaration('.$this->str($this->_xmldeclaration).','.($called_from_macro?'true':'false').')';
            $this->pushCode($code);
        }
    }
1089896
public function toXml(): string
    {
        if (null === $this->document) {
            throw new XslProcessorException(
                    'Can not transform, set document or xml file to transform first'
            );
        }

        $this->registerCallbacks();
        $result = $this->xsltProcessor->transformToXML($this->document);
        if (false === $result) {
            throw new XslProcessorException($this->createMessage());
        }

        return $result;
    }
893124
function outputTag( $element, &$siblingParams, $parentParams = array() )
    {
        $tagName = $element->localName;
        if ( isset( $this->OutputTags[$tagName] ) )
        {
            $currentTag = $this->OutputTags[$tagName];
        }
        else
        {
            $currentTag = null;
        }

        // Prepare attributes array
        $attributes = array();
        if ( $element->hasAttributes() )
        {
            $attributeNodes = $element->attributes;

            foreach ( $attributeNodes as $attrNode )
            {
                if ( $attrNode->prefix && $attrNode->prefix != 'custom' )
                {
                    $attrName = $attrNode->prefix . ':' . $attrNode->localName;
                }
                else
                {
                    $attrName = $attrNode->nodeName;
                }

                // classes check
                if ( $attrName == 'class' )
                {
                    $classesList = $this->XMLSchema->getClassesList( $tagName );
                    if ( !in_array( $attrNode->value, $classesList ) )
                    {
                        eZDebug::writeWarning( "Using tag '$tagName' with class '$attrNode->value' is not allowed.", 'XML output handler' );
                        return array( true, '' );
                    }
                }

                $attributes[$attrName] = $attrNode->value;
            }
        }

        // Set default attribute values if not present in the input
        $attrDefaults = $this->XMLSchema->attrDefaultValues( $tagName );
        foreach ( $attrDefaults as $name=>$value )
        {
            if ( !isset( $attributes[$name] ) )
            {
                $attributes[$name] = $value;
            }
        }

        // Init handler returns an array that may contain the following items:
        //
        // 'no_render'       (boolean) :
        //                   If false tag will not be rendered, only it's children (if any).
        // 'design_keys'     array( 'design_key_name_1' => 'value_1', 'design_key_name_2'=>'value_2', ... ) :
        //                   An array of additional design keys.
        // 'tpl_vars'        array( 'var_name_1' => 'value_1', 'var_name_2' => 'value_2', ... ) :
        //                   An array of additional template variables.
        // 'template_name'   (string) :
        //                   Overrides tag template name.

        $result = $this->callTagInitHandler( 'initHandler', $element, $attributes, $siblingParams, $parentParams );

        // Process children
        $childrenOutput = array();
        if ( $element->hasChildNodes() )
        {
            // Initialize sibiling parameters array for the next level children
            // Parent parameters for the children may be modified in the current tag handler.
            $nextSibilingParams = array();

            $this->NestingLevel++;
            foreach( $element->childNodes as $child )
            {
                $childOutput = $this->outputTag( $child, $nextSibilingParams, $parentParams );

                if ( is_array( $childOutput[0] ) )
                {
                    $childrenOutput = array_merge( $childrenOutput, $childOutput );
                }
                else
                {
                    $childrenOutput[] = $childOutput;
                }
            }
            $this->NestingLevel--;
        }
        else
        {
            $childrenOutput = array( array( true, '' ) );
        }

        if ( isset( $result['no_render'] ) && $result['no_render'] )
        {
            return $childrenOutput;
        }

        // Set tpl variables by attributes and rename rules
        $vars = array();

        if ( !isset( $currentTag['quickRender'] ) && isset( $currentTag['attrNamesTemplate'] ) )
        {
            $attrRenameRules = $currentTag['attrNamesTemplate'];
        }
        elseif ( isset( $currentTag['quickRender'] ) && isset( $currentTag['attrNamesQuick'] ) )
        {
            $attrRenameRules = $currentTag['attrNamesQuick'];
        }
        else
        {
            $attrRenameRules = array();
        }

        foreach( $attributes as $name=>$value )
        {
            if ( isset( $attrRenameRules[$name] ) )
            {
                $vars[$attrRenameRules[$name]] = $value;
                continue;
            }

            if ( strpos( $name, 'custom:' ) === 0 )
            {
                $name = substr( $name, 7 );
            }

            $vars[$name] = $value;
        }

        // set missing variables that have rename rules defined
        // but were not present in the element
        foreach( $attrRenameRules as $attrName=>$varName )
        {
            if ( !isset( $attributes[$attrName] ) )
            {
                $vars[$varName] = '';
            }
        }

        $this->TemplateUri = '';

        // In quick render mode we does not use templates and
        // render template variables as tag attributes
        if ( !isset( $currentTag['quickRender'] ) )
        {
            // Set additional variables passed by tag handler
            if ( isset( $result['tpl_vars'] ) )
            {
                $vars = array_merge( $vars, $result['tpl_vars'] );
            }

            foreach( $vars as $name=>$value )
            {
                $this->Tpl->setVariable( $name, $value, 'xmltagns' );
            }

            // Create design keys array (including the ones with no value so they still overwrite values of parent tag)
            $designKeys = array();
            if ( isset( $currentTag['attrDesignKeys'] ) )
            {
                foreach( $currentTag['attrDesignKeys'] as $attrName=>$keyName )
                {
                    if ( isset( $attributes[$attrName] ) )
                    {
                        $designKeys[$keyName] = $attributes[$attrName];
                    }
                }
            }
            // Set additional design keys passed by tag handler
            if ( isset( $result['design_keys'] ) )
            {
                $designKeys = array_merge( $designKeys, $result['design_keys'] );
            }

            $existingKeys = $this->Res->keys();
            $savedKeys = array();

            // Save old keys values and set new design keys
            foreach( $designKeys as $key=>$value )
            {
                if ( isset( $existingKeys[$key] ) )
                {
                    $savedKeys[$key] = $existingKeys[$key];
                }
                $this->Res->setKeys( array( array( $key, $value ) ) );
            }

            // Template name
            if ( isset( $result['template_name'] ) )
            {
                $templateName = $result['template_name'];
            }
            else
            {
                $templateName = $element->nodeName;
            }
            $this->TemplateUri = $this->TemplatesPath . $templateName . '.tpl';
        }

        $output = $this->callTagRenderHandler( 'renderHandler', $element, $childrenOutput, $vars );

        if ( !isset( $currentTag['quickRender'] ) )
        {
            // Restore saved template override keys and remove others
            foreach( $designKeys as $key => $value )
            {
                if ( isset( $savedKeys[$key] ) )
                {
                    $this->Res->setKeys( array( array( $key, $savedKeys[$key] ) ) );
                }
                else
                {
                    $this->Res->removeKey( $key );
                }
            }

            // Unset variables
            foreach ( $vars as $name=>$value )
            {
                if ( $this->Tpl->hasVariable( $name, 'xmltagns' ) )
                {
                    $this->Tpl->unsetVariable( $name, 'xmltagns' );
                }
            }
        }

        $this->callTagInitHandler( 'leavingHandler', $element, $attributes, $siblingParams, $parentParams );

        return $output;
    }
471609
private function processLabelLinkbaseXml( $linkbaseRef, $xml, $xml_basename, $usedOn )
	{
		// Make sure this file contains label link elements so is valid for the role type
		if ( ! count( $xml->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )->labelLink ) )
		{
			if ( ! empty( $linkbaseRef['role'] ) && $linkbaseRef['role'] != XBRL_Constants::$anyLinkbaseRef )
			{
				$this->reportNoRoleLinks( $linkbaseRef, 'label' );
			}
			return;
		}

		$arcroleRefs = array();
		foreach ( $xml->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )->arcroleRef as $arcroleRefKey => $arcroleRef )
		{
			$attributes = $arcroleRef->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XLINK ] );
			$arcroleRefHref = (string) $attributes->href;

			// BMS 2015-04-26 This is neessary now linkbases defined in the schema document are supported
			// because a role reference to a type might be a relative reference to an id in the schema doc.
			$arcroleRefParts = explode( "#", $arcroleRefHref );
			if ( ! $arcroleRefParts )
			{
				$arcroleRefHref = $this->getTaxonomyXSD();
			}
			else if ( ! $arcroleRefParts[0] )
			{
				$arcroleRefParts[0] = $this->getTaxonomyXSD();
				$arcroleRefHref = implode( "#", $arcroleRefParts );
			}

			$arcroleUri = (string) $arcroleRef->attributes()->arcroleURI;
			$fragment = parse_url( $arcroleRefHref, PHP_URL_FRAGMENT );

			if ( XBRL::isValidating() )
			{
				if ( isset( $arcroleRefs[ $arcroleUri ] ) )
				{
					$this->log()->taxonomy_validation( "3.5.2.4.5", "There MUST NOT be more than one arcroleRef element with the same @arcroleURI attribute value",
						array(
							'role' => $arcroleUri,
							'href' => $xml_basename,
						)
					);
				}
			}

			$arcroleRefs[ $arcroleUri ] = $fragment;

			$taxonomy = $this->getTaxonomyForXSD( $arcroleRefHref );
			if ( ! $taxonomy )
			{
				$xsd = strpos( $arcroleRefHref, '#' ) === false ? $arcroleRefHref : strstr( $arcroleRefHref, '#', true );
				if ( isset( XBRL_Global::$taxonomiesToIgnore[ $xsd ] ) ) continue;

				$xsd = $this->resolve_path( $linkbaseRef['href'], $xsd );
				// If the taxonomy is not already loaded, try loading it.
				$taxonomy = $xsd ? XBRL::withTaxonomy( $xsd ) : null;

				if ( ! $taxonomy )
				{
					$this->log()->taxonomy_validation( "5.1.3.4", "Taxonomy for arcroleRef href does not exist",
						array(
							'href' => "'$arcroleRefHref'",
							'linkbase' => "'$xml_basename'",
						)
					);
					continue;
				}
			}

			// This role MUST be defined as 'usedOn' in the linkbaseRef for link:labelArc
			if ( ! count( $taxonomy->arcroleTypes ) || ! isset( $taxonomy->arcroleTypes['link:labelArc'][ $arcroleUri ] ) )
			{
				$this->log()->taxonomy_validation( "5.1.3.4", "This arcrole is not defined to be used on the label linkbase",
					array(
						'arcrole' => "'$arcroleUri'",
						'linkbase' => "'$xml_basename'",
					)
				);
				continue;
			}

			// Make sure this arcrole is in the current taxonomy
			$this->arcroleTypes['link:labelArc'][ $arcroleUri ] = $taxonomy->arcroleTypes['link:labelArc'][ $arcroleUri ];
		}

		$labelRoles = array(
			XBRL_Constants::$labelRoleLabel,
			XBRL_Constants::$labelRoleTerseLabel,
			XBRL_Constants::$labelRoleVerboseLabel,
			XBRL_Constants::$labelRolePositiveLabel,
			XBRL_Constants::$labelRolePositiveTerseLabel,
			XBRL_Constants::$labelRolePositiveVerboseLabel,
			XBRL_Constants::$labelRoleNegativeLabel,
			XBRL_Constants::$labelRoleNegativeTerseLabel,
			XBRL_Constants::$labelRoleNegativeVerboseLabel,
			XBRL_Constants::$labelRoleZeroLabel,
			XBRL_Constants::$labelRoleZeroTerseLabel,
			XBRL_Constants::$labelRoleZeroVerboseLabel,
			XBRL_Constants::$labelRoleTotalLabel,
			XBRL_Constants::$labelRolePeriodStartLabel,
			XBRL_Constants::$labelRolePeriodEndLabel,
			XBRL_Constants::$labelRoleDocumentation,
			XBRL_Constants::$labelRoleDefinitionGuidance,
			XBRL_Constants::$labelRoleDisclosureGuidance,
			XBRL_Constants::$labelRolePresentationGuidance,
			XBRL_Constants::$labelRoleMeasurementGuidance,
			XBRL_Constants::$labelRoleCommentaryGuidance,
			XBRL_Constants::$labelRoleExampleGuidance,
		);

		$taxonomy_basename = $this->getTaxonomyXSD();

		foreach ( $labelRoles as $role )
		{
			$roleName = str_replace( XBRL_Constants::$rolePrefix, '', $role );

			$this->context->labelRoleRefs[ $role ] = array(
					'type' => 'simple',
					'href' => "$taxonomy_basename#$roleName",
					'roleUri' => $role,
			);
		}

		unset( $role );
		if ( ! isset( $this->roleTypes[ $usedOn ] ) )
		{
			$this->roleTypes[ $usedOn ] = array();
		}

		if ( count( $xml->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )->roleRef ) )
		{
			$linkbaseRoleRefs = array();

			/*
				<roleRef xlink:type="simple" xlink:href="uk-gaap-pt-2004-12-01.xsd#restated" roleURI="http://www.xbrl.org/2003/frta/role/restated" />
				<labelLink xlink:type="extended" xlink:role="http://www.xbrl.org/2003/role/link">
			 */
			foreach ( $xml->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )->roleRef as $roleRefKey => $roleRef )
			{
				$xlinkAttributes = $roleRef->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XLINK ] );
				$roleRefAttributes = $roleRef->attributes();
				$roleUri = (string) $roleRefAttributes->roleURI;
				$roleRefHref = (string) $xlinkAttributes->href;

				// BMS 2015-04-26 This is neessary now linkbases defined in the schema document are supported
				// because a role reference to a type might be a relative reference to an id in the schema doc.
				$roleRefParts = explode( "#", $roleRefHref );
				if ( ! $roleRefParts )
				{
					$roleRefHref = $this->getTaxonomyXSD();
				}
				else if ( ! $roleRefParts[0] )
				{
					$roleRefParts[0] = $this->getTaxonomyXSD();
					$roleRefHref = implode( "#", $roleRefParts );
				}

				if ( XBRL::isValidating() )
				{
					// BMS 2018-04-26 This test works when the linkbases are in different files not so much when they are all in the schema document
					// if ( isset( $this->linkbaseRoleTypes[ $xml_basename ][ "$usedOn:$roleUri" ] ) )
					if ( isset( $linkbaseRoleRefs[ "$usedOn:$roleUri" ] ) )
					{
						$this->log()->taxonomy_validation( "3.5.2.4.5", "There MUST NOT be more than one roleRef element with the same @roleURI attribute value",
							array(
								'role' => $roleUri,
								'usedon' => $usedOn,
								'href' => $xml_basename,
							)
						);
					}
				}

				$linkbaseRoleRefs[ "$usedOn:$roleUri" ] = $roleRefHref;
				$this->linkbaseRoleTypes[ $xml_basename ][ "$usedOn:$roleUri" ] = $roleRefHref;

				$taxonomy = $this->getTaxonomyForXSD( $roleRefHref );
				if ( ! $taxonomy )
				{
					// Look for the taxonomy and include its contents in the DTS
					$xsd = $this->resolve_path( $this->getSchemaLocation(), $roleRefHref );

					$taxonomy = XBRL::withTaxonomy( strpos( $xsd, '#' ) ? strstr( $xsd, '#', true ) : $xsd );

					$taxonomy = $this->getTaxonomyForXSD( $roleRefHref );
					if ( ! $taxonomy )
					{
						if ( XBRL::isValidating() )
						{
							$this->log()->taxonomy_validation( "5.1.3.4", "The role taxonomy cannot be located",
								array(
									'role' => $roleUri,
									'href' => $roleRefHref,
									'linkbase' => 'labels',
								)
							);
						}
						continue;
					}
				}

				// This role MUST be defined as 'usedOn' in the linkbaseRef for link:labelLink
				if ( XBRL::isValidating() && count( $taxonomy->roleTypes ) )
				{
					if ( ! isset( $taxonomy->roleTypes['link:labelLink'][ $roleUri ] ) && ! isset( $taxonomy->roleTypes[ $usedOn ][ $roleUri ] ) )
					{
						$scheme = parse_url( $roleRefHref, PHP_URL_SCHEME );

						if ( ! in_array( $scheme, array( 'http', 'https' ) ) )
						{
							$this->log()->taxonomy_validation( "5.1.3.4", "This role is not defined to be used on the label linkbase",
								array(
									'role' => $roleUri,
								)
							);
						}
					}
				}

				if ( isset( $this->roleTypes['link:labelLink'][ $roleUri ] ) )
				{
					$this->context->labelLinkRoleRefs[ $roleUri ] = array(
						'type' => (string) $xlinkAttributes->type,
						'href' => XBRL::resolve_path( $linkbaseRef['href'], (string) $xlinkAttributes->href ),
						'roleUri' => $roleUri,
					);
				}

				if ( isset( $this->roleTypes['link:label'][ $roleUri ] ) )
				{
					$this->context->labelRoleRefs[ $roleUri ] = array(
						'type' => (string) $xlinkAttributes->type,
						'href' => XBRL::resolve_path( $linkbaseRef['href'], (string) $xlinkAttributes->href ),
						'roleUri' => $roleUri,
					);
				}
			}
		}

		if ( ! isset( $this->context->labelRoleRefs[ XBRL_Constants::$labelRoleLabel ] ) )
		{
			$this->context->labelRoleRefs[ XBRL_Constants::$labelRoleLabel ] = array(
				'type' => 'simple',
				'href' => XBRL::resolve_path( $linkbaseRef['href'], $this->getTaxonomyXSD() ),
				'roleUri' => XBRL_Constants::$labelRoleLabel,
			);
		}

		if ( count( $this->context->labelLinkRoleRefs ) === 0 )
		{
			$this->context->labelLinkRoleRefs[ XBRL_Constants::$defaultLinkRole ] = array(
				'type' => 'simple',
				'href' => XBRL::resolve_path( $linkbaseRef['href'], $this->getTaxonomyXSD() ),
				'roleUri' => XBRL_Constants::$defaultLinkRole,
			);
		}

		foreach ( $this->context->labelLinkRoleRefs as $roleRefsKey => $labelRoleRef )
		{
			// Find the label link with the same role
			// Note: the XBRL specification defines 'labelLink' but the XLink spec will allow for an element with any
			//		 local name as long as it has an attribute 'type' with the value 'extended'
			foreach ( $xml->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )->labelLink as $linkKey => /* @var SimpleXMLElement $labelLink */$labelLink )
			{
				// Detection of duplicate from/to pairs only applies within an extended link so reset this varaible in each new link
				$this->resetValidateFromToArcPairs();

				$attributes = $labelLink->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XLINK ] );
				if ( ! property_exists( $attributes, 'role' ) || (string) $attributes->role !== $roleRefsKey )
				{
					// The role MUST either be  the default link role or be one of the roles with a 'usedOn' value for the label link element
					if ( XBRL::isValidating() && (string) $attributes->role != XBRL_Constants::$defaultLinkRole && ! isset( $this->context->labelLinkRoleRefs[ (string) $attributes->role ] ) )
					{
					 	$this->log()->taxonomy_validation( "", "Label link with non-standard roles does not have a usedon defined in a role type",
					 		array(
					 			'role' => (string) $attributes->role
					 		)
					 	);
					}
					continue;
				}

				// Process the labels
				//
				// <label
				//		id="uk-gaap-pt_ProfitLossAccountReserve_lbl_3"
				//		xlink:type="resource"
				//		xlink:role="http://www.xbrl.org/2003/role/label"
				//		xlink:label="uk-gaap-pt_ProfitLossAccountReserve_lbl"
				//		xml:lang="en" xlink:title="UKD_profitAndLosAccountRes">
				//	Profit and loss account reserve
				// </label>

				// Begin by reading the locators which have this sort of form
				//
				// <loc
				//		xlink:href="../../pt/2004-12-01/uk-gaap-pt-2004-12-01.xsd#uk-gaap-pt_ProfitLossAccountReserve"
				//		xlink:label="uk-gaap-pt_ProfitLossAccountReserve"
				//		xlink:type="locator"
				//	/>

				// Note: The XBRL specification explicitly defines an element called 'loc' to be the locator.  However,
				//		 the XLink specification allows an element with any local name so long as it has an attribute
				//		 called 'type' with a value of 'locator'.
				$locators = array();
				$locators = $this->retrieveLocators( $labelLink, XBRL_Constants::$LabelLinkbaseRef, $linkbaseRef['href'] );
				// BMS 2018-04-16 For now, label locators are single dimension so re-org the $locators array which allows mutiple text values per label
				$locators = array_map( function( $refsArray ) { return $refsArray[0]; }, $locators );
				//foreach ( $labelLink->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )->loc as $locatorKey => /* @var SimpleXMLElement $loc */ $loc )
				//{
				//	$xlinkAttributes = $loc->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XLINK ] );
                //
				//	if ( ! $this->validateXLinkLocatorAttributes( $xlinkAttributes, 'labels', $linkbaseRef['href'] ) )
				//	{
				//		continue;
				//	}
                //
				//	$type = (string) $xlinkAttributes->type;
				//	$this->validateXLinkLocatorType( 'labels', $type );
                //
				//	$label = (string) $xlinkAttributes->label;
				//	$this->validateXLinkLabel( 'labels', $label );
                //
				//	$parts = parse_url( (string) $xlinkAttributes->href );
				//	if ( ! isset( $parts['path'] ) ) return false;
				//	$xsd = pathinfo( $parts['path'], PATHINFO_BASENAME );
                //
				//	$locators[ $label ] = "$xsd#{$parts['fragment']}";
				//}

				/**
				 * A list of the labels indexed by [$role][$lang][$label]
				 * @var array $labels
				 */
				$labels = array();
				/**
				 * A list of labels indexed by [$xml_basename][$id] where an id attribute is available
				 * @var array $labelsByHref
				 */
				$labelsByHref = array();
				/**
				 * A list of the labels indexed by the xlink:label attribute
				 * @var array $labelsByLabel
				 */
				$labelsByLabel = array();

				// Note: The XBRL specification explicitly defines an element calle 'label' to be the label value.  However,
				//		 the XLink specification allows an element with any local name so long as it has an attribute
				//		 called 'type' with a value of 'resource'.
				foreach ( $labelLink->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )->label as $labelKey => /* @var SimpleXMLElement $labelEl */ $labelEl )
				{
					$xlinkAttributes = $labelEl->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XLINK ] );
					if ( ! $this->validateXLinkResourceAttributes( $xlinkAttributes, 'labels' ) )
					{
						continue;
					}

					$type = (string) $xlinkAttributes->type;
					if ( ! $this->validateXLinkResourceType( 'labels', $type ) )
					{
						continue;
					}

					$role = (string) $xlinkAttributes->role;
					if ( ! $role ) $role = XBRL_Constants::$labelRoleLabel;

					if ( ! isset( $this->context->labelRoleRefs[ $role ] ) )
					{
						$this->log()->warning( "The label role '$role' has not been defined in the schema" );
					}

					$labelLocator = (string) $xlinkAttributes->label;
					$this->validateXLinkLabel( 'labels', $labelLocator );

					$label = isset( $locators[ $labelLocator ] ) ? $locators[ $labelLocator ] : $labelLocator;

					$xmlAttributes = $labelEl->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XML ] );
					$lang = property_exists( $xmlAttributes, 'lang' ) ? (string) $xmlAttributes->lang : $this->getDefaultLanguage();
					if ( XBRL::isValidating() )
					{
						$space = (string)$xmlAttributes->space;
						if ( $space && ! in_array( $space, array( 'default', 'preserve' ) ) )
						{
							$this->log()->taxonomy_validation( "XML", "The xml:space element can only contain the values 'default' or 'preserve'",
								array(
									'space' => "'$space'"
								)
							);
						}

						if ( $lang && ! preg_match( "/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/", $lang ) )
						{
							$this->log()->taxonomy_validation( "XML", "The xml:lang element can only contain values with this regular expression '[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*'",
								array(
									'lang' => "'$lang'"
								)
							);
						}
					}

					$text = $labelEl->__toString();

					if ( ! isset( $labels[ $role ] ) )
					{
						$labels[ $role ] = array();
					}

					if ( ! isset( $labels[ $role ][ $lang ] ) )
					{
						$labels[ $role ][ $lang ] = array();
					}

					$labels[ $role ][ $lang ][ $label ] = array(
						'text' => $text,
					);

					$byLabel = array(
						'text' => $text,
						'lang' => $lang,
						'role' => $role,
					);

					$labelsByLabel[ $label ][] =& $byLabel;

					$attributes = $labelEl->attributes();

					if ( ! property_exists( $attributes, 'id' ) )
					{
						unset( $byLabel );
						continue;
					}

					$id = (string) $attributes->id;
					$labels[ $role ][ $lang ][ $label ]['id'] = $id;
					$byLabel['id'] = $id;
					unset( $byLabel );

					if ( ! isset( $labelsByHref[ $xml_basename ] ) )
					{
						$labelsByHref[ $xml_basename ] = array();
					}

					if ( ! isset( $labelsByHref[ $xml_basename ][ $id ] ) )
					{
						$labelsByHref[ $xml_basename ][ $id ] = array();
					}

					$labelsByHref[ $xml_basename ][ $id ][] = array(
						'role' => $role,
						'label' => $label,
						'lang' => $lang,
					);
				}

				$arcs = array();

				/*
				 * Process the label arcs
				 * In the general case they look like this
				 *
				 *	<labelArc
				 *		priority="1"
				 *		use="prohibited"
				 *		xlink:arcrole="http://www.xbrl.org/2003/arcrole/concept-label"
				 *		xlink:from="uk-gaap-pt_ProfitLossAccountReserve"
				 *		xlink:to="uk-gaap-pt_ProfitLossAccountReserve_lbl_1-orig"
				 *		xlink:type="arc"
				 *	/>
				 *
				 * This is a curious arrangement and comes from the Companies House AE 2009 taxonomy:
				 *
				 *	uk-gaap-ae-2009-06-21-label.xml
				 *	<loc
				 *		xlink:href="uk-gaap-pt-2004-12-01.xsd#uk-gaap-pt_ProfitLossAccountReserve"
				 *		xlink:label="uk-gaap-pt_ProfitLossAccountReserve"
				 *		xlink:type="locator"
				 *	/>
				 *	<loc
				 *		xlink:href="uk-gaap-pt-2004-12-01-labels.xml#uk-gaap-pt_ProfitLossAccountReserve_lbl_0"
				 *		xlink:label="uk-gaap-pt_ProfitLossAccountReserve_lbl_0-orig"
				 *		xlink:type="locator"
				 *	/>
				 *	<labelArc
				 *		priority="1"
				 *		use="prohibited"
				 *		xlink:arcrole="http://www.xbrl.org/2003/arcrole/concept-label"
				 *		xlink:from="uk-gaap-pt_ProfitLossAccountReserve"
				 *		xlink:to="uk-gaap-pt_ProfitLossAccountReserve_lbl_0-orig"
				 *		xlink:type="arc"
				 *	/>
				 *
				 *	uk-gaap-pt-2004-12-01-labels.xml
				 *	<loc
				 *		xlink:type="locator"
				 *		xlink:href="uk-gaap-pt-2004-12-01.xsd#uk-gaap-pt_ProfitLossAccountReserve"
				 *		xlink:label="uk-gaap-pt_ProfitLossAccountReserve"
				 *	/>
				 *	<labelArc
				 *		xlink:type="arc"
				 *		xlink:arcrole="http://www.xbrl.org/2003/arcrole/concept-label"
				 *		xlink:from="uk-gaap-pt_ProfitLossAccountReserve"
				 *		xlink:to="uk-gaap-pt_ProfitLossAccountReserve_lbl"
				 *	/>
				 *  <label
				 *  	id="uk-gaap-pt_ProfitLossAccountReserve_lbl_0"
				 *  	xlink:type="resource"
				 *  	xlink:role="http://www.xbrl.org/2003/role/periodEndLabel"
				 *  	xlink:label="uk-gaap-pt_ProfitLossAccountReserve_lbl"
				 *  	xml:lang="en">Profit and loss account reserve, end of period
				 *  </label>
				 *
				 *	It seems unlikely that the two label arcs shown in this example are equivalent and, so, represent the same relationship
				 *	(see http://www.xbrl.org/Specification/XBRL-2.1/REC-2003-12-31/XBRL-2.1-REC-2003-12-31+corrected-errata-2013-02-20.html#_3.5.3.9.7.4)
				 *	but they do.
				 *
				 *	There are examples from two files here.  The first locator in each defines the label 'uk-gaap-pt_ProfitLossAccountReserve'
				 *	to reference the same concept.  This label forms the 'from' side of the xlink relationships defined by the <labelArc>
				 *	in each file.
				 *
				 *	The second locator in uk-gaap-ae-2009-06-21-label.xml references a label in uk-gaap-ae-2009-06-21-labels.xml file
				 *	by id.  This locator is referenced by 'label' 'uk-gaap-pt_ProfitLossAccountReserve_lbl_0-orig' which is the
				 *	label used as the 'to' side of the labelArc.
				 *
				 *	The 'label' of the <label> is uk-gaap-pt_ProfitLossAccountReserve_lbl.  This makes the 'to' part of the relationship.
				 *	Therefore, the 'to' of the <labelArc> in uk-gaap-ae-2009-06-21-label.xml is really the 'label' of the <label>.  This
				 *	makes the two labelArc equivalent.  As a consequence, both are excluded from the relatationship network.
				 */

				// Used to catch duplicated from/to label pairs which is not alloed by the XLink specification
				$fromToPairs = array();

				// Note: The XBRL specification explicitly defines an element calle 'labelArc' to be the arc.  However,
				//		 the XLink specification allows an element with any local name so long as it has an attribute
				//		 called 'type' with a value of 'arc'.
				foreach ( $labelLink->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )->labelArc as $arcKey => /* @var SimpleXMLElement $labelArc */ $labelArc )
				{
					$xlinkAttributes = $labelArc->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XLINK ] );

					if ( ! $this->validateXLinkArcAttributes( $xlinkAttributes, 'labels' ) )
					{
						continue;
					}

					if ( isset( $fromToPairs[ (string)$xlinkAttributes->from ][ (string)$xlinkAttributes->to ] ) )
					{
						$this->log()->taxonomy_validation( "XLink", "Label arcs contain repeated from/to label pairs in the same extended link",
							array(
								'role' => $roleRefsKey,
								'from' => (string)$xlinkAttributes->from,
								'to' => (string)$xlinkAttributes->to
							)
						);
					}
					else
					{
						$fromToPairs[ (string)$xlinkAttributes->from ][ (string)$xlinkAttributes->to ] = 1;
					}

					$arcroleUri = (string) $xlinkAttributes->arcrole;
					if ( $arcroleUri != XBRL_Constants::$arcRoleConceptLabel )
					{
						if ( isset( $arcroleRefs[ $arcroleUri ] ) )
						{
							continue;
						}

						$this->log()->taxonomy_validation( "5.2.6.2", "The non-standard arcrole on the label arc has not been defined",
							array(
								'arcrole' => $arcroleUri,
							)
						);

						continue;
					}

					$fromLabel	= (string) $xlinkAttributes->from; // The label on the locator
					$this->validateXLinkLabel( 'labels', $fromLabel );

					if ( ! isset( $locators[ $fromLabel ] ) )
					{
						$href = basename( parse_url( $linkbaseRef['href'], PHP_URL_PATH ) );

						$this->log()->taxonomy_validation( "3.5.3.9.2", "The locator does not exist.  Review prior errors.",
							array(
								'linkbase' => $href,
								'from' => $fromLabel
							)
						);

						continue;
					}
					$from		= $locators[ $fromLabel ];
					$toLabel	= (string) $xlinkAttributes->to;   // The label on the <label>
					$this->validateXLinkLabel( 'labels', $toLabel );

					// OK, now the arcs have been read and anomolies addressed look for set
					// and make sure priorities and any prohibitions are taken into account

					$attributes = $labelArc->attributes();
					extract( $this->validateArcAttributes( 'labels', $fromLabel, $toLabel, $attributes ) );
					// $priority	= property_exists( $attributes, 'priority' ) ? (string) $attributes->priority	: "0";
					// $use			= property_exists( $attributes, 'use' ) 	 ? (string) $attributes->use		: "optional";
					// $order		= property_exists( $attributes, 'order' ) 	 ? (string) $attributes->order		: "1";

					// Create an arc for the 'to' component
					if ( ! isset( $arcs[ $from ] ) )
					{
						$arcs[ $from ] = array();
					}

					if ( ! isset( $arcs[ $from ][ $toLabel ] ) )
					{
						$arcs[ $from ][ $toLabel ] = array();
					}

					// Look to see if the 'to' label needs to be fixed.  This could happen if the locator points to a specific label.
					// If it does, then the priority and prohibited states need to be applied to label
					// Get the locator(s) for this 'to' if any exist.  There will be no locator if the $to value refers to a label in the current file.
					if ( isset( $locators[ $toLabel ] ) )
					{
						// It is an error for an arc to reference a locator unless it is probited (XBRL 2.1 5.2.2.3)
						if ( XBRL::isValidating() )
						{
							$error = false;
							if ( $use != 'prohibited' )
							{
								$details = array(
									"lineNo"	=> dom_import_simplexml( $labelArc )->getLineNo(),
									"file"		=> $linkbaseRef['href'],
									"arcLabel"	=> $toLabel,
									"arcHref"	=> $locators[ $toLabel ],
								);
								$this->log()->taxonomy_validation( "5.2.2.3", "Arc to remote resource not prohibited", $details );
								$error = true;
							}

							// A locator for the to label cannot be to a schema element
							// BMS 2019-01-25 So first check its a schema file

							$taxonomy = $this->getTaxonomyForXSD( $locators[ $toLabel ], false );
							if ( $taxonomy )
							{
								$this->log()->taxonomy_validation( "5.2.2.3", "The to attribute of a label arc cannot reference a schema concept",
									array(
										'to label' => "'$toLabel'",
										'to locator' => "'{$locators[ $toLabel ]}'",
										'file' => $linkbaseRef['href'],
									)
								);
								$error = true;
							}
							if ( $error ) continue;
						}

						$parts = parse_url( $locators[ $toLabel ] );
						$xsd = pathinfo( $parts['path'], PATHINFO_BASENAME ); // Could also be a linkbase xml file

						if ( ! isset( $this->context->labels[ XBRL_Constants::$defaultLinkRole ]['labelshref'][ $parts['path'] ] ) ) continue;
						$labelsByHref = $this->context->labels[ XBRL_Constants::$defaultLinkRole ]['labelshref'][ $parts['path'] ];

						if ( ! isset( $labelsByHref[ $parts['fragment'] ] ) ) continue;
						$hrefLabels = $labelsByHref[ $parts['fragment'] ];

						foreach ( $hrefLabels as $hrefLabel )
						{
							// Reconstruct the hash to reflect the reference to the label
							$hash = $this->equivalenceHash( 'labelArc','labelLink', $roleRefsKey, $from, "$xsd#{$hrefLabel['label']}{$hrefLabel['role']}{$hrefLabel['lang']}" );
							// $this->log()->info( $hash );
							// $this->log()->info( "'labelArc', 'labelLink', '$roleRefsKey', '$from', '$xsd#{$hrefLabel['label']}{$hrefLabel['role']}{$hrefLabel['lang']}'" );

							$arcs[ $from ][ $toLabel ][] = array(
								'label'		=> $toLabel,
								'priority'	=> $priority, // Set by extract() function so not visible in debugger until used
								'use'		=> $use, // Set by extract() function so not visible in debugger until used
								'role'		=> $hrefLabel['role'],
								'lang'		=> $hrefLabel['lang'],
								'hash'		=> $hash, // Hash is used to determine arc equivalence
							);
						}
					}
					else
					{
						$arcLables = $labelsByLabel[ $toLabel ];

						foreach ( $arcLables as $arcLabel )
						{
							// The $fromHref and $toHref used in this function should be the same ones used to define the respective label
							// It will be the xs/xml file and the to/from label as a fragment
							// $hash = $this->equivalenceHash( 'labelArc', 'labelLink', $roleRefsKey, $from, "$xml_basename#$toLabel" );
							$hash = $this->equivalenceHash( 'labelArc', 'labelLink', $roleRefsKey, $from, "$xml_basename#$toLabel{$arcLabel['role']}{$arcLabel['lang']}" );

							$arcs[ $from ][ $toLabel ][] = array(
									'label' => $toLabel,
									'priority' => $priority, // Set by extract() function so not visible in debugger until used
									'use' => $use, // Set by extract() function so not visible in debugger until used
									'role' => $arcLabel['role'],
									'lang' => $arcLabel['lang'],
									'hash' => $hash, // Hash is used to determine arc equivalence
							);
						};

					}

					/*

					// Create an arc for the 'to' component
					if ( ! isset( $arcs[ $from ] ) )
					{
						$arcs[ $from ] = array();
					}

					if ( ! isset( $arcs[ $from ][ $toLabel ] ) )
					{
						$arcs[ $from ][ $toLabel ] = array();
					}

					$arcs[ $from ][ $toLabel ][] = array(
						'label' => $toLabel,
						'priority' => $priority,
						'use' => $use,
						'hash' => $hash, // Hash is used to determine arc equivalence
					);

					*/
				}

				unset( $labelsByLabel );

				// Check to see if any of the arcs already exist. They may have been
				// defined in another extended link perhaps in a different linkbase.
				// If they do this can cause a problem so they should be made unique

				foreach ( $arcs as $from => $to )
				{
					foreach ( $to as $toLabel => $details )
					{
						if ( ! isset( $this->context->labels[ $roleRefsKey ]['arcs'][ $from ][ $toLabel ] ) ) continue;

						// A label with this combination already exists so this $toLabel needs
						// to be made unique or it will cause problem accessing the label later
						// Doing so means the corresponding labels need to change

						// The label should be unique within an extended link so generating a hash
						// that includes the extended link role and the linkbase file name should
						// be good enough
						$newLabel = "{$toLabel}_" . hash( "SHA256", "$roleRefsKey$xml_basename" );

						// if ( $roles )
						// {
						// Look for labels with these characteristics
						foreach ( $details as $index => $detail )
						{
							/*
							foreach ( $roles as $role )
							{
								if ( ! isset( $labels[ $role ][ $detail['lang'] ][ $toLabel ] ) ) continue;

								$existing = $labels[ $role ][ $detail['lang'] ][ $toLabel ];
								unset( $labels[ $role ][ $detail['lang'] ][ $toLabel ] );
								$labels[ $role ][ $detail['lang'] ][ $newLabel ] = $existing;
							}
							*/
							if ( ! isset( $labels[ $detail['role'] ][ $detail['lang'] ][ $toLabel ] ) )
							{
								continue;
							}

							$existing = $labels[ $detail['role'] ][ $detail['lang'] ][ $toLabel ];
							unset( $labels[ $detail['role'] ][ $detail['lang'] ][ $toLabel ] );
							$labels[ $detail['role'] ][ $detail['lang'] ][ $newLabel ] = $existing;
						}
						// }

						// Now change this arc label
						$arc = $arcs[ $from ][ $toLabel ];
						unset( $arcs[ $from ][ $toLabel ] );
						$arcs[ $from ][ $newLabel ] = $arc;
					}
				}

				// Now there is a set of locators, arcs, labels and $labelsByHref to store in the context
				$this->context->addLabels( $locators, $arcs, $labels, $labelsByHref, $roleRefsKey );

				// Keep a copy in the extension instance so they can be recovered easily
				if ( $this->context->isExtensionTaxonomy() )
				{
					$this->labels = array(
						// BMS 2018-04-27 Change to allow custom link roles
						// XBRL_Constants::$defaultLinkRole => array(
						$roleRefsKey => array(
							'locators' => $locators,
							'arcs' => $arcs,
							'labels' => $labels,
							'labelshref' => $labelsByHref,
						)
					);
				}

				break;
			}
		}

		return true;
	}
338027
function(options) {
    // Add option to create caller.
    var option = {enabled: true};
    var name = this.getFieldValue('NAME');
    option.text = Blockly.Msg.PROCEDURES_CREATE_DO.replace('%1', name);
    var xmlMutation = goog.dom.createDom('mutation');
    xmlMutation.setAttribute('name', name);
    for (var i = 0; i < this.arguments_.length; i++) {
      var xmlArg = goog.dom.createDom('arg');
      xmlArg.setAttribute('name', this.arguments_[i]);
      xmlMutation.appendChild(xmlArg);
    }
    var xmlBlock = goog.dom.createDom('block', null, xmlMutation);
    xmlBlock.setAttribute('type', this.callType_);
    option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
    options.push(option);

    // Add options to create getters for each parameter.
    if (!this.isCollapsed()) {
      for (var i = 0; i < this.arguments_.length; i++) {
        var option = {enabled: true};
        var name = this.arguments_[i];
        option.text = Blockly.Msg.VARIABLES_SET_CREATE_GET.replace('%1', name);
        var xmlField = goog.dom.createDom('field', null, name);
        xmlField.setAttribute('name', 'VAR');
        var xmlBlock = goog.dom.createDom('block', null, xmlField);
        xmlBlock.setAttribute('type', 'variables_get');
        option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
        options.push(option);
      }
    }
  }
1345267
private function _declare() {
    $node = new DeclareNode();
    $this->mustMatch(T_DECLARE, $node);
    $this->mustMatch('(', $node, 'openParen');
    $directives = new CommaListNode();
    $node->addChild($directives, 'directives');
    if (!$this->tryMatch(')', $node, 'closeParen', FALSE, TRUE)) {
      do {
        $declare_directive = new DeclareDirectiveNode();
        $this->tryMatch(T_STRING, $declare_directive, 'name');
        if ($this->tryMatch('=', $declare_directive)) {
          $declare_directive->addChild($this->staticScalar(), 'value');
        }
        $directives->addChild($declare_directive);
      } while ($this->tryMatch(',', $directives));
      $this->mustMatch(')', $node, 'closeParen', FALSE, TRUE);
    }
    if ($this->tryMatch(':', $node, NULL, FALSE, TRUE)) {
      $node->addChild($this->innerStatementListNode(T_ENDDECLARE), 'body');
      $this->mustMatch(T_ENDDECLARE, $node);
      $this->endStatement($node);
      return $node;
    }
    else {
      $node->addChild($this->statement(), 'body');
      return $node;
    }
  }
1072227
void generateAntIvyXml(Definition def, String outputDir)
   {
      try
      {
         FileWriter antfw = Utils.createFile("build.xml", outputDir);
         BuildIvyXmlGen bxGen = new BuildIvyXmlGen();
         bxGen.generate(def, antfw);
         antfw.close();

         FileWriter ivyfw = Utils.createFile("ivy.xml", outputDir);
         IvyXmlGen ixGen = new IvyXmlGen();
         ixGen.generate(def, ivyfw);
         ivyfw.close();

         FileWriter ivySettingsfw = Utils.createFile("ivy.settings.xml", outputDir);
         IvySettingsXmlGen isxGen = new IvySettingsXmlGen();
         isxGen.generate(def, ivySettingsfw);
         ivySettingsfw.close();
      }
      catch (IOException ioe)
      {
         ioe.printStackTrace();
      }
   }
27225
protected function buildXml()
  {
    if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
      $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
    }

    if (!extension_loaded('zip')) {
      $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_COMMAND);
    }

    $this->checkConnector();
    $this->checkRequest();

    if ( !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
      $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
    }

    if (!isset($_POST["fileName"])) {
      $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
    }

    $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]);
    $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();

    if (!$resourceTypeInfo->checkExtension($fileName)) {
      $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
    }

    if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
      $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
    }

    $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);

    if (!file_exists($filePath) || !is_file($filePath)) {
      $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
    }

    if (!is_writable(dirname($filePath))) {
      $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
    }

    if ( strtolower(pathinfo($fileName, PATHINFO_EXTENSION)) !== 'zip'){
      $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
    }

    $zip = new ZipArchive();
    $result = $zip->open($filePath);
    if ($result !== TRUE) {
      $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNKNOWN);
    }
    $this->zip = $zip;
    $this->filePath = $filePath;
    $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");

    // list of unzipped nodes
    $this->unzippedNodes = new CKFinder_Connector_Utils_XmlNode("UnzippedFiles");

    // list of files which could not be unzipped
    $this->skippedFilesNode = new CKFinder_Connector_Utils_XmlNode("Errors");
    $this->errorCode = CKFINDER_CONNECTOR_ERROR_NONE;
  }
1105417
static function generatePHPCode( $useComments, $php, $tpl, &$node, &$resourceData )
    {
        $parameters = array();
        $currentParameters = array( 'spacing' => 0 );
        $nodeType = $node[0];
        if ( $nodeType == eZTemplate::NODE_ROOT )
        {
            $children = $node[1];
            if ( $children )
            {
                eZTemplateCompiler::generatePHPCodeChildren( $useComments, $php, $tpl, $children, $resourceData, $parameters, $currentParameters );
            }
        }
        else
            $tpl->error( 'generatePHPCode', "Unknown root type $nodeType, should be " . eZTemplate::NODE_ROOT );
        $php->addSpace();
    }
499842
static function processElementTransformationChild( $useComments, $php, $tpl, &$node,
                                                $elementTree, $elementList, &$resourceData )
    {
        $count = is_countable( $elementList ) ? count( $elementList ) : 0;
        $lastElement = null;
        $newElementList = array();
        for ( $i = 0; $i < $count; ++$i )
        {
            $element =& $elementList[$i];
            $elementType = $element[0];
            if ( $elementType == eZTemplate::TYPE_OPERATOR )
            {
                $operatorName = $element[1][0];
                $operatorParameters = array_slice( $element[1], 1 );
                if ( !isset( $tpl->Operators[$operatorName] ) )
                    return false;

                if ( is_array( $tpl->Operators[$operatorName] ) )
                {
                    $tpl->loadAndRegisterOperators( $tpl->Operators[$operatorName] );
                }
                $operatorObject =& $tpl->Operators[$operatorName];
                if ( is_object( $operatorObject ) )
                {
                    $hasTransformationSupport = false;
                    $transformParameters = false;
                    $inputAsParameter = false;
                    $knownType = 'static';
                    if ( method_exists( $operatorObject, 'operatorTemplateHints' ) )
                    {
                        $hints = $operatorObject->operatorTemplateHints();
                        if ( isset( $hints[$operatorName] ) and
                             isset( $hints[$operatorName]['element-transformation'] ) and
                             $hints[$operatorName]['element-transformation'] )
                        {
                            $hasTransformationSupport = true;
                        }

                        if ( $hasTransformationSupport  and
                             isset( $hints[$operatorName]['element-transformation-func'] ) )
                        {
                            $transformationMethod = $hints[$operatorName]['element-transformation-func'];
                        }
                        else
                        {
                            $transformationMethod = 'templateElementTransformation';
                        }

                        if ( isset( $hints[$operatorName] ) and
                             isset( $hints[$operatorName]['transform-parameters'] ) )
                        {
                            $transformParameters = $hints[$operatorName]['transform-parameters'];
                        }

                        if ( isset( $hints[$operatorName] ) and
                             isset( $hints[$operatorName]['input-as-parameter'] ) )
                        {
                            $inputAsParameter = $hints[$operatorName]['input-as-parameter'];
                        }

                        if ( isset( $hints[$operatorName]['output'] ) and !$hints[$operatorName]['output'] )
                        {
                            $knownType = 'null';
                        }
                        else if ( isset( $hints[$operatorName]['output-type'] ) )
                        {
                            $knownType = $hints[$operatorName]['output-type'];
                        }
                    }
                    if ( $hasTransformationSupport and
                         method_exists( $operatorObject, $transformationMethod ) )
                    {
                        $resetNewElementList = false;
                        if ( $transformParameters )
                        {
                            $newParameters = array();
                            if ( $inputAsParameter )
                            {
                                $newParameterElements = eZTemplateCompiler::processElementTransformationChild( $useComments, $php, $tpl, $node,
                                                                                                               $elementTree, $newElementList, $resourceData );
                                if ( count( $newParameterElements ) > 0 or
                                     $inputAsParameter === 'always' )
                                {
                                    $newParameters[] = $newParameterElements;
                                    $resetNewElementList = true;
                                }
                            }

                            foreach ( $operatorParameters as $operatorParameter )
                            {
                                $newParameterElements = eZTemplateCompiler::processElementTransformationChild( $useComments, $php, $tpl, $node,
                                                                                                               $elementTree, $operatorParameter, $resourceData );
                                if ( !$newParameterElements )
                                    $newParameters[] = $operatorParameter;
                                else
                                    $newParameters[] = $newParameterElements;
                            }
                            $operatorParameters = $newParameters;
                        }

                        $newElements = $operatorObject->$transformationMethod( $operatorName, $node, $tpl, $resourceData,
                                                                               $element, $lastElement, $elementList, $elementTree,
                                                                               $operatorParameters );
                        if ( is_array( $newElements ) )
                        {
                            if ( $resetNewElementList )
                            {
                                $newElementList = $newElements;
                            }
                            else
                            {
                                $newElementList = array_merge( $newElementList, $newElements );
                            }
                        }
                        else
                        {
                            $newElementList[] = $element;
                        }
                    }
                    else
                    {
                        $newElementList[] = $element;
                    }
                }
                else if ( $resourceData['test-compile'] )
                {
                    $tpl->warning( '', "Operator '$operatorName' is not registered." );
                }
            }
            else
            {
                $newElementList[] = $element;
            }
            $lastElement = $element;
        }
        return $newElementList;
    }
330712
function inputTagXML( &$tag, $currentSectionLevel, $tdSectionLevel = null )
    {
        $output       = '';
        $tagName      = $tag instanceof DOMNode ? $tag->nodeName : '';
        $childTagText = '';

        // render children tags
        if ( $tag->hasChildNodes() )
        {
            $tagChildren = $tag->childNodes;
            foreach ( $tagChildren as $childTag )
            {
                $childTagText .= $this->inputTagXML( $childTag, $currentSectionLevel, $tdSectionLevel );
            }
        }
        switch ( $tagName )
        {
            case '#text' :
            {
                $tagContent = $tag->textContent;
                if ( !strlen( $tagContent ) )
                {
                    break;
                }

                $tagContent = htmlspecialchars( $tagContent );
                $tagContent = str_replace ( '&amp;nbsp;', '&nbsp;', $tagContent );

                if ( $this->allowMultipleSpaces )
                {
                    $tagContent = str_replace( '  ', ' &nbsp;', $tagContent );
                }
                else
                {
                    $tagContent = preg_replace( "/ {2,}/", ' ', $tagContent );
                }

                if ( $tagContent[0] === ' ' && !$tag->previousSibling )//- Fixed "first space in paragraph" issue (ezdhtml rev.12246)
                {
                    $tagContent[0] = ';';
                    $tagContent = '&nbsp' . $tagContent;
                }

                if ( $this->allowNumericEntities )
                    $tagContent = preg_replace( '/&amp;#([0-9]+);/', '&#\1;', $tagContent );

                $output .= $tagContent;

            }break;

            case 'embed' :
            case 'embed-inline' :
            {
                $view      = $tag->getAttribute( 'view' );
                $size      = $tag->getAttribute( 'size' );
                $alignment = $tag->getAttribute( 'align' );
                $objectID  = $tag->getAttribute( 'object_id' );
                $nodeID    = $tag->getAttribute( 'node_id' );
                $showPath  = $tag->getAttribute( 'show_path' );
                $htmlID    = $tag->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/', 'id' );
                $className = $tag->getAttribute( 'class' );
                $idString  = '';
                $tplSuffix = '';

                if ( !$size )
                {
                    $contentIni = eZINI::instance( 'content.ini' );
                    $size       = $contentIni->variable( 'ImageSettings', 'DefaultEmbedAlias' );
                }

                if ( !$view )
                {
                    $view = $tagName;
                }

                $objectAttr = '';
                $objectAttr .= ' alt="' . $size . '"';
                $objectAttr .= ' view="' . $view . '"';

                if ( $htmlID != '' )
                {
                    $objectAttr .= ' html_id="' . $htmlID . '"';
                }
                if ( $showPath === 'true' )
                {
                    $objectAttr .= ' show_path="true"';
                }

                if ( $tagName === 'embed-inline' )
                    $objectAttr .= ' inline="true"';
                else
                    $objectAttr .= ' inline="false"';

                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );
                $object              = false;

                if ( is_numeric( $objectID ) )
                {
                    $object = eZContentObject::fetch( $objectID );
                    $idString = 'eZObject_' . $objectID;
                }
                elseif ( is_numeric( $nodeID ) )
                {
                    $node      = eZContentObjectTreeNode::fetch( $nodeID );
                    $object    = $node instanceof eZContentObjectTreeNode ? $node->object() : false;
                    $idString  = 'eZNode_' . $nodeID;
                    $tplSuffix = '_node';
                }

                if ( $object instanceof eZContentObject )
                {
                    $objectName = $object->attribute( 'name' );
                    $classIdentifier = $object->attribute( 'class_identifier' );
                    if ( !$object->attribute( 'can_read' ) ||
                         !$object->attribute( 'can_view_embed' ) )
                    {
                        $tplSuffix = '_denied';
                    }
                    else if ( $object->attribute( 'status' ) == eZContentObject::STATUS_ARCHIVED )
                    {
                        $className .= ' ezoeItemObjectInTrash';
                        if ( self::$showEmbedValidationErrors )
                        {
                            $oeini = eZINI::instance( 'ezoe.ini' );
                            if ( $oeini->variable('EditorSettings', 'ValidateEmbedObjects' ) === 'enabled' )
                                $className .= ' ezoeItemValidationError';
                        }
                    }
                }
                else
                {
                    $objectName = 'Unknown';
                    $classIdentifier = false;
                    $tplSuffix = '_deleted';
                    $className .= ' ezoeItemObjectDeleted';
                    if ( self::$showEmbedValidationErrors )
                    {
                        $className .= ' ezoeItemValidationError';
                    }
                }

                $embedContentType = self::embedTagContentType( $classIdentifier );
                if ( $embedContentType === 'images' )
                {
                    $ini = eZINI::instance();
                    $URL = self::getServerURL();
                    $objectAttributes = $object->contentObjectAttributes();
                    $imageDatatypeArray = $ini->variable('ImageDataTypeSettings', 'AvailableImageDataTypes');
                    $imageWidth = 32;
                    $imageHeight = 32;
                    foreach ( $objectAttributes as $objectAttribute )
                    {
                        $classAttribute = $objectAttribute->contentClassAttribute();
                        $dataTypeString = $classAttribute->attribute( 'data_type_string' );
                        if ( in_array ( $dataTypeString, $imageDatatypeArray ) && $objectAttribute->hasContent() )
                        {
                            $content = $objectAttribute->content();
                            if ( $content == null )
                                continue;

                            if ( $content->hasAttribute( $size ) )
                            {
                                $imageAlias  = $content->imageAlias( $size );
                                $srcString   = $URL . '/' . $imageAlias['url'];
                                $imageWidth  = $imageAlias['width'];
                                $imageHeight = $imageAlias['height'];
                                break;
                            }
                            else
                            {
                                eZDebug::writeError( "Image alias does not exist: $size, missing from image.ini?",
                                    __METHOD__ );
                            }
                        }
                    }

                    if ( !isset( $srcString ) )
                    {
                        $srcString = self::getDesignFile('images/tango/mail-attachment32.png');
                    }

                    if ( $alignment === 'center' )
                    {
                        $objectAttr .= ' align="middle"';
                        $className .= ' ezoeAlignmiddle'; // align="middle" is not taken into account by browsers on img
                    }
                    else if ( $alignment )
                        $objectAttr .= ' align="' . $alignment . '"';

                    if ( $className != '' )
                        $objectAttr .= ' class="' . $className . '"';

                    $output .= '<img id="' . $idString . '" title="' . $objectName . '" src="' .
                               htmlspecialchars( $srcString ) . '" width="' . $imageWidth . '" height="' . $imageHeight .
                               '" ' . $objectAttr . $customAttributePart . $styleString . ' />';
                }
                else if ( self::embedTagIsCompatibilityMode() )
                {
                    $srcString = self::getDesignFile('images/tango/mail-attachment32.png');
                    if ( $alignment === 'center' )
                        $objectAttr .= ' align="middle"';
                    else if ( $alignment )
                        $objectAttr .= ' align="' . $alignment . '"';

                    if ( $className != '' )
                        $objectAttr .= ' class="' . $className . '"';

                    $output .= '<img id="' . $idString . '" title="' . $objectName . '" src="' .
                               $srcString . '" width="32" height="32" ' . $objectAttr .
                               $customAttributePart . $styleString . ' />';
                }
                else
                {
                    if ( $alignment )
                        $objectAttr .= ' align="' . $alignment . '"';

                    if ( $className )
                        $objectAttr .= ' class="ezoeItemNonEditable ' . $className . ' ezoeItemContentType' .
                                       ucfirst( $embedContentType ) . '"';
                    else
                        $objectAttr .= ' class="ezoeItemNonEditable ezoeItemContentType' .
                                       ucfirst( $embedContentType ) . '"';

                    if ( $tagName === 'embed-inline' )
                        $htmlTagName = 'span';
                    else
                        $htmlTagName = 'div';

                    $objectParam = array( 'size' => $size, 'align' => $alignment, 'show_path' => $showPath );
                    if ( $htmlID ) $objectParam['id'] = $htmlID;

                    $res = eZTemplateDesignResource::instance();
                    $res->setKeys( array( array('classification', $className) ) );

                    if ( isset( $node ) )
                    {
                        $templateOutput = self::fetchTemplate( 'design:content/datatype/view/ezxmltags/' . $tagName . $tplSuffix . '.tpl', array(
                            'view' => $view,
                            'object' => $object,
                            'link_parameters' => array(),
                            'classification' => $className,
                            'object_parameters' => $objectParam,
                            'node' => $node,
                        ));
                    }
                    else
                    {
                        $templateOutput = self::fetchTemplate( 'design:content/datatype/view/ezxmltags/' . $tagName . $tplSuffix . '.tpl', array(
                            'view' => $view,
                            'object' => $object,
                            'link_parameters' => array(),
                            'classification' => $className,
                            'object_parameters' => $objectParam,
                        ));
                    }

                    $output .= '<' . $htmlTagName . ' id="' . $idString . '" title="' . $objectName . '"' .
                               $objectAttr . $customAttributePart . $styleString . '>' . $templateOutput .
                               '</' . $htmlTagName . '>';
                }
            }break;

            case 'custom' :
            {
                $name = $tag->getAttribute( 'name' );
                $align = $tag->getAttribute( 'align' );
                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );
                $inline = self::customTagIsInline( $name );
                if ( $align )
                {
                    $customAttributePart .= ' align="' . $align . '"';
                }

                if ( isset( self::$nativeCustomTags[ $name ] ))
                {
                    if ( !$childTagText ) $childTagText = '&nbsp;';
                    $output .= '<' . self::$nativeCustomTags[ $name ] . $customAttributePart . $styleString .
                               '>' . $childTagText . '</' . self::$nativeCustomTags[ $name ] . '>';
                }
                else if ( $inline === true )
                {
                    if ( !$childTagText ) $childTagText = '&nbsp;';
                    $tagName = $name === 'underline' ? 'u' : 'span';
                    $output .= '<' . $tagName . ' class="ezoeItemCustomTag ' . $name . '" type="custom"' .
                               $customAttributePart . $styleString . '>' . $childTagText . '</' . $tagName . '>';
                }
                else if ( $inline )
                {
                    $imageUrl = self::getCustomAttribute( $tag, 'image_url' );
                    if ( $imageUrl === null || !$imageUrl )
                    {
                        $imageUrl = self::getDesignFile( $inline );
                        $customAttributePart .= ' width="22" height="22"';
                    }
                    $output .= '<img src="' . $imageUrl . '" class="ezoeItemCustomTag ' . $name .
                               '" type="custom"' . $customAttributePart . $styleString . ' />';
                }
                else if ( $tag->textContent === '' && !$tag->hasChildNodes() )
                {
                    // for empty custom tag, just put a paragraph with the name
                    // of the custom tag in to handle it in the rich text editor
                    $output .= '<div class="ezoeItemCustomTag ' . $name . '" type="custom"' .
                                    $customAttributePart . $styleString . '><p>' . $name . '</p></div>';
                }
                else
                {
                    $customTagContent = $this->inputSectionXML( $tag, $currentSectionLevel, $tdSectionLevel );
                    /*foreach ( $tag->childNodes as $tagChild )
                    {
                        $customTagContent .= $this->inputTdXML( $tagChild,
                                                                $currentSectionLevel,
                                                                $tdSectionLevel );
                    }*/
                    $output .= '<div class="ezoeItemCustomTag ' . $name . '" type="custom"' .
                               $customAttributePart . $styleString . '>' . $customTagContent . '</div>';
                }
            }break;

            case 'literal' :
            {
                $literalText = '';
                foreach ( $tagChildren as $childTag )
                {
                    $literalText .= $childTag->textContent;
                }
                $className = $tag->getAttribute( 'class' );

                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                $literalText = htmlspecialchars( $literalText );
                $literalText = str_replace( "\n", '<br />', $literalText );

                if ( $className != '' )
                    $customAttributePart .= ' class="' . $className . '"';

                $output .= '<pre' . $customAttributePart . $styleString . '>' . $literalText . '</pre>';

            }break;

            case 'ul' :
            case 'ol' :
            {
                $listContent = '';

                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                // find all list elements
                foreach ( $tag->childNodes as $listItemNode )
                {
                    if ( !$listItemNode instanceof DOMElement )
                    {
                        continue;// ignore whitespace
                    }

                    $LIcustomAttributePart = self::getCustomAttrPart( $listItemNode, $listItemStyleString );

                    $noParagraphs = self::childTagCount( $listItemNode ) <= 1;
                    $listItemContent = '';
                    foreach ( $listItemNode->childNodes as $itemChildNode )
                    {
                        $listSectionLevel = $currentSectionLevel;
                        if ( $itemChildNode instanceof DOMNode
                        && ( $itemChildNode->nodeName === 'section'
                          || $itemChildNode->nodeName === 'paragraph' ) )
                        {
                            $listItemContent .= $this->inputListXML( $itemChildNode,
                                                                     $currentSectionLevel,
                                                                     $listSectionLevel,
                                                                     $noParagraphs );
                        }
                        else
                        {
                            $listItemContent .= $this->inputTagXML( $itemChildNode,
                                                                    $currentSectionLevel,
                                                                    $tdSectionLevel );
                        }
                    }

                    $LIclassName = $listItemNode->getAttribute( 'class' );

                    if ( $LIclassName )
                        $LIcustomAttributePart .= ' class="' . $LIclassName . '"';

                    $listContent .= '<li' . $LIcustomAttributePart . $listItemStyleString . '>' .
                                    $listItemContent . '</li>';
                }
                $className = $tag->getAttribute( 'class' );
                if ( $className != '' )
                    $customAttributePart .= ' class="' . $className . '"';

                $output .= '<' . $tagName . $customAttributePart . $styleString . '>' . $listContent . '</' .
                           $tagName . '>';
            }break;

            case 'table' :
            {
                $tableRows = '';
                $border = $tag->getAttribute( 'border' );
                $width = $tag->getAttribute( 'width' );
                $align = $tag->getAttribute( 'align' );
                $tableClassName = $tag->getAttribute( 'class' );

                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                // find all table rows
                foreach ( $tag->childNodes as $tableRow )
                {
                    if ( !$tableRow instanceof DOMElement )
                    {
                        continue; // ignore whitespace
                    }
                    $TRcustomAttributePart = self::getCustomAttrPart( $tableRow, $tableRowStyleString );
                    $TRclassName = $tableRow->getAttribute( 'class' );

                    $tableData = '';
                    foreach ( $tableRow->childNodes as $tableCell )
                    {
                        if ( !$tableCell instanceof DOMElement )
                        {
                            continue; // ignore whitespace
                        }

                        $TDcustomAttributePart = self::getCustomAttrPart( $tableCell, $tableCellStyleString );

                        $className = $tableCell->getAttribute( 'class' );
                        $cellAlign = $tableCell->getAttribute( 'align' );

                        $colspan = $tableCell->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/',
                                                               'colspan' );
                        $rowspan = $tableCell->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/',
                                                               'rowspan' );
                        $cellWidth = $tableCell->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/',
                                                                 'width' );
                        if ( $className != '' )
                        {
                            $TDcustomAttributePart .= ' class="' . $className . '"';
                        }
                        if ( $cellWidth != '' )
                        {
                            $TDcustomAttributePart .= ' width="' . $cellWidth . '"';
                        }
                        if ( $colspan && $colspan !== '1' )
                        {
                            $TDcustomAttributePart .= ' colspan="' . $colspan . '"';
                        }
                        if ( $rowspan && $rowspan !== '1' )
                        {
                            $TDcustomAttributePart .= ' rowspan="' . $rowspan . '"';
                        }
                        if ( $cellAlign )
                        {
                        	$TDcustomAttributePart .= ' align="' . $cellAlign . '"';
                        }
                        $cellContent = '';
                        $tdSectionLevel = $currentSectionLevel;
                        foreach ( $tableCell->childNodes as $tableCellChildNode )
                        {
                            $cellContent .= $this->inputTdXML( $tableCellChildNode,
                                                               $currentSectionLevel,
                                                               $tdSectionLevel - $currentSectionLevel );
                        }
                        if ( $cellContent === '' )
                        {
                            // tinymce has some issues with empty content in some browsers
                            if ( self::browserSupportsDHTMLType() != 'Trident' )
                                $cellContent = '<p><br data-mce-bogus="1"/></p>';
                        }
                        if ( $tableCell->nodeName === 'th' )
                        {
                            $tableData .= '<th' . $TDcustomAttributePart . $tableCellStyleString . '>' .
                                          $cellContent . '</th>';
                        }
                        else
                        {
                            $tableData .= '<td' . $TDcustomAttributePart . $tableCellStyleString . '>' .
                                          $cellContent . '</td>';
                        }
                    }
                    if ( $TRclassName )
                        $TRcustomAttributePart .= ' class="' . $TRclassName . '"';

                    $tableRows .= '<tr' . $TRcustomAttributePart . $tableRowStyleString . '>' .
                                  $tableData . '</tr>';
                }
                //if ( self::browserSupportsDHTMLType() === 'Trident' )
                //{
                    $customAttributePart .= ' width="' . $width . '"';
                /*}
                else
                {
                    // if this is reenabled merge it with $styleString
                    $customAttributePart .= ' style="width:' . $width . ';"';
                }*/

                if ( $border !== '' && is_string( $border ) )
                {
                    if ( $border === '0%' )
                        $border = '0';// Strip % if 0 to make sure TinyMCE shows a dotted border

                    $customAttributePart .= ' border="' . $border . '"';
                }

                if ( $align )
                {
                    $customAttributePart .= ' align="' . $align . '"';
                }

                if ( $tableClassName )
                {
                    $customAttributePart .= ' class="' . $tableClassName . '"';
                }

                $output .= '<table' . $customAttributePart . $styleString . '><tbody>' . $tableRows .
                           '</tbody></table>';
            }break;

            // normal content tags
            case 'emphasize' :
            {
                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                $className = $tag->getAttribute( 'class' );
                if ( $className )
                {
                    $customAttributePart .= ' class="' . $className . '"';
                }
                $output .= '<em' . $customAttributePart . $styleString . '>' . $childTagText  . '</em>';
            }break;

            case 'strong' :
            {
                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                $className = $tag->getAttribute( 'class' );
                if ( $className  )
                {
                    $customAttributePart .= ' class="' . $className . '"';
                }
                $output .= '<strong' . $customAttributePart . $styleString . '>' . $childTagText  . '</strong>';
            }break;

            case 'line' :
            {
                $output .= $childTagText . '<br />';
            }break;

            case 'anchor' :
            {
                $name = $tag->getAttribute( 'name' );

                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                $output .= '<a name="' . $name . '" class="mceItemAnchor"' . $customAttributePart .
                           $styleString . '></a>';
            }break;

            case 'link' :
            {
                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                $linkID = $tag->getAttribute( 'url_id' );
                $target = $tag->getAttribute( 'target' );
                $className = $tag->getAttribute( 'class' );
                $viewName = $tag->getAttribute( 'view' );
                $objectID = $tag->getAttribute( 'object_id' );
                $nodeID = $tag->getAttribute( 'node_id' );
                $anchorName = $tag->getAttribute( 'anchor_name' );
                $showPath = $tag->getAttribute( 'show_path' );
                $htmlID = $tag->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/', 'id' );
                $htmlTitle = $tag->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/', 'title' );
                $attributes = array();

                if ( $objectID != null )
                {
                    $href = 'ezobject://' .$objectID;
                }
                elseif ( $nodeID != null )
                {
                    if ( $showPath === 'true' )
                    {
                        $node = eZContentObjectTreeNode::fetch( $nodeID );
                        $href = $node ?
                                'eznode://' . $node->attribute('path_identification_string') :
                                'eznode://' . $nodeID;
                    }
                    else
                    {
                        $href = 'eznode://' . $nodeID;
                    }
                }
                elseif ( $linkID != null )
                {
                    $href = eZURL::url( $linkID );
                }
                else
                {
                    $href = $tag->getAttribute( 'href' );
                }

                if ( $anchorName != null )
                {
                    $href .= '#' . $anchorName;
                }

                if ( $className != '' )
                {
                    $attributes[] = 'class="' . $className . '"';
                }

                if ( $viewName != '' )
                {
                    $attributes[] = 'view="' . $viewName . '"';
                }

                $attributes[] = 'href="' . $href . '"';
                // Also set mce_href for use by OE to make sure href attribute is not messed up by IE 6 / 7
                $attributes[] = 'data-mce-href="' . $href . '"';
                if ( $target != '' )
                {
                    $attributes[] = 'target="' . $target . '"';
                }
                if ( $htmlTitle != '' )
                {
                    $attributes[] = 'title="' . $htmlTitle . '"';
                }
                if ( $htmlID != '' )
                {
                   $attributes[] = 'id="' . $htmlID . '"';
                }

                $attributeText = '';
                if ( !empty( $attributes ) )
                {
                    $attributeText = ' ' .implode( ' ', $attributes );
                }
                $output .= '<a' . $attributeText . $customAttributePart . $styleString . '>' .
                           $childTagText . '</a>';
            }break;
            case 'tr' :
            case 'td' :
            case 'th' :
            case 'li' :
            case 'paragraph' :
            {
            }break;
            default :
            {

            }break;
        }
        return $output;
    }
550727
private function generateSingleArgumentDocblock(ClientMethodContext $context): DocBlockGenerator
    {
        $method = $context->getMethod();
        $class = $context->getClass();
        $param = current($method->getParameters());

        return DocBlockGeneratorFactory::fromArray(
            [
                'tags' => [
                    [
                        'name' => 'param',
                        'description' => sprintf(
                            '%s|%s $%s',
                            $this->generateClassNameAndAddImport(RequestInterface::class, $class),
                            $this->generateClassNameAndAddImport($param->getType(), $class, true),
                            $param->getName()
                        ),
                    ],
                    [
                        'name' => 'return',
                        'description' => sprintf(
                            '%s|%s',
                            $this->generateClassNameAndAddImport(ResultInterface::class, $class),
                            $this->generateClassNameAndAddImport(
                                $method->getNamespacedReturnType(),
                                $class,
                                true
                            )
                        ),

                    ],
                    [
                        'name' => 'throws',
                        'description' => $this->generateClassNameAndAddImport(
                            SoapException::class,
                            $class
                        ),
                    ],
                ],
            ]
        )->setWordWrap(false);
    }
303948
def to_xml(self, xml_declaration=True):
        
        xml = ET.tostring(self.xml()).decode('utf-8')
        return '<?xml version="1.0" encoding="UTF-8"?>{}'.format(xml) if xml_declaration else xml
139750
function buildXml()
    {
        if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
        }

        $this->checkConnector();
        $this->checkRequest();

        //resizing to 1x1 is almost equal to deleting a file, that's why FILE_DELETE permissions are required
        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE) || !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
        }

        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();

        if (!isset($_POST["fileName"])) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
        }

        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]);

        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
        }

        if (!$resourceTypeInfo->checkExtension($fileName, false)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
        }

        $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);

        if (!file_exists($filePath) || !is_file($filePath)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
        }

        $newWidth = trim($_POST['width']);
        $newHeight = trim($_POST['height']);
        $quality = 80;
        $resizeOriginal = !empty($_POST['width']) && !empty($_POST['height']);

        if ($resizeOriginal) {
            if (!preg_match("/^\d+$/", $newWidth) || !preg_match("/^\d+$/", $newHeight) || !preg_match("/^\d+$/", $newWidth)) {
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
            }
            if (!isset($_POST["newFileName"])) {
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
            }
            $newFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["newFileName"]);
            if (!$resourceTypeInfo->checkExtension($newFileName)) {
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
            }
            if (!CKFinder_Connector_Utils_FileSystem::checkFileName($newFileName) || $resourceTypeInfo->checkIsHiddenFile($newFileName)) {
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
            }
            $newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $newFileName);
            if (!is_writable(dirname($newFilePath))) {
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
            }
            if ($_POST['overwrite'] != "1" && file_exists($newFilePath)) {
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
            }
            $_imagesConfig = $_config->getImagesConfig();
            $maxWidth = $_imagesConfig->getMaxWidth();
            $maxHeight = $_imagesConfig->getMaxHeight();
            // Shouldn't happen as the JavaScript validation should not allow this.
            if ( ( $maxWidth > 0 && $newWidth > $maxWidth ) || ( $maxHeight > 0 && $newHeight > $maxHeight ) ) {
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
            }
        }

        require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/Thumbnail.php";

        if ($resizeOriginal) {
            $result = CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $newWidth, $newHeight, $quality, false) ;
            if (!$result) {
                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
            }
        }

        $config = $this->getConfig();
        $nameWithoutExt = preg_replace("/^(.+)\_\d+x\d+$/", "$1", CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($fileName));
        $extension = CKFinder_Connector_Utils_FileSystem::getExtension($fileName);
        foreach (array('small', 'medium', 'large') as $size) {
            if (!empty($_POST[$size]) && $_POST[$size] == '1') {
                $thumbName = $nameWithoutExt."_".$size.".".$extension;
                $newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $thumbName);
                if (!empty($config[$size.'Thumb'])) {
                    if (preg_match("/^(\d+)x(\d+)$/", $config[$size.'Thumb'], $matches)) {
                        CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $matches[1], $matches[2], $quality, true) ;
                    }
                }
            }
        }

    }
922992
function invoke() {
        parent::invoke();

        $result = true;

        // Set own core attributes
        $this->does_generate = ACTION_GENERATE_HTML;

        // These are always here
        global $CFG, $XMLDB;

        // Do the job, setting $result as needed

        // Get the dir containing the file
        $dirpath = required_param('dir', PARAM_PATH);
        $dirpath = $CFG->dirroot . $dirpath;
        $path = $dirpath.'/install.xml';
        if(!file_exists($path) || !is_readable($path)) {
            return false;
        }

        // Add link back to home
        $b = ' <p class="centerpara buttons">';
        $b .= '&nbsp;<a href="index.php?action=main_view#lastused">[' . $this->str['backtomainview'] . ']</a>';
        $b .= '</p>';
        $this->output=$b;

        $c = ' <p class="centerpara">';
        $c .= $this->str['documentationintro'];
        $c .= '</p>';
        $this->output.=$c;

        if(class_exists('XSLTProcessor')) {
            // Transform XML file and display it
            $doc = new DOMDocument();
            $xsl = new XSLTProcessor();

            $doc->load(__DIR__.'/xmldb.xsl');
            $xsl->importStyleSheet($doc);

            $doc->load($path);
            $this->output.=$xsl->transformToXML($doc);
            $this->output.=$b;
        } else {
            $this->output.=get_string('extensionrequired','tool_xmldb','xsl');
        }

        // Launch postaction if exists (leave this unmodified)
        if ($this->getPostAction() && $result) {
            return $this->launch($this->getPostAction());
        }

        return $result;
    }
1288547
def add_xml_declaration(fn):
    
    @wraps(fn)
    def add_xml_declaration_decorator(*args, **kwargs):
        return '<?xml version="1.0" encoding="UTF-8"?>\n\n' + fn(
            *args,
            **kwargs
        )

    return add_xml_declaration_decorator
729556
protected function createJUnitXMLWriter()
    {
        $streamWriter = $this->createStreamWriter($this->junitXMLFile);
        $utf8Converter = extension_loaded('mbstring') ? new UTF8Converter() : new NullUTF8Converter();

        return $this->junitXMLRealtime ? new StreamJUnitXMLWriter($streamWriter, $utf8Converter) : new DOMJUnitXMLWriter($streamWriter, $utf8Converter);
    }