| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
function wfile($obj, $f) { |
|---|
| 4 |
|
|---|
| 5 |
ob_start(); |
|---|
| 6 |
var_dump($obj); |
|---|
| 7 |
file_put_contents($f, ob_get_contents()); |
|---|
| 8 |
ob_end_clean(); |
|---|
| 9 |
|
|---|
| 10 |
} |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
require_once "phing/Task.php"; |
|---|
| 23 |
require_once 'PEAR/PackageFileManager2.php'; |
|---|
| 24 |
require_once 'PEAR/PackageFileManager/File.php'; |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
class packageMidCOMcore extends Task |
|---|
| 29 |
{ |
|---|
| 30 |
|
|---|
| 31 |
protected $package = null; |
|---|
| 32 |
/** |
|---|
| 33 |
* The PEAR name of the package. |
|---|
| 34 |
*/ |
|---|
| 35 |
protected $package_name; |
|---|
| 36 |
|
|---|
| 37 |
protected $channel = "ragnaroek.pear.midgard-project.org"; |
|---|
| 38 |
|
|---|
| 39 |
protected $stability = 'beta'; |
|---|
| 40 |
|
|---|
| 41 |
protected $phpversion = '5.2.0'; |
|---|
| 42 |
|
|---|
| 43 |
protected $returnProperty; |
|---|
| 44 |
protected $version; |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
* The root path to where the module is stored. |
|---|
| 48 |
*/ |
|---|
| 49 |
private $path = null; |
|---|
| 50 |
|
|---|
| 51 |
* The target directory where the packagefile should be saved. |
|---|
| 52 |
*/ |
|---|
| 53 |
protected $target_dir = null; |
|---|
| 54 |
|
|---|
| 55 |
* The setter for the attribute "message" |
|---|
| 56 |
*/ |
|---|
| 57 |
public function setTarget_dir($str) |
|---|
| 58 |
{ |
|---|
| 59 |
$this->target_dir = $str; |
|---|
| 60 |
} |
|---|
| 61 |
public function setPath($str) |
|---|
| 62 |
{ |
|---|
| 63 |
echo "Setting path to $str\n"; |
|---|
| 64 |
$this->path = $str; |
|---|
| 65 |
} |
|---|
| 66 |
public function setPackage($str) |
|---|
| 67 |
{ |
|---|
| 68 |
$this->package = $str; |
|---|
| 69 |
} |
|---|
| 70 |
public function setChannel($str) |
|---|
| 71 |
{ |
|---|
| 72 |
$this->channel = $str; |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
public function setReturnProperty($r) |
|---|
| 76 |
{ |
|---|
| 77 |
$this->returnProperty = $r; |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
* the template pacakge.xml file to use. |
|---|
| 81 |
*/ |
|---|
| 82 |
public function setTemplate($t) { |
|---|
| 83 |
$this->template = $t; |
|---|
| 84 |
} |
|---|
| 85 |
public function setStability($s) { |
|---|
| 86 |
$this->stability = $s; |
|---|
| 87 |
} |
|---|
| 88 |
public function setVersion($s) { |
|---|
| 89 |
$this->version = $s; |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
protected $copyfiles = array (); |
|---|
| 95 |
|
|---|
| 96 |
* array of files in the static dir. |
|---|
| 97 |
*/ |
|---|
| 98 |
protected $staticFiles ; |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
* The init method: Do init steps. |
|---|
| 102 |
*/ |
|---|
| 103 |
public function init() |
|---|
| 104 |
{ |
|---|
| 105 |
|
|---|
| 106 |
return; |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
* The main entry point method. |
|---|
| 111 |
*/ |
|---|
| 112 |
public function main() |
|---|
| 113 |
{ |
|---|
| 114 |
$baseOptions = array('filelistgenerator' => 'File', |
|---|
| 115 |
'packagedirectory' => $this->path, |
|---|
| 116 |
'baseinstalldir' => 'midcom/lib', |
|---|
| 117 |
'installexceptions' => array( 'support' => '/'), |
|---|
| 118 |
'dir_roles' => array(), |
|---|
| 119 |
'simpleoutput' => true, |
|---|
| 120 |
'ignore' => array('package-template.xml'), |
|---|
| 121 |
'include' => array('*.php', '*.inc', '*.txt', 'midcom*', 'support*'), |
|---|
| 122 |
); |
|---|
| 123 |
|
|---|
| 124 |
$package = $this->makeBase($baseOptions); |
|---|
| 125 |
$package->addRole('jpg','web'); |
|---|
| 126 |
$package->addRole('gif','web'); |
|---|
| 127 |
$package->addRole('png','web'); |
|---|
| 128 |
$package->addRole('zip','web'); |
|---|
| 129 |
$package->addRole('tgz','web'); |
|---|
| 130 |
$package->addRole('html','web'); |
|---|
| 131 |
$package->addRole('js','web'); |
|---|
| 132 |
$package->addRole('htc','web'); |
|---|
| 133 |
$package->addRole('css','web'); |
|---|
| 134 |
$package->addRole('inc','php'); |
|---|
| 135 |
$package->addRole('txt','php'); |
|---|
| 136 |
$package->addRole('sql','midgardsql'); |
|---|
| 137 |
$package->addRole('xml', 'mgdschema'); |
|---|
| 138 |
|
|---|
| 139 |
$package->generateContents(); |
|---|
| 140 |
|
|---|
| 141 |
$this->addStatic($package); |
|---|
| 142 |
|
|---|
| 143 |
if ($package->debugPackageFile()) { |
|---|
| 144 |
echo "Writing package.....\n"; |
|---|
| 145 |
$package->writePackageFile(); |
|---|
| 146 |
} |
|---|
| 147 |
$this->project->setProperty('pear_name', 'midcom_core'); |
|---|
| 148 |
|
|---|
| 149 |
} |
|---|
| 150 |
|
|---|
| 151 |
protected function getNotes($package) { |
|---|
| 152 |
|
|---|
| 153 |
} |
|---|
| 154 |
|
|---|
| 155 |
* This method builds the list of files in the static dir and adds them to the |
|---|
| 156 |
*/ |
|---|
| 157 |
protected function addStatic($package) |
|---|
| 158 |
{ |
|---|
| 159 |
$this->staticFiles = array(); |
|---|
| 160 |
$this->getDirFilesRecursive($this->path . "/static"); |
|---|
| 161 |
foreach ($this->staticFiles as $path => $files ) |
|---|
| 162 |
{ |
|---|
| 163 |
$fpath = str_replace($this->path . '/static/', "", $path); |
|---|
| 164 |
foreach ($files as $filename) |
|---|
| 165 |
{ |
|---|
| 166 |
$dir = '/static'; |
|---|
| 167 |
$filen = $fpath .'/' . $filename ; |
|---|
| 168 |
$package->addFile($dir, $filen , array( |
|---|
| 169 |
'role' => 'web', |
|---|
| 170 |
'baseinstalldir' => '/', |
|---|
| 171 |
'install-as' => $fpath ."/". $filename ) ); |
|---|
| 172 |
} |
|---|
| 173 |
} |
|---|
| 174 |
|
|---|
| 175 |
} |
|---|
| 176 |
|
|---|
| 177 |
protected function getDirFilesRecursive($path) { |
|---|
| 178 |
|
|---|
| 179 |
$list = dir($path); |
|---|
| 180 |
while (($file = $list->read()) !== FALSE) { |
|---|
| 181 |
if ($file{0} == '.') continue; |
|---|
| 182 |
if (is_dir($path .'/'.$file)) { |
|---|
| 183 |
$this->getDirFilesRecursive($path .'/' . $file); |
|---|
| 184 |
} else { |
|---|
| 185 |
if (!isset($this->staticFiles[$path])) $this->staticFiles[$path] = array(); |
|---|
| 186 |
$this->staticFiles[$path][] = $file; |
|---|
| 187 |
} |
|---|
| 188 |
} |
|---|
| 189 |
$list->close(); |
|---|
| 190 |
} |
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
* sets up the basic packageobject |
|---|
| 194 |
* @return the package object |
|---|
| 195 |
*/ |
|---|
| 196 |
protected function makeBase($options) { |
|---|
| 197 |
PEAR::setErrorHandling(PEAR_ERROR_DIE); |
|---|
| 198 |
|
|---|
| 199 |
$package = PEAR_PackageFileManager2::importOptions($this->template, $options); |
|---|
| 200 |
$package->setPackageType('php'); |
|---|
| 201 |
$package->setReleaseStability($this->stability); |
|---|
| 202 |
$package->setAPIStability($this->stability); |
|---|
| 203 |
$package->setPhpDep($this->phpversion); |
|---|
| 204 |
$package->setReleaseVersion($this->version); |
|---|
| 205 |
echo "Done with makeBase\n\n"; |
|---|
| 206 |
return $package; |
|---|
| 207 |
} |
|---|
| 208 |
} |
|---|
| 209 |
?> |
|---|