getSidebarAjaxContent();
break;
case 'index':
global $ENABLE_AUTOCOMPLETE, $MAX_PEDIGREE_GENERATIONS, $TEXT_DIRECTION, $WT_IMAGES, $controller, $WT_SESSION;
require_once WT_ROOT.WT_MODULES_DIR.'clippings/clippings_ctrl.php';
require_once WT_ROOT.'includes/functions/functions_export.php';
$clip_ctrl=new WT_Controller_Clippings();
$controller=new WT_Controller_Base();
$controller
->setPageTitle($this->getTitle())
->PageHeader();
if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm';
echo WT_JS_START;
echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}';
echo WT_JS_END;
if (!$WT_SESSION->cart[WT_GED_ID]) {
echo '
', WT_I18N::translate('Family Tree Clippings Cart'), '
';
}
if ($clip_ctrl->action=='add') {
$person = WT_GedcomRecord::getInstance($clip_ctrl->id);
echo '';
if ($clip_ctrl->type=='fam') { ?>
type=='indi') { ?>
type=='sour') { ?>
privCount>0) {
echo "".WT_I18N::translate('Some items could not be added due to privacy restrictions')."
";
}
if (!$WT_SESSION->cart[WT_GED_ID]) {
// -- new lines, added by Jans, to display helptext when cart is empty
if ($clip_ctrl->action!='add') {
echo WT_I18N::translate('The Clippings Cart allows you to take extracts ("clippings") from this family tree and bundle them up into a single file for downloading and subsequent importing into your own genealogy program. The downloadable file is recorded in GEDCOM format.
- How to take clippings?
This is really simple. Whenever you see a clickable name (individual, family, or source) you can go to the Details page of that name. There you will see the Add to Clippings Cart option. When you click that link you will be offered several options to download. - How to download?
Once you have items in your cart, you can download them just by clicking the Download Now link. Follow the instructions and links.
');
echo WT_JS_START;
echo 'var pastefield;';
echo 'function paste_id(value) {pastefield.value=value;}';
echo WT_JS_END;
?>
action != 'download' && $clip_ctrl->action != 'add') { ?>
getName()); ?>
getName()); ?> |
|
|
cart[WT_GED_ID]) as $xref) {
$record=WT_GedcomRecord::getInstance($xref);
if ($record) {
$tag = $record->getType();
if ($tag=='INDI') $icon = "indis";
if ($tag=='FAM' ) $icon = "sfamily";
if ($tag=='SOUR') $icon = "source";
if ($tag=='REPO') $icon = "repository";
if ($tag=='NOTE') $icon = "note";
if ($tag=='OBJE') $icon = "media";
?>
getHtmlUrl(), '">', $record->getFullName(), '';
?>
|
" border="0" alt="" title="" /> |
|
getTitle(), 'module.php?mod=clippings&mod_action=index&ged='.WT_GEDURL, 'menu-clippings', 'down');
$menu->addIcon('clippings');
$menu->addClass('menuitem', 'menuitem_hover', 'submenu', 'icon_large_clippings');
$submenu = new WT_Menu($this->getTitle(), 'module.php?mod=clippings&mod_action=index&ged='.WT_GEDURL, 'menu-clippingscart');
$submenu->addIcon('clippings');
$submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_clippings');
$menu->addSubmenu($submenu);
if (!empty($controller->record) && $controller->record->canDisplayDetails()) {
$submenu = new WT_Menu(WT_I18N::translate('Add to clippings cart'), 'module.php?mod=clippings&mod_action=index&action=add&id='.$controller->record->getXref(), 'menu-clippingsadd');
$submenu->addIcon('clippings');
$submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_add_clip');
$menu->addSubmenu($submenu);
}
return $menu;
}
// Implement WT_Module_Sidebar
public function defaultSidebarOrder() {
return 60;
}
// Impelement WT_Module_Sidebar
public function hasSidebarContent() {
require_once WT_ROOT.WT_MODULES_DIR.'clippings/clippings_ctrl.php';
// Creating a controller has the side effect of initialising the cart
$clip_ctrl=new WT_Controller_Clippings();
return true;
}
// Impelement WT_Module_Sidebar
public function getSidebarContent() {
return
WT_JS_START.'
jQuery(document).ready(function() {
jQuery(".add_cart, .remove_cart").live("click", function() {
jQuery("#sb_clippings_content").load(this.href);
return false;
});
});'.
WT_JS_END.
''.
$this->getCartList().
'
';
}
// Impelement WT_Module_Sidebar
public function getSidebarAjaxContent() {
require_once WT_ROOT.WT_MODULES_DIR.'clippings/clippings_ctrl.php';
global $WT_SESSION;
$clip_ctrl = new WT_Controller_Clippings();
$add = safe_GET_xref('add','');
$add1 = safe_GET_xref('add1','');
$remove = safe_GET('remove', WT_REGEX_XREF);
$others = safe_GET('others', WT_REGEX_ALPHANUM, '');
$clip_ctrl->level1 = safe_GET('level1');
$clip_ctrl->level2 = safe_GET('level2');
$clip_ctrl->level3 = safe_GET('level3');
if (!empty($add)) {
$record = WT_GedcomRecord::getInstance($add);
if ($record) {
$clip_ctrl->id=$record->getXref();
$clip_ctrl->type=$record->getType();
$ret = $clip_ctrl->add_clipping($record);
if ($ret) return $this->askAddOptions($record);
}
} elseif (!empty($add1)) {
$record = WT_Person::getInstance($add1);
if ($record) {
$clip_ctrl->id=$record->getXref();
$clip_ctrl->type=strtolower($record->getType());
if ($others == 'parents') {
foreach ($record->getChildFamilies() as $family) {
$clip_ctrl->add_clipping($family);
$clip_ctrl->add_family_members($family);
}
} elseif ($others == 'ancestors') {
$clip_ctrl->add_ancestors_to_cart($record, $clip_ctrl->level1);
} elseif ($others == 'ancestorsfamilies') {
$clip_ctrl->add_ancestors_to_cart_families($record, $clip_ctrl->level2);
} elseif ($others == 'members') {
foreach ($record->getSpouseFamilies() as $family) {
$clip_ctrl->add_clipping($family);
$clip_ctrl->add_family_members($family);
}
} elseif ($others == 'descendants') {
foreach ($record->getSpouseFamilies() as $family) {
$clip_ctrl->add_clipping($family);
$clip_ctrl->add_family_descendancy($family, $clip_ctrl->level3);
}
}
}
} elseif ($remove) {
unset ($WT_SESSION->cart[WT_GED_ID][$remove]);
} elseif (isset($_REQUEST['empty'])) {
$WT_SESSION->cart[WT_GED_ID] = array ();
} elseif (isset($_REQUEST['download'])) {
return $this->downloadForm($clip_ctrl);
}
return $this->getCartList();
}
// A list for the side bar.
public function getCartList() {
global $WT_IMAGES, $WT_SESSION;
// Keep track of the INDI from the parent page, otherwise it will
// get lost after ajax updates
$pid=safe_GET_xref('pid');
$out ='';
if ($WT_SESSION->cart[WT_GED_ID]) {
$out.=
'
'.
WT_I18N::translate('Empty Cart').
''.help_link('empty_cart', $this->getName()).
'
'.
''.
WT_I18N::translate('Download Now').
'';
}
$record=WT_Person::getInstance($pid);
if ($record && !array_key_exists($record->getXref(), $WT_SESSION->cart[WT_GED_ID])) {
$out .= '
'.WT_I18N::translate('Add %s to cart', $record->getFullName()).'';
}
return $out;
}
public function askAddOptions($person) {
global $MAX_PEDIGREE_GENERATIONS;
$out = '';
$out .= WT_JS_START;
$out .= 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}
function continueAjax(frm) {
var others = jQuery("input[name=\'others\']:checked").val();
var link = "module.php?mod='.$this->getName().'&mod_action=ajax&sb_action=clippings&add1="+frm.pid.value+"&others="+others+"&level1="+frm.level1.value+"&level2="+frm.level2.value+"&level3="+frm.level3.value;
jQuery("#sb_clippings_content").load(link);
}';
$out .= WT_JS_END;
if ($person->getType()=='FAM') {
$out .= '';
}
else if ($person->getType()=='INDI') {
$out .= '';
} else if ($person->getType()=='SOUR') {
$out .= '';
}
else return $this->getSidebarContent();
return $out;
}
public function downloadForm($clip_ctrl) {
global $TEXT_DIRECTION;
$pid=safe_GET_xref('pid');
$out = WT_JS_START;
$out .= 'function cancelDownload() {
var link = "module.php?mod='.$this->getName().'&mod_action=ajax&sb_action=clippings&pid='.$pid.'";
jQuery("#sb_clippings_content").load(link);
}';
$out .= WT_JS_END;
$out .= '