Пример #1
0
 /**
  * {element name[:method] [key]}
  */
 public function macroElement(MacroNode $node, PhpWriter $writer)
 {
     $rawName = $node->tokenizer->fetchWord();
     if ($rawName === FALSE) {
         throw new CompileException("Missing element type in {element}");
     }
     $rawName = explode(':', $rawName, 2);
     $name = $writer->formatWord($rawName[0]);
     $method = isset($rawName[1]) ? ucfirst($rawName[1]) : '';
     $method = Strings::match($method, '#^\\w*$#') ? "render{$method}" : "{\"render{$method}\"}";
     $idRaw = $node->tokenizer->fetchWord();
     $param = $writer->formatArray();
     if (!Strings::contains($node->args, '=>')) {
         $param = substr($param, 6, -1);
         // removes array()
     }
     if (!$idRaw) {
         throw new CompileException("Missing element title in {element}");
     }
     if (substr($idRaw, 0, 1) !== '$') {
         $id = Helpers::encodeName($idRaw);
     } else {
         $id = $idRaw;
     }
     return '$_ctrl = $_presenter->getComponent(\\CmsModule\\Content\\ElementManager::ELEMENT_PREFIX . ' . '"' . $id . '"' . ' . \'_\' . ' . $name . '); ' . '$_ctrl->setName("' . trim($idRaw, '"\'') . '");' . 'if ($presenter->isPanelOpened() && (!isset($__element) || !$__element)) { echo "<span id=\\"' . \CmsModule\Content\ElementManager::ELEMENT_PREFIX . (substr($id, 0, 1) === '$' ? '{' . $id . '}' : $id) . '_' . $rawName[0] . '\\" style=\\"display: inline-block; min-width: 50px; min-height: 25px;\\" class=\\"venne-element-container\\" data-venne-element-id=\\"' . trim($id, '"\'') . '\\" data-venne-element-name=\\"' . $rawName[0] . '\\" data-venne-element-route=\\"" . $presenter->route->id . "\\" data-venne-element-language=\\"" . $presenter->language->id . "\\" data-venne-element-buttons=\\"" . (str_replace(\'"\', "\'", json_encode($_ctrl->getViews()))) . "\\">"; }' . 'if ($_ctrl instanceof Nette\\Application\\UI\\IRenderable) $_ctrl->validateControl(); ' . "\$_ctrl->{$method}({$param});" . 'if ($presenter->isPanelOpened()) { echo "</span>"; }';
 }
Пример #2
0
 private function checkAliases($column)
 {
     if (Strings::contains($column, ".")) {
         return $column;
     }
     return current($this->data_source->getRootAliases()) . '.' . $column;
 }
Пример #3
0
 public function setDefaultDueDate($dueDate)
 {
     if (!\Nette\Utils\Strings::contains($dueDate, "+")) {
         $dueDate = "+ " . $dueDate;
     }
     $this->dueDate = $dueDate;
 }
Пример #4
0
 /**
  * @param IControlConfig $controlConfig
  * @return string
  */
 public function getLabelFor(IControlConfig $controlConfig)
 {
     $label = $this->format;
     $fieldName = $controlConfig->getFieldName();
     $className = $controlConfig->getParentClassName();
     if (Nette\Utils\Strings::contains($fieldName, DotNotation\ClassMetadataWrapper::FIELD_SEPARATOR)) {
         $classMetadata = $this->classMetadataFactory->getMetadataFor($className);
         $parts = explode(DotNotation\ClassMetadataWrapper::FIELD_SEPARATOR, $fieldName);
         $fieldName = array_pop($parts);
         $association = implode(DotNotation\ClassMetadataWrapper::FIELD_SEPARATOR, $parts);
         $className = $classMetadata->getAssociationTargetClass($association);
     }
     $classParts = explode('\\', $className);
     $classParts = array_map(function ($value) {
         return lcfirst($value);
     }, $classParts);
     // Convert \NameSpace1\NameSpace2\ClassName to nameSpace1.nameSpace2.className
     $fullQualifiedClassName = trim(implode('.', $classParts), '.');
     // Convert \NameSpace1\NameSpace2\ClassName to className
     $shortClassName = end($classParts);
     $label = str_replace(self::FIELD_NAME, $fieldName, $label);
     $label = str_replace(self::CLASS_NAME, $shortClassName, $label);
     $label = str_replace(self::FULL_QUALIFIED_CLASS_NAME, $fullQualifiedClassName, $label);
     return $label;
 }
Пример #5
0
 /**
  * @param $presenter
  * @return string
  */
 public function formatPresenterClass($presenter)
 {
     $class = str_replace(':', 'Module\\', $presenter) . 'Presenter';
     if (!Nette\Utils\Strings::contains($presenter, 'Kdyby')) {
         return $this->namespace . '\\' . $class;
     }
     return $class;
 }
Пример #6
0
 /**
  * @param  string                   $pageUrl
  * @throws InvalidVideoUrlException
  * @return string
  */
 public function getVideoSrc($pageUrl)
 {
     $key = 'watch?v=';
     if (!Strings::contains($pageUrl, $key)) {
         throw new InvalidVideoUrlException($this->translator->translate('locale.error.invalid_youtube_video_url'));
     }
     return str_replace($key, 'embed/', $pageUrl);
 }
Пример #7
0
 /**
  * Does $haystack contain $needle?
  *
  * @param string hastack
  * @param string needle
  * @param bool case sensitive?
  *
  * @return bool
  */
 public static function contains($haystack, $needle, $caseSensitive = true)
 {
     if ($caseSensitive) {
         return parent::contains($haystack, $needle);
     } else {
         return parent::contains(self::lower($haystack), self::lower($needle));
     }
 }
Пример #8
0
 /**
  * @param string $type
  * @param string $name
  *
  * @return Filters\IFilter|null
  */
 public function getFilter($type, $name)
 {
     foreach ($this->filters as $serviceName => $filter) {
         if (Utils\Strings::contains($serviceName, $type . '.' . $name)) {
             return $filter;
         }
     }
     return NULL;
 }
Пример #9
0
 /**
  * Check is somethink allowed
  * @param string $role
  * @param string $resource
  * @param string $privilege
  * @return boolean
  */
 public function isAllowed($role, $resource, $privilege)
 {
     if ($resource == 'Admin' && $privilege == 'can') {
         return \Nette\Utils\Strings::contains($role, '1');
     }
     $this->checkParams($resource, $privilege);
     $this->parseRole($role);
     $this->privileges['CommentsUnder'] = $this->privileges['Comments'];
     return $this->privileges[$resource][$privilege];
 }
Пример #10
0
 /**
  * @param  string  $column
  * @return string
  */
 private function checkAliases($column)
 {
     if (Strings::contains($column, ".")) {
         return $column;
     }
     if (!isset($this->root_alias)) {
         $this->root_alias = $this->data_source->getRootAliases();
         $this->root_alias = current($this->root_alias);
     }
     return $this->root_alias . '.' . $column;
 }
 /**
  * @param string $dataType
  * @return string
  */
 private static function encodeDbDataType($dataType)
 {
     $dataType = Strings::lower($dataType);
     if (Strings::contains($dataType, 'int(')) {
         return PpAttribute::TYPE_NUMERIC;
     } elseif (Strings::contains($dataType, 'float') || Strings::contains($dataType, 'double') || Strings::contains($dataType, 'real')) {
         return PpAttribute::TYPE_NUMERIC;
     } else {
         return PpAttribute::TYPE_NOMINAL;
     }
 }
Пример #12
0
 /**
  * check if service is running
  * @return boolean
  */
 public function check()
 {
     $result = $this->run($this->config["checkCommand"], false);
     if (empty($result)) {
         return false;
     }
     if (\Nette\Utils\Strings::contains($result, $this->config["name"]) == true) {
         return true;
     } else {
         return false;
     }
 }
Пример #13
0
    /**
     * Adds include of common config if it's missing.
     *
     * @param $wpConfigPath
     * @param $commonConfigName
     */
    public static function ensureCommonConfigInclude($wpConfigPath, $commonConfigName = self::COMMON_CONFIG_NAME)
    {
        $include = <<<DOC
// Configuration common to all environments
include_once __DIR__ . '/{$commonConfigName}';
DOC;
        $configContent = file_get_contents($wpConfigPath);
        if (!Strings::contains($configContent, $include)) {
            $configContent = str_replace('<?php', "<?php\n\n{$include}\n", $configContent);
            file_put_contents($wpConfigPath, $configContent);
        }
    }
Пример #14
0
 private function createThumb($originalFile, $targetPath, $type)
 {
     $resizeType = false;
     if (!Strings::contains($type, '_')) {
         $sizes = $type;
     } else {
         list($sizes, $resizeType) = explode('_', $type);
     }
     list($width, $height) = explode('x', $sizes);
     $image = Image::fromFile($originalFile);
     $image->resize($width, $height, $this->getResizeType($resizeType));
     $image->save($targetPath, $this->imageQuality, Image::JPEG);
     return $targetPath;
 }
Пример #15
0
 /**
  * @param string $value
  * @return Condition|bool
  * @throws \Exception
  * @internal
  */
 public function __getCondition($value)
 {
     if ($this->where === NULL && is_string($this->condition)) {
         list(, $from, $to) = \Nette\Utils\Strings::match($value, $this->mask);
         $from = \DateTime::createFromFormat($this->dateFormatInput, trim($from));
         $to = \DateTime::createFromFormat($this->dateFormatInput, trim($to));
         if ($to && !Strings::match($this->dateFormatInput, '/G|H/i')) {
             //input format haven't got hour option
             Strings::contains($this->dateFormatOutput[1], 'G') || Strings::contains($this->dateFormatOutput[1], 'H') ? $to->setTime(23, 59, 59) : $to->setTime(11, 59, 59);
         }
         $values = $from && $to ? array($from->format($this->dateFormatOutput[0]), $to->format($this->dateFormatOutput[1])) : NULL;
         return $values ? Condition::setup($this->getColumn(), $this->condition, $values) : Condition::setupEmpty();
     }
     return parent::__getCondition($value);
 }
Пример #16
0
 /** @return bool */
 public function isCorrectlyConfigured()
 {
     try {
         $res = $this->connector->request('/', [], 'GET');
         if (is_string($res) && Strings::contains($res, 'Error')) {
             return false;
         } else {
             return true;
         }
     } catch (NewsletterException $ex) {
         return false;
     } catch (ClientException $ex) {
         return false;
     }
 }
Пример #17
0
 /**
  * {control name[:method] [params]}
  */
 public function macroControl(MacroNode $node, PhpWriter $writer)
 {
     $words = $node->tokenizer->fetchWords();
     if (!$words) {
         throw new CompileException('Missing control name in {control}');
     }
     $name = $writer->formatWord($words[0]);
     $method = isset($words[1]) ? ucfirst($words[1]) : '';
     $method = Strings::match($method, '#^\\w*\\z#') ? "render{$method}" : "{\"render{$method}\"}";
     $param = $writer->formatArgs();
     if (Strings::contains($node->args, '=>')) {
         $param = "[{$param}]";
     }
     return ($name[0] === '$' ? "if (is_object({$name})) \$_l->tmp = {$name}; else " : '') . '$_l->tmp = $_control->getComponent(' . $name . '); ' . 'if ($_l->tmp instanceof Nette\\Application\\UI\\IRenderable) $_l->tmp->redrawControl(NULL, FALSE); ' . ($node->modifiers === '' ? "\$_l->tmp->{$method}({$param})" : $writer->write("ob_start(); \$_l->tmp->{$method}({$param}); echo %modify(ob_get_clean())"));
 }
Пример #18
0
 /**
  * Constructor
  */
 public function __construct()
 {
     // get wordpress database object (no injection sorry!
     global $wpdb;
     // variables
     $this->database = $wpdb;
     $this->settings = new \SimpleSubscribe\Settings(SUBSCRIBE_KEY);
     $this->settingsAll = $this->settings->getSettings();
     // we get the table name from class name
     preg_match('#Repository(\\w+)$#', get_class($this), $class);
     $tablePreName = \Nette\Utils\Strings::contains($class[1], 'Subscribers') ? $class[1] : 'Subscribers' . $class[1];
     $this->tableName = $this->database->prefix . Utils::camelCaseToUnderscore($tablePreName);
     $this->tableSingleName = \Nette\Utils\Strings::firstUpper($class[1]);
     $this->count = $this->count();
 }
Пример #19
0
 /**
  * @param MacroNode $node
  * @param PhpWriter $writer
  * @return string
  * @throws CompileException
  */
 public function wizardStart(MacroNode $node, PhpWriter $writer)
 {
     $words = $node->tokenizer->fetchWords();
     if (!$words) {
         throw new CompileException('Missing control name in {wizard}');
     }
     $name = $writer->formatWord($words[0]);
     $method = isset($words[1]) ? ucfirst($words[1]) : '';
     $method = Strings::match($method, '#^\\w*\\z#') ? "render{$method}" : "{\"render{$method}\"}";
     $param = $writer->formatArray();
     if (!Strings::contains($node->args, '=>')) {
         $param = substr($param, $param[0] === '[' ? 1 : 6, -1);
         // removes array() or []
     }
     return ($name[0] === '$' ? "if (is_object({$name})) \$_l->tmp = {$name}; else " : '') . '$_l->tmp = $_control->getComponent(' . $name . '); ' . 'if (!$_l->tmp instanceof WebChemistry\\Forms\\Controls\\IWizard) throw new \\Exception(\'Wizard must be instance of WebChemistry\\Forms\\Controls\\IWizard\');' . '$wizard = new WebChemistry\\Forms\\Controls\\Wizard\\Facade($_l->tmp);';
 }
Пример #20
0
 public function match(Http\IRequest $request)
 {
     $url = $request->getUrl();
     if (Strings::contains($url->path, $this->basePath) === false) {
         return;
     }
     $imgUrl = Strings::after($url->path, $this->basePath);
     $imgUrl = Strings::after($imgUrl, '/', -1);
     $parts = Imager\Helpers::parseName($imgUrl);
     if (!isset($parts['id'])) {
         return;
     }
     $url->setQueryParameter('id', $parts['id'])->setQueryParameter('width', $parts['width'])->setQueryParameter('height', $parts['height'])->setQueryParameter('quality', $parts['quality']);
     $response = new ImageResponse($this->repository, $this->imageFactory);
     $response->send(new Http\Request($url), new Http\Response());
 }
Пример #21
0
 public function macroWidget(MacroNode $node, PhpWriter $writer)
 {
     $pair = $node->tokenizer->fetchWord();
     if ($pair === FALSE) {
         throw new CompileException("Missing widget name in {widget}");
     }
     $pair = explode(':', $pair, 2);
     $name = $writer->formatWord($pair[0]);
     $method = isset($pair[1]) ? ucfirst($pair[1]) : '';
     $method = Strings::match($method, '#^\\w*\\z#') ? "render{$method}" : "{\"render{$method}\"}";
     $param = $writer->formatArray();
     if (!Strings::contains($node->args, '=>')) {
         $param = substr($param, 6, -1);
         // removes array()
     }
     return ($name[0] === '$' ? "if (is_object({$name})) \$_ctrl = {$name}; else " : '') . '$_ctrl = $presenter->getComponent("widgets")->getComponent(' . $name . '); ' . 'if ($_ctrl instanceof Nette\\Application\\UI\\IRenderable) $_ctrl->validateControl(); ' . "\$_ctrl->{$method}({$param})";
 }
Пример #22
0
 /**
  * Match request
  * @param  IRequest $request 
  * @return Request            
  */
 public function match(Http\IRequest $request)
 {
     $path = $request->url->getPathInfo();
     if (!Strings::contains($path, $this->prefix)) {
         return NULL;
     }
     $path = Strings::substring($path, strlen($this->prefix) + 1);
     $pathParts = explode('/', $path);
     $pathArguments = array_slice($pathParts, 1);
     $action = $this->getActionName($request->getMethod(), $pathArguments);
     $params = $this->getPathParameters($pathArguments);
     $params[Route::MODULE_KEY] = $this->module;
     $params[Route::PRESENTER_KEY] = $pathParts[0];
     $params['action'] = $action;
     $presenter = ($this->module ? $this->module . ':' : '') . $params[Route::PRESENTER_KEY];
     $appRequest = new Application\Request($presenter, $request->getMethod(), $params, $request->getPost(), $request->getFiles());
     return $appRequest;
 }
Пример #23
0
	/**
	 * {control name[:method] [params]}
	 */
	public function macroControl(MacroNode $node, PhpWriter $writer)
	{
		$words = $node->tokenizer->fetchWords();
		if (!$words) {
			throw new CompileException('Missing control name in {control}');
		}
		$name = $writer->formatWord($words[0]);
		$method = isset($words[1]) ? ucfirst($words[1]) : '';
		$method = Strings::match($method, '#^\w*\z#') ? "render$method" : "{\"render$method\"}";
		$param = $writer->formatArray();
		if (!Strings::contains($node->args, '=>')) {
			$param = substr($param, $param[0] === '[' ? 1 : 6, -1); // removes array() or []
		}
		return ($name[0] === '$' ? "if (is_object($name)) \$_l->tmp = $name; else " : '')
			. '$_l->tmp = $_control->getComponent(' . $name . '); '
			. 'if ($_l->tmp instanceof Nette\Application\UI\IRenderable) $_l->tmp->redrawControl(NULL, FALSE); '
			. ($node->modifiers === '' ? "\$_l->tmp->$method($param)" : $writer->write("ob_start(); \$_l->tmp->$method($param); echo %modify(ob_get_clean())"));
	}
Пример #24
0
 /**
  * Returns the NEON representation of a value.
  * @param  mixed
  * @param  int
  * @return string
  */
 public static function encode($var, $options = NULL)
 {
     if ($var instanceof \DateTime) {
         return $var->format('Y-m-d H:i:s O');
     } elseif ($var instanceof NeonEntity) {
         return self::encode($var->value) . '(' . substr(self::encode($var->attributes), 1, -1) . ')';
     }
     if (is_object($var)) {
         $obj = $var;
         $var = array();
         foreach ($obj as $k => $v) {
             $var[$k] = $v;
         }
     }
     if (is_array($var)) {
         $isList = Validators::isList($var);
         $s = '';
         if ($options & self::BLOCK) {
             if (count($var) === 0) {
                 return "[]";
             }
             foreach ($var as $k => $v) {
                 $v = self::encode($v, self::BLOCK);
                 $s .= ($isList ? '-' : self::encode($k) . ':') . (Strings::contains($v, "\n") ? "\n\t" . str_replace("\n", "\n\t", $v) : ' ' . $v) . "\n";
                 continue;
             }
             return $s;
         } else {
             foreach ($var as $k => $v) {
                 $s .= ($isList ? '' : self::encode($k) . ': ') . self::encode($v) . ', ';
             }
             return ($isList ? '[' : '{') . substr($s, 0, -2) . ($isList ? ']' : '}');
         }
     } elseif (is_string($var) && !is_numeric($var) && !preg_match('~[\\x00-\\x1F]|^\\d{4}|^(true|false|yes|no|on|off|null)$~i', $var) && preg_match('~^' . self::$patterns[4] . '$~', $var)) {
         return $var;
     } elseif (is_float($var)) {
         $var = var_export($var, TRUE);
         return Strings::contains($var, '.') ? $var : $var . '.0';
     } else {
         return json_encode($var);
     }
 }
Пример #25
0
 public function loadConfiguration()
 {
     $config = $this->getConfig($this->defaults);
     // validate apiKey
     Validators::assert($config['apiKey'], 'string', 'MailChimp - missing apiKey');
     // validate apiUrl
     Validators::assert($config['apiUrl'], 'string', 'MailChimp - invalid apiUrl');
     if (!Strings::contains($config['apiUrl'], '<dc>')) {
         throw new AssertionException("MailChimp - missing <dc> apiUrl");
     }
     Validators::assert($config['apiUrl'], 'string', 'MailChimp - missing apiUrl');
     list(, $datacentre) = explode('-', $config['apiKey']);
     $config['apiUrl'] = str_replace('<dc>', $datacentre, $config['apiUrl']);
     Validators::assert($config['apiUrl'], 'url', 'MailChimp - wrong apiUrl');
     $builder = $this->getContainerBuilder();
     $api = $builder->addDefinition($this->prefix('api'))->setClass('FreezyBee\\MailChimp\\Api')->setArguments([$config]);
     if ($config['debugger']) {
         $builder->addDefinition($this->prefix('panel'))->setClass('FreezyBee\\MailChimp\\Diagnostics\\Panel')->setInject(false);
         $api->addSetup($this->prefix('@panel') . '::register', ['@self']);
     }
 }
Пример #26
0
 /**
  * @param mixed $object
  * @param string $name
  * @throws PropertyAccessorException
  * @throws \Nette\MemberAccessException
  * @throws \InvalidArgumentException
  * @return mixed
  */
 public static function getProperty($object, $name)
 {
     if (is_array($object)) {
         if (!array_key_exists($name, $object)) {
             throw new PropertyAccessorException("Property with name '{$name}' does not exists in datasource.");
         }
         return $object[$name];
     } elseif (is_object($object)) {
         if (\Nette\Utils\Strings::contains($name, '.')) {
             $parts = explode('.', $name);
             foreach ($parts as $item) {
                 if (is_object($object)) {
                     $object = $object->{$item};
                 }
             }
             return $object;
         }
         return $object->{$name};
     } else {
         throw new \InvalidArgumentException('Please implement your own property accessor.');
     }
 }
Пример #27
0
 /**
  * @param $clause
  * @param array $parameters - first is $statement followed by $parameters
  * @return $this|SelectQuery
  */
 public function __call($clause, $parameters = array())
 {
     $this->getContext();
     //context must be available
     $clause = Helpers::toUpperWords($clause);
     if ($clause == 'GROUP') {
         $clause = 'GROUP BY';
     } elseif ($clause == 'ORDER') {
         $clause = 'ORDER BY';
     } elseif ($clause == 'FOOT NOTE') {
         $clause = "\n--";
     } elseif ($clause == 'WHERE PRIMARY') {
         $clause = 'WHERE';
         $primaryKey = $this->context->getDatabaseReflection()->getPrimary($this->getTable());
         array_unshift($parameters, "{$this->getTableAlias()}.{$primaryKey}");
     }
     $args = array_merge(array($clause), $parameters);
     if (Strings::contains($clause, 'JOIN')) {
         return call_user_func_array(array($this, 'addJoinStatements'), $args);
     }
     return call_user_func_array(array($this, 'processStatement'), $args);
 }
Пример #28
0
 /**
  * @param Table $table
  */
 protected function analyseColumns(Table $table)
 {
     $tableName = $table->getName();
     // Analyse columns
     $columns = $this->driver->getColumns($tableName);
     foreach ($columns as $key => $col) {
         $column = new Column();
         $column->setName($col['name']);
         $column->setNullable($col['nullable']);
         $column->setType(Helpers::columnType($col['nativetype']));
         $column->setDefault($col['default']);
         $column->setOnUpdate(Strings::contains($col['vendor']['Extra'], 'on update'));
         // Analyse ENUM
         if ($col['nativetype'] === ColumnTypes::NATIVE_TYPE_ENUM) {
             $enum = Strings::matchAll($col['vendor']['Type'], ColumnTypes::NATIVE_REGEX_ENUM, PREG_PATTERN_ORDER);
             if ($enum) {
                 $column->setEnum($enum[1]);
                 $column->setType(ColumnTypes::TYPE_ENUM);
                 $column->setSubType(Helpers::columnType($col['nativetype']));
             }
         }
         $table->addColumn($column);
     }
 }
Пример #29
0
	<!-- /#page-content-wrapper -->

</div>
<!-- /#wrapper -->


<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jsrender/0.9.72/jsrender.min.js"></script>

<?php 
require_once '../vendor/autoload.php';
?>

<?php 
if (\Nette\Utils\Strings::contains($_SERVER['REQUEST_URI'], 'www') || !($_SERVER['SERVER_NAME'] == 'localhost' || \Nette\Utils\Strings::startsWith($_SERVER['SERVER_NAME'], '192.168'))) {
    ?>
<script src="js/appStatic.js"></script>
<?php 
} else {
    ?>
<script src="www/js/appStatic.js"></script>
<?php 
}
?>





</body></html>
Пример #30
0
 private function processHtmlTagEnd(Token $token)
 {
     if ($token->text === '-->') {
         $this->output .= $token->text;
         $this->setContext(NULL);
         return;
     }
     $htmlNode = $this->htmlNode;
     $isEmpty = !$htmlNode->closing && (Strings::contains($token->text, '/') || $htmlNode->isEmpty);
     $end = '';
     if ($isEmpty && in_array($this->contentType, array(self::CONTENT_HTML, self::CONTENT_XHTML))) {
         // auto-correct
         $token->text = preg_replace('#^.*>#', $htmlNode->isEmpty && $this->contentType === self::CONTENT_XHTML ? ' />' : '>', $token->text);
         if (!$htmlNode->isEmpty) {
             $end = "</{$htmlNode->name}>";
         }
     }
     if (empty($htmlNode->macroAttrs)) {
         $this->output .= $token->text . $end;
     } else {
         $code = substr($this->output, $htmlNode->offset) . $token->text;
         $this->output = substr($this->output, 0, $htmlNode->offset);
         $this->writeAttrsMacro($code);
         if ($isEmpty) {
             $htmlNode->closing = TRUE;
             $this->writeAttrsMacro($end);
         }
     }
     if ($isEmpty) {
         $htmlNode->closing = TRUE;
     }
     $lower = strtolower($htmlNode->name);
     if (!$htmlNode->closing && ($lower === 'script' || $lower === 'style')) {
         $this->setContext($lower === 'script' ? self::CONTENT_JS : self::CONTENT_CSS);
     } else {
         $this->setContext(NULL);
         if ($htmlNode->closing) {
             $this->htmlNode = $this->htmlNode->parentNode;
         }
     }
 }