Beispiel #1
0
 protected function loadInfos(dom\handler $doc)
 {
     \Sylma::load('/sylma/core/functions/Numeric.php');
     $parser = $this->getManager('parser');
     $path = $this->getManager('path');
     $user = $this->getManager('user');
     $init = $this->getManager('init');
     $js = $this->getContexts()->get('js-common');
     $js->add($this->getFile('/#sylma/ui/mootools-min.js'));
     $js->add($this->getFile('/#sylma/ui/Main.js'));
     $aBuilded = $parser->aBuilded;
     $aLoaded = $parser::$aLoaded;
     $iLoaded = 0;
     array_walk($aLoaded, function (&$item, $key) use(&$iLoaded) {
         $iLoaded += $item;
         $item = "{$key} : ({$item})";
     });
     $file = $path->asFile();
     $sDevice = '[unknown]';
     if ($device = $this->getManager('device', false)) {
         $sDevice = $device->isDevice('tablet') ? 'tablet' : ($device->isDevice('mobile') ? 'mobile' : 'desktop');
     }
     $content = $this->createArgument(array('ul' => array('#li' => array(array('#button' => array(array('@type' => 'button', '@onclick' => "sylma.ui.send('/sylma/modules/rebuild/standalone', {path : '{$file}'}, null, true);", (string) $file), array('@type' => 'button', '@onclick' => "sylma.ui.debugSource();", 'source'))), 'user : '******'groups : ' . implode(',', $user->getGroups()), 'time : ' . functions\numeric\formatFloat($init->getElapsedTime()), 'device : ' . $sDevice, 'builded : ' . count($aBuilded), array('ul' => array('#li' => array_map('strval', $aBuilded))), 'loaded : ' . $iLoaded, array('ul' => array('#li' => $aLoaded))))), $this->getNamespace('html'));
     return $content;
 }
Beispiel #2
0
 public function getAbsoluteClass($sPath, $sDirectory = '/')
 {
     if ($sPath[0] == '\\') {
         $sResult = $sPath;
     } else {
         $aPaths = explode('\\', $sPath);
         $aDirectories = explode('/', $sDirectory);
         foreach ($aPaths as $sPath) {
             if ($sPath == '..') {
                 array_shift($aPaths);
                 array_pop($aDirectories);
             } else {
                 break;
             }
         }
         \Sylma::load('/core/functions/Path.php');
         $sResult = implode(array_merge($aDirectories, $aPaths), '\\');
     }
     return $sResult;
 }
Beispiel #3
0
 protected function getClassName($sName)
 {
     \Sylma::load('/core/functions/Path.php');
     return path\toAbsolute($sName, str_replace('/', '\\', (string) $this->getSourceDirectory()), '\\');
 }
Beispiel #4
0
<?php

namespace sylma\schema\cached\form;

use sylma\core, sylma\core\functions\path;
\Sylma::load('/core/functions/Path.php');
class Urlizer extends _String
{
    public function validate()
    {
        $sAlias = $this->getAlias(false);
        $sElement = substr($sAlias, 0, strpos($sAlias, '_'));
        $el = $this->getHandler()->getElement($sElement);
        $this->setValue(path\urlize($el->getValue()));
        return true;
    }
}
Beispiel #5
0
<?php

namespace sylma\modules\less;

use sylma\core;
\Sylma::load('lessc.php', __DIR__);
class Prefixer extends \lessc
{
    const MODE_PREFIX = 0;
    const MODE_DEFAULT = 1;
    protected $aProperties = array('backface-visibility' => array(), 'background-clip' => array(), 'background-origin' => array(), 'background-size' => array(), 'border-radius' => array(), 'box-sizing' => array('moz' => self::MODE_PREFIX), 'column-count' => array('moz' => self::MODE_PREFIX), 'column-fill' => array('moz' => self::MODE_PREFIX), 'transform' => array('o' => self::MODE_PREFIX), 'transform-style' => array('o' => self::MODE_PREFIX), 'perspective' => array('o' => self::MODE_PREFIX), 'transition' => array('o' => self::MODE_PREFIX), 'transition-duration' => array('o' => self::MODE_PREFIX), 'transition-delay' => array('o' => self::MODE_PREFIX), 'transition-property' => array('o' => self::MODE_PREFIX), 'user-select' => array('moz' => self::MODE_PREFIX, 'o' => self::MODE_PREFIX, 'ms' => self::MODE_PREFIX), 'overflow-scrolling' => array());
    protected $aVendors = array('moz' => array('mode' => self::MODE_DEFAULT), 'webkit' => array('mode' => self::MODE_PREFIX), 'o' => array('mode' => self::MODE_DEFAULT), 'ms' => array('mode' => self::MODE_DEFAULT));
    protected $aContainers = array('transition');
    public function __construct($fname = null)
    {
        parent::__construct($fname);
        $this->aVendors = array_map(function (array $aVendor, $sPrefix) {
            return new Browser($sPrefix, $aVendor);
        }, $this->aVendors, array_keys($this->aVendors));
    }
    protected function compileProp($prop, $block, $out)
    {
        if ($prop[0] === 'assign' && array_key_exists($prop[1], $this->getProperties())) {
            list(, $sName, $aValue) = $prop;
            foreach ($this->aVendors as $vendor) {
                if ($sPrefixed = $vendor->prefixProperty($sName, $this->getProperty($sName))) {
                    $out->lines[] = $this->formatter->property($sPrefixed, $this->compileValue($this->reduce($aValue), $vendor));
                }
            }
        }
        parent::compileProp($prop, $block, $out);
Beispiel #6
0
<?php

namespace sylma\parser\languages\php\basic;

use sylma\core, sylma\parser\languages\common, sylma\parser\languages\php;
\Sylma::load('/parser/languages/common/basic/Controled.php');
require_once 'core/argumentable.php';
/**
 * @deprected : do not use
 */
class Template extends common\basic\Controled implements core\argumentable
{
    private $content = '';
    protected static $iKey = 0;
    public function __construct(common\_window $controler, $mContent)
    {
        \Sylma::throwException('Must not be used');
        $this->setControler($controler);
        $this->content = $mContent;
    }
    public function asArgument()
    {
        self::$iKey++;
        return $this->getControler()->createArgument(array('template' => array('@key' => self::$iKey, $this->content)));
    }
}
Beispiel #7
0
 public function asString($iMode = 0)
 {
     \Sylma::load('/dom/functions.php');
     return $this->getName(true) . '="' . dom\xmlize($this->value) . '"';
 }
Beispiel #8
0
<?php

namespace sylma\device;

use sylma\core;
\Sylma::load('lib/Mobile_Detect.php', __DIR__);
/**
 * Use Mobile-Detect : https://github.com/serbanghita/Mobile-Detect
 */
class Dummy extends \Mobile_Detect
{
    protected $settings;
    public function setSettings(core\argument $settings)
    {
        $this->settings = $settings;
    }
    protected function getSettings()
    {
        if (!$this->settings) {
            \Sylma::throwException('No settings defined for device');
        }
        return $this->settings;
    }
    public function isDevice($sName)
    {
        $sForce = $this->getSettings()->read('force', false);
        switch ($sName) {
            case 'mobile':
                $bResult = $sForce === 'mobile' || !$sForce && $this->isMobile() && !$this->isTablet();
                break;
            case 'tablet':