diff options
| author | fisharebest <fisharebest@gmail.com> | 2010-04-11 16:06:34 +0000 |
|---|---|---|
| committer | fisharebest <fisharebest@gmail.com> | 2010-04-11 16:06:34 +0000 |
| commit | 1f23f323d4ce70c188c5f4e5cc100f480651379f (patch) | |
| tree | 34e3c18a03426355316a64587725e498496aa024 | |
| parent | 730d79fdca85c66b260bbc3f996c471fa1fcc1e7 (diff) | |
| download | webtrees-1f23f323d4ce70c188c5f4e5cc100f480651379f.tar.gz webtrees-1f23f323d4ce70c188c5f4e5cc100f480651379f.tar.bz2 webtrees-1f23f323d4ce70c188c5f4e5cc100f480651379f.zip | |
Fix tab/module issues; default tab, ajax loading, names instead of numbers (All tab still broken)
| -rw-r--r-- | includes/controllers/individual_ctrl.php | 22 | ||||
| -rw-r--r-- | individual.php | 83 | ||||
| -rw-r--r-- | modules/all_tab/pgv_module.php | 16 | ||||
| -rw-r--r-- | modules/lightbox/functions/lb_head.php | 1 | ||||
| -rw-r--r-- | modules/personal_facts/pgv_module.php | 3 |
5 files changed, 52 insertions, 73 deletions
diff --git a/includes/controllers/individual_ctrl.php b/includes/controllers/individual_ctrl.php index 29257615f1..d40357f8d0 100644 --- a/includes/controllers/individual_ctrl.php +++ b/includes/controllers/individual_ctrl.php @@ -84,7 +84,7 @@ class IndividualControllerRoot extends BaseController { var $total_names = 0; var $SEX_COUNT = 0; var $sexarray = array(); - var $modules = array(); + var $tabs; var $Fam_Navigator = 'YES'; var $NAME_LINENUM = 1; var $SEX_LINENUM = null; @@ -251,19 +251,17 @@ class IndividualControllerRoot extends BaseController { } */ } - - $this->modules = WT_Module::getActiveTabs(); - $count = 0; - if (empty($this->default_tab)) $this->default_tab=0; - foreach($this->modules as $mod) { + + // Initialise tabs + $this->tabs = WT_Module::getActiveTabs(); + foreach($this->tabs as $mod) { $mod->setController($this); - if ($mod->hasTabContent() || WT_USER_CAN_EDIT) { - //-- convert default tab as name to number - if ($mod->getName()===$this->default_tab) $this->default_tab = $count; - else $count++; + if ($mod->hasTabContent()) { + if (empty($this->default_tab)) { + $this->default_tab=$mod->getName(); + } } } - if ($this->default_tab<0 || $this->default_tab > count($this->modules)-1) $this->default_tab=0; if (!isset($_SESSION['WT_pin']) && $DEFAULT_PIN_STATE) $_SESSION['WT_pin'] = true; @@ -274,7 +272,7 @@ class IndividualControllerRoot extends BaseController { if (isset($_REQUEST['module'])) { $tabname = $_REQUEST['module']; header("Content-Type: text/html; charset=UTF-8"); //AJAX calls do not have the meta tag headers and need this set - $mod = $this->modules[$tabname]; + $mod = $this->tabs[$tabname]; if ($mod) { echo $mod->getTabContent(); // Allow the other tabs to modify this one - e.g. lightbox does this. diff --git a/individual.php b/individual.php index c219f5075c..ab218daa3b 100644 --- a/individual.php +++ b/individual.php @@ -111,33 +111,23 @@ jQuery(document).ready(function(){ // TODO: change images directory when the common images will be deleted. // jQuery('#tabs').tabs({ spinner: '<img src=\"<?php echo $WT_IMAGE_DIR; ?>/loading.gif\" height=\"18\" border=\"0\" />' }); jQuery('#tabs').tabs({ spinner: '<img src=\"images/loading.gif\" height=\"18\" border=\"0\" alt=\"\" />' }); - jQuery("#tabs").tabs({ cache: true, selected: <?php echo $controller->default_tab?> }); + jQuery("#tabs").tabs({ cache: true }); var $tabs = jQuery('#tabs'); jQuery('#tabs').bind('tabsshow', function(event, ui) { selectedTab = ui.tab.name; tabCache[selectedTab] = true; <?php - foreach ($controller->modules as $mod) { - if ($mod instanceof WT_Module_Tab) { - echo $mod->getJSCallbackAllTabs()."\n"; - $modjs = $mod->getJSCallback(); - if (!empty($modjs)) { - echo 'if (ui.tab.name == "'.$mod->getName().'") { '.$modjs.' }'; - } - } + foreach ($controller->tabs as $tab) { + echo $tab->getJSCallbackAllTabs()."\n"; + echo 'if (ui.tab.name == "'.$tab->getName().'") { '.$tab->getJSCallback().' }'; } ?> }); <?php - $tabcount = 0; - foreach($controller->modules as $mod) { - if ($mod instanceof WT_Module_Tab) { - if ($tabcount==$controller->default_tab || !$mod->canLoadAjax()) { - $modjs = $mod->getJSCallback(); - echo $modjs."\n"; - } - if ($mod->hasTabContent()) $tabcount++; + foreach ($controller->tabs as $tab) { + if ($tab->getName()==$controller->default_tab || !$tab->canLoadAjax()) { + echo $tab->getJSCallback(); } } ?> @@ -255,10 +245,8 @@ jQuery(document).ready(function(){ ?> <?php -foreach($controller->modules as $mod) { - if ($mod instanceof WT_Module_Tab) { - echo $mod->getPreLoadContent(); - } +foreach ($controller->tabs as $tab) { + echo $tab->getPreLoadContent(); } ?> <?php @@ -272,36 +260,31 @@ if (!$controller->indi->canDisplayDetails()) { print_privacy_error($CONTACT_EMAIL); print "</td></tr></table>"; } else { - ?> - <div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all"> - <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"> - <?php - $tabcount = 0; - foreach($controller->modules as $mod) { - if ($mod instanceof WT_Module_Tab) { - if ($tabcount==$controller->default_tab || !$mod->canLoadAjax()) {?> - <li class="ui-state-default ui-corner-top"><a name="<?php echo $mod->getName(); ?>" href="#<?php echo $mod->getName()?>"><span><?php echo $mod->getTitle(); ?></span></a></li> - <?php } else if ($mod instanceof WT_Module_Tab && ($mod->hasTabContent() || WT_USER_CAN_EDIT)) { ?> - <li class="ui-state-default ui-corner-top"><a name="<?php echo $mod->getName(); ?>" href="individual.php?action=ajax&module=<?php echo $mod->getName()?>&pid=<?php echo $controller->pid?>"> - <span><?php echo $mod->getTitle()?></span> - </a></li> - <?php } - if ($mod->hasTabContent()) $tabcount++; - } + echo '<div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">'; + echo '<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">'; + foreach ($controller->tabs as $tab) { + if ($tab->hasTabContent()) { + if ($tab->getName()==$controller->default_tab) { + // Default tab loads immediately + echo '<li class="ui-state-default ui-corner-top ui-tabs-selected"><a title="', $tab->getName(), '" href="#', $tab->getName(), '">'; + } elseif ($tab->canLoadAjax()) { + // AJAX tabs load later + echo '<li class="ui-state-default ui-corner-top"><a title="', $tab->getName(), '" href="individual.php?action=ajax&module=', $tab->getName(), '&pid=', $controller->pid, '">'; + } else { + // Non-AJAX tabs load immediately (search engines don't load ajax) + echo '<li class="ui-state-default ui-corner-top"><a title="', $tab->getName(), '" href="#', $tab->getName(), '">'; + } + echo '<span>', $tab->getTitle(), '</span></a></li>'; } - ?> - </ul> - - <?php - $tabcount = 0; - foreach($controller->modules as $mod) { - if ($mod instanceof WT_Module_Tab) { - if ($tabcount==$controller->default_tab || !$mod->canLoadAjax()) {?> - <div id="<?php echo $mod->getName()?>" class="ui-tabs-panel ui-widget-content ui-corner-bottom"> - <?php echo $mod->getTabContent(); ?> - </div> - <?php } - if ($mod->hasTabContent() || WT_USER_CAN_EDIT) $tabcount++; + } + echo '</ul>'; + foreach ($controller->tabs as $tab) { + if ($tab->hasTabContent()) { + if ($tab->getName()==$controller->default_tab || !$tab->canLoadAjax()) { + echo '<div id="', $tab->getName(), '" class="ui-tabs-panel ui-widget-content ui-corner-bottom">'; + echo $tab->getTabContent(); + echo '</div>'; + } } } ?> </div> <!-- tabs --> diff --git a/modules/all_tab/pgv_module.php b/modules/all_tab/pgv_module.php index 8d3f3c4def..080d4b83aa 100644 --- a/modules/all_tab/pgv_module.php +++ b/modules/all_tab/pgv_module.php @@ -82,16 +82,12 @@ class all_tab_WT_Module extends WT_Module implements WT_Module_Tab { // Implement WT_Module_Tab public function getJSCallback() { $out = 'if (selectedTab=="'.$this->getName().'") {'; - $i = 0; - foreach($this->controller->modules as $mod) { - if ($mod instanceof WT_Module_Tab) { - if ($i>0 && $mod->getName()!=$this->getName() && $mod->canLoadAjax()) { - $out .= 'if (!tabCache["'.$mod->getName().'"]) { - jQuery("#'.$mod->getName().'").load("individual.php?action=ajax&module='.$mod->getName().'&pid='.$this->controller->pid.'"); - tabCache["'.$mod->getName().'"] = true; - }'; - } - $i++; + foreach($this->controller->tabs as $tab) { + if ($tab->getName()!=$this->getName() && $tab->canLoadAjax()) { + $out .= 'if (!tabCache["'.$tab->getName().'"]) { + jQuery("#'.$tab->getName().'").load("individual.php?action=ajax&module='.$tab->getName().'&pid='.$this->controller->pid.'"); + tabCache["'.$tab->getName().'"] = true; + }'; } } diff --git a/modules/lightbox/functions/lb_head.php b/modules/lightbox/functions/lb_head.php index ac500d72d7..c80981792f 100644 --- a/modules/lightbox/functions/lb_head.php +++ b/modules/lightbox/functions/lb_head.php @@ -225,6 +225,7 @@ require_once WT_ROOT.'includes/media_reorder_count.php'; */ //Popup Reorder Media ( If media exists and is greater than 1 item ) ----- + global $tot_med_ct; if (WT_USER_CAN_EDIT && $tot_med_ct>1) { if ($LB_AL_HEAD_LINKS == "both") { print "<td class=\"width15 center wrap\" valign=\"top\">"; diff --git a/modules/personal_facts/pgv_module.php b/modules/personal_facts/pgv_module.php index 866224986b..efc400b408 100644 --- a/modules/personal_facts/pgv_module.php +++ b/modules/personal_facts/pgv_module.php @@ -138,7 +138,8 @@ class personal_facts_WT_Module extends WT_Module implements WT_Module_Tab { } // Implement WT_Module_Tab public function canLoadAjax() { - return true; + // Don't load this tab using AJAX, otherwise search engines won't see it + return false; } // Implement WT_Module_Tab |
