Merge branch 'master' of http://git.roojs.com/web.mtrack
authorAlan Knowles <alan@akkbhome.com>
Sun, 10 Apr 2011 08:20:50 +0000 (16:20 +0800)
committerAlan Knowles <alan@akkbhome.com>
Sun, 10 Apr 2011 08:20:50 +0000 (16:20 +0800)
MTrackWeb.php
MTrackWeb/Attachment.php
MTrackWeb/File.php
MTrackWeb/Ticket.php
MTrackWeb/templates/images/css/mtrack.css
MTrackWeb/templates/images/css/ticket.css
MTrackWeb/templates/images/js/mtrack.ticket.js
MTrackWeb/templates/ticket.html
index.php

index ff58ca4..2e0f492 100644 (file)
@@ -359,10 +359,8 @@ class MTrackWeb extends HTML_FlexyFramework_Page
         
         // log all errors!!!
         //$this->addEvent("ERROR", false, $str);
-        /*
-        if (!empty($_REQUEST['returnHTML']) || 
-            (isset($_SERVER['CONTENT_TYPE']) && preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']))
-        ) {
+        
+        if ((isset($_SERVER['CONTENT_TYPE']) && preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']))) {
             header('Content-type: text/html');
             echo "<HTML><HEAD></HEAD><BODY>";
             echo  $json->encodeUnsafe(array(
@@ -375,7 +373,7 @@ class MTrackWeb extends HTML_FlexyFramework_Page
             echo "</BODY></HTML>";
             exit;
         }
-        */
+        
         echo $json->encode(array(
             'success'=> false, 
             'data'=> array(), 
@@ -391,9 +389,8 @@ class MTrackWeb extends HTML_FlexyFramework_Page
         
         require_once 'Services/JSON.php';
         $json = new Services_JSON();
-        /*
-        if (!empty($_REQUEST['returnHTML']) || 
-            (isset($_SERVER['CONTENT_TYPE']) && preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']))
+        
+        if ( (isset($_SERVER['CONTENT_TYPE']) && preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']))
         
         ) {
             header('Content-type: text/html');
@@ -402,7 +399,7 @@ class MTrackWeb extends HTML_FlexyFramework_Page
             echo "</BODY></HTML>";
             exit;
         }
-        */
+        
         
         echo  $json->encode(array('success'=> true, 'data' => $str));
         exit;
index 595d7a9..844d89a 100644 (file)
@@ -12,7 +12,7 @@ class MTrackWeb_Attachment extends MTrackWeb
     
     function get($pi)
     {
-        
+        die("not yet");
         require_once 'MTrack/Attachment.php';
 
 
index 7cc7f00..98c3a63 100644 (file)
@@ -130,13 +130,21 @@ class MTrackWeb_File extends MTrackWeb
         require_once 'File/MimeType.php';
         $y = new File_MimeType();
         $this->mimetype = $y->fromFilename($this->file->name);
-
+        $ext = strtolower(array_pop(explode('.', $this->file->name)));
         
         //$this->mimetype = mtrack_mime_detect($location, $this->file->name);
-        
+        // special cases..
         
         list($major) = explode('/', $this->mimetype, 2);
 
+        switch ($ext) {
+            case 'sql':
+                $major = 'text';
+                break;
+            
+            
+        }
+
         // Obscure-ish special cases for mime types;
         // some .y files look like old image format data
         switch ($this->mimetype) {
index 169d609..89ae38d 100644 (file)
@@ -83,7 +83,7 @@ class MTrackWeb_Ticket extends MTrackWeb
             $this->showEditBar = true;
         }
          
+        $this->issue->images = $this->issue->images();
         
       
     }
@@ -180,6 +180,38 @@ class MTrackWeb_Ticket extends MTrackWeb
         $this->issue->updated = $CS->id;
         $this->issue->update($old);
         
+        
+        
+        
+        if (!empty($_FILES['attachments'])) {
+            foreach ($_FILES['attachments']['name'] as $fileid => $name) {
+                $i = DB_DataObject::factory('Images');
+                $i->associate($this->issue);
+                $i->ontable = $this->issue->tableName();
+                $i->onid = $this->issue->id;
+                $i->created_by = $this->authUser->id;
+                $i->mimetype = $_FILES['attachments']["type"][$fileid];
+                $i->createFrom($_FILES['attachments']['tmp_name'][$fileid],$_FILES['attachments']['name'][$fileid]);
+                
+                //    MTrackAttachment::add("ticket:{$this->issue->tid}",
+                //        $_FILES['attachments']['tmp_name'][$fileid],
+                //        $_FILES['attachments']['name'][$fileid],
+                //        $CS
+                //    );
+                //}
+            }
+        }
+        /*
+        if (!count($this->error) && $this->id != 'new') {
+            require_once 'MTrack/Attachment.php';
+            MTrackAttachment::process_delete("ticket:{$this->issue->tid}", $CS);
+        } 
+        */
+        
+        
+        
+        
+        
         $notify_query = "
                 (ontable='mtrack_ticket' and onid = {$this->issue->id})
                  OR
@@ -217,25 +249,7 @@ class MTrackWeb_Ticket extends MTrackWeb
         // if the owner has changed.. then we should add them to the watch list...
  
         // MTrackWatch::watch_object('ticket', $this->issue->tid,  $this->issue->owner);
-        /*         
-        if (!count($this->error)) {
-            if (!empty($_FILES['attachments'])) {
-                require_once 'MTrack/Attachment.php';
-                foreach ($_FILES['attachments']['name'] as $fileid => $name) {
-                      
-                    MTrackAttachment::add("ticket:{$this->issue->tid}",
-                        $_FILES['attachments']['tmp_name'][$fileid],
-                        $_FILES['attachments']['name'][$fileid],
-                        $CS
-                    );
-                }
-            }
-        }
-        if (!count($this->error) && $this->id != 'new') {
-            require_once 'MTrack/Attachment.php';
-            MTrackAttachment::process_delete("ticket:{$this->issue->tid}", $CS);
-        } 
-        */
+        
         $this->jok("OK");
         
     }
index f94690a..8762e7c 100644 (file)
@@ -472,10 +472,11 @@ pre {
 
 div#readonly-tkt-description {
   clear: both;
-  border: solid 1px #ccc;
-  min-width: 57em;
-  background-color: #ffc;
-  padding: 0.25em 0.5em 0.5em 0.5em;
+    border: solid 1px #9F2B33;
+    min-width: 57em;
+    background-color: #CEC;
+    padding: 0.25em 0.5em 0.5em 0.5em;
+    margin-bottom: 10px;
 }
 
 
index 348e6c8..eca445e 100644 (file)
@@ -25,7 +25,7 @@ fieldset.container-block-small input[type=file] {
    
 
 div.button-float {
-     background-color: #CC3;
+     background-color: #9F2B33;
     width: 100%;
    padding: 0;
    clear: both;
index c733fbd..4d159ee 100644 (file)
@@ -209,6 +209,26 @@ MTrack.register('.mtrack-ticket-comment .mtrack-make-comment', 'click', function
     MTrack.reportActiveURL = false;
     MTrack.ticketValues = false;  
     // reload the report..
+    
+    
+    MTrack.doFormUpload({
+        url: baseURL+'/Ticket/' + $(this.form).attr('id').split('-').pop(),
+        form : this.form,
+        scope : this,
+        success : function(o) {
+            
+            var res = jQuery.parseJSON( o.responseText );
+            if (!res.success) {
+                alert("Saving failed");
+                return;
+            }
+            
+
+            MTrack.ajaxLoad( MTrack.currentURL, true);
+        }
+     });
+
+    /*
     jQuery.ajax({
         url:  baseURL+'/Ticket/' + $('.mtrack-ticket-comment').attr('id').split('-').pop(),
         type : 'POST',
@@ -218,6 +238,7 @@ MTrack.register('.mtrack-ticket-comment .mtrack-make-comment', 'click', function
             
         }
     });
+    */
     
 });
 
@@ -245,3 +266,111 @@ MTrack.register('.ticketevent-expand', 'click', function() {
    
 })
 
+MTrack.urlDecode = function(string, overwrite){
+    if(!string || !string.length){
+        return {};
+    }
+    var obj = {};
+    var pairs = string.split('&');
+    var pair, name, value;
+    for(var i = 0, len = pairs.length; i < len; i++){
+        pair = pairs[i].split('=');
+        name = decodeURIComponent(pair[0]);
+        value = decodeURIComponent(pair[1]);
+        if(overwrite !== true){
+            if(typeof obj[name] == "undefined"){
+                obj[name] = value;
+            }else if(typeof obj[name] == "string"){
+                obj[name] = [obj[name]];
+                obj[name].push(value);
+            }else{
+                obj[name].push(value);
+            }
+        }else{
+            obj[name] = value;
+        }
+    }
+    return obj;
+};
+/**
+ * hack of Roo's upload form.
+ *
+ *
+MTrack.doFormUpload({
+    url: http://...
+    form : $(...)[0],
+    success : function() { }
+ })
+
+ *
+ */
+MTrack.doFormUpload_id = 0
+MTrack.doFormUpload = function(o){
+    var id = MTrack.doFormUpload_id++;
+    var frame = document.createElement('iframe');
+    frame.id = id;
+    frame.name = id;
+    //frame.className = 'x-hidden'; //<<<
+    frame.setAttribute('style', 'position:absolute;top:0;left:0;visibility:hidden;display:none;');
+    //if($.browser.msie){
+    //    frame.src = Roo.SSL_SECURE_URL;
+    //}
+    document.body.appendChild(frame);
+
+    if($.browser.msie){
+       document.frames[id].name = id;
+    }
+
+    var form = o.form;
+    form.target = id;
+    form.method = 'POST';
+    form.enctype = form.encoding = 'multipart/form-data';
+    if(o.url){
+        form.action = o.url;
+    }
+    
+    
+
+    function cb(){
+        var r = {  // bogus response object
+            responseText : '',
+            responseXML : null
+        };
+
+        r.argument = o ? o.argument : null;
+
+        try { //
+            var doc;
+            if($.browser.msie){
+                doc = frame.contentWindow.document;
+            }else {
+                doc = (frame.contentDocument || window.frames[id].document);
+            }
+            if(doc && doc.body){
+                r.responseText = doc.body.innerHTML;
+            }
+            if(doc && doc.XMLDocument){
+                r.responseXML = doc.XMLDocument;
+            }else {
+                r.responseXML = doc;
+            }
+        }
+        catch(e) {
+            // ignore
+        }
+        $(frame).unbind('load');
+        
+
+        //this.fireEvent("requestcomplete", this, r, o);
+        o.success.call( o.scope, r, o);
+        //o.callback.call( Roo.callback(o.callback, o.scope, [o, true, r]);
+
+        setTimeout(function(){document.body.removeChild(frame);}, 100);
+    }
+    $(frame).load(function() {
+        cb.call(this);
+        
+    });
+    form.submit();
+}
index 2e8ab43..aad6c06 100644 (file)
@@ -1,5 +1,10 @@
  
+<!--
+  This is the image viewer and comment ui
+  
+  The edit ui is in ticket_edit.html
 
+-->
 
 
 <div flexy:if="preview" class='ui-state-highlight ui-corner-all'>
             
         </div> 
         
-        {attachmentsToHtml(issue):h}
-    
+        
+        <div flexy:if="issue.images" class='attachment-list'><b>Attachments</b>
+            <ul>
+                <li flexy:foreach="issue.images,img"><a class='attachment' href="{img.URL(#-1#,#/Images/#)}">{img.filename}
+                    ({img.filesize}) added by {img.created_by_name} {img.created}</a>
+                    <br/>
+                     
+                    <a href="{img.URL(#-1#,#/Images/#)}">{img.toHTML(#150#):h}</a>
+                </li>
+            </ul>
+        </div> 
+     
+         
         <div id='readonly-tkt-description'>{issue.descriptionToHtml():h}</div>
             
         <div  class='button-float mtrack-view-editbar'>
index a07d322..65ae39e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -39,8 +39,11 @@ new HTML_FlexyFramework(array(
         'working_dir' => '/var/lib/mtrack', // this needs to be writable by web user..
         'email_address' => 'mtrack@roojs.com', // email address that spam comes from.
         'url' => 'http://www.roojs.com/mtrack/index.php', // url for the link on the emails.
+    ),
+    'Pman' => array(
+        // where the images go.
+       'storedir' => '/home/mtrack',
     )
-    
 ));