AssetTrait.php
[Pman.Core] / AssetTrait.php
index 4075ee7..24a2344 100644 (file)
@@ -1,7 +1,7 @@
-
+<?php
 // a little experimental... we are going to use the same name as the class. for these..
 
-trait Pman_Core_Asset_Trait {
+trait Pman_Core_AssetTrait {
     
     
     
@@ -39,7 +39,10 @@ trait Pman_Core_Asset_Trait {
         }
          // cached version?? - how do we decide if it's expired?
         // while scanning the directory is slow... - it's faster than serving every file...
-        
+        if (empty($ar)) {
+            echo "<!-- skipping $path - no files found -->\n";
+            return;
+        }
         
         //$path = $this->rootURL ."/Pman/$mod/";
         
@@ -107,9 +110,11 @@ trait Pman_Core_Asset_Trait {
         } else {
          //   echo "<!-- file already exists: {$basedir}/{$output} -->\n";
         }
+        
+        $asset = $ff->project == 'Pman' ? '/Core/Asset/js/' : '/Asset/js/';
         //$this->arrayToJsInclude(  $files);
         $this->assetArrayToHtml(  array(
-            $this->baseURL.'/Asset/js/'. $output,
+            $this->baseURL.$asset. $output,
           
         ), 'js');
         
@@ -161,7 +166,10 @@ trait Pman_Core_Asset_Trait {
             }
           
         }
-        
+        if (empty($ar)) {
+            echo "<!-- skipping $path - no files found -->\n";
+            return;
+        }
         
          // cached version?? - how do we decide if it's expired?
         // while scanning the directory is slow... - it's faster than serving every file...
@@ -232,18 +240,18 @@ trait Pman_Core_Asset_Trait {
         
         $output = date('Y-m-d-H-i-s-', $maxtime). $smod .'-'.md5(serialize($arfiles)) .'.css';
          
-         
+         $asset = $ff->project == 'Pman' ? '/Core/Asset/css/' : '/Asset/css/';
         
         // where are we going to write all of this..
         // This has to be done via a 
-        if (true || !file_exists($compiledir.'/'.$output) || !filesize($compiledir.'/'.$output)) {
-            
+        if (!file_exists($compiledir.'/'.$output) || !filesize($compiledir.'/'.$output)) {
             
+            //print_r($relfiles);
             
             require_once 'HTML/CSS/Minify.php';
             $x = new HTML_CSS_Minify(substr($relpath,0,-1), $dir, $relfiles);
             
-            file_put_contents($compiledir.'/'.$output , $x->minify( $this->baseURL.'/Asset/css'));
+            file_put_contents($compiledir.'/'.$output , $x->minify( $this->baseURL.$asset));
             clearstatcache();
             if (!file_exists($compiledir.'/'.$output) ||
                 !filesize($compiledir.'/'.$routput)) {
@@ -255,9 +263,11 @@ trait Pman_Core_Asset_Trait {
         } else {
          //   echo "<!-- file already exists: {$basedir}/{$output} -->\n";
         }
+        
+         
         //$this->arrayToJsInclude(  $files);
         $this->assetArrayToHtml(  array(
-            $this->baseURL.'/Asset/css/'. $output,
+            $this->baseURL.$asset. $output,
           
         ),'css');