From 6fa01c9bcc8e0b2d7cdbc0df1a6681180ccbe6b4 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 25 Feb 2015 13:15:54 -0500 Subject: [PATCH] Enable sorting of the member courses Adding same functions from the photo positioning to the member courses. --- .htaccess | 1 + Toolkit/Members.php | 4 + Toolkit/Members/Admin/EditCourses.php | 1 + Toolkit/Members/Admin/EditPhoto.php | 440 ++++++++++---------- Toolkit/Members/Photos.php | 362 ++++++++-------- Toolkit/Members/libjs/edit-member-course.js | 39 +- Toolkit/Members/libjs/edit-member-photos.js | 106 ++--- Toolkit/Members/sortCourses.php | 55 +++ Toolkit/Members/sortPhotos.php | 46 +- Toolkit/Members/templates/editCourse.tpl | 3 +- 10 files changed, 575 insertions(+), 482 deletions(-) create mode 100644 Toolkit/Members/sortCourses.php diff --git a/.htaccess b/.htaccess index 686c716..c7ab1b8 100644 --- a/.htaccess +++ b/.htaccess @@ -63,6 +63,7 @@ RewriteRule ^([A-Za-z0-9_-]*)/member-db-google-map/$ Toolkit/Members/memberDBGoo RewriteRule ^member-file/([0-9]*)/([0-9]*)/$ Toolkit/Members/memberFileDownload.php?mid=$1&fid=$2 [L] # Ajax call for saving photo repositioning RewriteRule ^member-save-photos/$ Toolkit/Members/sortPhotos.php [QSA,L] +RewriteRule ^member-save-courses/$ Toolkit/Members/sortCourses.php [QSA,L] RewriteRule ^memberdb-site-map index.php?catid=0&memberDbSiteMap=1 [L] RewriteRule ^map/([0-9A-F]{6})/([0-9]*).png Toolkit/Maps/marker.php?color=$1&text=$2 [L] diff --git a/Toolkit/Members.php b/Toolkit/Members.php index ea5bdb3..582d034 100644 --- a/Toolkit/Members.php +++ b/Toolkit/Members.php @@ -248,8 +248,12 @@ class Toolkit_Members break; case 'courses' : + $GLOBALS['styleSheets'][] + = JQUERY_UI_CDN_CSS . ''; $GLOBALS['bottomScripts'][] = CKEDITOR_JS . ''; + $GLOBALS['bottomScripts'][] + = MEDIA_APP_BASE_URL . 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js'; $GLOBALS['bottomScripts'][] = MEDIA_BASE_URL . 'Toolkit/Members/libjs/edit-member-course.js'; diff --git a/Toolkit/Members/Admin/EditCourses.php b/Toolkit/Members/Admin/EditCourses.php index fc2ba32..520a384 100644 --- a/Toolkit/Members/Admin/EditCourses.php +++ b/Toolkit/Members/Admin/EditCourses.php @@ -1356,6 +1356,7 @@ class EditAdminCourse extends Toolkit_FormBuilder $this->accept($renderer); $this->view = new stdClass(); + $this->view->courseId = $this->courseId; $this->view->showCurrImg = $this->showCurrImg; $this->view->form = $renderer->toObject(); $tEngine->compile($this->formTemplate); diff --git a/Toolkit/Members/Admin/EditPhoto.php b/Toolkit/Members/Admin/EditPhoto.php index 24bb215..7a923bb 100644 --- a/Toolkit/Members/Admin/EditPhoto.php +++ b/Toolkit/Members/Admin/EditPhoto.php @@ -1,5 +1,5 @@ dbh = $pdo; - $this->photoId = $attributes['id']; + $this->photoId = $attributes['id']; $this->photos = $ll; - } - - // }}} - - // {{{ configureDefaults() - - /** - * Sets the defaults for elements in the form. - * - * @return void - * @access public - */ - public function configureDefaults() - { - $photo = $this->photos->findNode($this->photoId); - $defaults = array( - 'caption' => $photo->getCaption(), - 'pos' => $photo->getPosition(), - 'pid' => $photo->getId(), - ); - $this->setupDefaults($defaults); - } - - // }}} - // {{{ configureElements() - - /** - * Setup the elements to use on the form. - * + } + + // }}} + + // {{{ configureDefaults() + + /** + * Sets the defaults for elements in the form. + * + * @return void + * @access public + */ + public function configureDefaults() + { + $photo = $this->photos->findNode($this->photoId); + $defaults = array( + 'caption' => $photo->getCaption(), + 'pos' => $photo->getPosition(), + 'pid' => $photo->getId(), + ); + $this->setupDefaults($defaults); + } + + // }}} + // {{{ configureElements() + + /** + * Setup the elements to use on the form. + * * @param Config_Container $c application configuration - * - * @return void - * @access public - */ - public function configureElements(Config_Container $c) - { - $positions = range(1, $this->photos->getListSize(true)); - $options = array_combine($positions, $positions); + * + * @return void + * @access public + */ + public function configureElements(Config_Container $c) + { + $positions = range(1, $this->photos->getListSize(true)); + $options = array_combine($positions, $positions); $config =& $c->getItem('section', 'photos'); $maxLength =& $config->getItem('directive', 'maxCaptionLength'); - // All Grouped Elements are created here. - - // All Elements are created here. This includes group element definitions. - $cur = $this->photos->findNode($this->photoId); - - $elements[] = array( - 'type' => 'hidden', - 'req' => false, - 'name' => 'pid' - ); - $elements[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'caption', + // All Grouped Elements are created here. + + // All Elements are created here. This includes group element definitions. + $cur = $this->photos->findNode($this->photoId); + + $elements[] = array( + 'type' => 'hidden', + 'req' => false, + 'name' => 'pid' + ); + $elements[] = array( + 'type' => 'text', + 'req' => false, + 'name' => 'caption', 'display' => 'Image Caption', - 'opts' => array( - 'class' => 'text', - 'maxlength' => $maxLength->getContent(), - ), + 'opts' => array( + 'class' => 'text', + 'maxlength' => $maxLength->getContent(), + ), 'noCharLimit' => true - ); - $elements[] = array( - 'type' => 'select', - 'req' => false, - 'name' => 'pos', - 'display' => 'Position', - 'opts' => $options, - 'att' => array('id' => "pos{$cur->getPosition()}") - ); - $elements[] = array( - 'type' => 'submit', - 'req' => false, - 'name' => 'update', - 'display' => 'Update Photo', - 'opts' => array('class' => 'submit') - ); - $elements[] = array( - 'type' => 'submit', - 'req' => false, - 'name' => 'delete', - 'display' => 'Delete Photo', - 'opts' => array('class' => 'photoDelete') - ); - - $this->setupElements($elements); - } - - // }}} + ); + $elements[] = array( + 'type' => 'select', + 'req' => false, + 'name' => 'pos', + 'display' => 'Position', + 'opts' => $options, + 'att' => array('id' => "pos{$cur->getPosition()}") + ); + $elements[] = array( + 'type' => 'submit', + 'req' => false, + 'name' => 'update', + 'display' => 'Update Photo', + 'opts' => array('class' => 'submit') + ); + $elements[] = array( + 'type' => 'submit', + 'req' => false, + 'name' => 'delete', + 'display' => 'Delete Photo', + 'opts' => array('class' => 'photoDelete') + ); + + $this->setupElements($elements); + } + + // }}} // {{{ configureForm() /** - * helper function to set up entire form definition - * + * helper function to set up entire form definition + * * @param Config_Container $c application configuration - * - * @return void - * @access public + * + * @return void + * @access public */ public function configureForm(Config_Container $c) { $this->configureElements($c); $this->configureDefaults(); - $this->configureRules($c); + $this->configureRules($c); } // }}} - // {{{ configureRules() + // {{{ configureRules() /** * Configures any rules we want to use on the form - * + * * @param Config_Container $c application configuration * * @access public * @return void */ - public function configureRules(Config_Container $c) - { - $r = array(); + public function configureRules(Config_Container $c) + { + $r = array(); $config =& $c->getItem('section', 'photos'); $maxLength =& $config->getItem('directive', 'maxCaptionLength'); - $r[] = array( - 'element' => 'caption', - 'message' => "ERROR: Please limit caption to {$maxLength->getContent()} characters!", - 'type' => 'maxlength', - 'format' => $maxLength->getContent(), - 'validation' => $this->validationType, - 'reset' => false, - 'force' => false - ); - $this->setupRules($r); - } - - // }}} - - // {{{ processData() - - /** - * Handles setting up the from processing and which function to get it done - * - * @param array $values submitted values from the form - * - * @return array Submitted values from the form. - * @access protected - */ - protected function processData($values) - { - if (!$this->getSubmitValue('delete')) { + $r[] = array( + 'element' => 'caption', + 'message' => "ERROR: Please limit caption to {$maxLength->getContent()} characters!", + 'type' => 'maxlength', + 'format' => $maxLength->getContent(), + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); + $this->setupRules($r); + } + + // }}} + + // {{{ processData() + + /** + * Handles setting up the from processing and which function to get it done + * + * @param array $values submitted values from the form + * + * @return array Submitted values from the form. + * @access protected + */ + protected function processData($values) + { + if (!$this->getSubmitValue('delete')) { unset($values['update']); $photo = $this->photos->findNode($values['pid']); try { - // This value might be removed by JS so make sure - // its in place before you try to update the positions + // This value might be removed by JS so make sure + // its in place before you try to update the positions // - // This is taken out in JS instead of just hiding it - // b/c if the image gets dragged and repositioned, - // and then the caption is updated, the old positions - // in the hidden select list will override all the - // newly positioned photos. - // This value might be removed by JS so make sure - // its in place before you try to update the positions + // This is taken out in JS instead of just hiding it + // b/c if the image gets dragged and repositioned, + // and then the caption is updated, the old positions + // in the hidden select list will override all the + // newly positioned photos. + // This value might be removed by JS so make sure + // its in place before you try to update the positions $this->dbh->beginTransaction(); if (isset($values['pos']) && $values['pos'] != $photo->getPosition()) { $this->photos->moveNode($photo->getId(), $values['pos']); @@ -311,14 +311,14 @@ class Toolkit_Members_Admin_EditPhoto extends Toolkit_FormBuilder $this->dbh->rollback(); return Toolkit_Common::handleError($e); } - } + } header('Location:' . $this->getAttribute('action')); - } + } - // }}} + // }}} - // {{{ setupRenderers() + // {{{ setupRenderers() /** * Set up the rendering engine we are going to use to display this form @@ -328,60 +328,60 @@ class Toolkit_Members_Admin_EditPhoto extends Toolkit_FormBuilder * @return void * @access protected */ - protected function setupRenderers(HTML_Template_Flexy $tEngine) - { - $renderer = new HTML_QuickForm_Renderer_ObjectFlexy($tEngine); - - $this->accept($renderer); - $this->view = new stdClass(); - $this->view->photoId = $this->photoId; - $this->view->form = $renderer->toObject(); - $photo = $this->photos->findNode($this->photoId); - $this->view->pending = $photo->getPending(); - $this->view->img_alt = $photo->getCaption(); - $this->view->img_src = MEMBER_PHOTOS . $photo->getImage(); - $tEngine->compile($this->formTemplate); - } - - // }}} - - // {{{ toHtml() - - /** - * Renders the form - * - * sets the page the form should be redirected to instead of coming back - * around to itself. - * + protected function setupRenderers(HTML_Template_Flexy $tEngine) + { + $renderer = new HTML_QuickForm_Renderer_ObjectFlexy($tEngine); + + $this->accept($renderer); + $this->view = new stdClass(); + $this->view->photoId = $this->photoId; + $this->view->form = $renderer->toObject(); + $photo = $this->photos->findNode($this->photoId); + $this->view->pending = $photo->getPending(); + $this->view->img_alt = $photo->getCaption(); + $this->view->img_src = MEMBER_PHOTOS . $photo->getImage(); + $tEngine->compile($this->formTemplate); + } + + // }}} + + // {{{ toHtml() + + /** + * Renders the form + * + * sets the page the form should be redirected to instead of coming back + * around to itself. + * * @param HTML_Template_Flexy $tEngine Templating Engine * @param Cache_Lite $cache Caching Engine * @param Toolkit_Image_Server $is Image Server * @param Config_Container $c Application configuration * - * @return string The rendered form - * @access public - */ - public function toHtml( + * @return string The rendered form + * @access public + */ + public function toHtml( HTML_Template_Flexy $tEngine, Cache_Lite $cache, Toolkit_Image_Server $is, Config_Container $c ) { - if ($this->validate()) { + if ($this->validate()) { $res = $cache->remove("Member-{$_GET['id']}", 'Profile'); if ($this->getSubmitValue('delete')) { $this->photos->removeNode($is, $c, $this->getSubmitValue('pid')); } - $this->process(array(&$this, 'processData'), $this->mergeFiles); - } + $this->process(array(&$this, 'processData'), $this->mergeFiles); + } - $this->setupRenderers($tEngine); + $this->setupRenderers($tEngine); - return $tEngine->bufferedOutputObject($this->view); - } + return $tEngine->bufferedOutputObject($this->view); + } - // }}} + // }}} } ?> diff --git a/Toolkit/Members/Photos.php b/Toolkit/Members/Photos.php index c5cfb42..4834bbf 100644 --- a/Toolkit/Members/Photos.php +++ b/Toolkit/Members/Photos.php @@ -1,5 +1,5 @@ setMember($mid); + parent::__construct($root); + $this->setMember($mid); /* - if (is_numeric($mid)) { - $this->createMemberList($mid); - } + if (is_numeric($mid)) { + $this->createMemberList($mid); + } */ - } + } - // }}} + // }}} - // {{{ createMemberList() + // {{{ createMemberList() /** * Creates a linked list from all the photos a member has in the db. @@ -80,111 +80,111 @@ class Toolkit_Members_Photos extends Structures_LinkedList_Double * @param PDO $dbh PHP Data Object * @param Config_Container $c Member configuration * @param string $order The order to make the linked list in - * + * * @return boolean false on error * @access public */ - public function createMemberList( + public function createMemberList( PDO $dbh, Config_Container $c, $order = 'pos' ) { - if (!ctype_digit((string) $this->mid)) { - return; - } + if (!ctype_digit((string) $this->mid)) { + return; + } // Make sure the list is actually empty before you recreate it // otherwise you can end up w/ duplicate values in the LL $this->emptyList(); - $safeOrder = array('pos', 'id'); - if (!in_array($order, $safeOrder)) { - $order = 'pos'; - } - try { - // Get each photo tuple from the member_photos table. - $sql = " - SELECT * - FROM member_photos - WHERE member_id = :member_id - ORDER BY $order"; - - $stmt = $dbh->prepare($sql); - $stmt->bindParam(':member_id', $this->mid, PDO::PARAM_INT); - $stmt->execute(); - - while ($row = $stmt->fetch()) { - // Create a new node w/ all the data we just extracted. - $node = $this->createNode($row); + $safeOrder = array('pos', 'id'); + if (!in_array($order, $safeOrder)) { + $order = 'pos'; + } + try { + // Get each photo tuple from the member_photos table. + $sql = " + SELECT * + FROM member_photos + WHERE member_id = :member_id + ORDER BY $order"; + + $stmt = $dbh->prepare($sql); + $stmt->bindParam(':member_id', $this->mid, PDO::PARAM_INT); + $stmt->execute(); + + while ($row = $stmt->fetch()) { + // Create a new node w/ all the data we just extracted. + $node = $this->createNode($row); $node->setDbh($dbh); - // Sets up any pending data the photo might currently have. - $node->setPendingData($c); - // Add the photo node to the end of the linked list. - $res = $this->appendNode($node); - } + // Sets up any pending data the photo might currently have. + $node->setPendingData($c); + // Add the photo node to the end of the linked list. + $res = $this->appendNode($node); + } - } catch (PDOException $e) { - return Toolkit_Common::handleError($e); - } - } + } catch (PDOException $e) { + return Toolkit_Common::handleError($e); + } + } - // }}} - // {{{ createNode() + // }}} + // {{{ createNode() /** * Creates a new linked list node object * * @param array $data Data to populate the new node with - * + * * @return Toolkit_Members_Photos_Photo linked list node * @access public */ - public function &createNode(array $data) - { - return new Toolkit_Members_Photos_Photo($data); - } + public function &createNode(array $data) + { + return new Toolkit_Members_Photos_Photo($data); + } - // }}} + // }}} - // {{{ getListSize() + // {{{ getListSize() /** * Get how many nodes are currently in the linked list * * @param boolean $filterPending Include pending photos in the count - * + * * @return integer number of nodes in the linked list * @access public */ - public function getListSize($filterPending = false) - { - $size = 0; - $cur = $this->rewind(); - - // If the current node is null, then we have no nodes - // in the linked list. return the empty size. - // Else we have at least one node in the linked list. - if (is_null($cur)) { - return $size; - } - - // Add one to the size of the list for every - // node we encounter. - do { - if ($filterPending) { - if (!$cur->getPending()) { - ++$size; - } - } else { - ++$size; - } - } while ($cur = $this->next()); - - return $size; - } - - // }}} - // {{{ getMemberId() + public function getListSize($filterPending = false) + { + $size = 0; + $cur = $this->rewind(); + + // If the current node is null, then we have no nodes + // in the linked list. return the empty size. + // Else we have at least one node in the linked list. + if (is_null($cur)) { + return $size; + } + + // Add one to the size of the list for every + // node we encounter. + do { + if ($filterPending) { + if (!$cur->getPending()) { + ++$size; + } + } else { + ++$size; + } + } while ($cur = $this->next()); + + return $size; + } + + // }}} + // {{{ getMemberId() /** * Get which member this linked list is for @@ -192,83 +192,83 @@ class Toolkit_Members_Photos extends Structures_LinkedList_Double * @return integer id of member we are dealing with * @access public */ - public function getMemberId() - { - return $this->mid; - } + public function getMemberId() + { + return $this->mid; + } - // }}} + // }}} - // {{{ findNode() + // {{{ findNode() /** * find a node from the linked list * * @param integer $target Id of photo you are searching for - * + * * @return mixed Toolkit_Members_Photos_Photo object if present, else false * @access public */ - public function &findNode($target) - { - $this->end(); - $startingId = $this->current->getId(); + public function &findNode($target) + { + $this->end(); + $startingId = $this->current->getId(); - if ($target == $startingId) { - return $this->current; - } + if ($target == $startingId) { + return $this->current; + } - while ($curr = $this->previous()) { - if ($target == $curr->getId()) { - return $curr; - } - } + while ($curr = $this->previous()) { + if ($target == $curr->getId()) { + return $curr; + } + } - return false; - } + return false; + } - // }}} + // }}} - // {{{ moveNode() + // {{{ moveNode() /** * Adjust nodes position in the linked list * * @param integer $pid id of photo you want to move * @param integer $pos new position you want to move to - * + * * @return void * @access public */ - public function moveNode($pid, $pos) - { - $node = $this->findNode($pid); - $oldPos = $node->getPosition(); - - if ($this->getListSize()) { - $cur = $this->rewind(); - do { - if ($cur->getId() == $pid) { - $cur->setPosition($pos); - } else { - $curPos = $cur->getPosition(); - if ($pos > $oldPos) { - if ($curPos <= $pos && $curPos > $oldPos) { - $cur->setPosition($curPos - 1); - } - } elseif ($pos < $oldPos) { - if ($curPos >= $pos && $curPos < $oldPos) { - $cur->setPosition($curPos + 1); - } - } - } - } while ($cur = $this->next()); - } - } - - // }}} - - // {{{ removeNode() + public function moveNode($pid, $pos) + { + $node = $this->findNode($pid); + $oldPos = $node->getPosition(); + + if ($this->getListSize()) { + $cur = $this->rewind(); + do { + if ($cur->getId() == $pid) { + $cur->setPosition($pos); + } else { + $curPos = $cur->getPosition(); + if ($pos > $oldPos) { + if ($curPos <= $pos && $curPos > $oldPos) { + $cur->setPosition($curPos - 1); + } + } elseif ($pos < $oldPos) { + if ($curPos >= $pos && $curPos < $oldPos) { + $cur->setPosition($curPos + 1); + } + } + } + } while ($cur = $this->next()); + } + } + + // }}} + + // {{{ removeNode() /** * Removes a node from the linked list @@ -276,59 +276,59 @@ class Toolkit_Members_Photos extends Structures_LinkedList_Double * @param Toolkit_Image_Server $is Image Server Object * @param Config_Container $c Member configuration * @param integer $target Id of photo you want to remove - * + * * @return boolean false on error * @access public */ - public function removeNode( + public function removeNode( Toolkit_Image_Server $is, Config_Container $c, $target ) { - $node = $this->findNode($target); - if (!$node) { - return false; - } + $node = $this->findNode($target); + if (!$node) { + return false; + } - $node->remove($is, $c); - $remNodePos = $node->getPosition(); + $node->remove($is, $c); + $remNodePos = $node->getPosition(); - // only try and update positions in the linked list if there are nodes that - // will still exists after this node is removed ie. size is greater than 1 - if ($this->getListSize() > 1) { - $cur = $this->rewind(); - do { - if ($cur->getPosition() > $remNodePos) { - $cur->setPosition($cur->getPosition() - 1); - } - } while ($cur = $this->next()); - } + // only try and update positions in the linked list if there are nodes that + // will still exists after this node is removed ie. size is greater than 1 + if ($this->getListSize() > 1) { + $cur = $this->rewind(); + do { + if ($cur->getPosition() > $remNodePos) { + $cur->setPosition($cur->getPosition() - 1); + } + } while ($cur = $this->next()); + } - $this->deleteNode($node); - } + $this->deleteNode($node); + } - // }}} + // }}} - // {{{ setMember() + // {{{ setMember() /** * Sets which member we are working with * * @param integer $mid id of member - * + * * @access public * @return void */ - public function setMember($mid) - { - if (ctype_digit((string) $mid)) { - $this->mid = $mid; - } - } + public function setMember($mid) + { + if (ctype_digit((string) $mid)) { + $this->mid = $mid; + } + } - // }}} + // }}} - // {{{ emptyList() + // {{{ emptyList() /** * Deletes all nodes from a list @@ -336,14 +336,14 @@ class Toolkit_Members_Photos extends Structures_LinkedList_Double * @access public * @return void */ - public function emptyList() - { - $this->end(); - while ($cur = $this->current()) { - $this->deleteNode($cur); - } - } - - // }}} + public function emptyList() + { + $this->end(); + while ($cur = $this->current()) { + $this->deleteNode($cur); + } + } + + // }}} } ?> diff --git a/Toolkit/Members/libjs/edit-member-course.js b/Toolkit/Members/libjs/edit-member-course.js index 79ac5bd..168d5bb 100755 --- a/Toolkit/Members/libjs/edit-member-course.js +++ b/Toolkit/Members/libjs/edit-member-course.js @@ -1,20 +1,51 @@ -var MemberPackages = +var MemberCourses = { init: function() { + $('input[name="remove_rmv"]').click(MemberCourses.remove); + if (CKEDITOR.env.isCompatible) { $("textarea.ckeditor").each(function() { CKEDITOR.replace( $(this).attr('id'), { toolbar : 'LimitedToolset', - width : 300, - height : 200 + width : 350, + height : 400 } ); }); } + + $('div.container').sortable({ + placeholder: 'ui-state-highlight', + //handle: 'div.packageItem', + opacity: 0.6, + revert: true, + scroll: true, + tolerance: 'pointer', + zIndex: 5, + axis: 'y', + cursor: 'n-resize', + update: MemberCourses.updatePos + }); + }, + + updatePos: function(event, ui) + { + var url = '../member-save-courses/?' + $(this).sortable('serialize'); + // Update the course positions through AJAX. + $.get(url, function(data) { + $('.movable').effect('highlight', {}, 700); + }); + }, + + remove: function(event) + { + if (!confirm('Are you sure you wish to remove this course?\nThis is not reversible!')) { + event.preventDefault(); + } } } -$(document).ready(MemberPackages.init); +$(document).ready(MemberCourses.init); diff --git a/Toolkit/Members/libjs/edit-member-photos.js b/Toolkit/Members/libjs/edit-member-photos.js index ae73b11..59913c4 100755 --- a/Toolkit/Members/libjs/edit-member-photos.js +++ b/Toolkit/Members/libjs/edit-member-photos.js @@ -1,58 +1,58 @@ var MemberPhotos = { - init: function() - { - $('.photoDelete').click(MemberPhotos.remove); - - // Make just the photos uploaded have an additional class - // on them, so we can make them movable later. - $(".photoItem:not(.photoUploadForm)").addClass('movable'); - - // Update the text on the update button. - // Since they have javascript on, the only update - // they will actually do on the form is the caption. - // They won't be updating the position through the select list. - $(":submit[name='update']").val('Update Caption Text'); - - // Remove all the positioning select elemnts - // so they can't override any new position adjustments - // done through drag and drop. - $('.position').remove(); - - // Add a message for users to tell them how to - // reposition thier images. - $('#photoList').before('
Click and drag images to reorder positions. Image positions are saved when the fields flash yellow
'); - - $('div.container').sortable({ - placeholder: 'ui-state-highlight', - handle: 'img.thumb', - opacity: 0.6, - revert: true, - scroll: true, - tolerance: 'pointer', - zIndex: 5, - axis: 'y', - cursor: 'n-resize', - update: MemberPhotos.updatePos - }); - $('img.thumb').disableSelection(); - }, - - updatePos: function(event, ui) - { - var url = '../member-save-photos/?' + $(this).sortable('serialize'); - // Update the photo positions through AJAX. - $.get(url, function(data) { - $('.movable').effect('highlight', {}, 700); - }); - }, - - remove: function(event) - { - if (!confirm('Are you sure you wish to remove this photo?\nThis is not reversible!')) { - event.preventDefault(); - } - } + init: function() + { + $('.photoDelete').click(MemberPhotos.remove); + + // Make just the photos uploaded have an additional class + // on them, so we can make them movable later. + $(".photoItem:not(.photoUploadForm)").addClass('movable'); + + // Update the text on the update button. + // Since they have javascript on, the only update + // they will actually do on the form is the caption. + // They won't be updating the position through the select list. + $(":submit[name='update']").val('Update Caption Text'); + + // Remove all the positioning select elemnts + // so they can't override any new position adjustments + // done through drag and drop. + $('.position').remove(); + + // Add a message for users to tell them how to + // reposition thier images. + $('#photoList').before('
Click and drag images to reorder positions. Image positions are saved when the fields flash yellow
'); + + $('div.container').sortable({ + placeholder: 'ui-state-highlight', + handle: 'img.thumb', + opacity: 0.6, + revert: true, + scroll: true, + tolerance: 'pointer', + zIndex: 5, + axis: 'y', + cursor: 'n-resize', + update: MemberPhotos.updatePos + }); + $('img.thumb').disableSelection(); + }, + + updatePos: function(event, ui) + { + var url = '../member-save-photos/?' + $(this).sortable('serialize'); + // Update the photo positions through AJAX. + $.get(url, function(data) { + $('.movable').effect('highlight', {}, 700); + }); + }, + + remove: function(event) + { + if (!confirm('Are you sure you wish to remove this photo?\nThis is not reversible!')) { + event.preventDefault(); + } + } }; $(document).ready(MemberPhotos.init); diff --git a/Toolkit/Members/sortCourses.php b/Toolkit/Members/sortCourses.php new file mode 100644 index 0000000..7e1f000 --- /dev/null +++ b/Toolkit/Members/sortCourses.php @@ -0,0 +1,55 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version CVS: $Id: sortCourses.php,v 1.5 2009/12/29 14:17:49 jamie Exp $ + * @link http://demo.gaslightmedia.com + */ + +require_once '../../setup.phtml'; +// Make sure the users browser doesn't cache the result. + +// Time in the past. +header('Expires: Wed, 23 Dec 1980 00:30::00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); +header('Cache-Control: no-cache, must-revalidate'); +header('Pragma: no-cache'); + +if (!is_array($_GET['courses'])) { + return; +} +$newOrder = $_GET['courses']; + +$dbh = Toolkit_Database::getInstance(); +try { + $dbh->beginTransaction(); + + $sql = " + UPDATE member_golf + SET pos = :pos + WHERE id = :id"; + $stmt = $dbh->prepare($sql); + foreach ($newOrder as $k => &$v) { + $pos = $k + 1; + $stmt->bindParam(':pos', $pos, PDO::PARAM_INT); + $stmt->bindParam(':id', $v, PDO::PARAM_INT); + $stmt->execute(); + } + $dbh->commit(); + echo true; +} catch (PDOException $e) { + $dbh->rollBack(); + echo 'PDO Exception Caught. '; + echo 'Error with the database:
'; + echo 'Error: ' . $e->getMessage() . '
'; + echo 'File: ' . $e->getFile() . '
'; + echo 'Line: ' . $e->getLine() . '
'; + print_r($dbh->errorInfo()); +} +?> diff --git a/Toolkit/Members/sortPhotos.php b/Toolkit/Members/sortPhotos.php index 72852c7..1e84d99 100644 --- a/Toolkit/Members/sortPhotos.php +++ b/Toolkit/Members/sortPhotos.php @@ -7,49 +7,49 @@ * @category MembersDB * @package Toolkit_Members * @author Jamie Kahgee - * @license http://www.gaslightmedia.com Gaslightmedia + * @license http://www.gaslightmedia.com Gaslightmedia * @version CVS: $Id: sortPhotos.php,v 1.5 2009/12/29 14:17:49 jamie Exp $ - * @link http://demo.gaslightmedia.com + * @link http://demo.gaslightmedia.com */ require_once '../../setup.phtml'; -// Make sure the users browser doesn't cache the result. +// Make sure the users browser doesn't cache the result. -// Time in the past. +// Time in the past. header('Expires: Wed, 23 Dec 1980 00:30::00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); if (!is_array($_GET['photos'])) { - return; + return; } $newOrder = $_GET['photos']; $dbh = Toolkit_Database::getInstance(); try { - $dbh->beginTransaction(); + $dbh->beginTransaction(); - $sql = " + $sql = " UPDATE member_photos SET pos = :pos WHERE id = :id"; - $stmt = $dbh->prepare($sql); - foreach ($newOrder as $k => &$v) { - $pos = $k + 1; - $stmt->bindParam(':pos', $pos, PDO::PARAM_INT); - $stmt->bindParam(':id', $v, PDO::PARAM_INT); - $stmt->execute(); - } - $dbh->commit(); - echo true; + $stmt = $dbh->prepare($sql); + foreach ($newOrder as $k => &$v) { + $pos = $k + 1; + $stmt->bindParam(':pos', $pos, PDO::PARAM_INT); + $stmt->bindParam(':id', $v, PDO::PARAM_INT); + $stmt->execute(); + } + $dbh->commit(); + echo true; } catch (PDOException $e) { - $dbh->rollBack(); - echo 'PDO Exception Caught. '; - echo 'Error with the database:
'; - echo 'Error: ' . $e->getMessage() . '
'; - echo 'File: ' . $e->getFile() . '
'; - echo 'Line: ' . $e->getLine() . '
'; - print_r($dbh->errorInfo()); + $dbh->rollBack(); + echo 'PDO Exception Caught. '; + echo 'Error with the database:
'; + echo 'Error: ' . $e->getMessage() . '
'; + echo 'File: ' . $e->getFile() . '
'; + echo 'Line: ' . $e->getLine() . '
'; + print_r($dbh->errorInfo()); } ?> diff --git a/Toolkit/Members/templates/editCourse.tpl b/Toolkit/Members/templates/editCourse.tpl index 15bb6be..2f505df 100644 --- a/Toolkit/Members/templates/editCourse.tpl +++ b/Toolkit/Members/templates/editCourse.tpl @@ -1,4 +1,5 @@ -
+
+ {form.javascript:h} {form.outputHeader():h} {form.hidden:h} -- 2.17.1