Index: openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.adp,v diff -u -r1.11 -r1.12 --- openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.adp 14 Mar 2007 14:21:32 -0000 1.11 +++ openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.adp 29 Aug 2008 18:08:35 -0000 1.12 @@ -2,14 +2,15 @@ <head> <title>#acs-templating.HTMLArea_InsertLink#</title> +<if @richtextEditor@ eq "xinha"> <script type="text/javascript" src="/resources/acs-templating/xinha-nightly/popups/popup.js"> </script> <script type="text/javascript"> var selector_window; - window.resizeTo(450, 300); + // window.resizeTo(450, 300); function Init() { __dlg_init(); @@ -64,7 +65,40 @@ }; </script> +</if> +<if @richtextEditor@ eq "tinymce"> +<script language="javascript" type="text/javascript" src="/resources/acs-templating/tinymce/jscripts/tiny_mce/tiny_mce_popup.js"></script> +<script language="javascript" type="text/javascript" src="/resources/acs-templating/tinymce/jscripts/tiny_mce/utils/mctabs.js"></script> +<script language="javascript" type="text/javascript" src="/resources/acs-templating/tinymce/jscripts/tiny_mce/utils/form_utils.js"></script> +<script language="javascript" type="text/javascript" src="/resources/acs-templating/tinymce/jscripts/tiny_mce/utils/validate.js"></script> +<script language="javascript" type="text/javascript" src="/resources/acs-templating/tinymce/jscripts/tiny_mce/plugins/oacslink/jscripts/functions.js">\ +</script> + <base target="_self" /> + +<script> + function Init() { + + var param = window.dialogArguments; + // document.getElementById("f_href").focus(); + var f_href = document.getElementById("f_href"); + var url = f_href.value; + // alert ('url:' + url+ ' f_href:' + f_href.value); + if (url) { + // alert ('url is set calling insertAction'); + insertAction(); + } + + tinyMCEPopup.executeOnLoad('init();'); + + } + function onCancel() { + tinyMCEPopup.close(); + } +</script> + +</if> + <style type="text/css"> html, body { background: ButtonFace; @@ -114,32 +148,25 @@ <td class="form-widget"> </else> <fieldset> - <legend>#acs-templating.Link_Title#</legend> + <legend>#acs-templating.Title#</legend> <formwidget id="f_title"> <formerror id="f_title"> <div class="form-error">@formerror.f_title@</div> </formerror> </fieldset> - You can link to the above text to a URL or a file. Select one of the options below.<br /><br /> - <fieldset> - <legend>Link to a URL</legend> - <formwidget id="f_url"> - <formerror id="f_url"> - <div class="form-error">@formerror.f_url@</div> - </formerror> - <br /><formwidget id="url_ok_btn"> <button type="button" name="cancel" onclick="return onCancel();">#acs-templating.HTMLArea_action_cancel#</button> - </fieldset> + You can link to the above text to a file. Select one of the options below.<br /><br /> + <if @recent_files_options@ ne ""> <fieldset> <legend>#acs-templating.Choose_File#</legend> <formgroup id="choose_file"> <if @formgroup.rownum@ odd and @formgroup.rownum@ gt 1><br /></if> - @formgroup.widget;noquote@ @formgroup.label;noquote@ + @formgroup.widget;noquote@ <label for="upload_form:elements:choose_file:@formgroup.option@">@formgroup.label;noquote@</label> </formgroup> <formerror id="choose_file"> <div class="form-error">@formerror.choose_file@</div> </formerror> - <br /><formwidget id="select_btn"> <button type="button" name="cancel" onclick="return onCancel();">#acs-templating.HTMLArea_action_cancel#</button> + <br /><formwidget id="select_btn"> <input type="button" value="#acs-templating.HTMLArea_action_cancel#" name="cancel" onclick="javascript:onCancel();"></input> </fieldset> </if> </td> Index: openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl 13 Mar 2007 13:48:20 -0000 1.11 +++ openacs-4/packages/acs-templating/www/scripts/xinha/attach-file.tcl 29 Aug 2008 18:08:35 -0000 1.12 @@ -1,36 +1,38 @@ ad_page_contract { - Simple image upload, attach image to object_id passed in, if no + Simple file upload, attach image to object_id passed in, if no object_id, use the current package_id @author Guenter Ernst guenter.ernst@wu-wien.ac.at, @author Gustaf Neumann neumann@wu-wien.ac.at @author Dave Bauer (dave@solutiongrove.com) @creation-date 13.07.2004 @cvs-id $Id$ } { - {parent_id:integer} + {parent_id:integer,optional} + {package_id ""} {selector_type "file"} {f_href ""} } #HAM : ajax sources set js_source [ah::js_sources] -set package_id [ad_conn package_id] +set f_url "" -set user_id [ad_conn user_id] +set user_id [auth::require_login] + # if user has write permission, create image upload form, -set write_p [permission::permission_p \ - -party_id $user_id \ - -object_id $parent_id \ - -privilege "write"] -if {!$write_p} { - # item might not exist! + +if {![info exists parent_id]} { + set parent_id $user_id + set write_p 1 +} else { + set write_p [permission::permission_p \ -party_id $user_id \ - -object_id $package_id \ + -object_id $parent_id \ -privilege "write"] } -#ns_log notice "HAM : permission write_p : $write_p ************" + if {$write_p} { # set recent files set recent_files_options [list] @@ -61,7 +63,7 @@ -html { enctype multipart/form-data } \ -form { item_id:key - {package_id:text(hidden)} + {package_id:text(hidden),optional} {f_href:text(hidden),optional {html {id f_href}}} {f_title:text,optional {label "[_ acs-templating.Link_Title]"} {html {size 50 id f_title} } } {f_url:url,optional {label "[_ acs-templating.Link_Url]"} {html {size 50 id f_url } } } @@ -88,24 +90,27 @@ if { ![exists_and_not_null f_title] && [exists_and_not_null url_ok_btn] } { template::form::set_error upload_form f_title "Specify a [_ acs-templating.Link_Title]" } + set error_p 0 # check file name - if {$choose_file eq "" && $upload_file eq "" && $f_url eq ""} { - if { [info exists f_url] && $url_ok_btn ne ""} { + if { [info exists f_url] && $f_url eq "" && $url_ok_btn ne ""} { template::form::set_error upload_form f_url "Specify a [_ acs-templating.Link_Url]" + set error_p 1 } - if {[info exists ok_btn] && $ok_btn ne ""} { + if {[info exists ok_btn] && $ok_btn ne "" && $upload_file eq ""} { template::form::set_error upload_form upload_file \ [_ acs-templating.HTMLArea_SpecifyUploadFilename] + set error_p 1 } - if {[info exists select_btn]} { + if {[info exists select_btn] && $select_btn ne "" && $choose_file eq ""} { template::form::set_error upload_form choose_file \ [_ acs-templating.Attach_File_Choose_a_file] + set error_p 1 } set share site - set f_title "" - set f_href "" +# set f_title "" +# set f_href "" - } else { + if { !$error_p } { if {$upload_file ne ""} { # check quota # FIXME quota is a good idea, set per-user upload quota?? @@ -191,7 +196,7 @@ } } - if {$f_title eq ""} { + if {$f_title eq "" && [info exists file_name]} { element set_value upload_form f_title $file_name } @@ -218,4 +223,10 @@ set write_p 0 } +# default to xinha but tinymce will work too. no plugins for rte +set richtextEditor [parameter::get \ + -package_id $package_id \ + -parameter "RichTextEditor" \ + -default "xinha"] + set HTML_UploadTitle "" \ No newline at end of file Index: openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.adp,v diff -u -r1.7 -r1.8 --- openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.adp 23 Jan 2007 22:39:31 -0000 1.7 +++ openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.adp 29 Aug 2008 18:08:35 -0000 1.8 @@ -1,14 +1,16 @@ <html> <head> - <title>#acs-templating.HTMLArea_InsertImageTitle#</title> +<title>#acs-templating.HTMLArea_InsertImageTitle#</title> -<script type="text/javascript" src="/resources/acs-templating/xinha-nightly/popups/popup.js"></script> - -@js_source;noquote@ +<if @richtextEditor@ eq "xinha"> +<script type="text/javascript" src="/resources/acs-templating/tinymce/popups/popup.js"></script> +</if> +<if @richtextEditor@ eq "xinha"> + <script type="text/javascript"> var selector_window; - window.resizeTo(415, 300); + // window.resizeTo(415, 300); function Init() { __dlg_init(); @@ -30,7 +32,7 @@ onOK(); __dlg_close(null); } else { - initCarousel_html_carousel(); + // initCarousel_html_carousel(); } }; @@ -119,7 +121,40 @@ } </script> +</if> +<if @richtextEditor@ eq "tinymce"> +<script language="javascript" type="text/javascript" src="/resources/acs-templating/tinymce/jscripts/tiny_mce/tiny_mce_popup.js"></script> +<script language="javascript" type="text/javascript" src="/resources/acs-templating/tinymce/jscripts/tiny_mce/plugins/oacsimage/jscripts/functions.js"></script> +<base target="_self" /> + +<script> +function Init() { + var param = window.dialogArguments; + + var f_url = document.getElementById("f_url"); + var url = f_url.value; + + if (url) { + // alert ('url is set calling insertAction'); + insertAction(); + } else { + // HAM : 060707 + // added setWindowArg to prevent tineMCEPopup from mangling + // the body.innerHTML, don't need it for this plugin + // besides it messes up the carousel on IE + tinyMCE.setWindowArg('mce_replacevariables', false); + + tinyMCEPopup.executeOnLoad('init(); initCarousel_html_carousel();'); + } +} +function onCancel() { + tinyMCEPopup.close(); +} + +</script> +</if> + <style type="text/css"> html, body { background: ButtonFace; @@ -185,25 +220,77 @@ #prev-arrow { cursor:pointer; } + + /* Overlay */ + #overlay { + width: 200px; + height: 80px; + background-color: #FFF; + position: absolute; + top: 25px; + left: 80px; + padding-top: 10px; + z-index: 100; + color: #000; + border:1px dotted #000; + text-align: center; + font-size: 24px; + filter:alpha(opacity=80); + -moz-opacity: 0.8; + opacity: 0.8; + } </style> +@js_source;noquote@ + <link href="/resources/ajaxhelper/carousel/carousel.css" media="all" rel="Stylesheet" type="text/css" /> <script src="/resources/ajaxhelper/carousel/carousel.js" type="text/javascript"></script> +<script type="text/javascript"> +var carousel; + +var buttonStateHandler = function (button, enabled) { + if (button == "prev-arrow") { + $('prev-arrow').src = enabled ? "/resources/ajaxhelper/carousel/left-enabled.gif" : "/resources/ajaxhelper/carousel/left-disabled.gif" + } else { + $('next-arrow').src = enabled ? "/resources/ajaxhelper/carousel/right-enabled.gif" : "/resources/ajaxhelper/carousel/right-disabled.gif" + } +} + +var ajaxHandler = function (carousel, status) { + var overlay = $('overlay'); + if (status == "before") { + if (overlay) { + overlay.setOpacity(0); + overlay.show(); + Effect.Fade(overlay, {from: 0, to: 0.8, duration: 0.2}) + } else { + new Insertion.Top("html-carousel", "<div id='overlay' ><br>Loading...<br><img src='/resources/ajaxhelper/images/indicator.gif'></div>"); + } + } else { + Effect.Fade(overlay, {from: 0.8, to: 0.0, duration: 0.2}) + } +} + +function initCarousel_html_carousel() { + carousel = new Carousel('html-carousel', {ajaxHandler:ajaxHandler, animParameters:{duration:0.5}, buttonStateHandler:buttonStateHandler, nextElementID:'next-arrow', prevElementID:'prev-arrow', url:'/acs-templating/xmlhttp/carousel-images'}) +} + +</script> + </head> <body onload="Init()"> -<!-- @parent_id@ --> <div id="insert_image_upload"> <table border="0" style="margin: 0 auto; text-align: left;padding: 0px;" width="100%"> <tbody> <td valign="top"> <if @write_p@ eq 1> - <legend><b>@HTML_UploadTitle@</b></legend> - <formtemplate id="upload_form"> - <input type="hidden" name="f_url" id="f_url" value="@f_url@"/> + + <formtemplate id="upload_form" style="attach-image-form"> + <input type="hidden" name="f_url" id="f_url" value="@f_url@"/> <table cellspacing="2" cellpadding="2" border="0"> <tr class="form-group"> <if @formerror.upload_file@ not nil> @@ -220,11 +307,11 @@ <table border=0 cellpadding=0 cellspacing=0 width="330px"> <tr><td> <div id="prev-arrow-container"> - <img id="prev-arrow" class="left-button-image" src="/resources/ajaxhelper/carousel/left-enabled.gif"/> + <img id="prev-arrow" class="left-button-image" src="/resources/ajaxhelper/carousel/left-disabled.gif"/> </div> </td><td> <div id="next-arrow-container" > - <img id="next-arrow" class="right-button-image" src="/resources/ajaxhelper/carousel/right-enabled.gif"/> + <img id="next-arrow" class="right-button-image" src="/resources/ajaxhelper/carousel/right-disabled.gif"/> </div> </td></tr> </table> @@ -234,47 +321,12 @@ <td align="center"> <div class="carousel-component" id="html-carousel"> <div class="carousel-clip-region"> - <ul class="carousel-list"> - <formgroup id="choose_file"> - <li> - <img src="/image/@formgroup.option@/thumbnail" onclick="document.getElementById('upload_form:elements:choose_file:@formgroup.option@').click()" /><br / >@formgroup.widget;noquote@ - <formerror id="upload_file"> - <div class="form-error"><br />@formerror.upload_file@</div> - </formerror> - </li> - </formgroup> - </ul> - </div> + <ul class="carousel-list"></ul> + </div> </div> - - <script type="text/javascript"> - - function initCarousel_html_carousel() { - carousel = new Carousel('html-carousel', {numVisible:1,scrollInc:3,animHandler:animHandler, animParameters:{duration:0.5}, buttonStateHandler:buttonStateHandler, nextElementID:'next-arrow', prevElementID:'prev-arrow', size:@recent_images:rowcount@}) - } - - function buttonStateHandler(button, enabled) { - if (button == "prev-arrow") { - $('prev-arrow').src = enabled ? "/resources/ajaxhelper/carousel/left-enabled.gif" : "/resources/ajaxhelper/carousel/left-disabled.gif" - } else { - $('next-arrow').src = enabled ? "/resources/ajaxhelper/carousel/right-enabled.gif" : "/resources/ajaxhelper/carousel/right-disabled.gif" - } - } - - function animHandler(carouselID, status, direction) { - var region = $(carouselID).down(".carousel-clip-region") - if (status == "before") { - Effect.Fade(region, {to: 0.3, queue: { position:'end', scope: "carousel" }, duration: 0.2}) - } - if (status == "after") { - Effect.Fade(region, {to: 1, queue: { position:'end', scope: "carousel" }, duration: 0.2}) - } - } - - </script> </td></tr> <tr><td> - <formwidget id="select_btn"> <button type="button" name="cancel" onclick="return onCancel();">#acs-templating.HTMLArea_action_cancel#</button> + <formwidget id="select_btn"> <input type="button" name="cancel" value="#acs-templating.HTMLArea_action_cancel#" onclick="javascript:onCancel();"></input> </td></tr> </table> </fieldset> @@ -303,7 +355,7 @@ <formerror id="share"> <div class="form-error">@formerror.share@</div> </formerror> - <br /><formwidget id="upload_btn"> <button type="button" name="cancel" onclick="return onCancel();">#acs-templating.HTMLArea_action_cancel#</button> + <br /><formwidget id="upload_btn"> <input type="button" name="cancel" value="#acs-templating.HTMLArea_action_cancel#" onclick="javascript:onCancel();"></input> </fieldset> </td> </tr> Index: openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.tcl 21 Dec 2006 15:12:39 -0000 1.7 +++ openacs-4/packages/acs-templating/www/scripts/xinha/attach-image.tcl 29 Aug 2008 18:08:35 -0000 1.8 @@ -7,8 +7,8 @@ @creation-date 13.07.2004 @cvs-id $Id$ } { - {parent_id:integer} - {package_id:integer} + {parent_id:integer,optional} + {package_id ""} {selector_type "image"} } @@ -17,15 +17,27 @@ set f_url "" -set user_id [ad_conn user_id] +set user_id [auth::require_login] # if user has write permission, create image upload form, -set write_p [permission::permission_p \ - -party_id $user_id \ - -object_id $parent_id \ - -privilege "write"] +if {![info exists parent_id]} { + set parent_id $user_id + set write_p 1 +} else { + + set write_p [permission::permission_p \ + -party_id $user_id \ + -object_id $parent_id \ + -privilege "write"] +} + if {!$write_p} { + # if parent_id does not exist yet, let's use the pacakage_id + if { ![db_0or1row "check_parent" "select object_id from acs_objects where object_id=:parent_id"] } { + set parent_id $package_id + } + # item might not exist! set write_p [permission::permission_p \ -party_id $user_id \ @@ -37,21 +49,21 @@ if {$write_p} { # set recent images - db_multirow -unclobber recent_images recent_images \ - { - select ci.item_id, ci.name - from cr_items ci, cr_revisionsx cr, cr_child_rels ccr - where ci.live_revision=cr.revision_id - and ci.content_type='image' - and cr.creation_user=:user_id - and ccr.parent_id=ci.item_id - and ccr.relation_tag='image-thumbnail' - order by creation_date desc - limit 6 - } { - set name [regsub "${item_id}_" $name ""] - lappend recent_images_options [list $name $item_id] - } + # db_multirow -unclobber recent_images recent_images \ + # { + # select ci.item_id, ci.name + # from cr_items ci, cr_revisionsx cr, cr_child_rels ccr + # where ci.live_revision=cr.revision_id + # and ci.content_type='image' + # and cr.creation_user=:user_id + # and ccr.parent_id=ci.item_id + # and ccr.relation_tag='image-thumbnail' + # order by creation_date desc + # limit 6 + # } { + # set name [regsub "${item_id}_" $name ""] + # lappend recent_images_options [list $name $item_id] + # } @@ -61,14 +73,14 @@ -name upload_form \ -mode edit \ -export {selector_type file_types parent_id} \ - -html { enctype multipart/form-data } \ + -html { enctype multipart/form-data } \ -form { item_id:key - {package_id:text(hidden)} - {choose_file:text(radio),optional {options $recent_images_options}} + {package_id:text(hidden),optional} + {choose_file:text(radio),optional {options $recent_images_options}} {upload_file:file(file),optional {html {size 30}} } {share:text(radio),optional {label "[_ acs-templating.This_image_can_be_reused_by]"} {options $share_options} {help_text "[_ acs-templating.This_image_can_be_reused_help]"}} - {select_btn:text(submit) {label "[_ acs-templating.Add_the_selected_image]"}} + {select_btn:text(submit) {label "[_ acs-templating.Add_the_selected_image]"}} {upload_btn:text(submit) {label "[_ acs-templating.HTMLArea_SelectUploadBtn]"} } } \ @@ -171,6 +183,11 @@ } else { set write_p 0 } +# default to xinha but tinymce will work too. no plugins for rte +set richtextEditor [parameter::get \ + -package_id [ad_conn package_id] \ + -parameter "RichTextEditor" \ + -default "xinha"] set HTML_Preview "Preview" set HTML_UploadTitle ""