Skip to content

Commit 7ce0595

Browse files
author
tobiasz.cudnik
committed
task 54: PEAR installaction support
http://code.google.com/p/phpquery/issues/detail?id=54 * changed directory layout git-svn-id: http://phpquery.googlecode.com/svn/branches/dev@367 afc5ee8f-4a33-0410-9214-8715c29b7d85
1 parent 286c75c commit 7ce0595

85 files changed

Lines changed: 93 additions & 175 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

phpQuery/phpQuery.php

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
define('DOMELEMENT', 'DOMElement');
1919
define('DOMNODELIST', 'DOMNodeList');
2020
define('DOMNODE', 'DOMNode');
21-
require_once(dirname(__FILE__).'/DOMEvent.php');
22-
require_once(dirname(__FILE__).'/DOMDocumentWrapper.php');
23-
require_once(dirname(__FILE__).'/phpQueryEvents.php');
24-
require_once(dirname(__FILE__).'/Callback.php');
25-
require_once(dirname(__FILE__).'/phpQueryObject.php');
26-
require_once(dirname(__FILE__).'/compat/mbstring.php');
21+
require_once(dirname(__FILE__).'/phpQuery/DOMEvent.php');
22+
require_once(dirname(__FILE__).'/phpQuery/DOMDocumentWrapper.php');
23+
require_once(dirname(__FILE__).'/phpQuery/phpQueryEvents.php');
24+
require_once(dirname(__FILE__).'/phpQuery/Callback.php');
25+
require_once(dirname(__FILE__).'/phpQuery/phpQueryObject.php');
26+
require_once(dirname(__FILE__).'/phpQuery/compat/mbstring.php');
2727
/**
2828
* Static namespace for phpQuery functions.
2929
*
@@ -243,7 +243,7 @@ public static function selectDocument($id) {
243243
*
244244
* @see phpQuery::selectDocument()
245245
* @param unknown_type $id
246-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
246+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
247247
*/
248248
public static function getDocument($id = null) {
249249
if ($id)
@@ -257,8 +257,7 @@ public static function getDocument($id = null) {
257257
* Chainable.
258258
*
259259
* @param unknown_type $markup
260-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
261-
* @TODO support DOMDocument
260+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
262261
*/
263262
public static function newDocument($markup = null, $contentType = null) {
264263
if (! $markup)
@@ -271,46 +270,50 @@ public static function newDocument($markup = null, $contentType = null) {
271270
* Chainable.
272271
*
273272
* @param unknown_type $markup
274-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
275-
* @TODO support DOMDocument
273+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
276274
*/
277-
public static function newDocumentHTML($markup = null, $charset = 'utf-8') {
278-
if (!isset($charset))
279-
$charset = self::$defaultCharset;
280-
return self::newDocument($markup, "text/html;charset=$charset");
275+
public static function newDocumentHTML($markup = null, $charset = null) {
276+
$contentType = $charset
277+
? ";charset=$charset"
278+
: '';
279+
return self::newDocument($markup, "text/html{$contentType}");
281280
}
282281
/**
283282
* Creates new document from markup.
284283
* Chainable.
285284
*
286285
* @param unknown_type $markup
287-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
288-
* @TODO support DOMDocument
286+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
289287
*/
290-
public static function newDocumentXML($markup = null, $charset = 'utf-8') {
291-
return self::newDocument($markup, "text/xml;charset=$charset");
288+
public static function newDocumentXML($markup = null, $charset = null) {
289+
$contentType = $charset
290+
? ";charset=$charset"
291+
: '';
292+
return self::newDocument($markup, "text/xml{$contentType}");
292293
}
293294
/**
294295
* Creates new document from markup.
295296
* Chainable.
296297
*
297298
* @param unknown_type $markup
298-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
299-
* @TODO support DOMDocument
299+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
300300
*/
301-
public static function newDocumentXHTML($markup = null, $charset = 'utf-8') {
302-
return self::newDocument($markup, "application/xhtml+xml;charset=$charset");
301+
public static function newDocumentXHTML($markup = null, $charset = null) {
302+
$contentType = $charset
303+
? ";charset=$charset"
304+
: '';
305+
return self::newDocument($markup, "application/xhtml+xml{$contentType}");
303306
}
304307
/**
305308
* Creates new document from markup.
306309
* Chainable.
307310
*
308311
* @param unknown_type $markup
309-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
310-
* @TODO support DOMDocument
312+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
311313
*/
312-
public static function newDocumentPHP($markup = null, $contentType = "text/html;charset=utf-8") {
313-
$markup = phpQuery::phpToMarkup($markup);
314+
public static function newDocumentPHP($markup = null, $contentType = "text/html") {
315+
// TODO pass charset to phpToMarkup if possible (use DOMDocumentWrapper function)
316+
$markup = phpQuery::phpToMarkup($markup, self::$defaultCharset);
314317
return self::newDocument($markup, $contentType);
315318
}
316319
public static function phpToMarkup($php, $charset = 'utf-8') {
@@ -324,7 +327,7 @@ public static function phpToMarkup($php, $charset = 'utf-8') {
324327
$regex,
325328
create_function('$m, $charset = "'.$charset.'"',
326329
'return $m[1].$m[2]
327-
.htmlspecialchars("<"."?php".$m[4]."?>", ENT_QUOTES|ENT_NOQUOTES, $charset)
330+
.htmlspecialchars("<"."?php".$m[4]."?".">", ENT_QUOTES|ENT_NOQUOTES, $charset)
328331
.$m[5].$m[2];'
329332
),
330333
$php
@@ -381,7 +384,7 @@ public static function markupToPHP($content) {
381384
* Chainable.
382385
*
383386
* @param string $file URLs allowed. See File wrapper page at php.net for more supported sources.
384-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
387+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
385388
*/
386389
public static function newDocumentFile($file, $contentType = null) {
387390
$documentID = self::createDocumentWrapper(
@@ -394,41 +397,46 @@ public static function newDocumentFile($file, $contentType = null) {
394397
* Chainable.
395398
*
396399
* @param unknown_type $markup
397-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
398-
* @TODO support DOMDocument
400+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
399401
*/
400-
public static function newDocumentFileHTML($file, $charset = 'utf-8') {
401-
return self::newDocumentFile($file, "text/html;charset=$charset");
402+
public static function newDocumentFileHTML($file, $charset = null) {
403+
$contentType = $charset
404+
? ";charset=$charset"
405+
: '';
406+
return self::newDocumentFile($file, "text/html{$contentType}");
402407
}
403408
/**
404409
* Creates new document from markup.
405410
* Chainable.
406411
*
407412
* @param unknown_type $markup
408-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
409-
* @TODO support DOMDocument
413+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
410414
*/
411-
public static function newDocumentFileXML($file, $charset = 'utf-8') {
412-
return self::newDocumentFile($file, "text/xml;charset=$charset");
415+
public static function newDocumentFileXML($file, $charset = null) {
416+
$contentType = $charset
417+
? ";charset=$charset"
418+
: '';
419+
return self::newDocumentFile($file, "text/xml{$contentType}");
413420
}
414421
/**
415422
* Creates new document from markup.
416423
* Chainable.
417424
*
418425
* @param unknown_type $markup
419-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
420-
* @TODO support DOMDocument
426+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
421427
*/
422-
public static function newDocumentFileXHTML($file, $charset = 'utf-8') {
423-
return self::newDocumentFile($file, "application/xhtml+xml;charset=$charset");
428+
public static function newDocumentFileXHTML($file, $charset = null) {
429+
$contentType = $charset
430+
? ";charset=$charset"
431+
: '';
432+
return self::newDocumentFile($file, "application/xhtml+xml{$contentType}");
424433
}
425434
/**
426435
* Creates new document from markup.
427436
* Chainable.
428437
*
429438
* @param unknown_type $markup
430-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
431-
* @TODO support DOMDocument
439+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
432440
*/
433441
public static function newDocumentFilePHP($file, $contentType = null) {
434442
return self::newDocumentPHP(file_get_contents($file), $contentType);
@@ -438,8 +446,8 @@ public static function newDocumentFilePHP($file, $contentType = null) {
438446
* Chainable.
439447
*
440448
* @param $document DOMDocument
441-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPick
442-
* up
449+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
450+
* @TODO support DOMDocument
443451
*/
444452
public static function loadDocument($document) {
445453
// TODO
@@ -1293,7 +1301,7 @@ public function __call($method, $args) {
12931301
* Chainable.
12941302
*
12951303
* @see phpQuery::pq()
1296-
* @return phpQueryObject|queryTemplatesFetch|queryTemplatesParse|queryTemplatesPickup
1304+
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
12971305
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
12981306
* @package phpQuery
12991307
*/
@@ -1307,12 +1315,12 @@ function pq($arg1, $context = null) {
13071315
// add plugins dir and Zend framework to include path
13081316
set_include_path(
13091317
get_include_path()
1310-
.PATH_SEPARATOR.dirname(__FILE__).'/'
1311-
.PATH_SEPARATOR.dirname(__FILE__).'/plugins/'
1318+
.PATH_SEPARATOR.dirname(__FILE__).'/phpQuery/'
1319+
.PATH_SEPARATOR.dirname(__FILE__).'/phpQuery/plugins/'
13121320
);
13131321
// why ? no __call nor __get for statics in php...
13141322
// XXX __callStatic will be available in PHP 5.3
13151323
phpQuery::$plugins = new phpQueryPlugins();
13161324
// include bootstrap file (personal library config)
1317-
if (file_exists(dirname(__FILE__).'/bootstrap.php'))
1318-
require_once dirname(__FILE__).'/bootstrap.php';
1325+
if (file_exists(dirname(__FILE__).'/phpQuery/bootstrap.php'))
1326+
require_once dirname(__FILE__).'/phpQuery/bootstrap.php';
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class Callback
1313
public $callback = null;
1414
public $params = null;
1515
protected $name;
16-
public function __construct($callback, $param1 = null, $param2 = null, $param3 = null) {
16+
public function __construct($callback, $param1 = null, $param2 = null,
17+
$param3 = null) {
1718
$params = func_get_args();
1819
$params = array_slice($params, 1);
1920
if ($callback instanceof Callback) {
@@ -45,7 +46,8 @@ public function setName($name) {
4546
* @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
4647
*/
4748
class CallbackBody extends Callback {
48-
public function __construct($paramList, $code, $param1 = null, $param2 = null, $param3 = null) {
49+
public function __construct($paramList, $code, $param1 = null, $param2 = null,
50+
$param3 = null) {
4951
$params = func_get_args();
5052
$params = array_slice($params, 2);
5153
$this->callback = create_function($paramList, $code);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)