_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q248700 | Font.color | validation | private function color(string $color): Font
{
$this->color = $color;
if ($this->background) {
$this->turnToBackground();
}
return $this;
} | php | {
"resource": ""
} |
q248701 | PasswordHelper.lookup | validation | public function lookup($hash, $className = 'Orkestra\Bundle\ApplicationBundle\Entity\User')
{
try {
return $this->hashedEntityHelper->lookup($hash, $className);
} catch (\RuntimeException $e) {
return null;
}
} | php | {
"resource": ""
} |
q248702 | PasswordHelper.sendPasswordResetEmail | validation | public function sendPasswordResetEmail(UserInterface $user, $subject = 'Password reset request')
{
$hashedEntity = $this->createHash($user);
$this->emailHelper->createAndSendMessageFromTemplate(
'OrkestraApplicationBundle:Email:setPassword.html.twig',
array(
'... | php | {
"resource": ""
} |
q248703 | Native.getContent | validation | public function getContent(string $name, array $data = []): string
{
$cacheName = $name;
if ('' == $name) {
$this->isRouteView = true;
$stack = debug_backtrace();
foreach ($stack as $item) {
if (false !== stripos($item['file'], DIRECTORY_SEPARATOR... | php | {
"resource": ""
} |
q248704 | Native.renderTemplate | validation | private static function renderTemplate(string $__file__, array $data): string
{
ob_start();
extract($data);
include $__file__;
return ob_get_clean();
} | php | {
"resource": ""
} |
q248705 | PasswordSetController.newAction | validation | public function newAction(Request $request, $hash)
{
$passwordHelper = $this->get('orkestra.application.helper.password');
$hashedEntityHelper = $this->get('orkestra.application.helper.hashed_entity');
$hashedEntity = $passwordHelper->lookup($hash);
if (!$hashedEntity) {
... | php | {
"resource": ""
} |
q248706 | File.createFromUploadedFile | validation | public static function createFromUploadedFile(UploadedFile $upload, $uploadPath, $filename = null)
{
if (!$upload->isValid()) {
throw new UploadException(sprintf('An error occurred during file upload. Error code: %s', $upload->getError()));
} elseif (($uploadPath = realpath($uploadPath .... | php | {
"resource": ""
} |
q248707 | File.moveUploadedFile | validation | public function moveUploadedFile()
{
$this->dateCreated = new DateTime();
if (null === $this->_uploadedFile) {
return;
}
$this->_uploadedFile->move(dirname($this->path), basename($this->path));
$this->_uploadedFile = null;
} | php | {
"resource": ""
} |
q248708 | ConsoleColor.addColor | validation | public function addColor($color, $code = null)
{
$newColors = $this->parseColor($color, $code);
$this->colors = array_merge($this->colors, $newColors);
return $this;
} | php | {
"resource": ""
} |
q248709 | ConsoleColor.colorize | validation | protected function colorize($str, $attrs)
{
$start = $this->start($attrs);
return $start.$str.$this->end();
} | php | {
"resource": ""
} |
q248710 | ConsoleColor.parseColor | validation | protected function parseColor($color, $code = null)
{
$colors = is_array($color) ? $color : [$color => $code];
$return = [];
array_walk($colors, function ($code, $color) use (&$return) {
$color = $this->snakeCase($color);
$return[$color] = $code;
});
... | php | {
"resource": ""
} |
q248711 | UserController.newAction | validation | public function newAction()
{
$user = new User();
$form = $this->createForm(UserType::class, $user);
return array(
'user' => $user,
'form' => $form->createView()
);
} | php | {
"resource": ""
} |
q248712 | UserController.createAction | validation | public function createAction(Request $request)
{
$user = new User();
$form = $this->createForm(UserType::class, $user);
$form->bind($request);
if ($form->isValid()) {
$factory = $this->get('security.encoder_factory');
$encoder = $factory->getEncoder($user);
... | php | {
"resource": ""
} |
q248713 | UserController.resetPasswordAction | validation | public function resetPasswordAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$user = $em->getRepository('Orkestra\Bundle\ApplicationBundle\Entity\User')->find($id);
if (!$user) {
throw $this->createNotFoundException('Unable to locate User');
}
... | php | {
"resource": ""
} |
q248714 | UserController.editAction | validation | public function editAction($id)
{
$em = $this->getDoctrine()->getManager();
$user = $em->getRepository('Orkestra\Bundle\ApplicationBundle\Entity\User')->find($id);
if (!$user) {
throw $this->createNotFoundException('Unable to locate User');
}
$form = $this->crea... | php | {
"resource": ""
} |
q248715 | UserController.updateAction | validation | public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$user = $em->getRepository('Orkestra\Bundle\ApplicationBundle\Entity\User')->find($id);
if (!$user) {
throw $this->createNotFoundException('Unable to locate User');
}
... | php | {
"resource": ""
} |
q248716 | ModifyServiceDefinitionsPass.configureEmailHelper | validation | private function configureEmailHelper(ContainerBuilder $container)
{
if (!class_exists('Swift_Mailer')) {
$definition = $container->getDefinition('orkestra.application.helper.email');
$definition->setClass('Orkestra\Bundle\ApplicationBundle\Helper\EmailHelper\MisconfiguredEmailHelper... | php | {
"resource": ""
} |
q248717 | ArbitrarySetLoader.getEntitiesByIds | validation | public function getEntitiesByIds($identifier, array $values)
{
$accessor = PropertyAccess::createPropertyAccessor();
return array_filter(is_array($this->entities) ? $this->entities : $this->entities->toArray(), function ($entity) use ($identifier, $values, $accessor) {
return in_array($a... | php | {
"resource": ""
} |
q248718 | FileController.downloadAction | validation | public function downloadAction($id)
{
$em = $this->getDoctrine()->getManager();
/** @var $file \Orkestra\Bundle\ApplicationBundle\Entity\File */
$file = $em->find('Orkestra\Bundle\ApplicationBundle\Entity\File', $id);
if (!$file) {
throw $this->createNotFoundException('... | php | {
"resource": ""
} |
q248719 | Controller.getFormFor | validation | public function getFormFor($entity, $className = null, array $options = array())
{
if (empty($this->_formHelper) && ($this->_formHelper = $this->get('orkestra.application.helper.form')) == null) {
throw new \RuntimeException('Orkestra FormHelper is not registered as a service');
}
... | php | {
"resource": ""
} |
q248720 | Index.getContent | validation | public function getContent()
{
$this->absolute();
//if the pat is not a real file
if (!is_file($this->data)) {
//throw an exception
Exception::i()
->setMessage(self::ERROR_PATH_IS_NOT_FILE)
->addVariable($this->data)
->... | php | {
"resource": ""
} |
q248721 | Index.getMime | validation | public function getMime()
{
$this->absolute();
//mime_content_type seems to be deprecated in some versions of PHP
//if it does exist then lets use it
if (function_exists('mime_content_type')) {
return mime_content_type($this->data);
}
//if not then use t... | php | {
"resource": ""
} |
q248722 | Index.setContent | validation | public function setContent($content)
{
//argument 1 must be string
Argument::i()->test(1, 'string');
try {
$this->absolute();
} catch (\Eden\Path\Exception $e) {
$this->touch();
}
file_put_contents($this->data, $content);
return $thi... | php | {
"resource": ""
} |
q248723 | StringBuilder.changeEncoding | validation | public function changeEncoding($encoding)
{
$encoding = (string) $encoding;
$this->string = iconv($this->encoding, $encoding, $this->string);
$this->encoding = $encoding;
return $this;
} | php | {
"resource": ""
} |
q248724 | StringBuilder.startsWith | validation | public function startsWith($string)
{
$string = static::convertString($string, $this->encoding);
return $string === $this->substring(0, (mb_strlen($string, $this->encoding) - 1))->__toString();
} | php | {
"resource": ""
} |
q248725 | StringBuilder.endsWith | validation | public function endsWith($string)
{
$string = static::convertString($string, $this->encoding);
return $string === $this->substring($this->length() - mb_strlen($string, $this->encoding))->__toString();
} | php | {
"resource": ""
} |
q248726 | StringBuilder.charAt | validation | public function charAt($index)
{
$index = (int) $index;
if ($index < 0 || $index >= $this->length()) {
throw new \OutOfBoundsException();
}
return mb_substr($this->string, $index, 1, $this->encoding);
} | php | {
"resource": ""
} |
q248727 | StringBuilder.indexOf | validation | public function indexOf($string, $offset = null)
{
$string = static::convertString($string, $this->encoding);
$offset = $offset !== null ? (int) $offset : null;
if ($offset !== null && ($offset < 0 || $offset >= $this->length())) {
throw new \OutOfBoundsException();
}
... | php | {
"resource": ""
} |
q248728 | StringBuilder.lastIndexOf | validation | public function lastIndexOf($string, $offset = null)
{
$string = static::convertString($string, $this->encoding);
$offset = $offset !== null ? (int) $offset : null;
if ($offset !== null && ($offset < 0 || $offset >= $this->length())) {
throw new \OutOfBoundsException();
... | php | {
"resource": ""
} |
q248729 | StringBuilder.append | validation | public function append($string)
{
$string = static::convertString($string, $this->encoding);
$this->string .= $string;
return $this;
} | php | {
"resource": ""
} |
q248730 | StringBuilder.insert | validation | public function insert($offset, $string)
{
$offset = (int) $offset;
$string = static::convertString($string, $this->encoding);
if ($offset < 0 || $offset >= $this->length()) {
throw new \OutOfBoundsException();
}
$this->string = mb_substr($this->string, 0, $offs... | php | {
"resource": ""
} |
q248731 | StringBuilder.reverse | validation | public function reverse()
{
$length = $this->length();
$reversed = '';
while ($length-- > 0) {
$reversed .= mb_substr($this->string, $length, 1, $this->encoding);
}
$this->string = $reversed;
return $this;
} | php | {
"resource": ""
} |
q248732 | StringBuilder.setLength | validation | public function setLength($newLength, $padding = ' ')
{
$newLength = (int) $newLength;
$currentLength = $this->length();
if ($newLength != $currentLength) {
while ($newLength > $this->length()) {
$this->string .= $padding;
}
if ($newLe... | php | {
"resource": ""
} |
q248733 | StringBuilder.trim | validation | public function trim($characters = null)
{
$this->string = trim($this->string, $characters);
return $this;
} | php | {
"resource": ""
} |
q248734 | StringBuilder.trimLeft | validation | public function trimLeft($characters = null)
{
$this->string = ltrim($this->string, $characters);
return $this;
} | php | {
"resource": ""
} |
q248735 | StringBuilder.trimRight | validation | public function trimRight($characters = null)
{
$this->string = rtrim($this->string, $characters);
return $this;
} | php | {
"resource": ""
} |
q248736 | StringBuilder.convertString | validation | private static function convertString($string, $outputEncoding)
{
if ($string instanceof StringBuilder) {
$inputEncoding = $string->getEncoding();
} else {
$inputEncoding = mb_detect_encoding((string) $string);
}
$string = (string) $string;
if ($inputE... | php | {
"resource": ""
} |
q248737 | EmailHelper.createMessageFromTemplateEntity | validation | public function createMessageFromTemplateEntity(EmailTemplate $template, array $parameters = array())
{
$subject = $this->renderStringTemplate($template->getSubject(), $parameters);
$recipient = $this->renderStringTemplate($template->getRecipient(), $parameters);
$body = $this->renderStringT... | php | {
"resource": ""
} |
q248738 | EmailHelper.createMessageFromTemplateFile | validation | public function createMessageFromTemplateFile($template, $params, $subject, $recipient, $sender = null)
{
$body = $this->templating->render($template, $params);
if (!$sender) {
$sender = $this->defaultSender;
}
$message = new \Swift_Message();
$message->setFrom(... | php | {
"resource": ""
} |
q248739 | EmailHelper.createAndSendMessageFromTemplate | validation | public function createAndSendMessageFromTemplate()
{
$args = func_get_args();
if (empty($args[0])) {
throw new \RuntimeException('First parameter must be a template filename or EmailTemplate entity');
} elseif ($args[0] instanceof EmailTemplate) {
$method... | php | {
"resource": ""
} |
q248740 | EmailHelper.renderStringTemplate | validation | protected function renderStringTemplate($template, $parameters = array())
{
$template = $this->environment->createTemplate($template);
return $template->render($parameters);
} | php | {
"resource": ""
} |
q248741 | CurlService.requestJson | validation | public function requestJson($method, $url, $options=array()){
$options['headers'][] = 'Content-Type: application/json';
$options['headers'][] = 'Content-Length: ' . strlen($options['body']);
$this->request($method, $url, $options);
} | php | {
"resource": ""
} |
q248742 | DbtextCollectionManager.clearCache | validation | public function clearCache(string $namespace = null) {
if (null !== $namespace) {
$this->cacheStore->remove(self::APP_CACHE_PREFIX . $namespace, array());
return;
}
$this->cacheStore->clear();
} | php | {
"resource": ""
} |
q248743 | DbtextDao.getOrCreateGroup | validation | private function getOrCreateGroup(string $namespace): Group {
$group = $this->em->find(Group::getClass(), $namespace);
if (null !== $group) {
return $group;
}
$group = new Group($namespace);
$t = $this->tm->createTransaction();
$this->em->persist($group);
$t->commit();
return $group;
} | php | {
"resource": ""
} |
q248744 | DbtextHtmlBuilder.tf | validation | public function tf(string $key, array $args = null, array $replacements = null, string ...$namespaces) {
$this->view->out($this->getTf($key, $args, $replacements, ...$namespaces));
} | php | {
"resource": ""
} |
q248745 | DbtextHtmlBuilder.getTf | validation | public function getTf(string $key, array $args = null, array $replacements = null, string ...$namespaces) {
if (empty($namespaces)) {
$namespaces = $this->meta->getNamespaces();
}
$translatedText = $this->textService->tf($namespaces, $key, $args, ...$this->meta->getN2nLocales());
$replacedText = Htm... | php | {
"resource": ""
} |
q248746 | DbtextHtmlBuilderMeta.assignNamespace | validation | public function assignNamespace(string $namespace, $prepend = false) {
if ($prepend) {
array_unshift($this->namespaces, $namespace);
return;
}
array_push($this->namespaces, $namespace);
} | php | {
"resource": ""
} |
q248747 | TokenizerBase.setDoc | validation | function setDoc($doc, $pos = 0) {
$this->doc = $doc;
$this->size = strlen($doc);
$this->setPos($pos);
} | php | {
"resource": ""
} |
q248748 | TokenizerBase.getTokenString | validation | function getTokenString($start_offset = 0, $end_offset = 0) {
$token_start = ((is_int($this->token_start)) ? $this->token_start : $this->pos) + $start_offset;
$len = $this->pos - $token_start + 1 + $end_offset;
return (($len > 0) ? substr($this->doc, $token_start, $len) : '');
} | php | {
"resource": ""
} |
q248749 | TokenizerBase.setWhitespace | validation | function setWhitespace($ws) {
if (is_array($ws)) {
$this->whitespace = array_fill_keys(array_values($ws), true);
$this->buildCharMap();
} else {
$this->setWhiteSpace(str_split($ws));
}
} | php | {
"resource": ""
} |
q248750 | TokenizerBase.setIdentifiers | validation | function setIdentifiers($ident) {
if (is_array($ident)) {
$this->identifiers = array_fill_keys(array_values($ident), true);
$this->buildCharMap();
} else {
$this->setIdentifiers(str_split($ident));
}
} | php | {
"resource": ""
} |
q248751 | TokenizerBase.addError | validation | function addError($error) {
$this->errors[] = htmlentities($error.' at '.($this->line_pos[0] + 1).', '.($this->pos - $this->line_pos[1] + 1).'!');
} | php | {
"resource": ""
} |
q248752 | TokenizerBase.parse_linebreak | validation | protected function parse_linebreak() {
if($this->doc[$this->pos] === "\r") {
++$this->line_pos[0];
if ((($this->pos + 1) < $this->size) && ($this->doc[$this->pos + 1] === "\n")) {
++$this->pos;
}
$this->line_pos[1] = $this->pos;
} elseif($this->doc[$this->pos] === "\n") {
++$this->line_po... | php | {
"resource": ""
} |
q248753 | TokenizerBase.next | validation | function next() {
$this->token_start = null;
if (++$this->pos < $this->size) {
if (isset($this->char_map[$this->doc[$this->pos]])) {
if (is_string($this->char_map[$this->doc[$this->pos]])) {
return ($this->token = $this->{$this->char_map[$this->doc[$this->pos]]}());
} else {
return ($t... | php | {
"resource": ""
} |
q248754 | TokenizerBase.next_no_whitespace | validation | function next_no_whitespace() {
$this->token_start = null;
while (++$this->pos < $this->size) {
if (!isset($this->whitespace[$this->doc[$this->pos]])) {
if (isset($this->char_map[$this->doc[$this->pos]])) {
if (is_string($this->char_map[$this->doc[$this->pos]])) {
return ($this->token = $t... | php | {
"resource": ""
} |
q248755 | TokenizerBase.next_search | validation | function next_search($characters, $callback = true) {
$this->token_start = $this->pos;
if (!is_array($characters)) {
$characters = array_fill_keys(str_split($characters), true);
}
while(++$this->pos < $this->size) {
if (isset($characters[$this->doc[$this->pos]])) {
if ($callback && isset($thi... | php | {
"resource": ""
} |
q248756 | TokenizerBase.next_pos | validation | function next_pos($needle, $callback = true) {
$this->token_start = $this->pos;
if (($this->pos < $this->size) && (($p = stripos($this->doc, $needle, $this->pos + 1)) !== false)) {
$len = $p - $this->pos - 1;
if ($len > 0) {
$str = substr($this->doc, $this->pos + 1, $len);
if (($l = strrpos(... | php | {
"resource": ""
} |
q248757 | TokenizerBase.expect | validation | protected function expect($token, $do_next = true, $try_next = false, $next_on_match = 1) {
if ($do_next) {
if ($do_next === 1) {
$this->next();
} else {
$this->next_no_whitespace();
}
}
if (is_int($token)) {
if (($this->token !== $token) && ((!$try_next) || ((($try_next === 1) && (... | php | {
"resource": ""
} |
q248758 | HtmlParserBase.parse_text | validation | function parse_text() {
$len = $this->pos - 1 - $this->status['last_pos'];
$this->status['text'] = (($len > 0) ? substr($this->doc, $this->status['last_pos'] + 1, $len) : '');
} | php | {
"resource": ""
} |
q248759 | HtmlParserBase.parse_comment | validation | function parse_comment() {
$this->pos += 3;
if ($this->next_pos('-->', false) !== self::TOK_UNKNOWN) {
$this->status['comment'] = $this->getTokenString(1, -1);
--$this->pos;
} else {
$this->status['comment'] = $this->getTokenString(1, -1);
$this->pos += 2;
}
$this->status['last_pos'] = $t... | php | {
"resource": ""
} |
q248760 | HtmlParserBase.parse_doctype | validation | function parse_doctype() {
$start = $this->pos;
if ($this->next_search('[>', false) === self::TOK_UNKNOWN) {
if ($this->doc[$this->pos] === '[') {
if (($this->next_pos(']', false) !== self::TOK_UNKNOWN) || ($this->next_pos('>', false) !== self::TOK_UNKNOWN)) {
$this->addError('Invalid doctype');
... | php | {
"resource": ""
} |
q248761 | HtmlParserBase.parse_cdata | validation | function parse_cdata() {
if ($this->next_pos(']]>', false) === self::TOK_UNKNOWN) {
$this->status['cdata'] = $this->getTokenString(9, -1);
$this->status['last_pos'] = $this->pos + 2;
return true;
} else {
$this->addError('Invalid cdata tag');
return false;
}
} | php | {
"resource": ""
} |
q248762 | HtmlParserBase.parse_asp | validation | function parse_asp() {
$start = $this->pos;
if ($this->next_pos('%>', false) !== self::TOK_UNKNOWN) {
$this->pos -= 2; //End of file
}
$len = $this->pos - 1 - $start;
$this->status['text'] = (($len > 0) ? substr($this->doc, $start + 1, $len) : '');
$this->status['last_pos'] = ++$this->pos;
re... | php | {
"resource": ""
} |
q248763 | HtmlParserBase.parse_style | validation | function parse_style() {
if ($this->parse_attributes() && ($this->token === self::TOK_TAG_CLOSE) && ($start = $this->pos) && ($this->next_pos('</style>', false) === self::TOK_UNKNOWN)) {
$len = $this->pos - 1 - $start;
$this->status['text'] = (($len > 0) ? substr($this->doc, $start + 1, $len) : '');
$t... | php | {
"resource": ""
} |
q248764 | HtmlParserBase.parse_tag_default | validation | function parse_tag_default() {
if ($this->status['closing_tag']) {
$this->status['attributes'] = array();
$this->next_no_whitespace();
} else {
if (!$this->parse_attributes()) {
return false;
}
}
if ($this->token !== self::TOK_TAG_CLOSE) {
if ($this->token === self::TOK_SLASH_FORW... | php | {
"resource": ""
} |
q248765 | HtmlParserBase.parse_all | validation | function parse_all() {
$this->errors = array();
$this->status['last_pos'] = -1;
if (($this->token === self::TOK_TAG_OPEN) || ($this->next_pos('<', false) === self::TOK_UNKNOWN)) {
do {
if (!$this->parse_tag()) {
return false;
}
} while ($this->next_pos('<') !== self::TOK_NULL);
}
... | php | {
"resource": ""
} |
q248766 | HtmlParser.select | validation | function select($query = '*', $index = false, $recursive = true, $check_self = false) {
return $this->root->select($query, $index, $recursive, $check_self);
} | php | {
"resource": ""
} |
q248767 | pQuery.parseFile | validation | public static function parseFile($path, $context = null) {
$html_str = file_get_contents($path, false, $context);
return static::parseStr($html_str);
} | php | {
"resource": ""
} |
q248768 | JSParser.nest | validation | private function nest($x, $node, $end = false)
{
array_push($x->stmtStack, $node);
$n = $this->statement($x);
array_pop($x->stmtStack);
if ($end)
$this->t->mustMatch($end);
return $n;
} | php | {
"resource": ""
} |
q248769 | HtmlFormatter.minify_javascript | validation | static function minify_javascript(&$root, $indent_string = ' ', $wrap_comment = true, $recursive = true) {
#php4 JSMin+ doesn't support PHP4
#return true;
#php4e
#php5
include_once('third party/jsminplus.php');
$errors = array();
foreach($root->select('script:not-empty > "~text~"', false, $recursive,... | php | {
"resource": ""
} |
q248770 | DomNode.dumpLocation | validation | function dumpLocation() {
return (($this->parent) ? (($p = $this->parent->dumpLocation()) ? $p.' > ' : '').$this->tag.'('.$this->typeIndex().')' : '');
} | php | {
"resource": ""
} |
q248771 | DomNode.toString_attributes | validation | protected function toString_attributes() {
$s = '';
foreach($this->attributes as $a => $v) {
$s .= ' '.$a;
if ((!$this->attribute_shorttag) || ($v !== $a)) {
$quote = (strpos($v, '"') === false) ? '"' : "'";
$s .= '='.$quote.$v.$quote;
}
}
return $s;
} | php | {
"resource": ""
} |
q248772 | DomNode.toString | validation | function toString($attributes = true, $recursive = true, $content_only = false) {
if ($content_only) {
if (is_int($content_only)) {
--$content_only;
}
return $this->toString_content($attributes, $recursive, $content_only);
}
$s = '<'.$this->tag;
if ($attributes) {
$s .= $this->toStrin... | php | {
"resource": ""
} |
q248773 | DomNode.html | validation | function html($value = null) {
if ($value !== null) {
$this->setInnerText($value);
}
return $this->getInnerText();
} | php | {
"resource": ""
} |
q248774 | DomNode.setInnerText | validation | function setInnerText($text, $parser = null) {
$this->clear();
if (trim($text)) {
if ($parser === null) {
$parser = new $this->parserClass();
}
$parser->root =& $this;
$parser->setDoc($text);
$parser->parse_all();
}
return (($parser && $parser->errors) ? $parser->errors : true);
} | php | {
"resource": ""
} |
q248775 | DomNode.getPlainTextUTF8 | validation | function getPlainTextUTF8() {
$txt = $this->toString(true, true, true);
$enc = $this->getEncoding();
if ($enc !== false) {
$txt = mb_convert_encoding($txt, 'UTF-8', $enc);
}
return preg_replace('`\s+`', ' ', html_entity_decode($txt, ENT_QUOTES, 'UTF-8'));
} | php | {
"resource": ""
} |
q248776 | DomNode.delete | validation | function delete() {
if (($p = $this->parent) !== null) {
$this->parent = null;
$p->deleteChild($this);
} else {
$this->clear();
}
} | php | {
"resource": ""
} |
q248777 | DomNode.detach | validation | function detach($move_children_up = false) {
if (($p = $this->parent) !== null) {
$index = $this->index();
$this->parent = null;
if ($move_children_up) {
$this->moveChildren($p, $index);
}
$p->deleteChild($this, true);
}
} | php | {
"resource": ""
} |
q248778 | DomNode.clear | validation | function clear() {
foreach($this->children as $c) {
$c->parent = null;
$c->delete();
}
$this->children = array();
} | php | {
"resource": ""
} |
q248779 | DomNode.getRoot | validation | function getRoot() {
$r = $this->parent;
$n = ($r === null) ? null : $r->parent;
while ($n !== null) {
$r = $n;
$n = $r->parent;
}
return $r;
} | php | {
"resource": ""
} |
q248780 | DomNode.isParent | validation | function isParent($tag, $recursive = false) {
return ($this->hasParent($tag, $recursive) === ($tag !== null));
} | php | {
"resource": ""
} |
q248781 | DomNode.index | validation | function index($count_all = true) {
if (!$this->parent) {
return -1;
} elseif ($count_all) {
return $this->parent->findChild($this);
} else{
$index = -1;
//foreach($this->parent->children as &$c) {
// if (!$c->isTextOrComment()) {
// ++$index;
// }
// if ($c === $this) {
//... | php | {
"resource": ""
} |
q248782 | DomNode.setIndex | validation | function setIndex($index) {
if ($this->parent) {
if ($index > $this->index()) {
--$index;
}
$this->delete();
$this->parent->addChild($this, $index);
}
} | php | {
"resource": ""
} |
q248783 | DomNode.typeIndex | validation | function typeIndex() {
if (!$this->parent) {
return -1;
} else {
$index = -1;
//foreach($this->parent->children as &$c) {
// if (strcasecmp($this->tag, $c->tag) === 0) {
// ++$index;
// }
// if ($c === $this) {
// return $index;
// }
//}
foreach(array_keys($this->pa... | php | {
"resource": ""
} |
q248784 | DomNode.getSibling | validation | function getSibling($offset = 1) {
$index = $this->index() + $offset;
if (($index >= 0) && ($index < $this->parent->childCount())) {
return $this->parent->getChild($index);
} else {
return null;
}
} | php | {
"resource": ""
} |
q248785 | DomNode.getNextSibling | validation | function getNextSibling($skip_text_comments = true) {
$offset = 1;
while (($n = $this->getSibling($offset)) !== null) {
if ($skip_text_comments && ($n->tag[0] === '~')) {
++$offset;
} else {
break;
}
}
return $n;
} | php | {
"resource": ""
} |
q248786 | DomNode.getNamespace | validation | function getNamespace() {
if ($this->tag_ns === null) {
$a = explode(':', $this->tag, 2);
if (empty($a[1])) {
$this->tag_ns = array('', $a[0]);
} else {
$this->tag_ns = array($a[0], $a[1]);
}
}
return $this->tag_ns[0];
} | php | {
"resource": ""
} |
q248787 | DomNode.setNamespace | validation | function setNamespace($ns) {
if ($this->getNamespace() !== $ns) {
$this->tag_ns[0] = $ns;
$this->tag = $ns.':'.$this->tag_ns[1];
}
} | php | {
"resource": ""
} |
q248788 | DomNode.getEncoding | validation | function getEncoding() {
$root = $this->getRoot();
if ($root !== null) {
if ($enc = $root->select('meta[charset]', 0, true, true)) {
return $enc->getAttribute("charset");
} elseif ($enc = $root->select('"?xml"[encoding]', 0, true, true)) {
return $enc->getAttribute("encoding");
} elseif ($en... | php | {
"resource": ""
} |
q248789 | DomNode.childCount | validation | function childCount($ignore_text_comments = false) {
if (!$ignore_text_comments) {
return count($this->children);
} else{
$count = 0;
//foreach($this->children as &$c) {
// if (!$c->isTextOrComment()) {
// ++$count;
// }
//}
foreach(array_keys($this->children) as $k) {
if (... | php | {
"resource": ""
} |
q248790 | DomNode.deleteChild | validation | function deleteChild($child, $soft_delete = false) {
if (is_object($child)) {
$child = $this->findChild($child);
} elseif ($child < 0) {
$child += count($this->children);
}
if (!$soft_delete) {
$this->children[$child]->delete();
}
unset($this->children[$child]);
//Rebuild indices
... | php | {
"resource": ""
} |
q248791 | DomNode.wrapInner | validation | function wrapInner($node, $start = 0, $end = -1, $wrap_index = -1, $node_index = null) {
if ($end < 0) {
$end += count($this->children);
}
if ($node_index === null) {
$node_index = $end + 1;
}
if (!is_object($node)) {
$node = $this->addChild($node, $node_index);
} elseif ($node->parent !... | php | {
"resource": ""
} |
q248792 | DomNode.hasAttribute | validation | function hasAttribute($attr, $compare = 'total', $case_sensitive = false) {
return ((bool) $this->findAttribute($attr, $compare, $case_sensitive));
} | php | {
"resource": ""
} |
q248793 | DomNode.getChildrenByCallback | validation | function getChildrenByCallback($callback, $recursive = true, $check_self = false) {
$count = $this->childCount();
if ($check_self && $callback($this)) {
$res = array($this);
} else {
$res = array();
}
if ($count > 0) {
if (is_int($recursive)) {
$recursive = (($recursive > 1) ? $recursi... | php | {
"resource": ""
} |
q248794 | DomNode.match_tags | validation | protected function match_tags($tags) {
$res = false;
foreach($tags as $tag => $match) {
if (!is_array($match)) {
$match = array(
'match' => $match,
'operator' => 'or',
'compare' => 'total',
'case_sensitive' => false
);
} else {
if (is_int($tag)) {
$tag = $mat... | php | {
"resource": ""
} |
q248795 | DomNode.match_filters | validation | protected function match_filters($conditions, $custom_filters = array()) {
foreach($conditions as $c) {
$c['filter'] = strtolower($c['filter']);
if (isset($this->filter_map[$c['filter']])) {
if (!$this->{$this->filter_map[$c['filter']]}($c['params'])) {
return false;
}
} elseif (isset($cu... | php | {
"resource": ""
} |
q248796 | DomNode.match | validation | function match($conditions, $match = true, $custom_filters = array()) {
$t = isset($conditions['tags']);
$a = isset($conditions['attributes']);
$f = isset($conditions['filters']);
if (!($t || $a || $f)) {
if (is_array($conditions) && $conditions) {
foreach($conditions as $c) {
if ($this->ma... | php | {
"resource": ""
} |
q248797 | DomNode.getChildrenByAttribute | validation | function getChildrenByAttribute($attribute, $value, $mode = 'equals', $compare = 'total', $recursive = true) {
if ($this->childCount() < 1) {
return array();
}
$mode = explode(' ', strtolower($mode));
$match = ((isset($mode[1]) && ($mode[1] === 'not')) ? 'false' : 'true');
return $this->getChildr... | php | {
"resource": ""
} |
q248798 | DomNode.getChildrenByTag | validation | function getChildrenByTag($tag, $compare = 'total', $recursive = true) {
if ($this->childCount() < 1) {
return array();
}
$tag = explode(' ', strtolower($tag));
$match = ((isset($tag[1]) && ($tag[1] === 'not')) ? 'false' : 'true');
return $this->getChildrenByMatch(
array(
'tags' => array... | php | {
"resource": ""
} |
q248799 | DomNode.query | validation | public function query($query = '*') {
$select = $this->select($query);
$result = new \pQuery((array)$select);
return $result;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.