/** * Проверяет условия указанные в теге condition. * * В данной момент реализована проверка установленного пакета * * @param DOMNode * @return bool */ private function checkCondition(DOMNode $node) { IO::info('Check Condition ', false); $attr = $node->attributes; $packageName = is_null($attr->getNamedItem('package')) ? null : $attr->getNamedItem('package')->nodeValue; if (!is_null($packageName)) { $version = is_null($attr->getNamedItem('version')) ? null : $attr->getNamedItem('version')->nodeValue; $rel = is_null($attr->getNamedItem('rel')) ? null : Deps::normalizeRel($attr->getNamedItem('rel')->nodeValue); if (is_null($version) && $rel != '!=') { $version = '0.0'; $rel = '>='; } elseif (is_null($rel)) { $rel = '='; } io::info($packageName . ' ' . $rel . ' ' . $version . "\t", false); $p = PackageManager::getInstalledPackage($packageName); if ($rel == '!=') { $res = $p === false; } elseif ($p !== false) { $res = version_compare($p->version, $version, $rel); } else { $res = false; } io::info('', $res ? IO::MESSAGE_OK : IO::MESSAGE_FAIL); return $res; } }
public function framework() { /* * You can echo HTML and other information directly from models or controllers * however it is usually better to create views for displaying model data. */ // Session tracking io::library('session'); // HTML Header echo '<h2>Internal Framework Information</h2>'; echo '<p>This method may be useful during development. It contains a list of available helpers, libraries, paths to the various folders, routing information, files that have been loaded, as well as all the objects loaded by Ornithopter.io ...</p>'; // Explain a little bit echo '<blockquote>Accessible by calling <strong class="io">io::info()</strong> within Ornithopter.io</blockquote>'; // Like so... var_dump(io::info()); }
/** * Добавление пакета в очередь * * @param Package $f package to add * @pad string optiontal parametr to finest output * @return true if pckage added and all depnedencies is statisfied. */ private function push(Package $f, $deep = 1, $pad = '') { io::info($pad . ' ' . $f->name . ' ' . $f->version . '{'); $oldPad = $pad . ' '; $pad .= "\t"; $packageDeps = $f->deps; // check env dependencie static $cached = array(); if (!isset($caches[$f->name][$f->version])) { if (!$this->checkEnviroment($packageDeps)) { return false; } } $caches[$f->name][$f->version] = true; foreach ($packageDeps['packages'] as $nvr) { //io::out($pad."deps: ".$nvr['name'].' '.$nvr['rel'].' '.$nvr['version']); if (($d = $this->searchInQueue($nvr['name'])) === false) { $d = new DepsItem($nvr['name']); $this->queue[] = $d; } io::info($pad . $d->getPackageName() . ': ( ' . $d->getFilteredStr() . ' )', false); io::info(' ' . $nvr['rel'] . ' ' . $nvr['version'] . ' : ', false); if (!$d->merge($nvr['version'], $nvr['rel'])) { io::info('~RED~Unable merge version. trying other one.~~~'); } else { io::info($d->getFilteredStr()); } $d->updateDeep($deep); while (!is_null($fpi = $d->popNext()) && !$this->push($fpi, $deep + 1, $pad)) { } // доступные версии пакета закончились раньше чем push вернул true; // те неудовлетворенная зависимость. if (is_null($fpi)) { return $d->unmerge(); } // false // найден пакет удовлетворяющий зависимостям. // запихиваем его обратно зависимость $d->pushBack($fpi); } io::info($oldPad . '}'); return true; }
public function del() { if (!count($this->list)) { return; } if (is_null($this->backup)) { foreach ($this->list as $l) { $olist[] = is_dir($this->target->getFile($l)) ? $this->target->getDir($l) : $this->target->getFile($l); } } else { $olist = $this->backup(); } //io::out(substr($path, strlen($this->target))."\t" , false); if (count($olist)) { foreach ($olist as $obj) { io::info("\t[~PURPLE~D~~~] " . substr($obj, strlen($this->target))); $obj->delete(); } } }
private function rename($param) { if (!isset($param['to'])) { throw new ConfigTaskException('New Key name( \\"to\\") not set in "' . __FUNCTION__ . '" operation. File(' . basename($this->file) . ')'); } $to = $param['to']; if (!isset($param['key'])) { throw new ConfigTaskException('Key name not set in "' . __FUNCTION__ . '" operation. File(' . basename($this->file) . ')'); } $key = $param['key']; if (!isset($param['section'])) { foreach ($this->pattern as $sect => $keys) { if (isset($this->pattern[$sect][$key])) { $param['section'] = $sect; $this->rename($param); } } return; } $section = $param['section']; io::info("\t[~PURPLE~R~~~] [" . $section . "] " . $key); if (!isset($this->pattern[$section][$key])) { throw new ConfigTaskException('Config key [' . $section . '][' . $key . '] not found', IO::MESSAGE_WARN); } $this->addRollbackOperation('rename', array('key' => $to, 'to' => $key, 'section' => $section)); $lines = $this->lines; $li = $this->k2l[$section][$key]; $a = explode('=', $lines[$li]); $a[0] = $to . ' '; $lines[$li] = implode('=', $a); $newini = $this->getPattern($lines); $diff = self::diffArray($newini, $this->pattern); if ($diff['del'] != 1 || $diff['add'] != 1 || $diff['modify'] != 0) { throw new ConfigTaskException('Error while rename constant. Given diff: ' . implode('-', $diff)); } $this->lines = $this->processLines($lines, $newK2l); $this->pattern = $newini; $this->k2l = $newK2l; }
/** * Public function the developer can call for sending a 404 error. This is * the default error which uses 404.html in the root directory. If the file * is not provided PHP will still send a 404 HEADER to the browser. */ public static function error_404($path = false) { // Send a 404 HTTP HEADER error code to the browser header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); // Include the 404.html file or exit on failure (include $path ?: \io::info()['paths']['root'] . '/404.html') ?: exit; // Exit anyways exit; }