当前位置: 首页>>代码示例>>PHP>>正文


PHP pq函数代码示例

本文整理汇总了PHP中pq函数的典型用法代码示例。如果您正苦于以下问题:PHP pq函数的具体用法?PHP pq怎么用?PHP pq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pq函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: readCoinInformation

 protected function readCoinInformation($pq_tr)
 {
     $coin_data = array();
     $img_indexes = array('obverse', 'reverse');
     $pq_td = $pq_tr->find('td');
     $as = $pq_td->find('a');
     foreach ($as as $index => $a) {
         $pq_a = pq($a);
         switch ($index) {
             case 0:
             case 1:
                 $img_url = $this->fixImageUrl($pq_a->find('img')->attr('src'));
                 $coin_data[$img_indexes[$index]] = $img_url;
                 break;
             case 2:
                 $coin_data['name'] = $pq_a->text();
                 $pq_td->find('span, a, br')->remove();
                 $chr = chr(194) . chr(160);
                 $km = trim(str_replace($chr, ' ', $pq_td->text()));
                 $km = trim(str_replace('Total:', '', $km));
                 $coin_data['km'] = $km;
                 break;
         }
     }
     return $coin_data;
 }
开发者ID:Qmegas,项目名称:numista-api,代码行数:26,代码来源:usercollection.php

示例2: run

 public function run()
 {
     $content = ob_get_clean();
     $formatted = phpQuery::newDocument($content);
     $imageNodes = pq('img');
     foreach ($imageNodes as $imNode) {
         $imNode = pq($imNode);
         $imPath = $imNode->attr('src');
         $thumbPath = $this->thumbsDir . '/' . basename($imPath);
         //$thumbPath = dirname($imPath).'/thumbs/'.basename($imPath);
         // Create thumbnail if not exists
         if (!file_exists($thumbPath)) {
             $imgObj = Yii::app()->simpleImage->load($imPath);
             if (!isset($this->thumbHeight)) {
                 $imgObj->resizeToWidth($this->thumbWidth);
             } else {
                 $imgObj->resize($this->thumbWidth, $this->thumbHeight);
             }
             $imgObj->save($thumbPath);
         }
         $imNode->wrap('<a href="' . $imPath . '" rel="gallery"></a>');
         $imNode->attr('src', Yii::app()->request->baseUrl . DIRECTORY_SEPARATOR . $thumbPath);
     }
     echo $formatted;
 }
开发者ID:hipogea,项目名称:zega,代码行数:25,代码来源:Thumbnailer.php

示例3: hyphenate

 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 &shy; will be added to links for example
         if ($strText != strip_tags($strText)) {
             continue;
         }
         $strText = str_replace('&shy;', '', $strText);
         // remove manual &shy; html entities before
         $strText = $h->hyphenate($strText);
         if (is_array($strText)) {
             $strText = current($strText);
         }
         pq($item)->html($strText);
     }
     return $doc->htmlOuter();
 }
开发者ID:heimrichhannot,项目名称:contao-hyphenator,代码行数:28,代码来源:Hyphenator.php

示例4: getHorario

    function getHorario() {
        if($this->horario != null) return $this->horario;
        parent::process();

        $dotw = array('Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado');

        $this->horario = array('Lunes' => array()
                       , 'Martes' => array()
                       , 'Miércoles' => array()
                       , 'Jueves' => array()
                       , 'Viernes' => array()
                       , 'Sábado' => array());

        foreach(pq('td.dia') as $day => $bloques) {
            foreach(pq('div', $bloques) as $tmp_bloque) {
                $bloque = new stdClass();
                $bloque->codigo = pq('a', $tmp_bloque)->html();
                list(,$tmp_tipo,, $tmp_horario) = pq($tmp_bloque)->contents()->elements;
                $bloque->tipo = trim(pq($tmp_tipo)->text());
                list($bloque->sala, $bloque->hora) = explode(chr(194).chr(160), pq($tmp_horario)->text());
                $this->horario[$dotw[$day]][] = $bloque;
            }
        }

        return $this->horario;
    }
开发者ID:rduenasf,项目名称:ucursos-scrapper,代码行数:26,代码来源:ucursos.horario.scrapper.php

示例5: get_data

 public function get_data()
 {
     if (!class_exists('phpQuery')) {
         include dirname(__FILE__) . '/phpQuery.php';
     }
     $response = wp_remote_get($this->url . '/tags');
     if (is_wp_error($response)) {
         return false;
     }
     phpQuery::newDocument($response['body']);
     $version = false;
     $zip_url = false;
     foreach (pq('table.tags a.name') as $tag) {
         $tag = pq($tag);
         if (version_compare($tag->text(), $version, '>=')) {
             $href = $tag->attr('href');
             $commit = substr($href, strrpos($href, '/') + 1);
             $zip_url = $this->url . '/snapshot/' . $commit . '.zip';
             $version = $tag->text();
             $updated_at = $tag->parent()->prev()->text();
         }
     }
     $this->new_version = $version;
     $this->zip_url = $zip_url;
     $this->updated_at = date('Y-m-d', strtotime($updated_at));
     $this->description = pq('div.page_footer_text')->text();
 }
开发者ID:webbab,项目名称:github-plugin-search,代码行数:27,代码来源:gitweb.php

示例6: success

 public function success($response)
 {
     $pq = phpQuery::newDocument($response);
     foreach ($this->calls as $k => $r) {
         // check if method exists
         if (!method_exists(get_class($pq), $r['method'])) {
             throw new Exception("Method '{$r['method']}' not implemented in phpQuery, sorry...");
             // execute method
         } else {
             $pq = call_user_func_array(array($pq, $r['method']), $r['arguments']);
         }
     }
     if (!isset($this->options['dataType'])) {
         $this->options['dataType'] = '';
     }
     switch (strtolower($this->options['dataType'])) {
         case 'json':
             if ($pq instanceof PHPQUERYOBJECT) {
                 $results = array();
                 foreach ($pq as $node) {
                     $results[] = pq($node)->htmlOuter();
                 }
                 print phpQuery::toJSON($results);
             } else {
                 print phpQuery::toJSON($pq);
             }
             break;
         default:
             print $pq;
     }
     // output results
 }
开发者ID:AloneFallen,项目名称:phpquery,代码行数:32,代码来源:jQueryServer.php

示例7: getList

 protected function getList()
 {
     $this->data['list'] = array();
     $ul = $this->q->find('#liste_echanges li');
     if ($ul->count() == 0) {
         return;
     }
     $years = $ul->find('ul li');
     foreach ($years as $year) {
         $pq_year = pq($year);
         $html = trim($pq_year->html());
         $year_txt = html_entity_decode(trim(strip_tags(substr($html, 0, strpos($html, ':')))));
         $item = array('year' => $year_txt, 'users' => array());
         $as = $pq_year->find('a');
         foreach ($as as $a) {
             $pq_a = pq($a);
             $href = $pq_a->attr('href');
             $user_name = $pq_a->text();
             $ret = preg_match('|membre\\.php\\?id=([0-9]+)|', $href, $matches);
             if ($ret == 1 && isset($matches[1])) {
                 $item['users'][] = array('id' => $matches[1], 'name' => $user_name);
             }
         }
         $this->data['list'][] = $item;
     }
 }
开发者ID:Qmegas,项目名称:numista-api,代码行数:26,代码来源:coinexchange.php

示例8: getNovedades

    function getNovedades() {
        if($this->novedades != null) return $this->novedades;
        parent::process();

        $this->novedades = array();
        foreach(pq('div.blog') as $item) {
            $novedad = new stdClass();
            $tmp_autor = pq('em', $item);
            $tmp_autor_i = strpos($tmp_autor, '<a class');
            $tmp_autor_f = strpos($tmp_autor, '</a>') + 4;

            $novedad->texto = pq($item)->children('p');
            foreach(pq('a', $novedad->texto) as $href) {
                $href_url = pq($href)->attr('href');
                if(substr($href_url, 0, 2) == 'r/')
                    pq($href)->attr('href', $this->url . $href_url);
            }
            foreach(pq('img', $novedad->texto) as $href) {
                $img_src = pq($href)->attr('src');
                if(substr($img_src, 0, 2) == 'r/')
                    pq($href)->attr('src', $this->url . $img_src);
            }

            $novedad->texto = mb_convert_encoding(pq($novedad->texto)->html(), 'UTF-8');
            $novedad->titulo = trim(pq(pq($item)->children('h1'))->text());
            $novedad->fecha = trim(substr($tmp_autor, $tmp_autor_f));
            $novedad->autor = new stdClass();
            $novedad->autor->nombre = pq(substr($tmp_autor, $tmp_autor_i, $tmp_autor_f - $tmp_autor_i + 1))->html();
            $novedad->autor->avatar = pq('img')->attr('src');
            $this->novedades[] = $novedad;
        }
        return $this->novedades;
    }
开发者ID:rduenasf,项目名称:ucursos-scrapper,代码行数:33,代码来源:ucursos.novedades.scrapper.php

示例9: elseif

 public function &__get($key)
 {
     if (isset($this->data[$key])) {
         return $this->data[$key];
     } elseif (isset($this->data['organization'][$key])) {
         return $this->data['organization'][$key];
     } elseif (method_exists($this, '_load_' . $key)) {
         $func = '_load_' . $key;
         return $this->{$func}();
     } elseif (isset($this->form_object)) {
         switch ($key) {
             case 'organization':
                 $this->data['organization']['id'] = pq('id')->text();
                 $this->data['organization']['short_name'] = pq('short_name')->text();
                 return $this->data['organization'];
             case 'id':
                 $this->data['organization']['id'] = pq('id')->text();
                 return $this->data['organization']['id'];
             case 'short_name':
                 $this->data['organization']['short_name'] = pq('short_name')->text();
                 return $this->data['organization']['short_name'];
             default:
                 $this->data[$key] = pq($key)->text();
                 return $this->data[$key];
         }
         //end switch
     }
     //end elseif
     return null;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:30,代码来源:Form.php

示例10: getLinkContent

 public function getLinkContent()
 {
     require_once './ThinkPHP/Library/Vendor/Collection/phpQuery.php';
     $link = op_t(I('post.url'));
     $content = get_content_by_url($link);
     $charset = preg_match("/<meta.+?charset=[^\\w]?([-\\w]+)/i", $content, $temp) ? strtolower($temp[1]) : "utf-8";
     \phpQuery::$defaultCharset = $charset;
     \phpQuery::newDocument($content);
     $title = pq("meta[name='title']")->attr('content');
     if (empty($title)) {
         $title = pq("title")->html();
     }
     $title = iconv($charset, "UTF-8", $title);
     $keywords = pq("meta[name='keywords'],meta[name='Keywords']")->attr('content');
     $description = pq("meta[name='description'],meta[name='Description']")->attr('content');
     $url = parse_url($link);
     $img = pq("img")->eq(0)->attr('src');
     if (is_bool(strpos($img, 'http://'))) {
         $img = 'http://' . $url['host'] . $img;
     }
     $title = text($title);
     $description = text($description);
     $keywords = text($keywords);
     $return['title'] = $title;
     $return['img'] = $img;
     $return['description'] = empty($description) ? $title : $description;
     $return['keywords'] = empty($keywords) ? $title : $keywords;
     exit(json_encode($return));
 }
开发者ID:ccccy,项目名称:wuanlife,代码行数:29,代码来源:LinkController.class.php

示例11: Process

 /**
  * Process emoticons inside a string
  * @since Version 3.10.0
  * @param string|DOMDocument $string The HTML or text block to process
  * @param boolean $doEmoticons Boolean flag for processing or skipping emoticons
  * @return DOMDocument
  */
 public static function Process($string, $doEmoticons = true)
 {
     if (!$doEmoticons) {
         return $string;
     }
     $emojiOne = new EmojioneClient(new EmoticonsRuleset());
     $emojiOne->ascii = true;
     $string = $emojiOne->toImage($string);
     $attr = "data-sceditor-emoticon";
     $timer = Debug::getTimer();
     if (is_string($string)) {
         $string = phpQuery::newDocumentHTML($string);
     }
     //phpQuery::selectDocument($doc);
     // Remove #tinymce and .mceContentBody tags
     foreach (pq('img') as $e) {
         if (pq($e)->attr($attr)) {
             $emoticon = pq($e)->attr($attr);
             if (strlen($emoticon) > 0) {
                 pq($e)->replaceWith(str_replace('\\"', "", $emoticon));
             }
         }
     }
     Debug::LogEvent(__METHOD__, $timer);
     return $string;
 }
开发者ID:railpage,项目名称:railpagecore,代码行数:33,代码来源:EmoticonsUtility.php

示例12: RenderImpl

 /**
  * @see HtmlComponent
  */
 public final function RenderImpl()
 {
     $tag = $this->getTag('table');
     pq($tag)->append($this->renderHeader());
     pq($tag)->append($this->renderData());
     pq($tag)->append($this->renderFooter());
 }
开发者ID:Niqpue,项目名称:zippyerp,代码行数:10,代码来源:datatable.php

示例13: getNotas

    function getNotas() {
        if($this->cursos != null) return $this->cursos;
        parent::process();

        $this->cursos = array();
        $identifier = null;
        foreach(pq('table > *:not(thead)') as $bloques) {
            if ($bloques->tagName == 'tr') {
                if(!$identifier) {
                    $identifier = pq('td', $bloques)->text();
                }
            }
            else {
                $identifier = $identifier ? $identifier : '';
                if (!isset($this->notas[$identifier])) $this->notas[$identifier] = array();
                foreach(pq('tr', $bloques) as $tr) {
                    $curso = new stdClass();
                    $curso->id = pq('td:nth-child(3)', $tr)->html();
                    $curso->nombre = mb_convert_encoding(pq('td:nth-child(4) > a', $tr)->html(), 'UTF-8');
                    $curso->url = pq('td:nth-child(4) > a', $tr)->attr('href');
                    $curso->cargo = UcursosScrapper::toUserType(pq('td:nth-child(1) > img', $tr)->attr('title'));
                    $curso->institucion = new stdClass();
                    $curso->institucion->nombre = pq('td:nth-child(2) > img', $tr)->attr('title');
                    $curso->institucion->icono = pq('td:nth-child(2) > img', $tr)->attr('src');
                    $this->cursos[$identifier][] = $curso;
                }
                $identifier = null;
            }
        }
        return $this->cursos;
    }
开发者ID:rduenasf,项目名称:ucursos-scrapper,代码行数:31,代码来源:ucursos.cursos.scrapper.php

示例14: createPost

 private function createPost(\phpQueryObject $form)
 {
     $result = [];
     foreach ($form->find('input, select, checkbox, textarea') as $input) {
         $el = pq($input);
         if (($value = $el->attr('example')) || ($value = $el->attr('value'))) {
             $result[$el->attr('name')] = $value;
             continue;
         }
         $value = $el->attr('example');
         switch ($input->tagName) {
             case 'input':
                 $this->addInput($el, $result, $value);
                 break;
             case 'select':
                 $this->addSelect($el, $result, $value);
                 break;
             case 'checkbox':
                 $this->addCheckbox($el, $result, $value);
                 break;
             case 'textarea':
                 $this->addTextarea($el, $result, $value);
                 break;
         }
     }
     return $result;
 }
开发者ID:bariew,项目名称:yii2-doctest-extension,代码行数:27,代码来源:FormTest.php

示例15: getData

 /**
  * Implements the getData method
  */
 public function getData()
 {
     //request the url
     $this->request(self::URL);
     $title = pq('h1.summary:first');
     return pq('a', $title)->text();
 }
开发者ID:remy22,项目名称:phpquery-crawler,代码行数:10,代码来源:CrawlerPhpnet.php


注:本文中的pq函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。