Ejemplo n.º 1
0
function getRelatedItems($type = 'news', $album = NULL)
{
    global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_page, $_zp_current_zenpage_news, $_zp_gallery_page;
    $tags = getTags();
    if (!empty($tags)) {
        // if there are tags at all
        $searchstring = '';
        $count = '';
        foreach ($tags as $tag) {
            $count++;
            if ($count == 1) {
                $bool = '';
            } else {
                $bool = '|';
                // connect tags by OR to get a wide range
            }
            $searchstring .= $bool . $tag;
        }
        $paramstr = urlencode('words') . '=' . $searchstring . '&searchfields=tags';
        if (!is_null($album)) {
            $paramstr = '&albumname=' . urlencode($album);
        }
        $search = new SearchEngine();
        switch ($type) {
            case 'albums':
                $paramstr .= '&inalbums=1';
                break;
            case 'images':
                $paramstr .= '&inimages=1';
                break;
            case 'news':
                $paramstr .= '&innews=1';
                break;
            case 'pages':
                $paramstr .= '&inpages=1';
                break;
            case 'all':
                $paramstr .= '&inalbums=1&inimages=1&innews=1&inpages=1';
                break;
        }
        $search->setSearchParams($paramstr);
        // get the results
        switch ($type) {
            case 'albums':
                $albumresult = $search->getAlbums(0, "date", "desc");
                $result = createRelatedItemsResultArray($albumresult, $type);
                break;
            case 'images':
                $imageresult = $search->getImages(0, 0, 'date', 'desc');
                $result = createRelatedItemsResultArray($imageresult, $type);
                break;
            case 'news':
                $newsresult = $search->getArticles(0, NULL, true, "date", "desc");
                $result = createRelatedItemsResultArray($newsresult, $type);
                break;
            case 'pages':
                $pageresult = $search->getPages();
                $result = createRelatedItemsResultArray($pageresult, $type);
                break;
            case 'all':
                $albumresult = $search->getAlbums(0, "date", "desc");
                $imageresult = $search->getImages(0, 0, 'date', 'desc');
                $newsresult = $search->getArticles(0, NULL, true, "date", "desc");
                $pageresult = $search->getPages();
                $result1 = createRelatedItemsResultArray($albumresult, 'albums');
                $result2 = createRelatedItemsResultArray($imageresult, 'images');
                $result3 = createRelatedItemsResultArray($newsresult, 'news');
                $result4 = createRelatedItemsResultArray($pageresult, 'pages');
                $result = array_merge($result1, $result2, $result3, $result4);
                $result = sortMultiArray($result, 'weight', true, true, false, false);
                // sort by search result weight
                break;
        }
        return $result;
    }
    return array();
}
Ejemplo n.º 2
0
/**
 * recovers search parameters from stored cookie, clears the cookie
 *
 * @param string $what the page type
 * @param string $album Name of the album
 * @param string $image Name of the image
 */
function handleSearchParms($what, $album = NULL, $image = NULL)
{
    global $_zp_current_search, $zp_request, $_zp_last_album, $_zp_current_album, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_gallery, $_zp_loggedin;
    $_zp_last_album = zp_getCookie('zenphoto_last_album');
    if (is_object($zp_request) && get_class($zp_request) == 'SearchEngine') {
        //	we are are on a search
        return $zp_request->getAlbumList();
    }
    $params = zp_getCookie('zenphoto_search_params');
    if (!empty($params)) {
        $context = get_context();
        $_zp_current_search = new SearchEngine();
        $_zp_current_search->setSearchParams($params);
        // check to see if we are still "in the search context"
        if (!is_null($image)) {
            $dynamic_album = $_zp_current_search->getDynamicAlbum();
            if ($_zp_current_search->getImageIndex($album->name, $image->filename) !== false) {
                if ($dynamic_album) {
                    $_zp_current_album = $dynamic_album;
                }
                $context = $context | ZP_SEARCH_LINKED | ZP_IMAGE_LINKED;
            }
        }
        if (!is_null($album)) {
            $albumname = $album->name;
            zp_setCookie('zenphoto_last_album', $albumname);
            if (hasDynamicAlbumSuffix($albumname) && !is_dir(ALBUM_FOLDER_SERVERPATH . $albumname)) {
                $albumname = stripSuffix($albumname);
                // strip off the suffix as it will not be reflected in the search path
            }
            //	see if the album is within the search context. NB for these purposes we need to look at all albums!
            $save_logon = $_zp_loggedin;
            $_zp_loggedin = $_zp_loggedin | VIEW_ALL_RIGHTS;
            $search_album_list = $_zp_current_search->getAlbums(0);
            $_zp_loggedin = $save_logon;
            foreach ($search_album_list as $searchalbum) {
                if (strpos($albumname, $searchalbum) !== false) {
                    $context = $context | ZP_SEARCH_LINKED | ZP_ALBUM_LINKED;
                    break;
                }
            }
        } else {
            zp_clearCookie('zenphoto_last_album');
        }
        if (!is_null($_zp_current_zenpage_page)) {
            $pages = $_zp_current_search->getPages();
            if (!empty($pages)) {
                $tltlelink = $_zp_current_zenpage_page->getTitlelink();
                foreach ($pages as $apage) {
                    if ($apage == $tltlelink) {
                        $context = $context | ZP_SEARCH_LINKED;
                        break;
                    }
                }
            }
        }
        if (!is_null($_zp_current_zenpage_news)) {
            $news = $_zp_current_search->getArticles(0, NULL, true);
            if (!empty($news)) {
                $tltlelink = $_zp_current_zenpage_news->getTitlelink();
                foreach ($news as $anews) {
                    if ($anews['titlelink'] == $tltlelink) {
                        $context = $context | ZP_SEARCH_LINKED;
                        break;
                    }
                }
            }
        }
        if ($context & ZP_SEARCH_LINKED) {
            set_context($context);
        } else {
            // not an object in the current search path
            $_zp_current_search = null;
            rem_context(ZP_SEARCH);
            if (!isset($_REQUEST['preserve_serch_params'])) {
                zp_clearCookie("zenphoto_search_params");
            }
        }
    }
}
Ejemplo n.º 3
0
$imagechecked = !isset($_POST['XSRFToken']) || @$_POST['image_tag'];
$albumchecked = !isset($_POST['XSRFToken']) || @$_POST['album_tag'];
$articlechecked = !isset($_POST['XSRFToken']) || @$_POST['article_tag'];
$pagechecked = !isset($_POST['XSRFToken']) || @$_POST['page_tag'];
$images = $search->getImages(0);
$albums = $search->getAlbums(0);
$count = 0;
if ($imagechecked) {
    $count = $count + count($images);
}
if ($albumchecked) {
    $count = $count + count($albums);
}
if (extensionEnabled('zenpage')) {
    $articles = $search->getArticles();
    $pages = $search->getPages();
    if ($articlechecked) {
        $count = $count + count($articles);
    }
    if ($pagechecked) {
        $count = $count + count($pages);
    }
} else {
    $articles = $pages = array();
}
printAdminHeader('tags');
echo "\n</head>";
?>

<body>
	<?php