(declaim (optimize (speed 0) (space 3) (safety 0)))
(in-package :lisp-on-lines)
;;;; I dont think i'm using these anymore.
(defun multiple-value-funcall->list (function &rest args)
"The function to be called by m-v-bf"
(multiple-value-call #'list (apply function args)))
(defmacro multiple-value-bindf (vars form &body body)
"Like M-V-B, only it works in actions. form must be a function call"
`(destructuring-bind ,vars
(multiple-value-funcall->list #',(car form) ,@(cdr form))
,@body))
;;;; ** Textarea Slot Presentation
(defslot-presentation text-slot-presentation ()
((rows :initarg :rows :accessor rows :initform 5)
(columns :initarg :columns :accessor columns :initform 40)
(escape-html-p :initarg :escape-html-p :accessor escape-html-p :initform nil)
(convert-newlines-p :initarg :convert-newlines-p :accessor convert-newlines-p :initform nil))
(:type-name text))
(defmethod present-slot ((slot text-slot-presentation) instance)
(flet ((maybe-convert-newline-and-escape-html-then-print ()
(let ((string (if (convert-newlines-p slot)
(with-output-to-string (new-string)
(with-input-from-string
(s (presentation-slot-value slot instance))
(loop for line = (read-line s nil)
while line
do (format new-string "~A~A" line "
"))))
(presentation-slot-value slot instance))))
(if (escape-html-p slot)
(<:as-html string)
(<:as-is string)))))
(if (editablep slot)
( " (foreign-instance slot) " from " instance )
(let* ((i (foreign-instance slot))
(pres (mewa::make-presentation
i
:type :one-line
:initargs (list
:global-properties
(list :editablep nil :linkedp nil)))))
(when (and (ucw::parent slot) (slot-boundp slot 'ucw::place))
(setf (component.place pres) (component.place (ucw::parent slot))))
(when i ( 0 (current slot))
;;what to do here is open to debate
(setf (current slot) (- (len slot)(number-to-display slot) ))))
(defmethod present-slot ((slot has-very-many-slot-presentation) instance)
;;(<:as-html "isance: " instance)
(if (slot-boundp slot 'ucw::place)
(progn
(>"))
(call-next-method)
(<:as-html "total :" (len slot)))
(call-next-method)))
(defmethod get-foreign-instances :around ((slot has-very-many-slot-presentation) instance)
(let ((f (call-next-method)))
(setf (len slot) (length f))
(setf (instances slot) f)
(loop for cons on (nthcdr (current slot) f)
for i from 0 upto (number-to-display slot)
collect (car cons))))
;;;; * Has-a
(defslot-presentation has-a-slot-presentation (mewa-relation-slot-presentation)
((allow-nil-p :accessor allow-nil-p :initarg :allow-nil-p :initform t)
(attributes :accessor attributes :initarg :attributes :initform nil))
(:type-name has-a))
(defmethod find-foreign-slot-value ((slot has-a-slot-presentation) (object t))
(multiple-value-bind (c s)
(meta-model:explode-foreign-key (instance (ucw::parent slot)) (slot-name slot))
(slot-value object s)))
(defmethod get-foreign-instances ((slot mewa-relation-slot-presentation) instance)
(clsql:select (class-name (class-of
(meta-model:explode-foreign-key instance (slot-name slot))))
:flatp t))
(defmethod present-slot ((slot has-a-slot-presentation) instance)
; (<:as-html (presentation-slot-value slot instance))
(if (editablep slot)
(progn (