[ PHPXref.com ] [ Generated: Sun Jul 20 19:39:24 2008 ] [ PhpGedView 4.0 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/blocks/ -> recent_changes.php (source)

   1  <?php
   2  /**
   3   * Recent Changes Block
   4   *
   5   * This block will print a list of recent changes
   6   *
   7   * phpGedView: Genealogy Viewer
   8   * Copyright (C) 2002 to 2003  John Finlay and Others
   9   *
  10   * This program is free software; you can redistribute it and/or modify
  11   * it under the terms of the GNU General Public License as published by
  12   * the Free Software Foundation; either version 2 of the License, or
  13   * (at your option) any later version.
  14   *
  15   * This program is distributed in the hope that it will be useful,
  16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18   * GNU General Public License for more details.
  19   *
  20   * You should have received a copy of the GNU General Public License
  21   * along with this program; if not, write to the Free Software
  22   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23   *
  24   * $Id: recent_changes.php,v 1.1.2.48 2006/05/24 05:07:45 yalnifj Exp $
  25   * @package PhpGedView
  26   * @subpackage Blocks
  27   */
  28  
  29  $PGV_BLOCKS["print_recent_changes"]["name"]        = $pgv_lang["recent_changes_block"];
  30  $PGV_BLOCKS["print_recent_changes"]["descr"]        = "recent_changes_descr";
  31  $PGV_BLOCKS["print_recent_changes"]["canconfig"]        = true;
  32  $PGV_BLOCKS["print_recent_changes"]["config"] = array("days"=>30, "hide_empty"=>"no");
  33  
  34  //-- Recent Changes block
  35  //-- this block prints a list of changes that have occurred recently in your gedcom
  36  function print_recent_changes($block=true, $config="", $side, $index) {
  37      global $pgv_lang, $factarray, $month, $year, $day, $monthtonum, $HIDE_LIVE_PEOPLE, $SHOW_ID_NUMBERS, $command, $TEXT_DIRECTION, $SHOW_FAM_ID_NUMBERS;
  38      global $PGV_IMAGE_DIR, $PGV_IMAGES, $GEDCOM, $REGEXP_DB, $DEBUG, $ASC, $IGNORE_FACTS, $IGNORE_YEAR, $TOTAL_QUERIES, $LAST_QUERY, $PGV_BLOCKS, $SHOW_SOURCES;
  39      global $objectlist;
  40  
  41      $block = true;            // Always restrict this block's height
  42  
  43      if ($command=="user") $filter = "living";
  44      else $filter = "all";
  45  
  46      if (empty($config)) $config = $PGV_BLOCKS["print_recent_changes"]["config"];
  47      if ($config["days"]<1) $config["days"] = 30;
  48      if (isset($config["hide_empty"])) $HideEmpty = $config["hide_empty"];
  49      else $HideEmpty = "no";
  50  
  51      $daytext = "";
  52      $action = "today";
  53      $found_facts = array();
  54      $monthstart = mktime(1,0,0,$monthtonum[strtolower($month)],$day,$year);
  55      $mmon2 = date("m", $monthstart-(60*60*24*$config["days"]));
  56      $mday2 = date("d", $monthstart-(60*60*24*$config["days"]));
  57      $myear2 = date("Y", $monthstart-(60*60*24*$config["days"]));
  58      $changes = get_recent_changes($mday2, $mmon2, $myear2);
  59  
  60      if (count($changes)>0) {
  61          $found_facts = array();
  62          $last_total = $TOTAL_QUERIES;
  63          foreach($changes as $id=>$change) {
  64              $gid = $change['d_gid'];
  65              $gedrec = find_gedcom_record($change['d_gid']);
  66              if (empty($gedrec)) $gedrec = find_record_in_file($change['d_gid']);
  67  
  68              if (empty($gedrec)) {
  69                  if ($DEBUG) print "Record ".$change['d_gid']." not found ";
  70              } else {
  71                  $type = "INDI";
  72                  $match = array();
  73                  $ct = preg_match("/0 @.*@ (\w*)/", $gedrec, $match);
  74                  if ($ct>0) $type = trim($match[1]);
  75                  $disp = true;
  76                  switch($type) {
  77                      case 'INDI':
  78                          if (($filter=="living")&&(is_dead_id($gid)==1)) $disp = false;
  79                          else if ($HIDE_LIVE_PEOPLE) $disp = displayDetailsByID($gid);
  80                          break;
  81                      case 'FAM':
  82                          if ($filter=="living") {
  83                              $parents = find_parents_in_record($gedrec);
  84                              if (is_dead_id($parents["HUSB"])==1) $disp = false;
  85                              else if ($HIDE_LIVE_PEOPLE) $disp = displayDetailsByID($parents["HUSB"]);
  86                              if ($disp) {
  87                                  if (is_dead_id($parents["WIFE"])==1) $disp = false;
  88                                  else if ($HIDE_LIVE_PEOPLE) $disp = displayDetailsByID($parents["WIFE"]);
  89                              }
  90                          }
  91                          else if ($HIDE_LIVE_PEOPLE) $disp = displayDetailsByID($gid, "FAM");
  92                          break;
  93                      default:
  94                          $disp = displayDetailsByID($gid, $type);
  95                          break;
  96                  }
  97                  if ($disp) {
  98                      $factrec = get_sub_record(1, "1 CHAN", $gedrec);
  99                      $found_facts[] = array($gid, $factrec, $type);
 100                  }
 101              }
 102          }
 103      }
 104  
 105  // Start output
 106      if (count($found_facts)==0 and $HideEmpty=="yes") return false;
 107  //        Print block header
 108      print "<div id=\"recent_changes\" class=\"block\">";
 109      print "<table class=\"blockheader\" cellspacing=\"0\" cellpadding=\"0\" style=\"direction:ltr;\"><tr>";
 110      print "<td class=\"blockh1\" >&nbsp;</td>";
 111      print "<td class=\"blockh2\" ><div class=\"blockhc\">";
 112      print_help_link("recent_changes_help", "qm");
 113      if ($PGV_BLOCKS["print_recent_changes"]["canconfig"]) {
 114          $username = getUserName();
 115          if ((($command=="gedcom")&&(userGedcomAdmin($username))) || (($command=="user")&&(!empty($username)))) {
 116              if ($command=="gedcom") $name = preg_replace("/'/", "\'", $GEDCOM);
 117              else $name = $username;
 118              print "<a href=\"javascript: configure block\" onclick=\"window.open('index_edit.php?name=$name&amp;command=$command&amp;action=configure&amp;side=$side&amp;index=$index', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">";
 119              print "<img class=\"adminicon\" src=\"$PGV_IMAGE_DIR/".$PGV_IMAGES["admin"]["small"]."\" width=\"15\" height=\"15\" border=\"0\" alt=\"".$pgv_lang["config_block"]."\" /></a>\n";
 120          }
 121      }
 122      print "<b>".$pgv_lang["recent_changes"]."</b>";
 123      print "</div></td>";
 124      print "<td class=\"blockh3\">&nbsp;</td></tr>\n";
 125      print "</table>";
 126      print "<div class=\"blockcontent\" >";
 127      if ($block) print "<div class=\"small_inner_block\">\n";
 128  
 129  //        Print block content
 130      $pgv_lang["global_num1"] = $config["days"];        // Make this visible
 131      if (count($found_facts)==0) {
 132          print_text("recent_changes_none");
 133      } else {
 134          print_text("recent_changes_some");
 135          $lastgid="";
 136          foreach($found_facts as $index=>$factarr) {
 137              if ($factarr[2]=="INDI") {
 138                  $gid = $factarr[0];
 139                  $factrec = $factarr[1];
 140                  if (displayDetailsById($gid)) {
 141                      $indirec = find_person_record($gid);
 142                      if ($lastgid!=$gid) {
 143                          $name = check_NN(get_person_name($gid));
 144                          print "<a href=\"individual.php?pid=$gid&amp;ged=".$GEDCOM."\"><b>".PrintReady($name)."</b>";
 145                          print "<img id=\"box-".$gid."-".$index."-sex\" src=\"$PGV_IMAGE_DIR/";
 146                          if (preg_match("/1 SEX M/", $indirec)>0) print $PGV_IMAGES["sex"]["small"]."\" title=\"".$pgv_lang["male"]."\" alt=\"".$pgv_lang["male"];
 147                          else  if (preg_match("/1 SEX F/", $indirec)>0) print $PGV_IMAGES["sexf"]["small"]."\" title=\"".$pgv_lang["female"]."\" alt=\"".$pgv_lang["female"];
 148                          else print $PGV_IMAGES["sexn"]["small"]."\" title=\"".$pgv_lang["unknown"]."\" alt=\"".$pgv_lang["unknown"];
 149                          print "\" class=\"sex_image\" />";
 150                          if ($SHOW_ID_NUMBERS) {
 151                              if ($TEXT_DIRECTION=="rtl") print "&rlm;";
 152                              print "(".$gid.")";
 153                              if ($TEXT_DIRECTION=="rtl") print "&rlm;";
 154                          }
 155                          print "</a><br />\n";
 156                          $lastgid=$gid;
 157                      }
 158                      print "<div class=\"indent" . ($TEXT_DIRECTION=="rtl"?"_rtl":"") . "\">";
 159                      print $factarray["CHAN"];
 160                      $ct = preg_match("/\d DATE (.*)/", $factrec, $match);
 161                      if ($ct>0) {
 162                              print " - <span class=\"date\">".get_changed_date($match[1]);
 163                              $tt = preg_match("/3 TIME (.*)/", $factrec, $match);
 164                              if ($tt>0) {
 165                                      print " - ".$match[1];
 166                              }
 167                              print "</span>\n";
 168                      }
 169                      print "</div><br />";
 170                  }
 171              }
 172  
 173              if ($factarr[2]=="FAM") {
 174                  $gid = $factarr[0];
 175                  $factrec = $factarr[1];
 176                  if (displayDetailsById($gid, "FAM")) {
 177                      $famrec = find_family_record($gid);
 178                      $name = get_family_descriptor($gid);
 179                      if ($lastgid!=$gid) {
 180                          print "<a href=\"family.php?famid=$gid&amp;ged=".$GEDCOM."\"><b>".PrintReady($name)."</b>";
 181                          if ($SHOW_FAM_ID_NUMBERS) {
 182                              print "&nbsp;&nbsp;";
 183                              if ($TEXT_DIRECTION=="rtl") print "&rlm;";
 184                              print "(".$gid.")";
 185                              if ($TEXT_DIRECTION=="rtl") print "&rlm;";
 186                          }
 187                          print "</a><br />\n";
 188                          $lastgid=$gid;
 189                      }
 190                      print "<div class=\"indent" . ($TEXT_DIRECTION=="rtl"?"_rtl":"") . "\">";
 191                      print $factarray["CHAN"];
 192                      $ct = preg_match("/\d DATE (.*)/", $factrec, $match);
 193                      if ($ct>0) {
 194                              print " - <span class=\"date\">".get_changed_date($match[1]);
 195                              $tt = preg_match("/3 TIME (.*)/", $factrec, $match);
 196                              if ($tt>0) {
 197                                      print " - ".$match[1];
 198                              }
 199                              print "</span>\n";
 200                      }
 201                      print "</div><br />";
 202                  }
 203              }
 204  
 205              if ($factarr[2]=="SOUR") {
 206                  $gid = $factarr[0];
 207                  $factrec = $factarr[1];
 208                  if (displayDetailsById($gid, "SOUR")) {
 209                      $sourcerec = find_source_record($gid);
 210                      $name = get_source_descriptor($gid);
 211                      if ($lastgid!=$gid) {
 212                          print "<a href=\"source.php?sid=$gid&amp;ged=".$GEDCOM."\"><b>".PrintReady($name)."</b>";
 213                          if ($SHOW_FAM_ID_NUMBERS) {
 214                              print "&nbsp;&nbsp;";
 215                              if ($TEXT_DIRECTION=="rtl") print "&rlm;";
 216                              print "(".$gid.")";
 217                              if ($TEXT_DIRECTION=="rtl") print "&rlm;";
 218                          }
 219                          print "</a><br />\n";
 220                          $lastgid=$gid;
 221                      }
 222                      print "<div class=\"indent" . ($TEXT_DIRECTION=="rtl"?"_rtl":"") . "\">";
 223                      print $factarray["CHAN"];
 224                      $ct = preg_match("/\d DATE (.*)/", $factrec, $match);
 225                      if ($ct>0) {
 226                              print " - <span class=\"date\">".get_changed_date($match[1]);
 227                              $tt = preg_match("/3 TIME (.*)/", $factrec, $match);
 228                              if ($tt>0) {
 229                                      print " - ".$match[1];
 230                              }
 231                              print "</span>\n";
 232                      }
 233                      print "</div><br />";
 234                  }
 235              }
 236  
 237              if ($factarr[2]=="REPO") {
 238                  $gid = $factarr[0];
 239                  $factrec = $factarr[1];
 240                  if (displayDetailsById($gid, "REPO")) {
 241                      $reporec = find_repo_record($gid);
 242                      $name = get_repo_descriptor($gid);
 243                      if ($lastgid!=$gid) {
 244                          print "<a href=\"repo.php?rid=$gid&amp;ged=".$GEDCOM."\"><b>".PrintReady($name)."</b>";
 245                          if ($SHOW_FAM_ID_NUMBERS) {
 246                              print "&nbsp;&nbsp;";
 247                              if ($TEXT_DIRECTION=="rtl") print "&rlm;";
 248                              print "(".$gid.")";
 249                              if ($TEXT_DIRECTION=="rtl") print "&rlm;";
 250                          }
 251                          print "</a><br />\n";
 252                          $lastgid=$gid;
 253                      }
 254                      print "<div class=\"indent" . ($TEXT_DIRECTION=="rtl"?"_rtl":"") . "\">";
 255                      print $factarray["CHAN"];
 256                      $ct = preg_match("/\d DATE (.*)/", $factrec, $match);
 257                      if ($ct>0) {
 258                              print " - <span class=\"date\">".get_changed_date($match[1]);
 259                              $tt = preg_match("/3 TIME (.*)/", $factrec, $match);
 260                              if ($tt>0) {
 261                                      print " - ".$match[1];
 262                              }
 263                              print "</span>\n";
 264                      }
 265                      print "</div><br />";
 266                  }
 267              }
 268              if ($factarr[2]=="OBJE") {
 269                  $gid = $factarr[0];
 270                  $factrec = $factarr[1];
 271                  if (displayDetailsById($gid, "OBJE")) {
 272                      $mediarec = find_media_record($gid);
 273                      if ($mediarec) {
 274                          if (isset($objectlist[$gid]["title"]) && $objectlist[$gid]["title"] != "") $title=$objectlist[$gid]["title"];
 275                          else $title = $objectlist[$gid]["file"];
 276                          $SearchTitle = preg_replace("/ /","+",$title);
 277                          if ($lastgid!=$gid) {
 278                               print "<a href=\"medialist.php?action=filter&amp;search=yes&amp;filter=$SearchTitle&amp;ged=".$GEDCOM."\"><b>".PrintReady($title)."</b>";
 279                              if ($SHOW_FAM_ID_NUMBERS) {
 280                                  print "&nbsp;&nbsp;";
 281                                  if ($TEXT_DIRECTION=="rtl") print "&rlm;";
 282                                  print "(".$gid.")";
 283                                  if ($TEXT_DIRECTION=="rtl") print "&rlm;";
 284                              }
 285                              print "</a><br />\n";
 286                              $lastgid=$gid;
 287                          }
 288                          print "<div class=\"indent" . ($TEXT_DIRECTION=="rtl"?"_rtl":"") . "\">";
 289                          print $factarray["CHAN"];
 290                          $ct = preg_match("/\d DATE (.*)/", $factrec, $match);
 291                          if ($ct>0) {
 292                                  print " - <span class=\"date\">".get_changed_date($match[1]);
 293                                  $tt = preg_match("/3 TIME (.*)/", $factrec, $match);
 294                                  if ($tt>0) {
 295                                          print " - ".$match[1];
 296                                  }
 297                                  print "</span>\n";
 298                          }
 299                          print "</div><br />";
 300                      }
 301                  }
 302              }
 303          }
 304  
 305      }
 306  
 307      if ($block) print "</div>\n"; //small_inner_block
 308      print "</div>"; // blockcontent
 309      print "</div>"; // block
 310  
 311  }
 312  
 313  function print_recent_changes_config($config) {
 314      global $pgv_lang, $PGV_BLOCKS, $TEXT_DIRECTION;
 315      if (empty($config)) $config = $PGV_BLOCKS["print_recent_changes"]["config"];
 316  
 317      print "<tr><td width=\"20%\" class=\"descriptionbox\">".$pgv_lang["days_to_show"]."</td>";?>
 318      <td class="optionbox">
 319          <input type="text" name="days" size="2" value="<?php print $config["days"]; ?>" />
 320      </td></tr>
 321  
 322      <?php
 323        print "<tr><td width=\"20%\" class=\"descriptionbox\">".$pgv_lang["show_empty_block"]."</td>";?>
 324      <td class="optionbox">
 325      <select name="hide_empty">
 326          <option value="no"<?php if ($config["hide_empty"]=="no") print " selected=\"selected\"";?>><?php print $pgv_lang["no"]; ?></option>
 327          <option value="yes"<?php if ($config["hide_empty"]=="yes") print " selected=\"selected\"";?>><?php print $pgv_lang["yes"]; ?></option>
 328      </select>
 329      </td></tr>
 330      <tr><td colspan="2" class="optionbox wrap">
 331          <span class="error"><?php print $pgv_lang["hide_block_warn"]; ?></span>
 332      </td></tr>
 333      <?php
 334  }
 335  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]