- md5
- 4855b9bbadc5e729a98148563843731c
- sha1
- 267427272b3f0d0ce961838cac48eb7907eb10de
- sha256
- 2796927c68319875c2322648435515b7e61b444ea9122910e9b401faccebd69c
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
<?php
/**
* @package FrameworkOnFramework
* @subpackage less
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*/
// Protect from unauthorized access
defined('FOF_INCLUDED') or die;
/**
* This class is taken verbatim from:
*
* lessphp v0.3.9
* http://leafo.net/lessphp
*
* LESS css compiler, adapted from http://lesscss.org
*
* Copyright 2012, Leaf Corcoran <[email protected]>
* Licensed under MIT or GPLv3, see LICENSE
*
* @package FrameworkOnFramework
* @since 2.0
*/
class FOFLessFormatterClassic
{
public $indentChar = " ";
public $break = "\n";
public $open = " {";
public $close = "}";
public $selectorSeparator = ", ";
public $assignSeparator = ":";
public $openSingle = " { ";
public $closeSingle = " }";
public $disableSingle = false;
public $breakSelectors = false;
public $compressColors = false;
/**
* Public constructor
*/
public function __construct()
{
$this->indentLevel = 0;
}
/**
* Indent a string by $n positions
*
* @param integer $n How many positions to indent
*
* @return string The indented string
*/
public function indentStr($n = 0)
{
return str_repeat($this->indentChar, max($this->indentLevel + $n, 0));
}
/**
* Return the code for a property
*
* @param string $name The name of the property
* @param string $value The value of the property
*
* @return string The CSS code
*/
public function property($name, $value)
{
return $name . $this->assignSeparator . $value . ";";
}
/**
* Is a block empty?
*
* @param stdClass $block The block to check
*
* @return boolean True if the block has no lines or children
*/
protected function isEmpty($block)
{
if (empty($block->lines))
{
foreach ($block->children as $child)
{
if (!$this->isEmpty($child))
{
return false;
}
}
return true;
}
return false;
}
/**
* Output a CSS block
*
* @param stdClass $block The block definition to output
*
* @return void
*/
public function block($block)
{
if ($this->isEmpty($block))
{
return;
}
$inner = $pre = $this->indentStr();
$isSingle = !$this->disableSingle &&
is_null($block->type) && count($block->lines) == 1;
if (!empty($block->selectors))
{
$this->indentLevel++;
if ($this->breakSelectors)
{
$selectorSeparator = $this->selectorSeparator . $this->break . $pre;
}
else
{
$selectorSeparator = $this->selectorSeparator;
}
echo $pre .
implode($selectorSeparator, $block->selectors);
if ($isSingle)
{
echo $this->openSingle;
$inner = "";
}
else
{
echo $this->open . $this->break;
$inner = $this->indentStr();
}
}
if (!empty($block->lines))
{
$glue = $this->break . $inner;
echo $inner . implode($glue, $block->lines);
if (!$isSingle && !empty($block->children))
{
echo $this->break;
}
}
foreach ($block->children as $child)
{
$this->block($child);
}
if (!empty($block->selectors))
{
if (!$isSingle && empty($block->children))
{
echo $this->break;
}
if ($isSingle)
{
echo $this->closeSingle . $this->break;
}
else
{
echo $pre . $this->close . $this->break;
}
$this->indentLevel--;
}
}
}
The same content is in 46 releases, Joomla 3.9.20-rc to 3.10.12. See them all, or every version of this file.