Render a resource URL for Fractal, possibly treated with the `path` view helper

@param array $arguments
@param \Closure $renderChildrenClosure
@param RenderingContextInterface $renderingContext

@return string
508140
public static function renderStatic(
        array $arguments,
        \Closure $renderChildrenClosure,
        RenderingContextInterface $renderingContext
    ) {
        $content = trim($renderChildrenClosure());

        return preg_match('%^https?\:\/\/%', $content) ?
            htmlspecialchars($content) : '{{ path \'/'.ltrim($content, '/').'\' }}';
    }
219044
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WCollapsible collapsible = (WCollapsible) component;
		XmlStringBuilder xml = renderContext.getWriter();
		WComponent content = collapsible.getContent();
		boolean collapsed = collapsible.isCollapsed();

		xml.appendTagOpen("ui:collapsible");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendAttribute("groupName", collapsible.getGroupName());
		xml.appendOptionalAttribute("collapsed", collapsed, "true");
		xml.appendOptionalAttribute("hidden", collapsible.isHidden(), "true");

		switch (collapsible.getMode()) {
			case CLIENT:
				xml.appendAttribute("mode", "client");
				break;
			case LAZY:
				xml.appendAttribute("mode", "lazy");
				break;
			case EAGER:
				xml.appendAttribute("mode", "eager");
				break;
			case DYNAMIC:
				xml.appendAttribute("mode", "dynamic");
				break;
			case SERVER:
				xml.appendAttribute("mode", "server");
				break;
			default:
				throw new SystemException("Unknown collapsible mode: " + collapsible.getMode());
		}

		HeadingLevel level = collapsible.getHeadingLevel();
		if (level != null) {
			xml.appendAttribute("level", level.getLevel());
		}

		xml.appendClose();

		// Render margin
		MarginRendererUtil.renderMargin(collapsible, renderContext);

		// Label
		collapsible.getDecoratedLabel().paint(renderContext);

		// Content
		xml.appendTagOpen("ui:content");
		xml.appendAttribute("id", component.getId() + "-content");
		xml.appendClose();

		// Render content if not EAGER Mode or is EAGER and is the current AJAX trigger
		if (CollapsibleMode.EAGER != collapsible.getMode() || AjaxHelper.isCurrentAjaxTrigger(
				collapsible)) {
			// Visibility of content set in prepare paint
			content.paint(renderContext);
		}

		xml.appendEndTag("ui:content");

		xml.appendEndTag("ui:collapsible");
	}
981051
protected function renderChildren(Context $context) {

        $doNotRenderFigParam = $context->isDoNotRenderFigParams();

		$result = '';
		//If a fig treatment happened already, then outputBuffer contains
		//the result to use. Otherwise, it needs to be calculated recursively
		//with the children.
		if($this->outputBuffer === null) {
			//A mute tag that does not have any content rendered yet, should not output the consecutive blank cdata.
			if( $this->isMute($context) ) {
				if(isset($this->children[0]) && ($this->children[0] instanceof ViewElementCData) ) {
					//TODO: comprendre pourquoi il me reste des blancs avant ?xml
					$this->children[0]->outputBuffer = preg_replace('#^[ \\t]*\\n#', '', $this->children[0]->outputBuffer);
				}
			}

			$nChildren = count($this->children);
			for($iChild = 0; $iChild < $nChildren; ++$iChild) {
				$child = & $this->children[$iChild];
				if($doNotRenderFigParam && ($child instanceof ViewElementTag) && ($child->getTagName() == $context->figNamespace . 'param') ) {
					//This situation is encountered when a sourced fig:trans tag has a fig:param immediate child:
					//the fig:param is used to resolve the translation, but it must not be rendered in the value of the
					//fig:trans tag (because it is sourced, it means that the translation is not to be taken from an external dictionary,
					//but rather directly the rendered content of the fig:trans tag).
					continue;
				}

				$subRender = $child->render($context);
				//Caution: it used to work fine, and then I got a: Could not
				//convert ViewElementTag to string,
				//as I called a macro with a fig:param being some XML piece, instead of a plain value.
				//So I added this additional step: the rendering of the said ViewElementTag.
				if($subRender instanceof ViewElement) {
					$subRender = $subRender->render($context);
				}
				$result .= $subRender;

			}
		} else {
			$result = $this->outputBuffer;
		}

		return $result;
	}
361248
@Override
    public boolean render (
        InternalContextAdapter context, Writer writer, Node node)
        throws IOException, ResourceNotFoundException, ParseErrorException,
               MethodInvocationException
    {
        // make sure an argument was supplied to the directive
        if (node.jjtGetChild(0) == null) {
            rsvc.getLog().error("#import() error :  null argument");
            return false;
        }

        // make sure that argument has a value
        Object value = node.jjtGetChild(0).value(context);
        if (value == null) {
            rsvc.getLog().error("#import() error :  null argument");
            return false;
        }

        // obtain the path to the desired template
        String path = value.toString();

        // make sure we haven't exceeded the configured parse depth
        Object[] templateStack = context.getTemplateNameStack();
        int maxlen = rsvc.getInt(
            RuntimeConstants.PARSE_DIRECTIVE_MAXDEPTH, 20);
        if (templateStack.length >= maxlen) {
            rsvc.getLog().error("Max recursion depth reached (" + maxlen + "). "  +
                                "File stack: " + StringUtil.toString(templateStack) + ".");
            return false;
        }

        // inherit the current encoding if there is a current template,
        // otherwise use the configured encoding
        String encoding = null;
        Resource current = context.getCurrentResource();
        if (current != null) {
            encoding = current.getEncoding();
        } else {
            encoding = (String)
                rsvc.getProperty(RuntimeConstants.INPUT_ENCODING);
        }

        // adjust the template path with the site information in the current
        // context if available. the siteid is shoved into the context by the
        // dispatcher servlet when we're using the site resource loader. this
        // is a hack, i know, but i couldn't convince the velocity peeps that
        // we should have access to a request context in places like this
        Object siteIdVal = context.get("__siteid__");
        if (siteIdVal != null) {
            int siteId = SiteIdentifier.DEFAULT_SITE_ID;
            try {
                siteId = ((Integer)siteIdVal).intValue();
            } catch (Exception e) {
                rsvc.getLog().error("#import() error: No siteId information in context.");
            }
            path = siteId + ":" + path;
        }

        // locate the requested template
        Template t = null;
        try {
            t = rsvc.getTemplate(path, encoding);

        } catch (ResourceNotFoundException rnfe) {
            rsvc.getLog().error("#import(): cannot find template '" + path +
                                "', called from template " + context.getCurrentTemplateName() +
                                " at (" + getLine() + ", " + getColumn() + ")");
            throw rnfe;

        } catch (ParseErrorException pee) {
            rsvc.getLog().error("#import(): syntax error in #import()-ed template '" + path +
                                "', called from template " + context.getCurrentTemplateName() +
                                " at (" + getLine() + ", " + getColumn() + ")");
            throw pee;

        } catch (Exception e) {
            rsvc.getLog().error("#import(): Error [path=" + path + ", error=" + e + "].");
            return false;
        }

        // finally render the template
        try {
            context.pushCurrentTemplateName(path);
            ((SimpleNode)t.getData()).render(context, writer);

        } catch (Throwable th) {
            rsvc.getLog().error("Exception rendering #import(" + path + "): " + th);
            // we want to pass method invocation exceptions through
            if (th instanceof MethodInvocationException) {
                throw (MethodInvocationException)th;
            }
            return false;

        } finally {
            context.popCurrentTemplateName();
        }

        return true;
    }
7082
public static function renderUri( $uri, $options = array() )
    {
        $serviceContainer = ezpKernel::instance()->getServiceContainer();
        $fragmentHandler = $serviceContainer->get( 'fragment.handler' );

        $strategy = isset( $options['strategy'] ) ? $options['strategy'] : 'inline';
        unset( $options['strategy'] );

        try
        {
            return $fragmentHandler->render( $uri, $strategy, $options );
        }
        catch ( InvalidArgumentException $e )
        {
            throw new InvalidArgumentException( "The URI {$uri->controller} couldn't be rendered", 0, $e );
        }
    }
1270721
protected function renderParameters(array $parameters, $recursion=false)
    {

        $isOperatorFormat = $this->toStringFormat == 'operator';

        $separator = $isOperatorFormat ? ', ' : ',';

        $rendered = [];

        foreach ($parameters as $parameter) {

            if ($parameter === null) {
                $rendered[] = 'null';
                continue;
            }

            if (is_resource($parameter)) {
                $rendered[] = $this->toStringFormat == 'operator' ? 'resource of type ' . get_resource_type($parameter) : get_resource_type($parameter);
                continue;
            }

            if (is_object($parameter)) {
                $rendered[] = get_class($parameter);
                continue;
            }

            if (!is_array($parameter)) {
                $rendered[] = "$parameter";
                continue;
            }

            if (count($parameter) > 80  || $recursion  || !$this->containsOnlyScalars($parameter)) {
                $rendered[] = '[' . $this->renderParameters($parameter) . ']';
                continue;
            }

            if ($isOperatorFormat) {
                $rendered[] = '(' . $this->renderParameters($parameter, true) . ')';
                continue;
            }

            $rendered[] = $this->renderParameters($parameter, true);

        }

        return implode($separator, $rendered);
    }
1182121
public function render(array $arguments = [], $renderer = null) {
        if($renderer === null) {
            if(static::$defaultRenderer === null) {
                throw new Exception('No Default Renderer Exists for Class ' . get_class());
            } else {
                if(is_callable(static::$defaultRenderer)) {
                    $callable = static::$defaultRenderer;
                    static::$defaultRenderer = $callable();
                }
                $renderer = static::$defaultRenderer;
            }
        } else {
            if(is_callable($renderer)) {
                $renderer = $renderer();
            }
        }

        return $renderer->render($this, $arguments);
    }
548199
public function renderRenderable(RootRenderableInterface $renderable)
    {
        $renderable->beforeRendering($this->formRuntime);

        $renderableType = $renderable->getType();

        if ($renderable->getRendererClassName() !== null && $renderable->getRendererClassName() !== get_class($this)) {
            $rendererClassName = $renderable->getRendererClassName();
            $renderer = new $rendererClassName;
            if (!($renderer instanceof RendererInterface)) {
                throw new RenderingException(sprintf('The renderer class "%s" for "%s" does not implement RendererInterface.', $rendererClassName, $renderableType), 1326098022);
            }
            $renderer->setControllerContext($this->controllerContext);
            $renderer->setFormRuntime($this->formRuntime);
            return $renderer->renderRenderable($renderable);
        }

        $renderingOptions = $renderable->getRenderingOptions();

        $renderablePathAndFilename = $this->getPathAndFilenameForRenderable($renderableType, $renderingOptions);
        $parsedRenderable = $this->getParsedRenderable($renderable->getType(), $renderablePathAndFilename);
        $currentTemplatePathsResolver = $this->getTemplatePaths();
        $newTemplatePathsResolver = $this->createTemplatePathsResolverWithRenderingOptions($renderingOptions);
        $this->baseRenderingContext->setTemplatePaths($newTemplatePathsResolver);

        if ($this->getCurrentRenderingContext() === null) {
            // We do not have a "current" rendering context yet, so we use the base rendering context
            $this->baseRenderingContext->setControllerContext($this->controllerContext);
            $renderingContext = $this->baseRenderingContext;
        } else {
            $renderingContext = clone $this->getCurrentRenderingContext();
        }
        $renderingContext->getViewHelperVariableContainer()->addOrUpdate(FluidFormRenderer::class, 'currentRenderable', $renderable);

        if (!isset($renderingOptions['renderableNameInTemplate'])) {
            throw new RenderingException(sprintf('The Renderable "%s" did not have the rendering option "renderableNameInTemplate" defined.', $renderableType), 1326094948);
        }

        $templateVariableContainer = new TemplateVariableContainer(array($renderingOptions['renderableNameInTemplate'] => $renderable));
        $renderingContext->setVariableProvider($templateVariableContainer);

        if ($parsedRenderable->hasLayout()) {
            $renderableLayoutName = $parsedRenderable->getLayoutName($renderingContext);
            $renderableLayoutPathAndFilename = $this->getPathAndFilenameForRenderableLayout($renderableLayoutName, $renderingOptions);
            $parsedLayout = $this->getParsedRenderable($renderableLayoutName, $renderableLayoutPathAndFilename);

            $this->startRendering(self::RENDERING_LAYOUT, $parsedRenderable, $renderingContext);
            $output = $parsedLayout->render($renderingContext);
            $this->stopRendering();
        } else {
            $this->startRendering(self::RENDERING_TEMPLATE, $parsedRenderable, $renderingContext);
            $output = $parsedRenderable->render($renderingContext);
            $this->stopRendering();
        }

        $this->baseRenderingContext->setTemplatePaths($currentTemplatePathsResolver);
        $output = $this->formRuntime->invokeRenderCallbacks($output, $renderable);
        return $output;
    }
780279
private function renderEdge(NodeInterface $node, NodeInterface $child, array $node_map, string $S): string
    {
        return sprintf(
            '%s -> %s [ '.self::BASE_EDGE_PROPS.' '.self::EDGE_PROPS.' ];',
            array_search($node, $node_map, true),
            array_search($child, $node_map, true),
            substr($S, $child->getStart(), $child->getEnd() - $child->getStart() + 1)
        );
    }
275750
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WLink link = (WLink) component;
		XmlStringBuilder xml = renderContext.getWriter();
		String text = link.getText();
		String targetWindowName = link.getOpenNewWindow() ? link.getTargetWindowName() : null;
		String imageUrl = link.getImageUrl();

		xml.appendTagOpen("ui:link");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("disabled", link.isDisabled(), "true");
		xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
		xml.appendOptionalAttribute("toolTip", link.getToolTip());
		xml.appendOptionalAttribute("accessibleText", link.getAccessibleText());
		xml.appendUrlAttribute("url", link.getUrl());
		xml.appendOptionalAttribute("rel", link.getRel());
		xml.appendOptionalAttribute("accessKey", Util.upperCase(link.getAccessKeyAsString()));

		if (imageUrl != null) {
			xml.appendUrlAttribute("imageUrl", imageUrl);
			ImagePosition imagePosition = link.getImagePosition();

			if (imagePosition != null) {
				switch (imagePosition) {
					case NORTH:
						xml.appendAttribute("imagePosition", "n");
						break;
					case EAST:
						xml.appendAttribute("imagePosition", "e");
						break;
					case SOUTH:
						xml.appendAttribute("imagePosition", "s");
						break;
					case WEST:
						xml.appendAttribute("imagePosition", "w");
						break;
					default:
						throw new SystemException("Unknown image position: " + imagePosition);
				}
			}
			// we have an image. We must have a text equivalent
			if (Util.empty(text) && Util.empty(link.getToolTip()) && Util.empty(link.getAccessibleText())) {
				// If the link has an umageUrl but no text equivalent get the text equivalent off of the image
				WImage linkImage = link.getImageHolder();
				if (null != linkImage) {
					xml.appendOptionalAttribute("toolTip", linkImage.getAlternativeText());
				}
			}
		}

		if (link.isRenderAsButton()) {
			xml.appendAttribute("type", "button");
		}

		xml.appendClose();

		if (targetWindowName != null) {
			xml.appendTagOpen("ui:windowAttributes");
			xml.appendAttribute("name", targetWindowName);

			WLink.WindowAttributes attributes = link.getWindowAttrs();

			if (attributes != null) {
				xml.appendOptionalAttribute("top", attributes.getTop() >= 0, attributes.getTop());
				xml.appendOptionalAttribute("left", attributes.getLeft() >= 0, attributes.getLeft());
				xml.appendOptionalAttribute("width", attributes.getWidth() > 0, attributes.
						getWidth());
				xml.appendOptionalAttribute("height", attributes.getHeight() > 0, attributes.
						getHeight());
				xml.appendOptionalAttribute("resizable", attributes.isResizable(), "true");
				xml.appendOptionalAttribute("showMenubar", attributes.isMenubar(), "true");
				xml.appendOptionalAttribute("showToolbar", attributes.isToolbars(), "true");
				xml.appendOptionalAttribute("showLocation", attributes.isLocation(), "true");
				xml.appendOptionalAttribute("showStatus", attributes.isStatus(), "true");
				xml.appendOptionalAttribute("showScrollbars", attributes.isScrollbars(), "true");
				xml.appendOptionalAttribute("showDirectories", attributes.isDirectories(), "true");
			}

			xml.appendEnd();
		}

		if (text != null) {
			xml.appendEscaped(text);
		}

		xml.appendEndTag("ui:link");

		// Paint the AJAX trigger if the link has an action
		if (link.getAction() != null) {
			paintAjaxTrigger(link, xml);
		}

	}
920249
function RenderContext() {
		this._aBuffer = [];
		var that = this;
		this.add = function() {
			that._aBuffer.push.apply(that._aBuffer, arguments);
		};
		this.addWithParam = function(s, o) {
			for (var n in o) {
				var reg = new RegExp("\{" + n + "\}","g");
				s = s.replace(reg,o[n]);
			}
			that.add(s);
		};
		this.toString = function() {
			return that._aBuffer.join("");
		};
	}
534801
public function setRenderingContext(RenderingContextInterface $renderingContext)
    {
        $this->baseRenderingContext = $renderingContext;
        $this->baseRenderingContext->getViewHelperVariableContainer()->setView($this);
        $this->controllerContext = $renderingContext->getControllerContext();
    }
811604
protected function _renderRepeatedDisplayView($options, $repeaterRows = [])
    {
        $repeaterBlocks = BlockRepeater::getRepeaterBlocks($this->_block->id);
        // $repeaterRows[0] check allows skipping of block check (used for dummy data)
        if (($repeaterRows && $repeaterBlocks) || (isset($repeaterRows[0]) && $repeaterRows[0] === 0)) {

            // pagination
            if (!empty($options['per_page'])) {
                $pagination = new LengthAwarePaginator($repeaterRows, count($repeaterRows), $options['per_page'], Request::input('page', 1));
                $pagination->setPath(Request::getPathInfo());
                $paginationLinks = PaginatorRender::run($pagination);
                $repeaterRows = array_slice($repeaterRows, (($pagination->currentPage() - 1) * $options['per_page']), $options['per_page'], true);
            } else {
                $paginationLinks = '';
            }
            $options['pagination'] = $paginationLinks;
            $options['links'] = $paginationLinks;
            $options['blocks'] = $repeaterBlocks;
            return parent::_renderRepeatedDisplayView($options, $repeaterRows);
        }
        return '';
    }
893819
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string {
    $input     = $arguments['input'];
    $separator = $arguments['separator'];
    $output    = '';

    if ($input) {
      $output = self::createSlug($input, $separator);
    }

    return $output;
  }
780038
@Override
	protected void afterPaint(final RenderContext renderContext) {
		super.afterPaint(renderContext);

		final int size = getChildCount();

		for (int i = 0; i < size; i++) {
			WComponent child = getChildAt(i);
			child.reset();
		}
	}
1362884
public function render($name, array $parameters = [])
    {
        $storage = $this->load($name);
        $key = hash('sha256', serialize($storage));
        $this->current = $key;
        $this->parents[$key] = null;

        // attach the global variables
        $parameters = array_replace($this->getGlobals(), $parameters);
        // render
        if (false === $content = $this->evaluate($storage, $parameters)) {
            throw new \RuntimeException(sprintf('The template "%s" cannot be rendered.', $this->parser->parse($name)));
        }

        // decorator
        if ($this->parents[$key]) {
            $slots = $this->get('slots');
            $this->stack[] = $slots->get('_content');
            $slots->set('_content', $content);

            $content = $this->render($this->parents[$key], $parameters);

            $slots->set('_content', array_pop($this->stack));
        }

        return $content;
    }
587087
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
    {
        $value = $arguments['value'];
        if ($value === null) {
            $value = $renderChildrenClosure();
        }
        $options = JSON_HEX_TAG;
        if ($arguments['forceObject'] !== false) {
            $options = $options | JSON_FORCE_OBJECT;
        }

        return json_encode($value, $options);
    }