newDocumentHTML() public static method

Chainable.
public static newDocumentHTML ( unknown_type $markup = null, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
$markup unknown_type
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
 public static function hyphenate($strBuffer)
 {
     global $objPage;
     $arrSkipPages = \Config::get('hyphenator_skipPages');
     if (is_array($arrSkipPages) && in_array($objPage->id, $arrSkipPages)) {
         return $strBuffer;
     }
     $o = new \Org\Heigl\Hyphenator\Options();
     $o->setHyphen(\Config::get('hyphenator_hyphen'))->setDefaultLocale(static::getLocaleFromLanguage($objPage->language))->setRightMin(\Config::get('hyphenator_rightMin'))->setLeftMin(\Config::get('hyphenator_leftMin'))->setWordMin(\Config::get('hyphenator_wordMin'))->setFilters(\Config::get('hyphenator_filter'))->setQuality(\Config::get('hyphenator_quality'))->setTokenizers(\Config::get('hyphenator_tokenizers'));
     $h = new \Org\Heigl\Hyphenator\Hyphenator();
     $h->setOptions($o);
     $doc = \phpQuery::newDocumentHTML($strBuffer);
     foreach (pq('body')->find(\Config::get('hyphenator_tags')) as $n => $item) {
         $strText = pq($item)->html();
         // ignore html tags, otherwise ­ will be added to links for example
         if ($strText != strip_tags($strText)) {
             continue;
         }
         $strText = str_replace('­', '', $strText);
         // remove manual ­ html entities before
         $strText = $h->hyphenate($strText);
         if (is_array($strText)) {
             $strText = current($strText);
         }
         pq($item)->html($strText);
     }
     return $doc->htmlOuter();
 }
Example #2
0
 public function getAllData()
 {
     $url = $this->getWebsiteUrl();
     $parser = new Parser();
     $html = $parser->getHtml($url);
     phpQuery::newDocumentHTML($html);
     $data = array();
     $data['logo'] = $this->getLogo();
     $data['sitename'] = "Sulekha.com";
     foreach (pq(".box") as $item) {
         $class_Discount_bg = pq($item)->find(".dealimgst");
         $href = pq($class_Discount_bg)->find("a")->attr("href");
         $href = 'http://deals.sulekha.com' . $href;
         $actual_price = trim(pq($item)->find(".dlpristrk")->text());
         $actual_price = (int) preg_replace('~\\D~', '', $actual_price);
         $img_src = pq($class_Discount_bg)->find("img")->attr("src");
         $price = trim(pq($item)->find(".hgtlgtorg")->text());
         $price = (int) preg_replace('~\\D~', '', $price);
         $off_percent = $actual_price - $price;
         $off_percent = number_format($off_percent) . "/-";
         $price = number_format($price) . "/-";
         $name = trim(pq($item)->find(".deallstit>a")->text());
         //$time_left = pq($item)->find(".countdown_row")->text();
         $data[] = array('name' => $name, 'href' => $href, 'price' => 'Rs.' . $price, 'image' => $img_src, 'off' => 'Rs.' . $off_percent);
     }
     return $data;
 }
 function process() {
     if (!$this->processed) {
         $this->processed = true;
         $this->phpQueryDocument = phpQuery::newDocumentHTML($this->content);
         phpQuery::selectDocument($this->phpQueryDocument);
     }
 }
Example #4
0
function search_query($kw)
{
    $wf = new Workflows();
    $url = 'http://www.bilibili.tv/search?keyword=' . urlencode($kw) . '&orderby=&formsubmit=';
    $content = $wf->request($url, array(CURLOPT_ENCODING => 1));
    $doc = phpQuery::newDocumentHTML($content);
    $list = $doc->find('li.l');
    $i = 0;
    foreach ($list as $item) {
        $link = pq($item)->children('a:first')->attr('href');
        if (strpos($link, 'http') !== 0) {
            $link = 'http://www.bilibili.tv' . $link;
        }
        $info = pq($item)->find('div.info > i');
        $author = pq($item)->find('a.upper:first')->text();
        $view = $info->eq(0)->text();
        $comment = $info->eq(1)->text();
        $bullet = $info->eq(2)->text();
        $save = $info->eq(3)->text();
        $date = $info->eq(4)->text();
        $subtitle = 'UP主:' . $author . ' 播放:' . $view . ' 评论:' . $comment . ' 弹幕:' . $bullet . ' 收藏:' . $save . ' 日期:' . $date;
        $wf->result($i, $link, pq($item)->find('div.t:first')->text(), $subtitle, 'icon.png', 'yes');
        $i++;
    }
    if (count($wf->results()) == 0) {
        $wf->result('0', $url, '在bilibili.tv中搜索', $kw, 'icon.png', 'yes');
    }
    return $wf->toxml();
}
Example #5
0
 public function __construct($content, $params = [])
 {
     $this->dom = \phpQuery::newDocumentHTML($content);
     foreach ($params as $attribute => $value) {
         $this->{$attribute} = $value;
     }
 }
Example #6
0
 public function first_image($htmldata)
 {
     $pq = phpQuery::newDocumentHTML($htmldata);
     $img = $pq->find('img:first');
     $src = $img->attr('src');
     return $src;
 }
 public function addBackendAdminMenu($strBuffer, $strTemplate)
 {
     if ($strTemplate != 'be_main' || !\BackendUser::getInstance()->isAdmin) {
         return $strBuffer;
     }
     // replace the scripts before processing -> https://code.google.com/archive/p/phpquery/issues/212
     $arrScripts = StringUtil::replaceScripts($strBuffer);
     $objDoc = \phpQuery::newDocumentHTML($arrScripts['content']);
     $objMenu = new BackendTemplate($this->strTemplate);
     $arrActions = array();
     $arrActiveActions = deserialize(\Config::get('backendAdminMenuActiveActions'), true);
     foreach (empty($arrActiveActions) ? array_keys(\Config::get('backendAdminMenuActions')) : $arrActiveActions as $strAction) {
         $arrActionData = $GLOBALS['TL_CONFIG']['backendAdminMenuActions'][$strAction];
         $objAction = new BackendTemplate($this->strEntryTemplate);
         $objAction->setData($arrActionData);
         // href = callback?
         if (is_array($arrActionData['href']) || is_callable($arrActionData['href'])) {
             $strClass = $arrActionData['href'][0];
             $strMethod = $arrActionData['href'][1];
             $objInstance = \Controller::importStatic($strClass);
             $objAction->href = $objInstance->{$strMethod}();
         }
         $objAction->class = $strAction;
         $arrActions[] = $objAction->parse();
     }
     $objMenu->actions = $arrActions;
     $objDoc['#tmenu']->prepend($objMenu->parse());
     $strBuffer = StringUtil::unreplaceScripts($objDoc->htmlOuter(), $arrScripts['scripts']);
     // avoid double escapings introduced by phpquery :-(
     $strBuffer = preg_replace('@&([^;]{2,4};)@i', '&$1', $strBuffer);
     return $strBuffer;
 }
Example #8
0
 public function parse_archive(Archive $archive)
 {
     if ($archive->cover_mode) {
         return [$this->get_image_by_cover($archive->cover)];
     }
     $result = curl($archive->url, curl_options($this->domain));
     $archivePQ = \phpQuery::newDocumentHTML($result['data']);
     $content = $archivePQ['#content'];
     $title = $content['.entry-title']->html();
     $imgs = $content['.entry-content']->html();
     if (preg_match_all('#' . $this->domain . 'wp-content/[^"]*#', $imgs, $matches)) {
         $archive->images = array_merge(array_unique($matches[0]));
     }
     if (!$archive->images) {
         $title = $content['.main-title']->html();
         $imgs = $content['.main-body']->html();
         if (preg_match_all('#<a[^>]+href="(' . $this->domain . 'wp-content/[^"]*)">#', $imgs, $matches)) {
             $archive->images = array_merge(array_unique($matches[1]));
         }
     }
     if (strtolower($this->charset) != strtolower($GLOBALS['app_config']['charset'])) {
         $archive->title = iconv(strtoupper($this->charset), strtoupper($GLOBALS['app_config']['charset']) . '//IGNORE', $title);
     }
     $archive->title = $title;
 }
function getAllSubCategories($filename)
{
    $categories = unserialize(file_get_contents($filename));
    echo "---- run getAllSubCategories() ----\n\r";
    foreach ($categories as $j => $category) {
        if ($category['childrens']) {
            foreach ($category['childrens'] as $k => $children) {
                echo "---- crawling childrens for {$children['name']} ----\n\r";
                $doc = phpQuery::newDocumentHTML(fetch('http://www.walmart.com' . $children['link']));
                phpQuery::selectDocument($doc);
                foreach (pq('.shop-by-category li') as $el) {
                    echo "---- " . pq($el)->find('a')->attr('href') . "} ----\n\r";
                    $childrens[] = array('name' => pq($el)->find('a')->data('name'), 'link' => pq($el)->find('a')->attr('href'));
                }
                $categories[$j]['childrens'][$k]['childrens'] = $childrens;
            }
        }
    }
    echo "---- creating deparment file ----\n\r";
    $file = fopen($filename, 'w+');
    echo "---- writing deparment file ----\n\r";
    fputs($file, serialize($categories));
    echo "---- closing deparment file ----\n\r";
    fclose($file);
}
Example #10
0
function service($nik)
{
    $default = ['wilayah_id' => '0', 'g-recaptcha-response' => '000', 'cmd' => 'Cari.', 'page' => '', 'nik_global' => $nik];
    $params = $default;
    $client = new GuzzleHttp\Client();
    $res = $client->request('POST', 'http://data.kpu.go.id/ss8.php', ['form_params' => $params]);
    $html = $res->getBody();
    $startsAt = strpos($html, '<body onload="loadPage()">') + strlen('<body onload="loadPage()">');
    $endsAt = strpos($html, '</body>', $startsAt);
    $result = substr($html, $startsAt, $endsAt - $startsAt);
    // return $html;
    $dom = phpQuery::newDocumentHTML($result);
    // return $dom;
    $result = [];
    foreach (pq('div.form') as $content) {
        $key = snake(preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', rtrim(trim(pq($content)->find('.label')->eq(0)->html()), ':')));
        $value = preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', rtrim(trim(pq($content)->find('.field')->eq(0)->html()), ':'));
        if (empty($key)) {
            continue;
        }
        $result[$key] = $value;
    }
    if (!empty($result)) {
        echo json_encode(['success' => true, 'message' => 'Success', 'data' => $result]);
    } else {
        http_response_code(400);
        echo json_encode(['success' => false, 'message' => 'Data tidak ditemukan']);
    }
}
Example #11
0
 static function getProducts()
 {
     $products = pq(self::$productsQuery);
     $productData = array();
     foreach ($products->elements as $good) {
         $product_links[$good->textContent] = $good->getAttribute('href');
     }
     foreach ($product_links as $sku => $link) {
         $html = file_get_contents(self::$srcUrl . $link);
         $url = parse_url($link);
         if (isset($url['query'])) {
             parse_str($url['query'], $params);
             $cat = isset($params['cat_id']) ? $params['cat_id'] : 0;
             $vendor = isset($params['vendor_id']) ? $params['vendor_id'] : 0;
         }
         phpQuery::newDocumentHTML($html, self::$encoding);
         $product = new stdClass();
         $product->model = $sku;
         $product->sku = $sku;
         $product->name = self::getProductName();
         $product->specs = self::getProductSpecs();
         $product->img = self::getProductImage();
         $product->cat = $cat;
         $product->vendor = $vendor;
         $productData[] = $product;
     }
     return $productData;
 }
Example #12
0
 /**
  * @param string $pageHtml
  * @param string $link
  * @return string
  */
 public function detectPageType($pageHtml, $link)
 {
     require_once './vendors/phpQuery.php';
     $doc = phpQuery::newDocumentHTML($pageHtml);
     $item = $doc->get('#fw_post_wrap');
     if (preg_match("/id([0-9]+)/", $link, $matches)) {
         return 'user';
     }
     if (preg_match("/wall-?([0-9_]+)/", $link, $matches)) {
         return 'wall';
     }
     if (preg_match("/public([0-9]+)/", $link, $matches)) {
         return 'public';
     }
     if (preg_match("/photo-?([0-9_]+)/", $link, $matches)) {
         return 'photo';
     }
     if (!empty($item)) {
         return "post";
     }
     $item = $doc['#group'];
     if (!empty($item)) {
         return "group";
     }
     $item = $doc['#public'];
     if (!empty($item)) {
         return 'public';
     }
 }
Example #13
0
 public function actionKNet()
 {
     // создаем экземпляр класса
     $client = new Client();
     // отправляем запрос к странице Яндекса
     $res = $client->request('GET', 'http://kondratiev.net/loader.php?getPage=gallery');
     // получаем данные между открывающим и закрывающим тегами body
     $body = $res->getBody();
     // подключаем phpQuery
     $document = \phpQuery::newDocumentHTML($body);
     // получаем список новостей
     //$news = $document->find("ul.b-news-list");
     $kSite = $document->find(".widePhotoGallery");
     //d(count($kSite));
     // выполняем проход циклом по списку
     foreach ($kSite as $elem) {
         //pq аналог $ в jQuery
         $pq = pq($elem);
         // удалим первую новость в списке
         //$pq->find('li.list__item:first')->remove();
         // выполним поиск в скиске ссылок
         //$tags = $pq->find('li.list__item a');
         // добавим ковычки в начало и в конец предложения
         //$tags->append('" ')->prepend(' "'); //
         // добавим свой класс к последней новости списка
         $pq->find('div.widePhoto')->addClass('display-block');
     }
     // вывод списка новостей яндекса с главной страницы в представление
     return $this->render('k-net', ['kSite' => $kSite]);
 }
Example #14
0
 function start_el(&$output, $object, $depth = 0, $args = array(), $current_object_id = 0)
 {
     // append next menu element to $output
     parent::start_el($output, $object, $depth, $args, $current_object_id);
     // now let's add a custom form field
     if (!class_exists('phpQuery')) {
         // load phpQuery at the last moment, to minimise chance of conflicts (ok, it's probably a bit too defensive)
         require_once 'phpQuery-onefile.php';
     }
     $_doc = phpQuery::newDocumentHTML($output);
     $_li = phpQuery::pq('li.menu-item:last');
     // ":last" is important, because $output will contain all the menu elements before current element
     // if the last <li>'s id attribute doesn't match $item->ID something is very wrong, don't do anything
     // just a safety, should never happen...
     $menu_item_id = str_replace('menu-item-', '', $_li->attr('id'));
     if ($menu_item_id != $object->ID) {
         return;
     }
     // fetch previously saved meta for the post (menu_item is just a post type)
     $curr_bg = esc_attr(get_post_meta($menu_item_id, 'snpshpwp_menu_item_bg', TRUE));
     $curr_bg_pos = esc_attr(get_post_meta($menu_item_id, 'snpshpwp_menu_item_bg_pos', TRUE));
     $curr_upldr = '<span class="button media_upload_button" id="snpshpwp_upload_' . $menu_item_id . '">' . __('Upload', 'snpshpwp') . '</span>';
     // by means of phpQuery magic, inject a new input field
     $_li->find('a.item-delete')->before("\n\t\t\t\t\t<p class='snpshpwp_menu_item_bg description description-thin'>\n\t\t\t\t\t<label for='snpshpwp_menu_item_bg_{$menu_item_id}'>" . __('Background image', 'snpshpwp') . "<br/>\n\t\t\t\t\t<input type='text' value='{$curr_bg}' name='snpshpwp_menu_item_bg_{$menu_item_id}' /><br/>\n\t\t\t\t\t</label>\n\t\t\t\t\t{$curr_upldr}\n\t\t\t\t\t</p>\n\t\t\t\t\t<p class='snpshpwp_menu_item_bg_pos description description-thin'>\n\t\t\t\t\t<label for='snpshpwp_menu_item_bg_{$menu_item_id}'>" . __('Background orientation', 'snpshpwp') . "<br/>\n\t\t\t\t\t<select name='snpshpwp_menu_item_bg_pos_{$menu_item_id}'>\n\t\t\t\t\t\t<option value='left-landscape'" . ($curr_bg_pos == 'left-landscape' ? ' selected' : '') . ">" . __('Left Landscape', 'snpshpwp') . "</option>\n\t\t\t\t\t\t<option value='left-portraid'" . ($curr_bg_pos == 'left-portraid' ? ' selected' : '') . ">" . __('Left Portraid', 'snpshpwp') . "</option>\n\t\t\t\t\t\t<option value='right-landscape'" . ($curr_bg_pos == 'right-landscape' ? ' selected' : '') . ">" . __('Right Landscape', 'snpshpwp') . "</option>\n\t\t\t\t\t\t<option value='right-portraid'" . ($curr_bg_pos == 'right-portraid' ? ' selected' : '') . ">" . __('Right Portraid', 'snpshpwp') . "</option>\n\t\t\t\t\t\t<option value='pattern-repeat'" . ($curr_bg_pos == 'pattern-repeat' ? ' selected' : '') . ">" . __('Pattern', 'snpshpwp') . "</option>\n\t\t\t\t\t\t<option value='framed-full'" . ($curr_bg_pos == 'framed-full' ? ' selected' : '') . ">" . __('Framed', 'snpshpwp') . "</option>\n\t\t\t\t\t</select>\n\t\t\t\t\t</label>\n\t\t\t\t\t</p>\n\t\t\t\t\t");
     // swap the $output
     $output = $_doc->html();
 }
 function theContent($content)
 {
     $doc = phpQuery::newDocumentHTML($content);
     phpQuery::selectDocument($doc);
     foreach (pq('a') as $link) {
         $linkurl = pq($link)->attr('href');
         $linkHostname = $this->getUrlHostname($linkurl);
         if ($linkHostname != FALSE) {
             if (!in_array($linkHostname, $this->blockedDomains)) {
                 $linkHash = md5($linkurl);
                 $query = "SELECT * FROM {$this->tableBitlyExternal} WHERE id='{$linkHash}'LIMIT 1;";
                 $linkData = $this->db->get_row($query, ARRAY_A);
                 if (empty($linkData)) {
                     $bitly = new Bitly($this->bitlyUsername, $this->bitlyApikey);
                     $shortURL = $bitly->shorten($linkurl);
                     $shortURLData = get_object_vars($bitly->getData());
                     if (!empty($shortURLData)) {
                         $linkData = array('id' => $linkHash, 'url' => $linkurl, 'short_url' => $shortURLData['shortUrl'], 'hash' => $shortURLData['userHash'], 'created' => current_time('mysql'));
                         $this->db->insert($this->tableBitlyExternal, $linkData);
                     }
                 }
                 if (!empty($linkData)) {
                     pq($link)->attr('href', $linkData['short_url']);
                 }
             }
         }
     }
     return $doc->htmlOuter();
 }
Example #16
0
    public function go()
    {
        require_once $_SERVER["DOCUMENT_ROOT"] . "/classes/XML.php";
        $xml = file_get_contents("http://alfabank.by/a-blog.xml");
        $rss = new \XML($xml);
        foreach ($rss->rss->channel->item as $it) {
            $dom = \phpQuery::newDocumentHTML($it->childByName("content:encoded"));
            $date = date_create($it->pubDate->getData());
            $arResult = array(
                "IBLOCK_ID" => self::ABLOG_IBLOCK_ID,
                "NAME" => $it->title->getData(),
                "DATE_ACTIVE_FROM" => date_format($date, 'd.m.Y'),
                "PREVIEW_TEXT" => $it->description->getData(),
                "PREVIEW_PICTURE" => \CFile::MakeFileArray($dom->find('img')->attr('src')),
                "DETAIL_TEXT" => $it->childByName("content:encoded"),
                "CODE" => \Ns\Bitrix\Helper::Create('iblock')->useVariant('text')->translite($it->title->getData()),
                "PROPERTY_VALUES" => array("ORIGINAL_LINK" => $it->link->getData())
            );
            $this->objElement->Add($arResult);
            if ($this->objElement->LAST_ERROR) {
                prentExpection($this->objElement->LAST_ERROR);
            }
        }

        return true;
	}
Example #17
0
function moegirl_analysis($text)
{
    $content = file_get_contents(moegirl_url($text));
    $doc = phpQuery::newDocumentHTML($content);
    phpQuery::selectDocument($doc);
    $ansList = pq(".NetDicBody");
    $ans = 0;
}
Example #18
0
 function load_html($html)
 {
     $tidy = tidy_parse_string($html);
     tidy_clean_repair($tidy);
     $html = tidy_get_html($tidy);
     phpQuery::unloadDocuments();
     return phpQuery::newDocumentHTML($html);
 }
Example #19
0
function wikipedia_analysis($text)
{
    $content = file_get_contents(wikipedia_url($text));
    $doc = phpQuery::newDocumentHTML($content);
    phpQuery::selectDocument($doc);
    $ansList = pq(".NetDicBody");
    $ans = 0;
    return $doc;
}
 public function actionValidatestep1()
 {
     $Company = Yii::app()->getUser()->getProfile()->company;
     $CompanyValidateForm = new CompanyValidateForm();
     $pars = new Parser();
     $page = $pars->curl('https://www.lursoft.lv/ru/evropeiskii-biznes-reestr');
     $page = phpQuery::newDocumentHTML($page);
     $select_eu = $page->find('.col-md-4 select', 0);
     $this->render('validatestep1', ['Company' => $Company, 'CompanyValidateForm' => $CompanyValidateForm, 'select_eu' => $select_eu]);
 }
Example #21
0
 public function verificadorCEP($cep)
 {
     $this->cep = $cep;
     $html = $this->simple_curl('http://m.correios.com.br/movel/buscaCepConfirma.do', array('cepEntrada' => $this->cep, 'tipoCep' => '', 'cepTemp' => '', 'metodo' => 'buscarCep'));
     require 'complements/phpQuery-onefile.php';
     phpQuery::newDocumentHTML($html, $charset = 'utf-8');
     $dados = array('logradouro' => trim(pq('.caixacampobranco .resposta:contains("Logradouro: ") + .respostadestaque:eq(0)')->html()), 'bairro' => trim(pq('.caixacampobranco .resposta:contains("Bairro: ") + .respostadestaque:eq(0)')->html()), 'cidade/uf' => trim(pq('.caixacampobranco .resposta:contains("Localidade / UF: ") + .respostadestaque:eq(0)')->html()), 'cep' => trim(pq('.caixacampobranco .resposta:contains("CEP: ") + .respostadestaque:eq(0)')->html()));
     $dados[cidade_uf] = explode('/', $dados['cidade/uf']);
     return utf8_decode($dados[logradouro]) . '|' . utf8_decode($dados[bairro]) . '|' . utf8_decode(trim($dados['cidade_uf'][0])) . '|' . utf8_decode(trim($dados['cidade_uf'][1]));
 }
 public static function addHeaderCss($strText, Message $objMessage)
 {
     $arrHeaderStylesheetContents = static::getStylesheetContents($objMessage, static::CSS_MODE_HEADER);
     if (!empty($arrHeaderStylesheetContents)) {
         $doc = \phpQuery::newDocumentHTML($strText);
         pq('html > head')->append(sprintf('<style type="text/css">%s</style>', implode(' ', $arrHeaderStylesheetContents)));
         return $doc->htmlOuter();
     }
     return $strText;
 }
Example #23
0
function CEPdata($cep)
{
    $html = simple_curl('http://m.correios.com.br/movel/buscaCepConfirma.do', array('cepEntrada' => $cep, 'tipoCep' => '', 'cepTemp' => '', 'metodo' => 'buscarCep'));
    phpQuery::newDocumentHTML($html, $charset = 'utf-8');
    $dados = array('logradouro' => trim(pq('.caixacampobranco .resposta:contains("Logradouro: ") + .respostadestaque:eq(0)')->html()), 'bairro' => trim(pq('.caixacampobranco .resposta:contains("Bairro: ") + .respostadestaque:eq(0)')->html()), 'cidade/uf' => trim(pq('.caixacampobranco .resposta:contains("Localidade / UF: ") + .respostadestaque:eq(0)')->html()), 'cep' => trim(pq('.caixacampobranco .resposta:contains("CEP: ") + .respostadestaque:eq(0)')->html()));
    $dados['cidade/uf'] = explode('/', $dados['cidade/uf']);
    $dados['cidade'] = trim($dados['cidade/uf'][0]);
    $dados['uf'] = trim($dados['cidade/uf'][1]);
    unset($dados['cidade/uf']);
    return $dados;
}
 public static function loadHtmlTemplateWithPhpQuery($file)
 {
     $html = file_get_contents($file);
     $html = self::encodePHP($html);
     $html = preg_replace('/(\\&)(\\w+)(\\;)/i', '[:[${2}]:]', $html);
     $html = preg_replace('/(\\&)(\\#)(\\d+)(\\;)/i', '[:[${2}${3}]:]', $html);
     //because of html5
     libxml_use_internal_errors(true);
     $doc = \phpQuery::newDocumentHTML($html);
     libxml_use_internal_errors(false);
     return $doc;
 }
 public static function addHeaderCss(PostRenderMessageContentEvent $objEvent)
 {
     if (Environment::getUrlBasename() != 'preview') {
         $arrHeaderStylesheetContents = static::getStylesheetContents($objEvent->getMessage()->getLayout(), static::AVISOTA_CSS_MODE_HEADER);
         if (!empty($arrHeaderStylesheetContents)) {
             $strContent = $objEvent->getContent();
             $doc = \phpQuery::newDocumentHTML($strContent);
             pq('html > head')->append(sprintf('<style type="text/css">%s</style>', implode(' ', $arrHeaderStylesheetContents)));
             $objEvent->setContent($doc->htmlOuter());
         }
     }
 }
Example #26
0
 public function init_rand_thumb_with_fancybox($obj)
 {
     $style = $this->_rand_style();
     $this->thumb_src = $this->thumb_dir . '/' . $obj->thumbFile;
     $this->orig_src = $this->orig_dir . '/' . $obj->originalFile;
     $this->title = $obj->title;
     $thumb = phpQuery::newDocumentHTML("<img src='{$this->thumb_src}' alt='{$this->title}'/>");
     $anchor = phpQuery::newDocumentHTML("<a href='{$this->orig_src}' title='{$this->title}'></a>");
     $thumb = $thumb['img']->attr('style', $style)->addClass('pic')->attr('data-livesite', $obj->url);
     $this->html = $anchor['a']->addClass('fancybox')->append($thumb);
     return $this;
 }
Example #27
0
 /**
  * @param string $pageHtml
  * @param string $link
  * @return string
  */
 public function detectPageType($pageHtml, $link)
 {
     require_once './vendors/phpQuery.php';
     $doc = phpQuery::newDocumentHTML($pageHtml);
     if (preg_match("/\\/(p)\\//", $link, $matches)) {
         return 'post';
     }
     $postPage = $doc['.-cx-PRIVATE-ProfilePage__root'];
     if (!empty($postPage)) {
         return 'profile';
     }
     return false;
 }
 public function processForImages()
 {
     if ($this->options->convert_page_images) {
         $this->document = phpQuery::newDocumentHTML(JResponse::getBody());
         $this->identifyImageSources();
         $this->processImages();
         $this->populateImages();
         $markup = $this->document->getDocument()->htmlOuter();
         //TODO fix so that regex works with data uris?
         $markup = preg_replace('/(<(base|img|br|meta|area|input|link|col|hr|param|frame|isindex)+([\\s]+[\\S]+[\\s]*=[\\s]*("([^"]*)"|\'([^\']*)\'))*[\\s]*)>/imx', '$1/>', $markup);
         JResponse::setBody($markup);
     }
 }
Example #29
0
function getIpList($url)
{
    $list = '';
    $content = curl_string($url);
    $doc = phpQuery::newDocumentHTML($content);
    $artlist = pq('#ip_list tr');
    foreach ($artlist as $li) {
        if (pq($li)->find('td:eq(2)')->html()) {
            $list .= "'" . pq($li)->find('td:eq(2)')->html() . ':' . pq($li)->find('td:eq(3)')->html() . "', ";
        }
    }
    return $list;
}
Example #30
0
 public static function _ajax_footer()
 {
     $html = ob_get_contents();
     ob_clean();
     \phpQuery::newDocumentHTML($html);
     global $wp_query;
     $result = array('content' => pq(self::$selector)->html(), 'faceting' => Faceting::all(), 'found' => $wp_query->found_posts);
     echo json_encode($result);
     if (!empty($_REQUEST)) {
         // only fail on webserver, not tests
         die;
     }
 }