Ejemplo n.º 1
0
 public static function objectForData($data, $model = null, $className = null)
 {
     if (!$model) {
         $model = Media::getInstance();
     }
     if (!strlen($className) || $className == 'Asset') {
         if (!isset($data['kind'])) {
             $data['kind'] = 'asset';
         }
         switch ($data['kind']) {
             case 'asset':
                 $className = 'Asset';
                 break;
             case 'scheme':
                 require_once dirname(__FILE__) . '/scheme.php';
                 $className = 'Scheme';
                 break;
             case 'resource':
                 require_once dirname(__FILE__) . '/resource.php';
                 $className = 'Resource';
                 break;
             case 'version':
                 require_once dirname(__FILE__) . '/version.php';
                 $className = 'Version';
                 break;
             case 'episode':
             case 'clip':
                 require_once dirname(__FILE__) . '/episode.php';
                 $className = 'Episode';
                 break;
             case 'show':
             case 'series':
                 require_once dirname(__FILE__) . '/show.php';
                 $className = 'Show';
                 break;
             default:
                 if ($cs = $model->locateObject('[scheme:' . $data['kind'] . ']', null, 'scheme')) {
                     require_once dirname(__FILE__) . '/classification.php';
                     $className = 'Classification';
                     break;
                 }
                 trigger_error('Asset::objectForData(): No suitable class for a "' . $data['kind'] . '" asset is available', E_USER_NOTICE);
                 return null;
         }
     }
     return parent::objectForData($data, $model, $className);
 }
Ejemplo n.º 2
0
function print_favorite_selector_xx($option = 0)
{
    global $pgv_lang, $GEDCOM, $SCRIPT_NAME, $SHOW_ID_NUMBERS, $pid, $INDEX_DIRECTORY, $indilist, $famlist, $sourcelist, $medialist, $QUERY_STRING, $famid, $sid;
    global $TEXT_DIRECTION, $REQUIRE_AUTHENTICATION, $PGV_IMAGE_DIR, $PGV_IMAGES, $SEARCH_SPIDER;
    //	$username = getUserName();
    //	if (!empty($username)) $userfavs = getUserFavorites($username);
    //	else {
    //		if ($REQUIRE_AUTHENTICATION) return false;
    //		$userfavs = array();
    //	}
    if (empty($pid) && !empty($famid)) {
        $pid = $famid;
    }
    if (empty($pid) && !empty($sid)) {
        $pid = $sid;
    }
    $gedcomfavs = array();
    if (empty($username) && count($gedcomfavs) == 0) {
        return;
    }
    if (!empty($SEARCH_SPIDER)) {
        return;
        // show no favorites, because they taint every page that is indexed.
    }
    print "<div class=\"favorites_form\">\n";
    switch ($option) {
        case 1:
            $menu = array();
            $menu["label"] = $pgv_lang["favorites"];
            $menu["labelpos"] = "right";
            $menu["link"] = "#";
            $menu["class"] = "favmenuitem";
            $menu["hoverclass"] = "favmenuitem_hover";
            $menu["flyout"] = "down";
            $menu["submenuclass"] = "favsubmenu";
            $menu["items"] = array();
            $mygedcom = $GEDCOM;
            $current_gedcom = $GEDCOM;
            $mypid = $pid;
            if (count($userfavs) > 0) {
                $submenu = array();
                $submenu["label"] = "<b>" . $pgv_lang["my_favorites"] . "</b>";
                $submenu["labelpos"] = "right";
                $submenu["link"] = "#";
                $submenu["class"] = "favsubmenuitem";
                $submenu["hoverclass"] = "favsubmenuitem_hover";
                $menu["items"][] = $submenu;
            }
            foreach ($userfavs as $key => $favorite) {
                $pid = $favorite["gid"];
                $current_gedcom = $GEDCOM;
                $GEDCOM = $favorite["file"];
                $submenu = array();
                if ($favorite["type"] == "URL" && !empty($favorite["url"])) {
                    //					$submenu["link"] = $favorite["url"]."&amp;ged=$GEDCOM";
                    $submenu["link"] = $favorite["url"];
                    $submenu["label"] = PrintReady($favorite["title"]);
                    $submenu["labelpos"] = "right";
                    $submenu["class"] = "favsubmenuitem";
                    $submenu["hoverclass"] = "favsubmenuitem_hover";
                    $menu["items"][] = $submenu;
                } else {
                    if (displayDetailsById($pid, $favorite["type"])) {
                        $indirec = find_gedcom_record($pid);
                        if ($favorite["type"] == "INDI") {
                            $submenu["link"] = "individual.php?pid=" . $favorite["gid"] . "&amp;ged={$GEDCOM}";
                            $submenu["label"] = PrintReady(get_person_name($favorite["gid"]));
                            if ($SHOW_ID_NUMBERS) {
                                if ($TEXT_DIRECTION == "ltr") {
                                    $submenu["label"] .= " (" . $favorite["gid"] . ")";
                                } else {
                                    $submenu["label"] .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                }
                            }
                            unset($indilist[$pid]);
                        }
                        if ($favorite["type"] == "FAM") {
                            $submenu["link"] = "family.php?famid=" . $favorite["gid"] . "&amp;ged={$GEDCOM}";
                            $submenu["label"] = PrintReady(get_family_descriptor($favorite["gid"]));
                            if ($SHOW_ID_NUMBERS) {
                                if ($TEXT_DIRECTION == "ltr") {
                                    $submenu["label"] .= " (" . $favorite["gid"] . ")";
                                } else {
                                    $submenu["label"] .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                }
                            }
                            unset($famlist[$pid]);
                        }
                        if ($favorite["type"] == "SOUR") {
                            $submenu["link"] = "source.php?sid=" . $favorite["gid"] . "&amp;ged={$GEDCOM}";
                            $submenu["label"] = PrintReady(get_source_descriptor($favorite["gid"]));
                            if ($SHOW_ID_NUMBERS) {
                                if ($TEXT_DIRECTION == "ltr") {
                                    $submenu["label"] .= " (" . $favorite["gid"] . ")";
                                } else {
                                    $submenu["label"] .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                }
                            }
                            unset($sourcelist[$pid]);
                        }
                        if ($favorite["type"] == "OBJE") {
                            $media = Media::getInstance($pid);
                            if (!is_null($media)) {
                                $submenu["link"] = "mediaviewer.php?mid=" . $favorite["gid"] . "&amp;ged={$GEDCOM}";
                                $submenu["label"] = PrintReady($media->getTitle());
                                if ($SHOW_ID_NUMBERS) {
                                    if ($TEXT_DIRECTION == "ltr") {
                                        $submenu["label"] .= " (" . $favorite["gid"] . ")";
                                    } else {
                                        $submenu["label"] .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                    }
                                }
                                if (isset($medialist[$pid])) {
                                    unset($medialist[$pid]);
                                }
                            }
                        }
                        $submenu["labelpos"] = "right";
                        $submenu["class"] = "favsubmenuitem";
                        $submenu["hoverclass"] = "favsubmenuitem_hover";
                        $menu["items"][] = $submenu;
                    }
                }
            }
            $pid = $mypid;
            $GEDCOM = $mygedcom;
            if (!empty($username) && strpos($_SERVER["SCRIPT_NAME"], "individual.php") !== false) {
                $menu["items"][] = "separator";
                $submenu = array();
                $submenu["label"] = $pgv_lang["add_to_my_favorites"];
                $submenu["labelpos"] = "right";
                $submenu["link"] = "individual.php?action=addfav&amp;gid={$pid}&amp;pid={$pid}";
                $submenu["class"] = "favsubmenuitem";
                $submenu["hoverclass"] = "favsubmenuitem_hover";
                $menu["items"][] = $submenu;
            }
            if (count($gedcomfavs) > 0) {
                $menu["items"][] = "separator";
                $submenu = array();
                $submenu["label"] = "<b>" . $pgv_lang["gedcom_favorites"] . "</b>";
                $submenu["labelpos"] = "right";
                $submenu["link"] = "#";
                $submenu["class"] = "favsubmenuitem";
                $submenu["hoverclass"] = "favsubmenuitem_hover";
                $menu["items"][] = $submenu;
                $current_gedcom = $GEDCOM;
                foreach ($gedcomfavs as $key => $favorite) {
                    $GEDCOM = $favorite["file"];
                    $pid = $favorite["gid"];
                    $submenu = array();
                    if ($favorite["type"] == "URL" && !empty($favorite["url"])) {
                        //						$submenu["link"] = $favorite["url"]."&amp;ged=$GEDCOM";
                        $submenu["link"] = $favorite["url"];
                        $submenu["label"] = PrintReady($favorite["title"]);
                        $submenu["labelpos"] = "right";
                        $submenu["class"] = "favsubmenuitem";
                        $submenu["hoverclass"] = "favsubmenuitem_hover";
                        $menu["items"][] = $submenu;
                    } else {
                        if (displayDetailsById($pid, $favorite["type"])) {
                            $indirec = find_gedcom_record($pid);
                            if ($favorite["type"] == "INDI") {
                                $submenu["link"] = "individual.php?pid=" . $favorite["gid"] . "&amp;ged={$GEDCOM}";
                                $submenu["label"] = PrintReady(get_person_name($favorite["gid"]));
                                if ($SHOW_ID_NUMBERS) {
                                    if ($TEXT_DIRECTION == "ltr") {
                                        $submenu["label"] .= " (" . $favorite["gid"] . ")";
                                    } else {
                                        $submenu["label"] .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                    }
                                }
                            }
                            if ($favorite["type"] == "FAM") {
                                $submenu["link"] = "family.php?famid=" . $favorite["gid"] . "&amp;ged={$GEDCOM}";
                                $submenu["label"] = PrintReady(get_family_descriptor($favorite["gid"]));
                                if ($SHOW_ID_NUMBERS) {
                                    if ($TEXT_DIRECTION == "ltr") {
                                        $submenu["label"] .= " (" . $favorite["gid"] . ")";
                                    } else {
                                        $submenu["label"] .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                    }
                                }
                            }
                            if ($favorite["type"] == "SOUR") {
                                $submenu["link"] = "source.php?sid=" . $favorite["gid"] . "&amp;ged={$GEDCOM}";
                                $submenu["label"] = PrintReady(get_source_descriptor($favorite["gid"]));
                                if ($SHOW_ID_NUMBERS) {
                                    if ($TEXT_DIRECTION == "ltr") {
                                        $submenu["label"] .= " (" . $favorite["gid"] . ")";
                                    } else {
                                        $submenu["label"] .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                    }
                                }
                            }
                            $submenu["labelpos"] = "right";
                            $submenu["class"] = "favsubmenuitem";
                            $submenu["hoverclass"] = "favsubmenuitem_hover";
                            $menu["items"][] = $submenu;
                        }
                    }
                }
                $pid = $mypid;
                $GEDCOM = $mygedcom;
                print_menu($menu);
            }
            break;
        default:
            print "<form name=\"favoriteform\" action=\"{$SCRIPT_NAME}";
            print "\" method=\"post\" onsubmit=\"return false;\">";
            print "\n\t\t<select name=\"fav_id\" class=\"header_select\" onchange=\"if (document.favoriteform.fav_id.options[document.favoriteform.fav_id.selectedIndex].value!='') window.location=document.favoriteform.fav_id.options[document.favoriteform.fav_id.selectedIndex].value; if (document.favoriteform.fav_id.options[document.favoriteform.fav_id.selectedIndex].value=='add') window.location='{$SCRIPT_NAME}?{$QUERY_STRING}&amp;action=addfav&amp;gid={$pid}&amp;pid={$pid}';\">";
            print "\n\t\t\t<option value=\"\">" . $pgv_lang["favorites"] . "</option>\n";
            if (!empty($username)) {
                if (count($userfavs) > 0 || (strpos($_SERVER["SCRIPT_NAME"], "individual.php") !== false || strpos($_SERVER["SCRIPT_NAME"], "family.php") !== false || strpos($_SERVER["SCRIPT_NAME"], "source.php") !== false)) {
                    print "\n\t\t\t<optgroup label=\"" . $pgv_lang["my_favorites"] . "\">";
                }
                $mygedcom = $GEDCOM;
                $current_gedcom = $GEDCOM;
                $mypid = $pid;
                if (strpos($_SERVER["SCRIPT_NAME"], "individual.php") !== false || strpos($_SERVER["SCRIPT_NAME"], "family.php") !== false || strpos($_SERVER["SCRIPT_NAME"], "source.php") !== false) {
                    print "<option value=\"add\">- " . $pgv_lang["add_to_my_favorites"] . " -</option>\n";
                }
                foreach ($userfavs as $key => $favorite) {
                    $current_gedcom = $GEDCOM;
                    $GEDCOM = $favorite["file"];
                    $pid = $favorite["gid"];
                    if ($favorite["type"] == "URL" && !empty($favorite["url"])) {
                        //							print "\n\t\t\t\t<option value=\"".$favorite["url"]."&amp;ged=".$GEDCOM."\">".PrintReady($favorite["title"]);
                        print "\n\t\t\t\t<option value=\"" . $favorite["url"] . "\">" . PrintReady($favorite["title"]);
                        print "</option>";
                    } else {
                        if (displayDetailsById($pid, $favorite["type"])) {
                            $indirec = find_gedcom_record($pid);
                            $name = $pgv_lang["unknown"];
                            if ($favorite["type"] == "INDI") {
                                $name = strip_tags(PrintReady(get_person_name($pid)));
                                if ($SHOW_ID_NUMBERS) {
                                    if ($TEXT_DIRECTION == "ltr") {
                                        $name .= " (" . $favorite["gid"] . ")";
                                    } else {
                                        $name .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                    }
                                }
                                print "\n\t\t\t\t<option value=\"individual.php?pid=";
                                unset($indilist[$pid]);
                            }
                            if ($favorite["type"] == "FAM") {
                                $name = strip_tags(PrintReady(get_family_descriptor($pid)));
                                if (strlen($name) > 50) {
                                    $name = substr($name, 0, 50);
                                }
                                if ($SHOW_ID_NUMBERS) {
                                    if ($TEXT_DIRECTION == "ltr") {
                                        $name .= " (" . $favorite["gid"] . ")";
                                    } else {
                                        $name .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                    }
                                }
                                print "\n\t\t\t\t<option value=\"family.php?famid=";
                                unset($famlist[$pid]);
                            }
                            if ($favorite["type"] == "SOUR") {
                                $name = strip_tags(PrintReady(get_source_descriptor($pid)));
                                if (strlen($name) > 50) {
                                    $name = substr($name, 0, 50);
                                }
                                if ($SHOW_ID_NUMBERS) {
                                    if ($TEXT_DIRECTION == "ltr") {
                                        $name .= " (" . $favorite["gid"] . ")";
                                    } else {
                                        $name .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                    }
                                }
                                print "\n\t\t\t\t<option value=\"source.php?sid=";
                                unset($sourcelist[$pid]);
                            }
                            if ($favorite["type"] == "OBJE") {
                                $media = Media::getInstance($pid);
                                if (!is_null($media)) {
                                    $name = strip_tags(PrintReady($media->getTitle()));
                                    if (strlen($name) > 50) {
                                        $name = substr($name, 0, 50);
                                    }
                                    if ($SHOW_ID_NUMBERS) {
                                        if ($TEXT_DIRECTION == "ltr") {
                                            $name .= " (" . $favorite["gid"] . ")";
                                        } else {
                                            $name .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                        }
                                    }
                                    print "\n\t\t\t\t<option value=\"mediaviewer.php?mid=";
                                    unset($sourcelist[$pid]);
                                }
                            }
                            print $favorite["gid"] . "&amp;ged=" . $GEDCOM . "\">" . $name . "</option>";
                        }
                    }
                }
                if (count($userfavs) > 0 || (strpos($_SERVER["SCRIPT_NAME"], "individual.php") !== false || strpos($_SERVER["SCRIPT_NAME"], "family.php") !== false || strpos($_SERVER["SCRIPT_NAME"], "source.php") !== false)) {
                    print "\n\t\t\t</optgroup>";
                }
                $GEDCOM = $mygedcom;
                $pid = $mypid;
            }
            if (count($gedcomfavs) > 0) {
                print "\n\t\t\t<optgroup label=\"" . $pgv_lang["gedcom_favorites"] . "\">\n";
                $mygedcom = $GEDCOM;
                $current_gedcom = $GEDCOM;
                $mypid = $pid;
                foreach ($gedcomfavs as $key => $favorite) {
                    $current_gedcom = $GEDCOM;
                    $GEDCOM = $favorite["file"];
                    $pid = $favorite["gid"];
                    if ($favorite["type"] == "URL" && !empty($favorite["url"])) {
                        //							print "\n\t\t\t\t<option value=\"".$favorite["url"]."&amp;ged=".$GEDCOM."\">".PrintReady($favorite["title"]);
                        print "\n\t\t\t\t<option value=\"" . $favorite["url"] . "\">" . PrintReady($favorite["title"]);
                        print "</option>";
                    } else {
                        $indirec = find_gedcom_record($pid);
                        $name = $pgv_lang["unknown"];
                        if (displayDetailsById($pid, $favorite["type"])) {
                            if ($favorite["type"] == "INDI") {
                                $name = strip_tags(PrintReady(get_person_name($pid)));
                                if ($SHOW_ID_NUMBERS) {
                                    if ($TEXT_DIRECTION == "ltr") {
                                        $name .= " (" . $favorite["gid"] . ")";
                                    } else {
                                        $name .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                    }
                                }
                                print "\n\t\t\t\t<option value=\"individual.php?pid=";
                            }
                            if ($favorite["type"] == "FAM") {
                                $name = strip_tags(PrintReady(get_family_descriptor($pid)));
                                if ($SHOW_ID_NUMBERS) {
                                    if ($TEXT_DIRECTION == "ltr") {
                                        $name .= " (" . $favorite["gid"] . ")";
                                    } else {
                                        $name .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                    }
                                }
                                print "\n\t\t\t\t<option value=\"family.php?famid=";
                            }
                            if ($favorite["type"] == "SOUR") {
                                $name = strip_tags(PrintReady(get_source_descriptor($pid)));
                                if ($SHOW_ID_NUMBERS) {
                                    if ($TEXT_DIRECTION == "ltr") {
                                        $name .= " (" . $favorite["gid"] . ")";
                                    } else {
                                        $name .= " &rlm;(" . $favorite["gid"] . ")&rlm;";
                                    }
                                }
                                print "\n\t\t\t\t<option value=\"source.php?sid=";
                            }
                            print $favorite["gid"] . "&amp;ged={$GEDCOM}\">" . $name . "</option>";
                        }
                    }
                }
                print "\n\t\t\t</optgroup>";
                $GEDCOM = $mygedcom;
                $pid = $mypid;
            }
            print "</select>\n\t</form>\n";
            break;
    }
    print "</div>\n";
}
Ejemplo n.º 3
0
     }
 }
 // Fetch all data, regardless of privacy
 $rows = get_REPO_rows($WT_TREE, $term);
 // Filter for privacy
 foreach ($rows as $row) {
     $repository = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom);
     if ($repository->canShowName()) {
         $data[] = array('value' => $repository->getXref(), 'label' => $repository->getFullName());
     }
 }
 // Fetch all data, regardless of privacy
 $rows = get_OBJE_rows($WT_TREE, $term);
 // Filter for privacy
 foreach ($rows as $row) {
     $media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom);
     if ($media->canShowName()) {
         $data[] = array('value' => $media->getXref(), 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName());
     }
 }
 // Fetch all data, regardless of privacy
 $rows = get_FAM_rows($WT_TREE, $term);
 // Filter for privacy
 foreach ($rows as $row) {
     $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom);
     if ($family->canShowName()) {
         $marriage_year = $family->getMarriageYear();
         if ($marriage_year) {
             $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>');
         } else {
             $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName());
Ejemplo n.º 4
0
/**
 * find the highlighted media object for a gedcom entity
 *
 * Rules for finding the highlighted media object:
 * 1. The first _PRIM Y object will be used regardless of level in gedcom record
 * 2. The first level 1 object will be used if there if it doesn't have _PRIM N (level 1 objects appear on the media tab on the individual page)
 *
 * @param string $pid the individual, source, or family id
 * @param string $indirec the gedcom record to look in
 * @return array an object array with indexes "thumb" and "file" for thumbnail and filename
 */
function find_highlighted_object($pid, $indirec)
{
    global $MEDIA_DIRECTORY, $MEDIA_DIRECTORY_LEVELS, $PGV_IMAGE_DIR, $PGV_IMAGES, $MEDIA_EXTERNAL;
    global $GEDCOMS, $GEDCOM, $TBLPREFIX, $gBitDb;
    if (!showFactDetails("OBJE", $pid)) {
        return false;
    }
    $object = array();
    $media = array();
    //-- handle finding the media of remote objects
    $ct = preg_match("/(.*):(.*)/", $pid, $match);
    if ($ct > 0) {
        require_once '../classes/class_serviceclient.php';
        $client = ServiceClient::getInstance($match[1]);
        if (!is_null($client)) {
            $mt = preg_match_all('/\\n\\d OBJE @(' . PGV_REGEX_XREF . ')@/', $indirec, $matches, PREG_SET_ORDER);
            for ($i = 0; $i < $mt; $i++) {
                $mediaObj = Media::getInstance($matches[$i][1]);
                $mrec = $mediaObj->getGedcomRecord();
                if (!empty($mrec)) {
                    $file = get_gedcom_value("FILE", 1, $mrec);
                    $row = array($matches[$i][1], $file, $mrec, $matches[$i][0]);
                    $media[] = $row;
                }
            }
        }
    }
    //-- find all of the media items for a person
    $media = $gBitDb->query("SELECT m_media, m_file, m_gedrec, mm_gedrec FROM {$TBLPREFIX}media, {$TBLPREFIX}media_mapping WHERE m_media=mm_media AND m_gedfile=mm_gedfile AND m_gedfile=? AND mm_gid=? ORDER BY mm_order", array($GEDCOMS[$GEDCOM]["id"], $pid));
    while ($row = $media->fetchRow()) {
        if (displayDetailsById($row['m_media'], 'OBJE') && !FactViewRestricted($row['m_media'], $row['m_gedrec'])) {
            $level = 0;
            $ct = preg_match("/(\\d+) OBJE/", $row['mm_gedrec'], $match);
            if ($ct > 0) {
                $level = $match[1];
            }
            if (strstr($row['mm_gedrec'], "_PRIM ")) {
                $thum = get_gedcom_value('_THUM', $level + 1, $row['mm_gedrec']);
                $prim = get_gedcom_value('_PRIM', $level + 1, $row['mm_gedrec']);
            } else {
                $thum = get_gedcom_value('_THUM', 1, $row['m_gedrec']);
                $prim = get_gedcom_value('_PRIM', 1, $row['m_gedrec']);
            }
            if ($prim == 'N') {
                continue;
            }
            // Skip _PRIM N objects
            if ($prim == 'Y') {
                // Take the first _PRIM Y object
                $object["file"] = check_media_depth($row['m_file']);
                $object["thumb"] = thumbnail_file($row['m_file'], true, false, $pid);
                //				$object["_PRIM"] = $prim;	// Not sure whether this is needed.
                $object["_THUM"] = $thum;
                // This overrides GEDCOM's "Use main image as thumbnail" option
                $object["level"] = $level;
                $object["mid"] = $row['m_media'];
                break;
                // Stop looking: we found a suitable image
            }
            if ($level == 1 && empty($object)) {
                // Take the first level 1 object, but keep looking for an overriding _PRIM Y
                $object["file"] = check_media_depth($row['m_file']);
                $object["thumb"] = thumbnail_file($row['m_file'], true, false, $pid);
                //				$object["_PRIM"] = $prim;	// Not sure whether this is needed.
                $object["_THUM"] = $thum;
                // This overrides GEDCOM's "Use main image as thumbnail" option
                $object["level"] = $level;
                $object["mid"] = $row['m_media'];
            }
        }
    }
    return $object;
}
Ejemplo n.º 5
0
 function init()
 {
     global $MEDIA_DIRECTORY, $USE_MEDIA_FIREWALL, $GEDCOM, $pgv_changes;
     $filename = decrypt(safe_GET('filename'));
     $this->mid = safe_GET_xref('mid');
     if ($USE_MEDIA_FIREWALL && empty($filename) && empty($this->mid)) {
         // this section used by mediafirewall.php to determine what media file was requested
         if (isset($_SERVER['REQUEST_URI'])) {
             // NOTE: format of this server variable:
             // Apache: /phpGedView/media/a.jpg
             // IIS:    /phpGedView/mediafirewall.php?404;http://server/phpGedView/media/a.jpg
             $requestedfile = $_SERVER['REQUEST_URI'];
             // urldecode the request
             $requestedfile = rawurldecode($requestedfile);
             // make sure the requested file is in the media directory
             if (strpos($requestedfile, $MEDIA_DIRECTORY) !== false) {
                 // strip off the pgv directory and media directory from the requested url so just the image information is left
                 $filename = substr($requestedfile, strpos($requestedfile, $MEDIA_DIRECTORY) + strlen($MEDIA_DIRECTORY) - 1);
                 // if user requested a thumbnail, lookup permissions based on the original image
                 $filename = str_replace('/thumbs', '', $filename);
             }
         }
     }
     //Checks to see if the File Name ($filename) exists
     if (!empty($filename)) {
         //If the File Name ($filename) is set, then it will call the method to get the Media ID ($this->mid) from the File Name ($filename)
         $this->mid = get_media_id_from_file($filename);
         if (!$this->mid) {
             //This will set the Media ID to be false if the File given doesn't match to anything in the database
             $this->mid = false;
             // create a very basic gedcom record for this file so that the functions of the media object will work
             // this is used by the media firewall when requesting an object that exists in the media firewall directory but not in the gedcom
             $this->mediaobject = new Media("0 @" . "0" . "@ OBJE\n1 FILE " . $filename);
         }
     }
     //checks to see if the Media ID ($this->mid) is set. If the Media ID isn't set then there isn't any information avaliable for that picture the picture doesn't exist.
     if ($this->mid) {
         //This creates a Media Object from the getInstance method of the Media Class. It takes the Media ID ($this->mid) and creates the object.
         $this->mediaobject = Media::getInstance($this->mid);
         //This sets the controller ID to be the Media ID
         $this->pid = $this->mid;
     }
     if (is_null($this->mediaobject)) {
         return false;
     }
     $this->mediaobject->ged_id = PGV_GED_ID;
     // This record is from a file
     //-- perform the desired action
     switch ($this->action) {
         case "addfav":
             $this->addFavorite();
             break;
         case "accept":
             $this->acceptChanges();
             break;
         case "undo":
             $this->mediaobject->undoChange();
             break;
     }
     if ($this->mediaobject->canDisplayDetails()) {
         $this->canedit = PGV_USER_CAN_EDIT;
     }
 }
Ejemplo n.º 6
0
/**
* returns OBJEcts matching filter
* @return Array of string
*/
function autocomplete_OBJE($FILTER)
{
    $rows = get_autocomplete_OBJE($FILTER);
    $data = array();
    foreach ($rows as $row) {
        $media = Media::getInstance($row["m_media"]);
        if ($media && $media->canDisplayDetails()) {
            $data[$row["m_media"]] = "<img alt=\"" . $media->getXref() . "\" src=\"" . $media->getThumbnail() . "\" width=\"40\" /> " . $media->getFullName();
        }
    }
    return $data;
}
Ejemplo n.º 7
0
/**
* returns OBJEcts matching filter
* @return Array of string
*/
function autocomplete_OBJE($FILTER)
{
    global $TBLPREFIX, $gBitDb;
    $sql = "SELECT m_media FROM {$TBLPREFIX}media WHERE (m_titl LIKE ? OR m_media LIKE ?) AND m_gedfile=?";
    $rows = $gBitDb->query($sql, array("%{$FILTER}%", "%{$FILTER}%", PGV_GED_ID), PGV_AUTOCOMPLETE_LIMIT);
    $data = array();
    while ($row = $rows->fetchRows()) {
        $media = Media::getInstance($row['m_media']);
        if ($media && $media->canDisplayDetails()) {
            $data[$row['m_media']] = "<img alt=\"" . $media->getXref() . "\" src=\"" . $media->getThumbnail() . "\" width=\"40\" /> " . $media->getFullName();
        }
    }
    return $data;
}
Ejemplo n.º 8
0
function fetch_linked_obje($xref, $link, $ged_id)
{
    global $TBLPREFIX, $gBitDb;
    $rows = $gBitDb->getAll("SELECT 'OBJE' AS type, m_media AS xref, m_gedfile AS ged_id, m_gedrec AS gedrec, m_titl, m_file FROM {$TBLPREFIX}link, {$TBLPREFIX}media m WHERE m_gedfile=l_file AND m_media=l_from AND l_file=? AND l_type=? AND l_to=?", array($ged_id, $link, $xref));
    $list = array();
    foreach ($rows as $row) {
        $list[] = Media::getInstance($row);
    }
    return $list;
}
Ejemplo n.º 9
0
 public function __construct()
 {
     $this->model = Media::getInstance();
 }