private function _processDependencyFile($assetsType, $file)
 {
     if (substr($file, -3) == '.js') {
         echo "<h1>{$file}</h1>\n";
         $l = new Kwf_Assets_Loader();
         $c = $l->getFileContents("web-" . $file);
         echo round(strlen($l->pack($c['contents'], 'js')) / 1024) . "kB";
         echo "<ul>";
         foreach ($this->_stack as $s) {
             echo "<li>{$s}</li>";
         }
         echo "</ul>\n";
     }
 }
Esempio n. 2
0
 public function setBodyHtml($html, $charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE)
 {
     while (preg_match('/(img src|background)=\\"\\/(.*?)\\"/i', $html, $matches)) {
         $path = '/' . $matches[2];
         if ($this->_attachImages) {
             if (substr($path, 0, 6) == '/media') {
                 $parts = explode('/', substr($path, 1));
                 $class = $parts[1];
                 $id = $parts[2];
                 $type = $parts[3];
                 $checksum = $parts[4];
                 $filename = $parts[6];
                 $output = Kwf_Media::getOutputWithoutCheckingIsValid($class, $id, $type);
             } else {
                 try {
                     $f = new Kwf_Assets_Loader();
                     $output = $f->getFileContents(substr($path, 8));
                 } catch (Kwf_Exception_NotFound $e) {
                     throw new Kwf_Exception('Asset not found: ' . $path);
                 }
             }
             if (isset($output['contents'])) {
                 $contents = $output['contents'];
             } else {
                 if (isset($output['file'])) {
                     $contents = file_get_contents($output['file']);
                 } else {
                     throw new Kwf_Exception("didn't get image contents");
                 }
             }
             $image = new Zend_Mime_Part($contents);
             $image->type = $output['mimeType'];
             $image->disposition = Zend_Mime::DISPOSITION_INLINE;
             $image->encoding = Zend_Mime::ENCODING_BASE64;
             $filename = rawurldecode(substr(strrchr($path, '/'), 1));
             $filename = preg_replace('/([^a-z0-9\\-\\.]+)/i', '_', $filename);
             $image->filename = $filename;
             $image->id = md5($path);
             $this->setType(Zend_Mime::MULTIPART_RELATED);
             $this->addAttachment($image);
             $replace = "cid:{$image->id}";
         } else {
             $replace = "http://" . $this->getDomain() . $path;
         }
         $html = str_replace($matches[0], "{$matches[1]}=\"{$replace}\"", $html);
     }
     parent::setBodyHtml($html, $charset, $encoding);
 }