Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 public function __construct(string $url, string $integrityCheck = '', string $crossorigin = 'anonymous')
 {
     parent::__construct('', false, false);
     $this->url = $url;
     $this->integrityCheck = $integrityCheck;
     $this->crossorigin = $crossorigin;
 }
Esempio n. 2
0
 public static function minify($type, $content)
 {
     if ($type == 'js') {
         $content = JSMin::minify($content);
     } else {
         $content = Css::minify($content);
     }
     return $content;
 }
Esempio n. 3
0
 /**
  * Parses the css code converting to a Css object with all selectors, properties and values.
  *
  * @param string $string_code The css code to parse
  *
  * @return Stylecow\Css The parsed css code
  */
 private static function parse($string_code)
 {
     $Css = new Css();
     while ($string_code) {
         $pos = strpos($string_code, '{');
         $pos2 = strpos($string_code, ';');
         if ($pos2 !== false && $pos2 < $pos) {
             $Css->addChild(new Css(Selector::createFromString(substr($string_code, 0, $pos2))));
             $string_code = trim(substr($string_code, $pos2 + 1));
             continue;
         }
         if ($pos === false) {
             break;
         }
         $selector = substr($string_code, 0, $pos);
         $string_code = trim(substr($string_code, $pos + 1));
         $length = strlen($string_code);
         $in = 1;
         for ($n = 0; $n <= $length; $n++) {
             $letter = $string_code[$n];
             if ($letter === '{') {
                 $in++;
                 continue;
             }
             if ($letter !== '}' || --$in) {
                 continue;
             }
             $Child = $Css->addChild(new Css(Selector::createFromString($selector)));
             $string_piece = $n === 0 ? '' : trim(substr($string_code, 0, $n - 1));
             $string_code = trim(substr($string_code, $n + 1));
             $pos = strpos($string_piece, '{');
             if ($pos === false) {
                 $properties_string = $string_piece;
                 $content_string = '';
             } else {
                 $pos = strrpos(substr($string_piece, 0, $pos), ';');
                 if ($pos !== false) {
                     $properties_string = trim(substr($string_piece, 0, $pos + 1));
                     $content_string = trim(substr($string_piece, $pos + 1));
                 } else {
                     $properties_string = '';
                     $content_string = $string_piece;
                 }
             }
             if ($properties_string) {
                 foreach (self::explodeTrim(';', $properties_string) as $property) {
                     $Child->addProperty(Property::createFromString($property));
                 }
             }
             if ($content_string) {
                 foreach (self::parse($content_string) as $child) {
                     $Child->addChild($child);
                 }
             }
             break;
         }
     }
     return $Css;
 }
<?php

require_once 'cst.php';
require_once INC_GSESSION;
require_once INC_SRECHARGECSS;
require_once INC_CSSCONSTRUCTEUR;
require_once INC_CSS;
//if (GSession::HasDroit(FONC_CREER_CSS))
//{
$nomElement = GSession::LirePost('NomElement');
$nomPresentation = GSession::LirePost('NomPresentation');
$cssId = GSession::LirePost('cssId');
$cssClass = GSession::LirePost('cssClass');
if ($nomElement != NULL && $nomElement != '' && $nomPresentation != NULL && $nomPresentation != '') {
    // On fabrique le fichier Css sur le disque.
    $cssConstructeur = new CssConstructeur($nomElement, $nomPresentation, $cssId, $cssClass);
    $cssConstructeur->ConstruireCss();
    $lien = Css::GetNomFichierLien($nomElement, $nomPresentation);
    $id = Css::GetIdLienHTML($nomElement);
    if ($id !== '' && $lien !== '') {
        // On retourne un ordre de rechargement du Css.
        $sRechargeCss = new SRechargeCss();
        $sRechargeCss->AjouterElement($id, $lien);
        echo $sRechargeCss->BuildHTML();
    }
}
//}
Esempio n. 5
0
<?php

require_once "classes/Css.php";
$c = new Css();
echo $c->addClass('hahah')->background('red');
Esempio n. 6
0
File: CssTest.php Progetto: jyxo/php
 /**
  * Tests the convertStyleToInline() method.
  *
  * @see \Jyxo\Css::convertStyleToInline()
  */
 public function testConvertStyleToInline()
 {
     $testCount = 10;
     for ($i = 1; $i <= $testCount; $i++) {
         $this->assertStringEqualsFile($this->filePath . '/' . sprintf('convertstyle-%s-expected.html', $i), Css::convertStyleToInline(file_get_contents($this->filePath . '/' . sprintf('convertstyle-%s.html', $i))), sprintf('Failed test %s for method %s::convertStyleToInline().', $i, \Jyxo\Css::class));
     }
 }
Esempio n. 7
0
 /**
  * Adds a new css object as child
  *
  * @param Stylecow\Css $css The css object to add as child
  * @param int The optional position. If its not defined, the child will be append
  *
  * @return Stylecow\Css The new css object inserted;
  */
 public function addChild(Css $css, $position = null)
 {
     $css->setParent($this);
     if (!isset($position)) {
         return $this[] = $css;
     }
     $children = $this->getArrayCopy();
     array_splice($children, $position, 0, array($css));
     $this->exchangeArray($children);
     return $css;
 }
<?php

require_once 'cst.php';
require_once INC_GSESSION;
require_once INC_CSSPARSEUR;
require_once INC_CSS;
//if (GSession::HasDroit(FONC_CREER_CSS))
//{
$nomElement = GSession::LirePost('NomElement');
$nomPresentation = GSession::LirePost('NomPresentation');
if ($nomElement != NULL && $nomElement != '') {
    $nomFichier = Css::GetNomFichierDestination($nomElement, $nomPresentation);
    if ($nomFichier !== '') {
        $cssParseur = new CssParseur();
        $css = $cssParseur->ParseCSS($nomFichier);
        if ($css != NULL) {
            switch ($nomElement) {
                case 'AMI':
                    include INC_FCHARGERPRESENTATIONAMI;
                    break;
                case 'FORUM':
                    include INC_FCHARGERPRESENTATIONFORUM;
                    break;
            }
        }
    }
}
//}
Esempio n. 9
0
 /**
  * @return mixed
  */
 public static function delCssLink()
 {
     return Css::add();
 }
Esempio n. 10
0
 /**
  * Runs a css query against the wrapped dom object. Internally the css will translate to xpath
  *
  * @link http://php.net/manual/en/domxpath.query.php
  *
  * @param string $query the css query
  * @param \DOMNode|null $node the context node for the query, leave it null to query the root
  * @return DomNodeList
  */
 public function cssQuery($query, $node = null)
 {
     return $this->getXpath()->query(Css::toXPath($query), $node);
 }