Skip to content

Commit dd4f279

Browse files
author
tobiasz.cudnik
committed
• added wrapInnerPHP
• fixed empty return from phpQuery::$plugins namespace git-svn-id: http://phpquery.googlecode.com/svn/branches/dev@323 afc5ee8f-4a33-0410-9214-8715c29b7d85
1 parent 54961ca commit dd4f279

2 files changed

Lines changed: 128 additions & 125 deletions

File tree

phpQuery/phpQuery.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,13 @@ public static function phpToMarkup($php, $charset = 'utf-8') {
295295
$php = preg_replace($regex, '\\1<php><!-- \\3 --></php>', $php);
296296
return $php;
297297
}
298+
/**
299+
* Converts document markup containing PHP code generated by phpQuery::php()
300+
* into valid (executable) PHP code syntax.
301+
*
302+
* @param string|phpQueryObject $content
303+
* @return string PHP code.
304+
*/
298305
public static function markupToPHP($content) {
299306
if ($content instanceof phpQueryObject)
300307
$content = $content->markupOuter();
@@ -311,6 +318,7 @@ public static function markupToPHP($content) {
311318
array('<?php', '<?php', '?>', '?>'),
312319
$content
313320
);*/
321+
/* <node attr='<?php ?>'> */
314322
$regexes = array(
315323
'@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(\')([^\']*)(?:&lt;|%3C)\\?(?:php)?(.*?)(?:\\?(?:&gt;|%3E))([^\']*)\'@s',
316324
'@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(")([^"]*)(?:&lt;|%3C)\\?(?:php)?(.*?)(?:\\?(?:&gt;|%3E))([^"]*)"@s',
@@ -970,7 +978,10 @@ public static function browser($ajaxSettings, $callback, $param1 = null, $param2
970978
}
971979
}
972980
public static function php($code) {
973-
return "<php><!-- ".trim($code)." --></php>";
981+
return self::code('php', $code);
982+
}
983+
public static function code($type, $code) {
984+
return "<$type><!-- ".trim($code)." --></$type>";
974985
}
975986
}
976987
/**
@@ -989,7 +1000,7 @@ public function __call($method, $args) {
9891000
array($realClass, $method),
9901001
$args
9911002
);
992-
return $return
1003+
return isset($return)
9931004
? $return
9941005
: $this;
9951006
} else

0 commit comments

Comments
 (0)