Chainable.
public static newDocumentFileXML ( $file, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery | ||
return | phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery |
public function loadWP() { if (file_exists($this->wpPath)) { phpQuery::newDocumentFileXML($this->wpPath); $itemArr = pq("channel item"); phpQuery::each($itemArr, "WordPress::parseWpItem"); } else { $this->_error = "wordpress.xml文件不存在"; } }
/** * Function called to retrieve the events owned by an organization, and store the info in the data array * * @return Returns a array of event objects indexed by their ids * * TODO: make the function take in start_date, end_date, and keyword for more specific event querying */ public function _load_events($start_date = null, $end_date = null, $keyword = null) { $events_obj = phpQuery::newDocumentFileXML($this->api_base_url . 'events/' . $this->data['id'] . '?key=' . $this->api_key()); $this->data['events_obj'] = $events_obj; $this->data['number_of_events'] = $events_obj->find('number_of_results')->text(); foreach ($events_obj->find('event') as $node) { $event = new PSU_OrgSync_Event($node); $this->data['events'][$event->event_id] = $event; } //end foreach return $this->data['events']; }
/** * Get status records, parse new records * and remove processed xml files * * @throws \Exception */ public function collection() { $finder = new Finder(); $finder->files()->in($this->source); if ($finder->files()->count()) { $parser = new Parser($finder, function ($file) use($filesystem) { if (!\phpQuery::newDocumentFileXML($file)) { throw new \Exception('Can not create php query object'); } return (new Record())->setName(pq('task')->text())->setDate(pq('date')->text())->setDescription("<p>Status: " . pq('status')->text() . "</p>" . "<p>Command: " . pq('command')->text() . "</p>" . "<p>Error: " . pq('error')->text() . "</p>"); }); $this->cache->refresh($parser->collection()); } return $this->cache->load(); }
public function loadWP() { $f*g = false; if (file_exists($this->wpPath)) { phpQuery::newDocumentFileXML($this->wpPath); $itemArr = pq("channel item"); if ($itemArr->size() > 0) { phpQuery::each($itemArr, "WordPress::parseWpItem"); $this->_error = "finish!"; $f*g = true; } else { $this->_error = "not detected data!"; } } else { $this->_error = "wordpress.xml file is not exists!"; } return $f*g; }
/** * Get status records, parse new records * and remove processed xml files * * @throws \Exception */ public function collection(\Closure $on_remove_record = null) { $finder = new Finder(); $finder->files()->in($this->source); if ($finder->files()->count()) { $parser = new Parser($finder, function ($file) { assert(\phpQuery::newDocumentFileXML($file), 'Can not create php query object'); $record = new Record(); $record->setName(pq('task')->text()); $record->setDate(pq('date')->text()); $record->setStatus(pq('status')->text()); $record->setNotice(pq('notice')->text()); $record->setError(pq('error')->text()); $record->setFatal(pq('fatal')->text()); $record->setLog(pq('log')->text()); return $record; }); $this->cache->refresh($parser->collection(), $on_remove_record); } return $this->cache->load(); }
/** * Load function called in the constructor to handle the loading of account objects * based on what type of identifying information that we have. * * @param $identifier The unique identifier used to get an account from OrgSync * @param $identifier_type The type of identifier being passed: account_id, email_address, username */ public function load($identifier, $identifier_type) { $callout_url = $this->api_base_url . 'accounts/'; switch ($identifier_type) { case 'account_id': $callout_url .= $identifier . '?'; break; case 'email': $callout_url .= 'search_by_email/?email=' . $identifier . '&'; break; case 'username': $callout_url .= 'search_by_username/?username='******'&'; break; default: //put the search query functionality in here in case someone decides to use it... $callout_url .= 'search_by_custom_profile/?q=' . $identifier . '&'; break; } //end switch $callout_url .= 'key=' . $this->api_key(); $this->account_obj = phpQuery::newDocumentFileXML($callout_url); $this->data['account_id'] = pq('account_id')->text(); }
/** * Get xml model from xml template file * * @param $name * @return \phpQueryObject */ public function fromTemplate($name) { $template = basename(__DIR__) . '/templates/' . $name . '.xml'; return \phpQuery::newDocumentFileXML($template); }
/** * Function to load info about a partiucular form submission. Currently * the function only loads in the submission ID * * @param $submission_id The unique id of the submission of the form */ public function load($submission_id) { $this->submission_object = phpQuery::newDocumentFileXML($this->api_base_url . 'forms/view_submission/' . $submission_id . '?key=' . $this->api_key()); $this->data['submission_id'] = pq('submission_id')->text(); }
/** * Returns an associative array of all organizations containing detailed information. * * @return An associative array containing organizations with shot_name, long_name, category, and description */ public function get_organizations_detail() { $orgs_obj = phpQuery::newDocumentFileXML($this->api_base_url . 'organizations/?key=' . $this->api_key()); foreach ($orgs_obj->find('organization') as $node) { $node = pq($node); $orgs[$node->find('id')->text()] = array('short_name' => $node->find('short_name')->text(), 'long_name' => $node->find('long_name')->text(), 'category' => $node->find('group_type')->text(), 'description' => $node->find('description')->text()); } //end foreach return $orgs; }
public function load($form_id) { $this->form_obj = phpQuery::newDocumentFileXML($this->api_base_url . 'forms/' . $form_id . '?key=' . $this->api_key()); $this->data['form_id'] = $form_id; }
public function index() { set_time_limit(0); import('Org.JAE.QueryList'); header("Content-type: text/html; charset=utf-8"); $page = 0; $isend = false; while (true) { if ($isend) { break; } if (page > 1000) { break; } $offset = $page * 200; $listurl = "http://app.wenwen.sogou.com/front/catquestions?category=18060544&limit=200&offset=" . $offset . ""; $page++; $pagecontent = \phpQuery::newDocumentFileXML($listurl); $results = pq('question')->find(); if (empty($results)) { continue; } foreach ($results as $result) { $id = pq($result)->attr('id'); $url = "http://app.wenwen.sogou.com/front/q?id=" . $id; $iscollect = D('ClCollect')->findUrl($url); if ($iscollect) { continue; } $answercount = pq($result)->find("numOfAnswers")->text(); if (empty($answercount) || $answercount == 0) { continue; } $content = \phpQuery::newDocumentFileXML($url); $title = pq('title')->text(); if (empty($title)) { continue; } $answers = pq('answer')->find(); if (empty($answers)) { continue; } $data['question_title'] = $title; $data['question_detail'] = $title; $data['published_uid'] = 0; $data['game_id'] = 7; $data['anonymous'] = 1; $data['is_recommend'] = 1; $Question = D('AsQuestion'); $question_id = $Question->addQuestion($data); if ($question_id) { $best_answer = 0; foreach ($answers as $answer) { $content = pq($answer)->find('content')->text(); $adata['question_id'] = $question_id; $adata['answer_content'] = $content; $adata['anonymous'] = 1; $answer_id = D('AsAnswer')->addAnswer($adata); if ($best_answer == 0) { $best_answer = $answer_id; } } D('AsQuestion')->saveCollectAnswer($question_id, $best_answer); } $cdata['url'] = $url; $cdata['site'] = "wenwen"; $cdata['page'] = $page; D('ClCollect')->addCollect($cdata); } } return; }