Changeset 12599

Show
Ignore:
Timestamp:
09/30/07 14:16:47 (1 year ago)
Author:
tarjei
Message:

Add static files to build

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/build/packageMidCOMcore.php

    r12307 r12599  
    11<?php 
    22 
     3function 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} 
    311 
    412/** 
     
    7785 
    7886    // todo: add a setVersion from the commandline 
    79         protected $copyfiles = array (); 
     87    protected $copyfiles = array (); 
     88    /* array of files in the static dir. */ 
     89    protected $staticFiles ; 
    8090 
    8191        /** 
     
    96106            'packagedirectory' => $this->path, 
    97107            'baseinstalldir' => 'midcom/lib', 
     108            'installexceptions' => array( 'support' => '/'), 
     109            'dir_roles' => array(),  
    98110            'simpleoutput' => true, 
    99                                     'include' => array('*.php', 'midcom/*', 'support/*'), 
     111                                    'include' => array('*.php', 'midcom*', 'support*'), 
    100112            ); 
    101113           
     
    115127        $package->generateContents(); 
    116128 
     129        $this->addStatic($package); 
     130 
    117131        if ($package->debugPackageFile()) { 
    118132            echo "Writing package.....\n"; 
     
    125139    protected function getNotes($package) { 
    126140        // todo add release notes... 
     141    } 
     142    /* 
     143     * This method builds the list of files in the static dir and adds them to the  
     144     * */ 
     145    protected function addStatic($package)  
     146    { 
     147 
     148        $this->staticFiles = array(); 
     149        $this->getDirFilesRecursive($this->path . "/static"); 
     150        foreach ($this->staticFiles as $path => $files )  
     151        { 
     152            $fpath = str_replace($this->path . '/static/', "", $path); 
     153            foreach ($files as $filename)  
     154            { 
     155                $dir = '/static'; 
     156                $filen =  $fpath .'/' . $filename ; 
     157                $package->addFile($dir, $filen , array( 
     158                            'role' => 'web',  
     159                            'baseinstalldir' => '/',  
     160                            'install-as' => $fpath ."/". $filename ) ); 
     161            } 
     162        } 
     163 
     164    } 
     165 
     166    protected function getDirFilesRecursive($path) { 
     167        $list = dir($path); 
     168        while (($file = $list->read()) !== FALSE) { 
     169            if ($file{0} == '.') continue; // skipp .svn , . and .. 
     170            if (is_dir($path .'/'.$file)) { 
     171                $this->getDirFilesRecursive($path .'/' . $file); 
     172            } else { 
     173                if (!isset($this->staticFiles[$path])) $this->staticFiles[$path] = array(); 
     174                $this->staticFiles[$path][] = $file; 
     175            } 
     176        } 
     177        $list->close(); 
    127178    } 
    128179