public function getIDNodeFromUserPage($idnode) { $html_page = new DomDocument(); $html_page->loadHTML($this->getCachedUserPage()); if ($html_page->getElementById($idnode)) { return $html_page->getElementById($idnode); } return false; }
private function getGEDTFormTokens() { //Extract the validation data libxml_use_internal_errors(true); //skip DOM errors $dom = new DomDocument(); $dom->loadHTML($this->upload_form); $this->form_objects['__VIEWSTATE'] = $dom->getElementById('__VIEWSTATE')->getAttribute('value'); $this->form_objects['__EVENTVALIDATION'] = $dom->getElementById('__EVENTVALIDATION')->getAttribute('value'); }
function __construct($ch, $url) { print "Initializing hero's adventure data\n"; curl_setopt($ch, CURLOPT_URL, $url . $this->relativeUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); $doc = new DomDocument(); $doc->loadHTML($result); $adventures = $doc->getElementById('adventureListForm')->getElementsByTagName('tr'); // The first element will be the title of the table so we have to skip it $firstElement = true; foreach ($adventures as $i => $adv) { if ($firstElement) { $firstElement = false; } else { $fields = array(); // Add the link needed to go to this adventure if (count($adv->getElementsByTagName('a')) > 1) { $fields['href'] = $adv->getElementsByTagName('a')->item(1)->getAttribute('href'); // Getting hidden fields foreach ($adv->getElementsByTagName('input') as $j => $input) { $fields[$input->getAttribute('name')] = $input->getAttribute('value'); } $this->adventureList[trim($adv->getElementsByTagName('td')->item(2)->childNodes->item(0)->nodeValue) . ' <=> ' . $adv->getElementsByTagName('td')->item(4)->childNodes->item(1)->nodeValue] = $fields; } else { echo "No hay aventuras. Si este mensaje se imprime mas de una vez, algo va mal"; } } } asort($this->adventureList); }
public function process($args) { $answer = ""; $args = trim($args); if (strlen($args) > 0) { $entrada = urlencode($args); $url = "https://www.google.com.mx/search?q={$entrada}&oq=200&aqs=chrome.1.69i57j69i59j69i65l2j0l2.3015j0j8&client=ubuntu-browser&sourceid=chrome&es_sm=122&ie=UTF-8"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.120 Chrome/37.0.2062.120 Safari/537.36'); $html = curl_exec($ch); $web = new DomDocument(); @$web->loadHTML($html); $nodos = @$web->getElementById('topstuff')->getElementsByTagName('div'); $answer = "No pude convertir lo que me pides."; if ($nodos) { $nodos = iterator_to_array($nodos); if (count($nodos) === 6) { $answer = utf8_decode($nodos[3]->nodeValue . " " . $nodos[4]->nodeValue); } } } else { $answer = "Ingresa una expresion."; } $this->reply($answer, $this->currentchannel, $this->nick); }
function getFollowers($username){ $x = file_get_contents("http://twitter.com/".$username); $doc = new DomDocument; @$doc->loadHTML($x); $ele = $doc->getElementById('follower_count'); $innerHTML=preg_replace('/^<[^>]*>(.*)<[^>]*>$/',"\\1",DOMElement_getOuterHTML($doc,$ele)); return $innerHTML; }
public function testToOptionArray() { $this->dispatch('backend/admin/system_config/edit/section/admin'); $dom = new DomDocument(); $dom->loadHTML($this->getResponse()->getBody()); $select = $dom->getElementById('admin_startup_menu_item_id'); $this->assertNotEmpty($select, 'Startup Page select missed'); $options = $select->getElementsByTagName('option'); $optionsCount = $options->length; $this->assertGreaterThan(98, $optionsCount, 'Paucity count of menu items in the list'); $this->assertEquals('Dashboard', $options->item(0)->nodeValue, 'First element is not Dashboard'); $this->assertContains('Configuration', $options->item($optionsCount - 1)->nodeValue); }
function parseAllProducts($timePoint = 0) { global $productModel; $dom = new DomDocument('1.0', 'utf-8'); $dom->strictErrorChecking = false; @$dom->loadHTML(getGuzzleContent()); $productsParentDE = $dom->getElementById('hl'); $productDEs = getElementsByClass($productsParentDE, 'div', 'chotot-list-row'); $time = time(); $products = []; foreach ($productDEs as $productDE) { $productUrlTag = $productDE->getElementsByTagName('a')->item(0); $productInfo = $productDE->getElementsByTagName('div')->item(0); $product = new stdClass(); $thumbDEs = getElementsByClass($productDE, 'div', 'listing_thumbs_image'); $priceDEs = getElementsByClass($productDE, 'div', 'ad-price'); $locationDEs = getElementsByClass($productDE, 'span', 'municipality'); $linkDEs = getElementsByClass($productDE, 'a', 'ad-subject'); foreach ($linkDEs as $linkDE) { $url = $linkDE->getAttribute('href'); $urlExpStr = explode('-', $url); $id = explode('.', end($urlExpStr))[0]; $product->id = $id; $product->title = trim($linkDE->getAttribute('title')); $product->url = $url; $product->created_at = $time; } foreach ($thumbDEs as $thumbDE) { $img = $thumbDE->getElementsByTagName('img')->item(0); $product->thumbnail = $img->getAttribute('src'); } foreach ($priceDEs as $priceDE) { $product->price = trim($priceDE->nodeValue); } foreach ($locationDEs as $locationDE) { $product->location = trim($locationDE->nodeValue); } $products[] = $product; $productModel->insertProduct($product); } return $productModel->getProducts($timePoint); }
<?php $next = true; $url = "http://www.alexa.com/topsites/countries/SE"; $sites_list = array(); $args = getopt("n:"); $number_of_sites = intval($args["n"]); if ($number_of_sites > 500 || $number_of_sites < 0) { $number_of_sites = 20; } while ($next) { $doc = new DomDocument(); @$doc->loadHTMLFile($url); $data = $doc->getElementById('topsites-countries'); $my_data = $data->getElementsByTagName('div'); $xpath = new DOMXpath($doc); $get_websites = $xpath->query('//span[@class="small topsites-label"]'); foreach ($get_websites as $sites) { $sites_list[] = $sites->nodeValue . "\n"; } $is_next = $xpath->query('//a[@class="next"]'); if ($is_next->item(0)) { $url = "http://www.alexa.com" . $is_next->item(0)->getAttribute("href"); } else { $next = NULL; } if (count($sites_list) >= $number_of_sites) { break; } } for ($i = 0; $i < $number_of_sites; $i++) {
private function _postToLoginParseHtmlForm($html) { $data = array(); $dom = new DomDocument(); @$dom->loadHTML($html); $loginForm = $dom->getElementById("loginForm"); $z = $loginForm->getElementsByTagName("input"); foreach ($z as $input) { $name = $input->getAttribute('name'); $value = $input->getAttribute('value'); $data[$name] = $value; } $data['username'] = $this->username; $data['password'] = $this->password; $data['timezone_field'] = str_replace(':', '|', date('P')); // ?data.put("timezone_field", new SimpleDateFormat("XXX").format(now).replace(':', '|')); $data['js_time'] = time() / 1000; // ? data.put("js_time", String.valueOf(now.getTime() / 1000)); return $data; }
<?php header('Content-Type: application/json'); $channel = $_GET['channel']; $id = $_GET['id']; $title = ''; $view = ''; $status = ''; $object = array(); switch ($channel) { case 'talktv': $doc = new DomDocument(); $doc->loadHTMLFile('http://talktv.vn/' . $id); //status $thediv = $doc->getElementById('stream-status-live'); $status = trim($thediv->textContent); if ($status == 'Đang phát') { $status = 'live'; } else { $status = 'offline'; } //view $thediv = $doc->getElementById('player-viewing-count'); $view = trim($thediv->textContent); //title $thediv = $doc->getElementById('broadcast-title'); $title = trim($thediv->textContent); break; case 'youtube': $view = file_get_contents('https://www.youtube.com/live_stats?v=' . $id); //get view
} $display = true; if (isset($_POST['submit'])) { unset($_POST['submit']); $user_id = ""; if (validateUserLogin($err_msg)) { $conn = new dbAccess($debug); if (($rc = $conn->dbLoginUser($username, $password, $user_id)) == GOOD_RC) { // we have a valid user // Create new session, store the user id $_SESSION['user_id'] = $user_id; $sess_id = session_id(); $_SESSION['sess_id'] = $sess_id; $dom = new DomDocument(); $dom->validateOnParse = true; $el = $dom->getElementById('sess_id'); $el->nodeValue = $sess_id; $uid = $dom->getElementById('user_id'); $uid->nodeValue = $user_id; // Redirect to user info page ob_end_clean(); header('Location: ' . $baseURL . '/dataAccess/userInfo.php'); //http_redirect('www.google.com', true, HTTP_REDIRECT_PERM); exit; } else { $err_msg = $conn->errmsg; session_destroy(); } } // end if valid input }
/** * 从页面抓取酒店信息 * @param string $html html内容 * @param int $hotelid 酒店id * @return mixed $data */ private function _getHotelMessage($html, $hotelid) { $dom = new DomDocument(); $searchPage = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"); @$dom->loadHTML($searchPage); $idhtml = $dom->getElementById($hotelid); if (gettype($idhtml) != "object") { return false; } $p = @$idhtml->firstChild->firstChild->nextSibling->firstChild->firstChild->lastChild; if (gettype($p) != "object") { return false; } $data['brief'] = @$p->lastChild->previousSibling->previousSibling->nodeValue; $data['address'] = @$p->firstChild->nextSibling->lastChild->attributes->item(0)->value; $data['tarea'] = @$p->firstChild->nextSibling->lastChild->previousSibling->previousSibling->nodeValue; if ($data['tarea'] == " ") { $data['tarea'] = @$p->firstChild->nextSibling->lastChild->previousSibling->previousSibling->previousSibling->nodeValue; } if (!$data['brief'] || !$data['address'] || !$data['tarea']) { return false; } return $data; }
require AT_INCLUDE_PATH . 'header.inc.php'; // // Mauro Donadio // $fp = @file_get_contents($content_row['text']); // just for AContent content if (strstr($fp, 'AContentXX')) { //$fp = str_ireplace('<head>','<MAURO>',$fp); //<base href="http://www.w3schools.com/images/" target="_blank" /> // a new dom object $dom = new DomDocument(); libxml_use_internal_errors(TRUE); // load the html into the object $dom->loadHTML($fp); libxml_use_internal_errors(FALSE); $doc->formatOutput = TRUE; //discard white space $dom->preserveWhiteSpace = false; $node = $dom->getElementById('content-text'); // row commented because of the old version of PHP //$content = $dom->saveHTML($node); $content = $dom->saveXML($node, LIBXML_NOEMPTYTAG); // overwrite the original content with the filtered one $savant->assign('body', stripslashes($content)); $savant->assign('module_contents', ''); } $savant->display('content.tmpl.php'); // -- //save last visit page. $_SESSION['last_visited_page'] = $server_protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; require AT_INCLUDE_PATH . 'footer.inc.php';
include "inc/header.inc"; $doc = new DomDocument(); // We need to validate our document before refering to the id $doc->validateOnParse = false; $doc->loadHtml(file_get_contents($_GET['page'])); ?> <div data-role="page" id="content" data-add-back-btn="true"> <div data-role="header"> <h1><?echo $_GET['title'] ?></h1> </div><!-- /header --> <div data-role="content"> <p> <? $links = $doc->getElementsByTagName("a"); foreach($links as $link) { $href = $link->getAttribute("href"); $newLink = "content.php?page=" . $href; $link->setAttribute("href",$newLink); } $elemContent = $doc->getElementById('content'); $elemText = $elemContent->ownerDocument->saveXML($elemContent); echo $elemText; ?> </p> </div><!-- /content --> <?php include "inc/footer.inc";
if (!file_exists(plotsXml)) { // DES plots description errorProcessing($ID, "InternalError00: no plots description file"); if (file_exists(resultDir . $ID)) { rrmdir(resultDir . $ID); } die; } $dom = new DomDocument("1.0"); $dom->load(plotsXml); chdir($resDirName . "/RES"); // Down to working directory $i = 0; foreach ($missions as $mission) { $fileS = fopen(requestList, "w"); $missionTag = $dom->getElementById($mission); $params = $missionTag->getElementsByTagName('param'); //TODO calculate deltaY from number of vars $yStart = 0.1; fwrite($fileS, $params->length . PHP_EOL); foreach ($params as $param) { $yStop = $yStart + 0.2; fwrite($fileS, $param->getAttribute('name') . ' 0 ' . $yStart . ' 0.95 ' . $yStop . ' 0 0 0 0' . PHP_EOL); $yStart += 0.2; } $startTime = strtotime($start[$i]); $endTime = strtotime($stop[$i]); $TIMEINTERVAL = timeInterval2Days($endTime - $startTime); $STARTTIME = startTime2Days($startTime); fwrite($fileS, $STARTTIME . PHP_EOL . $TIMEINTERVAL . PHP_EOL); fclose($fileS);
} exec("cp Logbook-A7-_dwustronny_by_rushcore_page{$page}{$noftf}.svg work/{$shortname}.svg"); } } replace_text_in_file("work/{$shortname}.svg", "logo.png", "/tmp/" . $shortname . "2.{$ext}"); replace_text_in_file("work/{$shortname}.svg", "logo2.png", "/tmp/" . $shortname . "3.{$ext2}"); $cachename = substr($_POST['cache_name'], 0, 80); $coords = substr($_POST['coords'], 0, 80); $nick = substr($_POST['nick'], 0, 80); $email = substr($_POST['email'], 0, 80); $svg = new DomDocument(); $svg->validateOnParse = true; $svg->Load("work/{$shortname}.svg"); if ($_POST['noborders'] && !($i % 2)) { for ($f = 1; $f <= 4; ++$f) { $elem = $svg->getElementById('frame' . $f); if ($elem) { $elem->setAttribute("style", "fill:none;stroke-opacity: 0"); } } } $elem = $svg->getElementById('titlelogo'); $mod = 0; if ($elem) { $elem->setAttribute("height", $elem->getAttribute("height") + (double) $_POST['h1']); $elem->setAttribute("width", $elem->getAttribute("width") + (double) $_POST['w1']); $elem->setAttribute("x", $elem->getAttribute("x") + (double) $_POST['x1']); $elem->setAttribute("y", $elem->getAttribute("y") + (double) $_POST['y1']); $mod = 1; } for ($j = 1; $j <= 4; ++$j) {
//TODO if not parameters // Get parameter used in the function // $params = $thisFunction->getElementsByTagName('param'); // velocity_magnitude = $param; ex.sw(1) to find in AmdaParametersBrief.xml if (!file_exists(amdaParametersXml)) { // Internal file to connect DES - AMDA parameters errorProcessing($ID, "InternalError03: no AMDA - DES translation file"); if (file_exists(resultDir . $ID)) { rrmdir(resultDir . $ID); } die; } $domParam = new DomDocument("1.0"); $domParam->load(amdaParametersXml); // Find tag with predefined mission $thisMission = $domParam->getElementById($mission); if ($thisMission == null) { errorProcessing($ID, "InternalError04: {$mission} is not found in AMDA - DES translation table"); if (file_exists(resultDir . $ID)) { rrmdir(resultDir . $ID); } die; } // Find parameter tag (V, N, B etc) if (trim($parameter)) { // if (Verbose) fwrite(log,'$parameter2= '.$parameter.PHP_EOL); $thisParam = $thisMission->getElementsByTagName(trim($parameter)); if ($thisParam) { if (!$thisParam->item(0)) { errorProcessing($ID, "InternalError05: {$parameter} is not found in AMDA - DES translation table"); if (file_exists(resultDir . $ID)) {
/** * Bing query resolver server * * @return bool */ private function executeBing($ch) { $url = 'http://www.bing.com/search?q=ip%3a' . $this->ip; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: SRCHHPGUSR=NRSLT=500")); $result = curl_exec($ch); $this->hosts = array(); $doc = new \DomDocument(); if ($doc->loadHTML($result)) { foreach ($doc->getElementById('b_results')->getElementsByTagName('li') as $elements) { foreach ($elements->getElementsByTagName('cite') as $element) { if (preg_match('/((\\w+\\.)?[a-zA-Z0-9\\-]+\\.[a-z]+)/', $element->textContent, $matches)) { $this->hosts[$matches[1]] = $matches[1]; } } } return true; } return false; }
$key_old = 'AIzaSyBWadID4BBABPNdBTAebYgIXZ_zQDmmyOo'; $h = get_headers($data_url, TRUE); $time_new = $h["Last-Modified"]; $time_old = file_get_contents($time_file); //sometimes the website returns empty last modified time if ($time_new == "" || $time_new == $time_old) { $msg = 'Not updated after ' . $time_new . '.'; } else { file_put_contents($time_file, $time_new); file_put_contents($time_file_debug, $time_old); $doc = new DomDocument(); libxml_use_internal_errors(true); $data = file_get_contents($data_url); $doc->loadHTML(mb_convert_encoding($data, 'HTML-ENTITIES', 'UTF-8')); libxml_clear_errors(); $div = $doc->getElementById('vmarquee'); //create the array of new notices //foreach($div->getElementsByTagName('a') as $link) { foreach ($div->getElementsByTagName('p') as $link) { $new_notices[] = $link->nodeValue; } //read old notices from file $string_data = file_get_contents($data_file); $old_notices = unserialize($string_data); //check which notices are actually new foreach ($new_notices as $newVal) { //reset flag $match = false; //compare each new notice with every old notice foreach ($old_notices as $oldVal) { if ($newVal == $oldVal) {
/** * get a specific element ( mostly placeholders ) * * @param mixed $id * @access public * @return DomElement */ function getElementById($id) { //$xpath = new DOMXPath($this->document); //return $xpath->query("//*[@id='$id']")->item(0); return $this->document->getElementById($id); }
private function makeRequest($conditions, $start, $stop) { $oneInterval = count($start) == 1; if (!file_exists(functionsXml)) { // DES functions description //error "InternalError00: no functions description file"); //return; } $dom = new DomDocument("1.0"); $dom->load(functionsXml); $index = 0; /* Create object for search request[s] */ foreach ($conditions as $condition) { if ($condition != '') { $parts = explode(',', $condition); $func = trim($parts[0]); $thisFunction = $dom->getElementById($func); if ($thisFunction == null) { // if ($this->isSoap) throw new SoapFault("InternalError01","function $func is not implemented in AMDA-HELIO yet"); // else return array("error" => "InternalError01: function $func is not implemented in AMDA-HELIO yet"); // return; } $params = explode(':', $parts[1]); $mission = trim($params[0]); // find predefined arguments in functions.xml file $args = $thisFunction->getElementsByTagName('arg'); $n_param = $thisFunction->getAttribute('n_param'); $totalArgs = $args->length + $n_param; if ($totalArgs != count($params) - 1) { // if ($this->isSoap) throw new SoapFault("InternalError02","function $func : arguments number is ".count($function->arg). // " expected number is ".$args->length)); // else return array("error" => "function $func : arguments number is ".count($function->arg). // " expected number is ".$args->length)); // return; } // CHECK if parameters are really applicable to the function $helioRequest = new stdClass(); $helioRequest->func = $func; $helioRequest->mission = $mission; $helioRequest->starttime = $oneInterval ? $start[0] : $start[$index]; $helioRequest->stoptime = $oneInterval ? $stop[0] : $stop[$index]; for ($i = 0; $i < $n_param; $i++) { $helioRequest->parameter[] = $params[$i + 1]; } $j = 0; foreach ($args as $arg) { $helioRequest->arg[$arg->getAttribute('name')] = $this->parseCondition($params[$n_param + $j + 1]); $j++; } $index++; $helioRequests[] = $helioRequest; } } return $helioRequests; }
return Bem::bm($block, $class); }, $classes); return $classes; }, apply_filters('wpbem_post_class_priority', 30), 1); if (apply_filters('wpbem_amend_comment_form', true)) { add_action('comment_form_before', 'ob_start', apply_filters('wpbem_comment_form_priority', 30)); add_action('comment_form_after', function () { $container_class = apply_filters('wpbem_comment_container_block', 'comments'); $form_class = apply_filters('wpbem_comment_form_block', 'comment-form'); $form = ob_get_contents(); ob_end_clean(); $dom = new DomDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = false; $dom->loadHTML($form); $root = $dom->getElementById('respond'); $root->setAttribute('class', $container_class); $title = $dom->getElementById('reply-title'); $title->setAttribute('class', Bem::bem($container_class, 'title')); $title->getElementsByTagName('a')->item(0)->setAttribute('class', Bem::bem($container_class, 'cancel-link')); $form = $dom->getElementById('commentform'); $form->setAttribute('class', $form_class); foreach ($form->getElementsByTagName('p') as $p) { $current_class = $p->getAttribute('class'); if ('comment-form-' == substr($current_class, 0, 13)) { $p->setAttribute('class', sprintf('%s %s', Bem::bem($form_class, 'row'), Bem::bem($form_class, 'row', substr($current_class, 13)))); } } foreach ($form->getElementsByTagName('label') as $label) { $label->setAttribute('class', Bem::bem($form_class, 'label')); }
/** * Instantiates the $special_page_class with supplied $initial_vars, * yoinks the html output from the output buffer, loads that into a * DomDocument and performs asserts on the results per the checks * supplied in $perform_these_checks. * Optional: Asserts that the gateway has logged nothing at ERROR level. * * @param string $special_page_class A testing descendant of GatewayPage * @param array $initial_vars Array that will be loaded straight into a * test version of the http request. * @param array $perform_these_checks Array of checks to perform in the * following format: * $perform_these_checks[$element_id][$check_to_perform][$expected_result] * So far, $check_to_perform can be either 'nodename' or 'innerhtml' * @param boolean $fail_on_log_errors When true, this will fail the * current test if there are entries in the gateway's error log. * @param array $session pre-existing session data. */ function verifyFormOutput($special_page_class, $initial_vars, $perform_these_checks, $fail_on_log_errors = false, $session = null) { // Nasty hack to clear output from any previous tests. $mainContext = RequestContext::getMain(); $newOutput = new OutputPage($mainContext); $newRequest = new TestingRequest($initial_vars, false, $session); $newTitle = Title::newFromText('nonsense is apparently fine'); $mainContext->setRequest($newRequest); $mainContext->setOutput($newOutput); $mainContext->setTitle($newTitle); $globals = array('wgTitle' => $newTitle, 'wgOut' => $newOutput); $this->setMwGlobals($globals); $this->setLanguage($initial_vars['language']); ob_start(); $formpage = new $special_page_class(); $formpage->execute(NULL); $formpage->getOutput()->output(); $form_html = ob_get_contents(); ob_end_clean(); // In the event that something goes crazy, uncomment the next line for much easier local debugging // file_put_contents( '/tmp/xmlout.txt', $form_html ); if ($fail_on_log_errors) { $this->verifyNoLogErrors(); } $dom_thingy = new DomDocument(); //// DEBUGGING, foo // if (property_exists($this, 'FOO')) { // error_log(var_export($formpage->getRequest()->response()->getheader('Location'), true)); // error_log(var_export($form_html, true)); // } if ($form_html) { // p.s. i'm SERIOUS about the character encoding. $dom_thingy->loadHTML('<?xml encoding="UTF-8">' . $form_html); $dom_thingy->encoding = 'UTF-8'; } foreach ($perform_these_checks as $id => $checks) { if ($id == 'headers') { foreach ($checks as $name => $expected) { $actual = $formpage->getRequest()->response()->getheader($name); $this->performCheck($actual, $expected, "header '{$name}'"); break; } continue; } unset($perform_these_checks['headers']); $input_node = $dom_thingy->getElementById($id); $this->assertNotNull($input_node, "Couldn't find the '{$id}' element"); foreach ($checks as $name => $expected) { switch ($name) { case 'nodename': $this->performCheck($input_node->nodeName, $expected, "name of node with id '{$id}'"); break; case 'innerhtml': $actual_html = self::getInnerHTML($input_node); // Strip comments $actual_html = preg_replace('/<!--[^>]*-->/', '', $actual_html); $this->performCheck($actual_html, $expected, "innerHTML of node '{$id}'"); break; case 'innerhtmlmatches': $this->assertEquals(1, preg_match($expected, self::getInnerHTML($input_node)), "Value of the node with id '{$id}' does not match pattern '{$expected}'. It has value " . self::getInnerHTML($input_node)); break; case 'value': $this->performCheck($input_node->getAttribute('value'), $expected, "value of node with id '{$id}'"); break; case 'selected': $selected = null; if ($input_node->nodeName === 'select') { $options = $input_node->getElementsByTagName('option'); foreach ($options as $option) { if ($option->hasAttribute('selected')) { $selected = $option->getAttribute('value'); break; } } $this->performCheck($selected, $expected, "selected option value of node with id '{$id}'"); } else { $this->fail("Attempted to test for selected value on non-select node, id '{$id}'"); } break; } } } // Are there untranslated boogers? if (preg_match_all('/<[^<]+(>|>)/', $form_html, $matches)) { $this->fail('Untranslated messages present: ' . implode(', ', $matches[0])); } }
function onBeforeRender() { $app = self::$app; $reqParams = self::$reqParams; $id = $reqParams['id']; if (!$app->isAdmin()) { return; } $user = self::$user; if (!$user->authorise('core.edit', 'com_content')) { return; } // termina la ejecución del plugin si los parametros recibidos no cumplen // con las condiciones preestablecidas para modificar el contexto de edición de // artículos if ($reqParams["view"] != "article" || $reqParams["layout"] != "edit") { return; } $doc = JFactory::getDocument(); $doc->addStyleSheet(JURI::root() . 'plugins/system/jokte_adjuntos/assets/css/estilos.css'); // obtiene el buffer del documento que será renderizado $buffer = mb_convert_encoding($doc->getBuffer('component'), 'html-entities', 'utf-8'); // inicializa la manipulación del DOM para el buffer del documento $dom = new DomDocument(); $dom->validateOnParse = true; $dom->loadHTML($buffer); // obtiene los datos de los adjuntos $data = self::getAttachmentsData($id); // selecciona elemento del DOM que contendrá los registros de los archivos adjuntos $contenedor = $dom->getElementById("adjuntos"); // realiza la construcción de la tabla con el listado de adjuntos $wrap = $dom->createElement("div"); $wrap->setAttribute("class", "wrap"); $tabla = $dom->createElement("table"); $tbody = $dom->createElement("tbody"); $c = 0; foreach ($data as $item) { $itemId = 'item-' . $c; $rutaArchivo = '/uploads' . DS . $item->hash . '-' . $item->nombre_archivo; $iconSrc = JMime::checkIcon($item->mime_type); $fileSize = JFile::getSize(JPATH_ROOT . $rutaArchivo); $row = $dom->createElement("tr"); $row->setAttribute('id', $itemId); $mime = $dom->createElement("td"); $file = $dom->createElement("td"); $info = $dom->createElement("td"); $info->setAttribute('class', 'center'); $trash = $dom->createElement("td"); $trash->setAttribute('class', 'center'); $mimeImg = $dom->createElement("img"); $mimeImg->setAttribute('src', $iconSrc); $mime->appendChild($mimeImg); $name = $dom->createElement("span"); $nameAnchor = $dom->createElement("a"); $nameAnchor->setAttribute('href', $rutaArchivo); $nameAnchor->setAttribute('target', '_blank'); $nameAnchor->nodeValue = $item->nombre_archivo; $name->appendChild($nameAnchor); $file->appendChild($name); $infoBtn = $dom->createElement("a"); $infoBtn->setAttribute('onclick', 'mostrarInfo(this, event)'); $infoBtn->setAttribute('title', 'Información'); $infoBtn->setAttribute('class', 'modal'); $infoBtn->setAttribute('href', 'javascript:void(0)'); $infoBtn->setAttribute('data-file', $item->nombre_archivo); $infoBtn->setAttribute('data-mimeIcon', $iconSrc); $infoBtn->setAttribute('data-hash', $item->hash); $infoBtn->setAttribute('data-size', $fileSize); $infoBtn->setAttribute('data-mime', $item->mime_type); $infoImg = $dom->createElement("img"); $infoImg->setAttribute('src', JURI::root() . '/media/adjuntos/file-info-icon.png'); $infoBtn->appendChild($infoImg); $info->appendChild($infoBtn); $trashBtn = $dom->createElement("button"); $trashBtn->setAttribute('onclick', 'eliminarAdjunto(this, event)'); $trashBtn->setAttribute('title', 'Eliminar archivo'); $trashBtn->setAttribute('data-hash', $item->hash); $trashBtn->setAttribute('data-id', $itemId); $trashImg = $dom->createElement("img"); $trashImg->setAttribute('src', JURI::root() . '/media/adjuntos/caneca.png'); $trashBtn->appendChild($trashImg); $trash->appendChild($trashBtn); $row->appendChild($mime); $row->appendChild($file); $row->appendChild($info); $row->appendChild($trash); $tbody->appendChild($row); $c++; } $wrap->appendChild($tabla); $tabla->appendChild($tbody); $contenedor->appendChild($wrap); // aplica los cambios realizados al DOM en un nuevo buffer para actualizar la presentación // del la vista del componente en el contexto indicado $newBuffer = $dom->saveHTML(); $doc->setBuffer($newBuffer, 'component'); }
$node = $domXml->getElementsByTagName("TimeTable")->item(0); $node->setAttribute('Name', $timeTableList[$j]); // Delete ';' in the end of <Chain> Ask ob Bob e-mail from 20/07/2011 $chainBob = $domXml->getElementsByTagName("Chain")->item(0); $chainToChange = $chainBob->nodeValue; $newChain = rtrim(trim($chainToChange), ";"); // Add MISSION_INSTRUMENT (ask of Anja see e-mail 20/07/2011) // Load XML from 'DesFunctionsHFE.xml' file == file describing implemented AMDA functions to HFE $domHFE = new DomDocument("1.0"); if (file_exists(xmlDir . 'DesFunctionsHFE.xml')) { $domHFE->load(xmlDir . 'DesFunctionsHFE.xml'); $xml = $domHFE->saveXML(); } $arrayArg = explode(':', $timeTableList[$j]); $arrayMiss = explode('_', $timeTableList[$j]); $missionHFE = $domHFE->getElementById($arrayMiss[0]); // $xml = $missionHFE->saveXML(); foreach ($missionHFE->getElementsByTagName('param') as $par) { if (trim($par->getAttribute('name')) == trim($arrayArg[1])) { // fwrite($fp, trim($par->getAttribute('name')).'_'.trim($par->getAttribute('instrument'))."\n"); $instr = $arrayMiss[0] . '__' . trim($par->getAttribute('instrument')); } } // fwrite($fp, $arrayMiss[0].'_'.$arrayArg[1].'====='.$instr."\n\n"); // Add TIME_RANGE (FOR Bob) $TIME_RANGE = $domXml->createElement('TIME_RANGE', 'FROM:' . $arrayStartTime[$j] . ' TO:' . $arrayStopTime[$j]); $node->appendChild($TIME_RANGE); // Add New Chain $newChaine = $domXml->createElement('newChain', $newChain); $node->appendChild($newChaine); // Add Instrument