From cd1794b35e8d6e8296875e8d2376718e26e5109f Mon Sep 17 00:00:00 2001 From: Christian Fowler Date: Sun, 20 May 2007 19:45:06 +0000 Subject: migrate to new ajax-ified structure editing. work in progress, currently uses ThickBox, will likely remove. checkout beware\! --- add_structure_content.php | 29 ++++++++++++++++ edit_structure_inc.php | 16 ++++++--- modules/mod_structure_toc.php | 4 ++- templates/add_structure_content.tpl | 58 ++++++++++++++++++++++++++++++++ templates/add_structure_feedback_inc.tpl | 1 + templates/edit_structure.tpl | 51 +++++++++++++++++++++++++--- 6 files changed, 149 insertions(+), 10 deletions(-) create mode 100644 add_structure_content.php create mode 100644 templates/add_structure_content.tpl create mode 100644 templates/add_structure_feedback_inc.tpl diff --git a/add_structure_content.php b/add_structure_content.php new file mode 100644 index 0000000..d4e2004 --- /dev/null +++ b/add_structure_content.php @@ -0,0 +1,29 @@ +mConfig['site_top_bar'] = FALSE; + $gBitSystem->mConfig['site_left_column'] = FALSE; + $gBitSystem->mConfig['site_right_column'] = FALSE; + $gBitSmarty->assign( 'popupPage', '1' ); +} + +require_once( LIBERTY_PKG_PATH.'lookup_content_inc.php' ); +require_once( LIBERTY_PKG_PATH.'edit_structure_inc.php' ); + +error_log( print_r( $_REQUEST, TRUE ) ); + +if( $gBitSystem->isAjaxRequest() ) { + header( 'Content-Type: text/html; charset=utf-8' ); + print $gBitSmarty->fetch( "bitpackage:liberty/add_structure_feedback_inc.tpl" ); + exit; +} else { + if( !$gBitSystem->loadAjax( 'mochikit', array( 'Iter.js', 'DOM.js', 'Format.js', 'Style.js', 'Signal.js', 'Logging.js', 'ThickBox.js' ) ) ) { + // do something.... + } + $gBitSystem->display( 'bitpackage:liberty/add_structure_content.tpl', "Add Content" ); +} + +?> diff --git a/edit_structure_inc.php b/edit_structure_inc.php index 3f398d3..13c8dde 100644 --- a/edit_structure_inc.php +++ b/edit_structure_inc.php @@ -3,7 +3,7 @@ * edit_structure_inc * * @author Christian Fowler> - * @version $Revision: 1.19 $ + * @version $Revision: 1.20 $ * @package liberty * @subpackage functions */ @@ -19,6 +19,8 @@ require_once( '../bit_setup_inc.php' ); include_once( LIBERTY_PKG_PATH.'LibertyStructure.php'); $gBitSmarty->assign_by_ref( 'feedback', $feedback = array() ); +$gBitSystem->loadAjax( 'mochikit', array( 'Iter.js', 'DOM.js', 'Format.js', 'Style.js', 'Signal.js', 'Logging.js', 'ThickBox.js', 'Controls.js' ) ); + if( !@BitBase::verifyId( $_REQUEST["structure_id"] ) ) { $gBitSystem->fatalError( tra( "No structure indicated" )); } else { @@ -123,13 +125,19 @@ if( !@BitBase::verifyId( $_REQUEST["structure_id"] ) ) { } elseif(!empty($_REQUEST['content'])) { foreach ($_REQUEST['content'] as $conId ) { $structureHash['content_id'] = $conId; - $new_structure_id = $gStructure->storeNode( $structureHash ); - $structureHash['after_ref_id'] = $new_structure_id; + if( $new_structure_id = $gStructure->storeNode( $structureHash ) ) { + $structureHash['after_ref_id'] = $new_structure_id; + $feedback['success'] = tra( "Items added." ); + } else { + $feedback['failure'] = $gStructure->mErrors; + } } } } - $gBitSmarty->assign('subtree', $rootTree = $rootStructure->getSubTree( $rootStructure->mStructureId )); + $rootTree = $rootStructure->getSubTree( $rootStructure->mStructureId ); + $gBitSmarty->assign('subtree', $rootTree); + $gBitSmarty->assign_by_ref('feedback', $feedback); } ?> diff --git a/modules/mod_structure_toc.php b/modules/mod_structure_toc.php index 3f36042..f109a62 100644 --- a/modules/mod_structure_toc.php +++ b/modules/mod_structure_toc.php @@ -1,5 +1,5 @@ isValid() $structures = $gContent->getStructures(); // We take the first structure. not good, but works for now - spiderr if( !empty( $structures[0] ) ) { + require_once( LIBERTY_PKG_PATH.'LibertyStructure.php' ); $struct = new LibertyStructure( $structures[0]['structure_id'] ); + $struct->load(); } } else { $struct = &$gStructure; diff --git a/templates/add_structure_content.tpl b/templates/add_structure_content.tpl new file mode 100644 index 0000000..d032e4f --- /dev/null +++ b/templates/add_structure_content.tpl @@ -0,0 +1,58 @@ + +{strip} + +
+ +
+ {form legend="Add Content" id="structureaddform"} + + + + {if $subtree} +
+ {formlabel label="After page" for="after_ref_id"} + {forminput} + + {formhelp note=""} + {/forminput} +
+ {/if} + +
+ {formlabel label="Search" for="lib-content"} + {forminput} + + {formhelp note=""} + {/forminput} +
+ +
+ {forminput} + {html_options onchange="submit();" options=$contentTypes name=content_type_guid selected=$contentSelect} + {/forminput} + + {forminput} + {html_options multiple="multiple" id="lib-content" size="12" name="content[]" values=$contentList options=$contentList} + {/forminput} +
+ +
foo submit
+ +
+ +
+ {/form} +
+ +
+ +
+
+{/strip} diff --git a/templates/add_structure_feedback_inc.tpl b/templates/add_structure_feedback_inc.tpl new file mode 100644 index 0000000..5534b67 --- /dev/null +++ b/templates/add_structure_feedback_inc.tpl @@ -0,0 +1 @@ +{formfeedback hash=$feedback} diff --git a/templates/edit_structure.tpl b/templates/edit_structure.tpl index 3a1aaa8..a2b14fe 100644 --- a/templates/edit_structure.tpl +++ b/templates/edit_structure.tpl @@ -3,6 +3,49 @@ {if !$structureName} {assign var=structureName value="Structure"} {/if} + +{literal} + +{* + +
+ +*} + +{/literal} + +{if $gBitSystem->mAjax=='mochikit'} +{literal} + +{/literal} + +
+
+ {$gContent->getContentTypeDescription()} {tr}Structure{/tr} +
+ {forminput} +Add Content + {include file="bitpackage:liberty/edit_structure_inc.tpl"} + {/forminput} +
+ +{else} + {jstabs} {jstab title="`$structureName` Organization"} {include file="bitpackage:liberty/edit_structure_inc.tpl"} @@ -12,10 +55,8 @@ {include file="bitpackage:liberty/edit_structure_content.tpl"} {/jstab} {/if} -{* removing alias stuff until we know what to do with it - XING - {jstab title="Update Alias"} - {include file="bitpackage:liberty/edit_structure_alias.tpl"} - {/jstab} -*} {/jstabs} + +{/if} + {/strip} -- cgit v1.3