<?php
/**
* Class representing phpQuery objects.
*
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
* @package phpQuery
* @method phpQueryObject clone() clone()
* @method phpQueryObject empty() empty()
* @method phpQueryObject next() next($selector = null)
* @method phpQueryObject prev() prev($selector = null)
* @property Int $length
*/
class phpQueryObject
implements Iterator, Countable, ArrayAccess {
public $documentID = null;
/**
* DOMDocument class.
*
* @var DOMDocument
*/
public $document = null;
public $charset = null;
/**
*
* @var DOMDocumentWrapper
*/
public $documentWrapper = null;
/**
* XPath interface.
*
* @var DOMXPath
*/
public $xpath = null;
/**
* Stack of selected elements.
* @TODO refactor to ->nodes
* @var array
*/
public $elements = array();
/**
* @access private
*/
protected $elementsBackup = array();
/**
* @access private
*/
protected $previous = null;
/**
* @access private
* @TODO deprecate
*/
protected $root = array();
/**
* Indicated if doument is just a fragment (no <html> tag).
*
* Every document is realy a full document, so even documentFragments can
* be queried against <html>, but getDocument(id)->htmlOuter() will return
* only contents of <body>.
*
* @var bool
*/
public $documentFragment = true;
/**
* Iterator interface helper
* @access private
*/
protected $elementsInterator = array();
/**
* Iterator interface helper
* @access private
*/
protected $valid = false;
/**
* Iterator interface helper
* @access private
*/
protected $current = null;
/**
* Enter description here...
*
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
*/
public function __construct($documentID) {
// if ($documentID instanceof self)
// var_dump($documentID->getDocumentID());
$id = $documentID instanceof self
? $documentID->getDocumentID()
: $documentID;
// var_dump($id);
if (! isset(phpQuery::$documents[$id] )) {
// var_dump(phpQuery::$documents);
throw new Exception("Document with ID '{$id}' isn't loaded. Use phpQuery::newDocument(\$html) or phpQuery::newDocumentFile(\$file) first.");
}
$this->documentID = $id;
$this->documentWrapper =& phpQuery::$documents[$id];
$this->document =& $this->documentWrapper->document;
$this->xpath =& $this->documentWrapper->xpath;
$this->charset =& $this->documentWrapper->charset;
$this->documentFragment =& $this->documentWrapper->isDocumentFragment;
// TODO check $this->DOM->documentElement;
// $this->root = $this->document->documentElement;
$this->root =& $this->documentWrapper->root;
// $this->toRoot();
$this->elements = array($this->root);
}
/**
*
* @access private
* @param $attr
* @return unknown_type
*/
public function __get($attr) {
switch($attr) {
// FIXME doesnt work at all ?
case 'length':
return $this->size();
break;
default:
return $this->$attr;
}
}
/**
* Saves actual object to $var by reference.
* Useful when need to break chain.
* @param phpQueryObject $var
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
*/
public function toReference(&$var) {
return $var = $this;
}
public function documentFragment($state = null) {
if ($state) {
phpQuery::$documents[$this->getDocumentID()]['documentFragment'] = $state;
return $this;
}
return $this->documentFragment;
}
/**
* @access private
* @TODO documentWrapper
*/
protected function isRoot( $node) {
// return $node instanceof DOMDOCUMENT || $node->tagName == 'html';
return $node instanceof DOMDOCUMENT
|| ($node instanceof DOMELEMENT && $node->tagName == 'html')
|| $this->root->isSameNode($node);
}
/**
* @access private
*/
protected function stackIsRoot() {
return $this->size() == 1 && $this->isRoot($this->elements[0]);
}
/**
* Enter description here...
* NON JQUERY METHOD
*
* Watch out, it doesn't creates new instance, can be reverted with end().
*
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
*/
public function toRoot() {
$this->elements = array($this->root);
return $this;
// return $this->newInstance(array($this->root));
}
/**
* Saves object's DocumentID to $var by reference.
* <code>
* $myDocumentId;
* phpQuery::newDocument('<div/>')
* ->getDocumentIDRef($myDocumentId)
* ->find('div')->...
* </code>
*
* @param unknown_type $domId
* @see phpQuery::newDocument
* @see phpQuery::newDocumentFile
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
*/
public function getDocumentIDRef(&$documentID) {
$documentID = $this->getDocumentID();
return $this;
}
/**
* Returns object with stack set to document root.
*
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
*/
public function getDocument() {
return phpQuery::getDocument($this->getDocumentID());
}
/**
*
* @return DOMDocument
*/
public function getDOMDocument() {
return $this->document;
}
/**
* Get object's Document ID.
*
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
*/
public function getDocumentID() {
return $this->documentID;
}
/**
* Unloads whole document from memory.
* CAUTION! None further operations will be possible on this document.
* All objects refering to it will be useless.
*
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
*/
public function unloadDocument() {
phpQuery::unloadDocuments($this->getDocumentID());
}
public function isHTML() {
return $this->documentWrapper->isHTML;
}
public function isXHTML() {
return $this->documentWrapper->isXHTML;
}
public function isXML() {
return $this->documentWrapper->isXML;
}
/**
* Enter description here...
*
* @link http://docs.jquery.com/Ajax/serialize
* @return string
*/
public function serialize() {
return phpQuery::param($this->serializeArray());
}
/**
* Enter description here...
*
* @link http://docs.jquery.com/Ajax/serializeArray
* @return array
*/
public function serializeArray($submit = null) {
$source = $this->filter('form, input, select, textarea')
->find('input, select, textarea')
->andSelf()
->not('form');
$return = array();
// $source->dumpDie();
foreach($source as $input) {
$input = phpQuery::pq($input);
if ($input->is('[disabled]'))
continue;
if (!$input->is('[name]'))
continue;
if ($input->is('[type=checkbox]') && !$input->is('[checked]'))
continue;
// jquery diff
if ($submit && $input->is('[type=submit]')) {
if ($submit instanceof DOMELEMENT && ! $input->elements[0]->isSameNode($submit))
continue;
else if (is_string($submit) && $input->attr('name') != $submit)
continue;
}
$return[] = array(
'name' => $input->attr('name'),
'value' => $input->val(),
);
}
return $return;
}
/**
* @access private
*/
protected function debug($in) {
if (! phpQuery::$debug )
return;
print('<pre>');
print_r($in);
// file debug
// file_put_contents(dirname(__FILE__).'/phpQuery.log', print_r($in, true)."\n", FILE_APPEND);
// quite handy debug trace
// if ( is_array($in))
// print_r(array_slice(debug_backtrace(), 3));
print("</pre>\n");
}
/**
* @access private
*/
protected function isRegexp($pattern) {
return in_array(
$pattern[ mb_strlen($pattern)-1 ],
array('^','*','$')
);
}
/**
* Determines if $char is really a char.
*
* @param string $char
* @return bool
* @todo rewrite me to charcode range ! ;)
* @access private
*/
protected function isChar($char) {
return extension_loaded('mbstring') && phpQuery::$mbstringSupport
? mb_eregi('\w', $char)
: preg_match('@\w@', $char);
}
/**
* @access private
*/
protected function pars
没有合适的资源?快使用搜索试试~ 我知道了~
最新微信文章编辑器排版工具程序源码.rar
共1374个文件
gif:383个
png:303个
js:235个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 62 浏览量
2024-04-28
19:22:03
上传
评论
收藏 51.72MB RAR 举报
温馨提示
最新微信文章编辑器排版工具程序源码.rar最新微信文章编辑器排版工具程序源码.rar最新微信文章编辑器排版工具程序源码.rar
资源推荐
资源详情
资源评论
收起资源包目录
最新微信文章编辑器排版工具程序源码.rar (1374个子文件)
0 2KB
layer.min.js.bak 15KB
style.css 125KB
style.min.css 116KB
bootstrap.min.css 114KB
bootstrap.min.css 111KB
animate.min.css 46KB
ueditor.css 45KB
ueditor.css 45KB
ueditor.css 45KB
font-awesome.css 34KB
ueditor.min.css 34KB
ueditor.min.css 34KB
font-awesome.min.css 28KB
font-awesome.min.css 28KB
font-awesome.css 28KB
admin.css 27KB
easyui.css 27KB
easyui.css 26KB
style2.0.css 25KB
index.css 25KB
index.css 24KB
index.css 24KB
font-awesome.min.css 23KB
video-js.css 22KB
video-js.css 22KB
style.css 21KB
image.css 19KB
image.css 19KB
guoyoo.css 15KB
bianji.css 15KB
video.css 15KB
video.css 15KB
attachment.css 15KB
attachment.css 15KB
video-js.min.css 11KB
video-js.min.css 11KB
editor-min.css 7KB
shCoreDefault.css 7KB
shCoreDefault.css 7KB
datagrid.css 5KB
datagrid.css 4KB
jquery.jgrowl.css 4KB
scrawl.css 4KB
scrawl.css 4KB
editor-min.css 4KB
tabs.css 4KB
iframe.css 3KB
iframe.css 3KB
tabs.css 3KB
jquery.Jcrop.css 3KB
common.css 3KB
colorpicker.css 3KB
common.css 3KB
calendar.css 3KB
adminstyle.css 3KB
calendar.css 3KB
default.css 3KB
codemirror.css 3KB
codemirror.css 3KB
codemirror.css 3KB
default.css 3KB
charts.css 3KB
charts.css 3KB
exd-mui.css 2KB
background.css 2KB
background.css 2KB
tree.css 2KB
tree.css 2KB
emotion.css 2KB
emotion.css 2KB
css.css 2KB
dialogbase.css 2KB
dialogbase.css 2KB
layout.css 2KB
layout.css 2KB
music.css 2KB
music.css 2KB
panel.css 2KB
panel.css 2KB
style.css 1KB
linkbutton.css 1KB
linkbutton.css 1KB
login.css 1KB
edittable.css 1KB
edittable.css 1KB
menu.css 1KB
menu.css 1KB
window.css 1KB
window.css 1KB
template.css 1KB
template.css 1KB
icon.css 952B
pagination.css 948B
pagination.css 948B
splitbutton.css 758B
splitbutton.css 758B
spinner.css 732B
spinner.css 732B
combo.css 667B
共 1374 条
- 1
- 2
- 3
- 4
- 5
- 6
- 14
资源评论
依星net188.com
- 粉丝: 7775
- 资源: 2098
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功