r4245: Auto commit for Debian build
[hyperobject.git] / views.lisp
index fadc3ba1736479d035975a40eab26c2bdbfb3593..795f079bc47cdc2a7601e6de99d6cd0afe8b9989 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: views.lisp,v 1.16 2002/12/13 12:23:17 kevin Exp $
+;;;; $Id: views.lisp,v 1.22 2003/03/25 06:45:57 kevin Exp $
 ;;;;
 ;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
 ;;;;
 
 
 (defclass object-view ()
-  ((object-class :initform nil :initarg :object-class :accessor object-class
-                :documentation "Name of class for object to be viewed.")
+  ((object-class-name :initform nil :initarg :object-class-name
+                     :accessor object-class-name
+                :documentation "Name of class of object to be viewed.")
+   (object-class :initform nil :initarg :object-class
+                :accessor object-class
+                :documentation "Class of object to be viewed.")
    (slots :initform nil :initarg :slots :accessor slots
          :documentation "List of effective slots for object to be viewed.")
    (name :initform nil :initarg :name :accessor name
        (aif (find category (views obj-class) :key #'category)
             it
             (let ((view
-                   (make-instance 'object-view :object-class (class-name obj-class)
+                   (make-instance 'object-view :object-class-name (class-name obj-class)
                                   :category category
                                   :slots slots)))
               (push view (views obj-class))
     ((eq view-def :default)
      (let* ((name (class-name cl))
            (view (make-instance 'object-view :name "automatic"
-                                :object-class name
+                                :object-class-name name
                                 :category :compact-text)))
        view))
     ((consp view-def)
 
 (defmethod initialize-instance :after ((view object-view)
                                       &rest initargs &key &allow-other-keys)
-  (initialize-view (find-class (object-class view)) view))
+  (initialize-view (object-class view) view))
   
 (defun initialize-view (obj-cl view)
   "Calculate all view slots for a hyperobject class"
     )
   )
 
+
 (defun initialize-view-by-category (obj-cl view)
   "Initialize a view based upon a preset category"
   (let ((fmtstr nil)
     (unless (in category :compact-text :compact-text-labels
                :html :html-labels :html-link-labels
                :xhtml :xhtml-labels :xhtml-link-labels
-               :xml :xml-labels :xml-link-labels)
+               :xml :xml-labels :xml-link :ie-xml-link
+               :xml-link-labels :ie-xml-link-labels)
       (error "Unknown view category ~A" category))
     
     (unless (slots view)
       (let ((slot (find-slot-by-name obj-cl slot-name)))
        (unless slot
          (error "Slot ~A is not found in class ~S" slot-name obj-cl))
-       (let ((name (slot-definition-name slot))
-             (namestr-lower (string-downcase (symbol-name (slot-definition-name slot))))
-             (type (slot-value slot 'type))
-             (print-formatter (esd-print-formatter slot)))
+       (let* ((name (slot-definition-name slot))
+              (namestr-lower (string-downcase (symbol-name name)))
+              (xml-namestr (escape-xml-string namestr-lower))
+              (xml-tag (escape-xml-string namestr-lower))
+              (type (slot-value slot 'type))
+              (print-formatter (esd-print-formatter slot)))
 
          (cond
            (first-field
              (:html-labels
               (string-append fmtstr (concatenate 'string "<span class=\"label\">" namestr-lower "</span> <span class=\"" namestr-lower "\">" value-fmt "</span>")))
              (:xhtml-labels
-              (string-append fmtstr (concatenate 'string "<span class=\"label\"><![CDATA[" namestr-lower "]]></span> <span class=\"" namestr-lower "\">" value-fmt "</span>")))
+              (string-append fmtstr (concatenate 'string "<span class=\"label\">" xml-namestr "</span> <span class=\"" namestr-lower "\">" value-fmt "</span>")))
              (:xml-labels
-              (string-append fmtstr (concatenate 'string "<label><[!CDATA[" namestr-lower "]]></label> <" namestr-lower ">" value-fmt "</" namestr-lower ">")))
+              (string-append fmtstr (concatenate 'string "<label>" xml-namestr "</label> <" xml-tag ">" value-fmt "</" xml-tag ">")))
              ((or :html-link :xhtml-link)
               (push name links)
               (if (esd-hyperlink slot)
                   (string-append fmtstr "<~~a>" value-fmt "</~~a>")
                   (string-append fmtstr (concatenate 'string "<span class=\"" namestr-lower "\">" value-fmt "</span>"))))
-             (:xml-link
+             ((or :xml-link :ie-xml-link)
               (push name links)
               (if (esd-hyperlink slot)
                   (string-append fmtstr "<~~a>" value-fmt "</~~a>")
-                  (string-append fmtstr (concatenate 'string "<" namestr-lower ">" value-fmt "</" namestr-lower ">"))))
+                  (string-append fmtstr (concatenate 'string "<" xml-tag ">" value-fmt "</" xml-tag ">"))))
              (:html-link-labels
               (push name links)
               (if (esd-hyperlink slot)
              (:xhtml-link-labels
               (push name links)
               (if (esd-hyperlink slot)
-                  (string-append fmtstr "<span class=\"label\"><[!CDATA[" namestr-lower "]]></span> <~~a>" value-fmt "</~~a>")
-                  (string-append fmtstr (concatenate 'string "<span class=\"label\"><![CDATA[" namestr-lower "]]></span> <span class=\"" namestr-lower "\">" value-fmt "</span>"))))
-             (:xml-link-labels
+                  (string-append fmtstr "<span class=\"label\">" xml-namestr "</span> <~~a>" value-fmt "</~~a>")
+                  (string-append fmtstr (concatenate 'string "<span class=\"label\">" xml-namestr "</span> <span class=\"" namestr-lower "\">" value-fmt "</span>"))))
+             ((or :xml-link-labels :ie-xml-link-labels)
               (push name links)
               (if (esd-hyperlink slot)
-                  (string-append fmtstr "<label><[![CDATA[" namestr-lower "]]></label> <~~a>" value-fmt "</~~a>")
-                  (string-append fmtstr (concatenate 'string "<label><![CDATA[" namestr-lower "]]></label> <" namestr-lower ">" value-fmt "</" namestr-lower ">")))))
+                  (string-append fmtstr "<label>" xml-namestr "</label> <~~a>" value-fmt "</~~a>")
+                  (string-append fmtstr (concatenate 'string "<label>" xml-namestr "</label> <" xml-tag ">" value-fmt "</" xml-tag ">")))))
            ) ;; let value-fmt
-         
+           
          (let ((func (if print-formatter
                  `(,print-formatter (slot-value x (quote ,name)))
                  `(slot-value x (quote ,name)))))
            (when (and (in category :xml :xhtml :xml-link :xhtml-link
+                          :xml-labels :ie-xml-labels
                           :xhtml-link-labels :xml-link-labels :ie-xml-link
                           :ie-xml-link-labels)
                       (or print-formatter
   (setf (list-end-indent view) t)
   (setf (list-end-fmtstr view) "</~a>~%")
   (setf (list-end-value-func view) #'xmlformat-list-end-value-func)
-  (setf (obj-start-fmtstr view) (format nil "<~(~a~)>" (object-class view)))
+  (setf (obj-start-fmtstr view) (format nil "<~(~a~)>" (object-class-name view)))
   (setf (obj-start-indent view) t)
-  (setf (obj-end-fmtstr view) (format nil "</~(~a~)>~%" (object-class view)))
+  (setf (obj-end-fmtstr view) (format nil "</~(~a~)>~%" (object-class-name view)))
   (setf (obj-end-indent view) nil)
   (setf (obj-data-indent view) nil))
 
 
 (defun fmt-comma-integer (i)
   (format nil "~:d" i))
-