![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| Pear Pear programming, this is a very complex subject as with using pear with php can be a difficult task for some, so lets talk pear. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| cellog Sat May 19 19:25:44 2007 UTC Modified files: /pear/PHP_Archive/Archive Creator.php Log: add ability to specify a base directory for addDir() add ability to clear magic require callbacks add tokenizer-based magic require http://cvs.php.net/viewvc.cgi/pear/P...&diff_format=u Index: pear/PHP_Archive/Archive/Creator.php diff -u pear/PHP_Archive/Archive/Creator.php:1.38 pear/PHP_Archive/Archive/Creator.php:1.39 --- pear/PHP_Archive/Archive/Creator.php:1.38 Fri May 18 03:49:36 2007 +++ pear/PHP_Archive/Archive/Creator.php Sat May 19 19:25:44 2007 @@ -24,7 +24,7 @@ * @author Davey Shafik <davey@synapticmedia.net> * @author Greg Beaver <cellog@php.net> * @link http://www.synapticmedia.net Synaptic Media - * @version $Id: Creator.php,v 1.38 2007/05/18 03:49:36 cellog Exp $ + * @version $Id: Creator.php,v 1.39 2007/05/19 19:25:44 cellog Exp $ * @package PHP_Archive * @category PHP */ @@ -388,6 +388,11 @@ 'metadata' => $metadata); } + public function clearMagicRequire() + { + $this->_magicRequireCallbacks = array(); + } + /** * prepends all include/require calls with "phar://alias" * @@ -431,6 +436,73 @@ return $file_contents; } + public function tokenMagicRequire($contents, $path) + { + $info = pathinfo($path); + if (!isset($info['extension'])) { + return $contents; + } + if ($info['extension'] != 'php') { + return $contents; + } + $alias = '\'phar://' . $this->alias . '/\' . '; + $contents = token_get_all($contents); + $inphp = false; + $finished = ''; + for ($i = 0; $i < count($contents); $i++) { + $token = $contents[$i]; + if (!$inphp) { + if (!is_array($token)) { + $finished .= $token; + continue; + } + if ($token[0] == T_OPEN_TAG) { + $finished .= $token[1]; + $inphp = true; + continue; + } + } + if (!is_array($token)) { + $finished .= $token; + continue; + } + if ($token[0] == T_CLOSE_TAG) { + $finished .= $token[1]; + $inphp = false; + continue; + } + if ($token[0] != T_INCLUDE && $token[0] != T_INCLUDE_ONCE && + $token[0] != T_REQUIRE && $token[0] != T_REQUIRE_ONCE) { + $finished .= $token[1]; + continue; + } + $finished .= $token[1]; + $new = ''; + $done = false; + $token = $contents[++$i]; + for (;!$done;$i++) { + $token = $contents[$i]; + if (!is_array($token)) { + if ($token == '(' || $token == '{' || $token == '"' || + $token == "'") { + $finished .= ' ' . $alias . $token; + continue 2; + } + $finished .= $token; + // we have some oddness, don't touch this with a 10-foot pole + continue 2; + } + if ($token[0] == T_WHITESPACE) { + $finished .= $token[1]; + continue; + } + $done = true; + $finished .= $alias . $token[1]; + $i--; + } + } + return $finished; + } /** * Tell whether to ignore a file or a directory * allows * and ? wildcards @@ -624,15 +696,17 @@ * @param array files to ignore * @param array files to include (all others ignored) * @param bool If set, then "require_once '" will be replaced with - * "require_once 'phar://$magicrequire/" + * "require_once 'phar://$magicrequire/" [deprecated] + * @param string Directory to consider as the top-level directory * @return boolean */ - public function addDir($dir, $ignore = array(), $include = array(), $magicrequire = false) + public function addDir($dir, $ignore = array(), $include = array(), $magicrequire = false, + $toplevel = null) { $this->_setupIgnore($ignore, 1); $this->_setupIgnore($include, 0); - $list = $this->dirList($dir); + $list = $this->dirList($dir, $toplevel); return $this->addArray($list, $magicrequire); } | |||
| Featured Websites | ||||
|
![]() |
| Tags: creatorphp, cvs, pear, php_archivearchive |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| LOGO and BUTTONS creator | modric | Image Software Programs | 7 | 08-29-2007 4:07 PM |
| cvs: pear /PHP_Archive Archive.php | Greg Beaver | Pear | 0 | 05-20-2007 7:42 PM |
| cvs: pear /PHP_Archive Archive.php package.php package.xml /PHP_Archive/Archive Creator.php /PHP_Archive/data phar_frontcontroller.tpl | Greg Beaver | Pear | 0 | 05-20-2007 7:42 PM |
| cvs: pear-core / package-PEAR.xml package2.xml /PEAR Installer.php /PEAR/PackageFile v1.php /PEAR/PackageFile/v2 Validator.php | Greg Beaver | Pear | 0 | 05-20-2007 7:42 PM |
| pear install doesn't work due to bug in Archive/Tar | Lars Petersen | Pear | 1 | 05-20-2007 7:41 PM |
| Featured Websites | ||||
|