Ejemplo n.º 1
0
/**
 * Prints a list of tags, editable by admin
 *
 * @param string $option links by default, if anything else the
 *               tags will not link to all other images with the same tag
 * @param string $preText text to go before the printed tags
 * @param string $class css class to apply to the div surrounding the UL list
 * @param string $separator what charactor shall separate the tags
 * @param bool   $editable true to allow admin to edit the tags
 * @param string $editclass CSS class applied to editable element if editable
 * @param mixed $messageIfEmpty Either bool or string. If false, echoes nothing when description is empty. If true, echoes default placeholder message if empty. If string, echoes string.
 * @since 1.1
 */
function printTags($option = 'links', $preText = NULL, $class = NULL, $separator = ', ', $editable = true, $editclass = NULL, $messageIfEmpty = true)
{
    global $_zp_current_search;
    if (is_null($class)) {
        $class = 'taglist';
    }
    $editable = $editable && getOption('edit_in_place');
    $singletag = getTags();
    $tagstring = implode(', ', $singletag);
    if ($tagstring === '' or $tagstring === NULL) {
        $preText = '';
        if ($messageIfEmpty === true && $editable && zp_loggedin()) {
            $tagstring = gettext('(No tags...)');
        } elseif (is_string($messageIfEmpty)) {
            $tagstring = $messageIfEmpty;
        }
    }
    if (in_context(ZP_IMAGE)) {
        $object = "image";
    } else {
        if (in_context(ZP_ALBUM)) {
            $object = "album";
        } else {
            if (in_context(ZP_ZENPAGE_PAGE)) {
                $object = "pages";
            } else {
                if (in_context(ZP_ZENPAGE_NEWS_ARTICLE)) {
                    $object = "news";
                }
            }
        }
    }
    if ($editable && zp_loggedin()) {
        printEditable($object, '_update_tags', true, $editclass, $tagstring);
    } else {
        if (count($singletag) > 0) {
            if (!empty($preText)) {
                echo "<span class=\"tags_title\">" . $preText . "</span>";
            }
            echo "<ul class=\"" . $class . "\">\n";
            if (is_object($_zp_current_search)) {
                $albumlist = $_zp_current_search->album_list;
            } else {
                $albumlist = NULL;
            }
            $ct = count($singletag);
            $x = 0;
            foreach ($singletag as $atag) {
                $latag = search_quote($atag);
                if (++$x == $ct) {
                    $separator = "";
                }
                if ($option === "links") {
                    $links1 = "<a href=\"" . html_encode(getSearchURL($latag, '', 'tags', 0, array('albums' => $albumlist))) . "\" title=\"" . html_encode($atag) . "\" rel=\"nofollow\">";
                    $links2 = "</a>";
                } else {
                    $links1 = $links2 = '';
                }
                echo "\t<li>" . $links1 . $atag . $links2 . $separator . "</li>\n";
            }
            echo "</ul>";
        } else {
            echo "{$tagstring}";
        }
    }
}
/**
 * @deprecated
 */
function printAlbumPlace($editable = false, $editclass = '', $messageIfEmpty = true)
{
    deprecated_function_notify(gettext('Use printAlbumLocation().'));
    if ($messageIfEmpty === true) {
        $messageIfEmpty = gettext('(No place...)');
    }
    printEditable('album', 'location', $editable, $editclass, $messageIfEmpty, !getOption('tinyMCEPresent'));
}
/**
 * Prints a list of tags, editable by admin
 *
 * @param string $option links by default, if anything else the
 *               tags will not link to all other photos with the same tag
 * @param string $preText text to go before the printed tags
 * @param string $class css class to apply to the div surrounding the UL list
 * @param string $separator what charactor shall separate the tags
 * @param bool   $editable true to allow admin to edit the tags
 * @param string $editclass CSS class applied to editable element if editable
 * @param mixed $messageIfEmpty Either bool or string. If false, echoes nothing when description is empty. If true, echoes default placeholder message if empty. If string, echoes string.
 * @since 1.1
 */
function printTags($option = 'links', $preText = NULL, $class = 'taglist', $separator = ', ', $editable = TRUE, $editclass = '', $messageIfEmpty = true)
{
    $singletag = getTags();
    $tagstring = implode(', ', $singletag);
    if ($tagstring === '' or $tagstring === NULL) {
        $preText = '';
        if ($messageIfEmpty === true && $editable && zp_loggedin()) {
            $tagstring = gettext('(No tags...)');
        } elseif (is_string($messageIfEmpty)) {
            $tagstring = $messageIfEmpty;
        }
    }
    $object = in_context(ZP_IMAGE) ? 'image' : 'album';
    if ($editable && zp_loggedin()) {
        printEditable($object, '_update_tags', true, $editclass, $tagstring);
    } else {
        if (count($singletag) > 0) {
            if (!empty($preText)) {
                echo "<span class=\"tags_title\">" . $preText . "</span>";
            }
            echo "<ul class=\"" . $class . "\">\n";
            $ct = count($singletag);
            for ($x = 0; $x < $ct; $x++) {
                if ($x === $ct - 1) {
                    $separator = "";
                }
                if ($option === "links") {
                    $links1 = "<a href=\"" . htmlspecialchars(getSearchURL($singletag[$x], '', SEARCH_TAGS, 0, 0)) . "\" title=\"" . html_encode($singletag[$x]) . "\" rel=\"nofollow\">";
                    $links2 = "</a>";
                }
                echo "\t<li>" . $links1 . $singletag[$x] . $links2 . $separator . "</li>\n";
            }
            echo "</ul>";
        } else {
            echo "{$tagstring}";
        }
    }
}