1<?php 2/** 3 * My Page page allows a logged in user the abilty 4 * to keep bookmarks, see a list of upcoming events, etc. 5 * 6 * webtrees: Web based Family History software 7 * Copyright (C) 2010 webtrees development team. 8 * 9 * Derived from PhpGedView 10 * Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. 11 * 12 * This program is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by 14 * the Free Software Foundation; either version 2 of the License, or 15 * (at your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * You should have received a copy of the GNU General Public License 23 * along with this program; if not, write to the Free Software 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 * 26 * @package webtrees 27 * @subpackage Display 28 * @version $Id$ 29 */ 30 31define('WT_SCRIPT_NAME', 'index.php'); 32require './includes/session.php'; 33 34// The only option for action is "ajax" 35$action=safe_REQUEST($_REQUEST, 'action', 'ajax'); 36 37// The default view depends on whether we are logged in 38$ctype=safe_REQUEST($_REQUEST, 'ctype', array('gedcom', 'user'), WT_USER_ID ? 'user' : 'gedcom'); 39 40// A request to see a user page, but not logged in? 41if (!WT_USER_ID && $ctype=='user') { 42 header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.'login.php?url='.rawurlencode('index.php?ctype=user')); 43 exit; 44} 45 46//-- get the blocks list 47if ($ctype=='user') { 48 $blocks=get_user_blocks(WT_USER_ID); 49} else { 50 $blocks=get_gedcom_blocks(WT_GED_ID); 51} 52 53require_once WT_ROOT.'includes/classes/class_module.php'; 54$all_blocks=WT_Module::getActiveBlocks(); 55 56// We generate individual blocks using AJAX 57if ($action=='ajax') { 58 header('Content-Type: text/html; charset=UTF-8'); 59 // Check we're displaying an allowable block. 60 $block_id=safe_GET('block_id'); 61 if (array_key_exists($block_id, $blocks['main'])) { 62 $module_name=$blocks['main'][$block_id]; 63 } elseif (array_key_exists($block_id, $blocks['side'])) { 64 $module_name=$blocks['side'][$block_id]; 65 } else { 66 exit; 67 } 68 if (array_key_exists($module_name, $all_blocks)) { 69 $class_name=$module_name.'_WT_Module'; 70 $module=new $class_name; 71 $module->getBlock($block_id); 72 } 73 if (WT_DEBUG) { 74 echo execution_stats(); 75 } 76 if (WT_DEBUG_SQL) { 77 echo WT_DB::getQueryLog(); 78 } 79 exit; 80} 81 82// We have finished writing session data, so release the lock 83Zend_Session::writeClose(); 84 85if ($ctype=='user') { 86 $helpindex = 'mypage_portal'; 87 print_header(i18n::translate('My Page')); 88} else { 89 $helpindex = 'index_portal'; 90 print_header(get_gedcom_setting(WT_GED_ID, 'title')); 91} 92 93if (WT_USE_LIGHTBOX) { 94 require WT_ROOT.'modules/lightbox/lb_defaultconfig.php'; 95 require WT_ROOT.'modules/lightbox/functions/lb_call_js.php'; 96} 97 98// TODO: these should be moved to their respective module/block 99echo WT_JS_START; 100?> 101 function refreshpage() { 102 window.location = 'index.php?ctype=<?php echo $ctype; ?>'; 103 } 104 function addnews(uname) { 105 window.open('editnews.php?username='+uname, '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1'); 106 } 107 function editnews(news_id) { 108 window.open('editnews.php?news_id='+news_id, '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1'); 109 } 110 var pastefield; 111 function paste_id(value) { 112 pastefield.value=value; 113 } 114<?php 115echo WT_JS_END; 116//-- start of main content section 117if ($ctype=='user') { 118 echo '<div align="center">'; 119 echo '<h1>', i18n::translate('My Page'), '</h1>'; 120 echo i18n::translate('My Page allows you to keep bookmarks of your favorite people, track upcoming events, and collaborate with other webtrees users.'); 121 echo '<br /><br /></div>'; 122} 123echo '<script src="js/jquery/jquery.min.js" type="text/javascript"></script>'; 124echo '<script type="text/javascript">jQuery.noConflict();</script>'; 125if ($blocks['main']) { 126 if ($blocks['side']) { 127 echo '<div id="index_main_blocks">'; 128 } else { 129 echo '<div id="index_full_blocks">'; 130 } 131 foreach ($blocks['main'] as $block_id=>$module_name) { 132 $class_name=$module_name.'_WT_Module'; 133 $module=new $class_name; 134 if ($SEARCH_SPIDER || !$module->loadAjax()) { 135 // Load the block directly 136 $module->getBlock($block_id); 137 } else { 138 // Load the block asynchronously 139 echo '<div id="block_', $block_id, '"><img src="images/loading.gif" alt="', htmlspecialchars(i18n::translate('Loading...')), '"/></div>'; 140 echo WT_JS_START, "jQuery('#block_{$block_id}').load('index.php?ctype={$ctype}&action=ajax&block_id={$block_id}');", WT_JS_END; 141 } 142 } 143 echo '</div>'; 144} 145 146if ($blocks['side']) { 147 if ($blocks['main']) { 148 echo '<div id="index_small_blocks">'; 149 } else { 150 echo '<div id="index_full_blocks">'; 151 } 152 foreach ($blocks['side'] as $block_id=>$module_name) { 153 $class_name=$module_name.'_WT_Module'; 154 $module=new $class_name; 155 if ($SEARCH_SPIDER || !$module->loadAjax()) { 156 // Load the block directly 157 $module->getBlock($block_id); 158 } else { 159 // Load the block asynchronously 160 echo '<div id="block_', $block_id, '"><img src="images/loading.gif" alt="', htmlspecialchars(i18n::translate('Loading...')), '"/></div>'; 161 echo WT_JS_START, "jQuery('#block_{$block_id}').load('index.php?ctype={$ctype}&action=ajax&block_id={$block_id}');", WT_JS_END; 162 } 163 } 164 echo '</div>'; 165} 166 167// Ensure there is always way to configure the blocks 168if ($ctype=='user' && !in_array('user_welcome', $blocks['main']) && !in_array('user_welcome', $blocks['side'])) { 169 echo '<div align="center">'; 170 echo "<a href=\"javascript:;\" onclick=\"window.open('index_edit.php?name=".rawurlencode(WT_USER_NAME)."&ctype=user', '_blank', 'top=50,left=10,width=600,height=500,scrollbars=1,resizable=1');\">".i18n::translate('Customize My Page').'</a>'; 171 echo help_link('mypage_customize'); 172 echo '</div>'; 173} 174if (WT_USER_IS_ADMIN && $ctype=='gedcom' && !in_array('gedcom_block', $blocks['main']) && !in_array('gedcom_block', $blocks['side'])) { 175 echo '<div align="center">'; 176 echo "<a href=\"javascript:;\" onclick=\"window.open('index_edit.php?name=".WT_GEDURL."&ctype=gedcom', '_blank', 'top=50,left=10,width=600,height=500,scrollbars=1,resizable=1');\">".i18n::translate('Customize this GEDCOM Home Page').'</a>'; 177 echo '</div>'; 178} 179 180print_footer(); 181