public function loadBuilder(fs\file $file, fs\directory $dir = null, core\argument $args = null, dom\document $doc = null) { if (!$dir) { $dir = $file->getParent(); } if (!$doc) { $doc = $file->asDocument(); } $result = $this->loadBuilderFromNS($doc->getRoot()->getNamespace(), $file, $dir, $args, $doc); return $result; }
public function buildArgument(dom\element $arg, fs\file $file, dom\element $test) { require_once 'core/functions/Path.php'; $sName = core\functions\path\urlize($file->getName() . '-' . $test->readAttribute('name')); $tmp = $this->exportDirectory->createFile($sName . '.xml'); $doc = $this->getManager('dom')->createDocument($arg); $doc->saveFile($tmp, true); $result = $this->getManager()->load($tmp, array(), true); //$result->setBaseDirectory($file->getParent()); return $result; }
public function initTest(fs\file $file, $iTest) { $this->setDirectory($file->getParent()); $this->setNamespace(self::NS, 'self'); $this->setManager($this); //$this->resetDB(); $this->setFile($file); $this->setTestKey($iTest); $this->setSettings(array()); $this->exportDirectory = $this->loadCacheDirectory($this->getDirectory()); }
protected function createWindowFile(fs\file $file) { $sResult = ''; switch ($file->getExtension()) { case 'php': $this->throwException('Cannot read php files'); default: $window = $this->create('window', array($this->getInitializer())); $sResult = $this->loadWindowFile($file, $window); break; } return $sResult; }
protected function parseResult(dom\element $test, fs\file $file, array $aArguments = array()) { $result = null; if ($document = $test->getx('self:document', array(), false)) { require_once 'core/functions/Path.php'; $sName = core\functions\path\urlize($file->getName() . '-' . $test->readx('@name')); $cache = $this->getExportDirectory()->createFile($sName); $cache->saveText((string) $this->createDocument($document->getFirst())); $manager = $this->getManager(self::PARSER_MANAGER); $result = $this->buildResult($test, $manager, $cache, $aArguments); $this->set('result', $result); } return $result; }
protected function parseLess(fs\file $file) { $sResult = ''; $less = new Prefixer(); //$less->setImportDir($file->getParent()->getRealPath()); //echo (string) $file->getControler()->getDirectory()->getRealPath(); $less->setImportDir($file->getControler()->getDirectory()->getRealPath()); try { $sResult = $less->compileFile($file->getRealPath()); } catch (\Exception $e) { throw \Sylma::loadException($e); } return $sResult; }
public function parseFile(fs\file $file) { return $this->getParser()->addSchema($file->getDocument()); }
/** * Create cache object * * @param $file Script * @param array $aArguments * @return \sylma\parser\cached\documented */ protected function createCache(fs\file $file, array $aArguments, $bExternal = false) { return \Sylma::includeFile($file->getRealPath(), $aArguments, $bExternal); }
protected function loadTarget(dom\document $doc, fs\file $file) { if ($sTarget = $doc->getRoot()->readx('@build:target', array('build' => self::BUILD_NS), false)) { if ($sTarget[0] == '[') { switch (substr($sTarget, 1, -1)) { case 'current()': $sTarget = (string) $file->getParent(); break; default: $this->throwException(sprintf('Cannot handler build option %s', $sTarget)); } } $dir = $this->getControler('fs/editable')->getDirectory($sTarget); $result = $dir->getFile($file->getName() . '.php', fs\resource::DEBUG_EXIST); } else { $result = $this->loadSelfTarget($file); } return $result; }
public function importTree(fs\file $file, $sType = '') { switch ($sType) { case 'argument': $content = $this->createArgumentFromString((string) $file); break; default: case 'document': $this->loadDefaultArguments(); $content = $this->create('options', array($file->getDocument(), $this->getNS())); break; } $result = $this->loadSimpleComponent('component/tree'); $result->setOptions($content); return $result; }
protected function readFile(fs\file $file) { $bDebug = $this->getFusion() ? $this->getFusion()->read('debug') : false; return "// {$file->asToken()}\n\n" . ($bDebug ? "console.log('load : {$file}');" . parent::readFile($file) : parent::readFile($file)); }
public function callScript(fs\file $file, common\_window $window, $return = null, $bReturn = true) { $arguments = $window->getVariable('aSylmaArguments'); //$closure = $window->createClosure(array($arguments)); //$closure->addContent($window->callFunction('include', $return, array($file->getName()))); $call = $window->createCall($window->getSylma(), 'includeFile', $return, array($file->getRealPath(), $arguments, $window->getVariable('bSylmaExternal'))); if ($bReturn) { $result = $window->createAssign($window->getVariable('result'), $call); } else { $result = $call; } return $result; }
protected function catchExceptionCheck($sException, dom\element $test, core\exception $e, fs\file $file) { $bResult = false; if ($sException && $e instanceof $sException) { $bResult = true; } else { $e->addPath($file->asToken()); $e->addPath('Test ID : ' . $test->readAttribute('name')); if ($sException) { $e->addPath(sprintf('Exception of type %s expected', $sException)); } //$e->addPath($test->asString()); $e->save(false); } return $bResult; }
protected function secureFile(fs\file $file) { //dspf($file); if ($this->getControler()->mustSecure()) { if (!$this->getSettings() or !($aRights = $this->getSettings()->getFile($file->getName()))) { $aRights = $this->getChildrenRights(); } $file->setRights($aRights); } else { $file->setRights($this->getChildrenRights()); } }
protected function prepareMain(fs\file $file, core\argument $args, core\argument $post) { switch ($file->getExtension()) { case 'vml': $result = $this->runScript($file, $args, $post); break; default: $this->launchException('Unknown extension for window content'); } if (!$result) { $result = ''; //$this->launchException('No content for main window'); } return $result; }
protected function addFile(fs\file $file, $bReal = false) { $aResult = array('link' => array('@href' => $bReal ? '/' . $file->getRealPath() : (string) $file, '@type' => 'text/css', '@media' => 'all', '@rel' => 'stylesheet')); return $aResult; }
protected function checkUpdate(fs\file $cache, array $aFiles) { $bResult = $this->getFusion() ? $this->getFusion()->read('update') : false; if (!$bResult) { $update = $cache->getLastChange(); foreach ($aFiles as $file) { if ($file->getLastChange() > $update) { $bResult = true; break; } } } return $bResult; }