function editInPlace_handle_request($context = '', $field = '', $value = '', $orig_value = '')
{
// Cannot edit when context not set in current page (should happen only when editing in place from index.php page)
if (!in_context(ZP_IMAGE) && !in_context(ZP_ALBUM) && !in_context(ZP_ZENPAGE_PAGE) && !in_context(ZP_ZENPAGE_NEWS_ARTICLE)) {
die($orig_value . '<script type="text/javascript">alert("' . gettext('Oops.. Cannot edit from this page') . '");</script>');
}
// Make a copy of context object
switch ($context) {
case 'image':
global $_zp_current_image;
$object = $_zp_current_image;
break;
case 'album':
global $_zp_current_album;
$object = $_zp_current_album;
break;
case 'zenpage_page':
global $_zp_current_zenpage_page;
$object = $_zp_current_zenpage_page;
break;
case 'zenpage_news':
global $_zp_current_zenpage_news;
$object = $_zp_current_zenpage_news;
break;
default:
die(gettext('Error: malformed Ajax POST'));
}
// Dates need to be handled before stored
if ($field == 'date') {
$value = date('Y-m-d H:i:s', strtotime($value));
}
// Sanitize new value
switch ($field) {
case 'desc':
$level = 1;
break;
case 'title':
$level = 2;
break;
default:
$level = 3;
}
$value = str_replace("\n", '<br />', sanitize($value, $level));
// note: not using nl2br() here because it adds an extra "\n"
// Write new value
if ($field == '_update_tags') {
$value = trim($value, ', ');
$object->setTags($value);
} else {
$object->set($field, $value);
}
$result = $object->save();
if ($result !== false) {
echo $value;
} else {
echo '<script type="text/javascript">alert("' . gettext('Could not save!') . '");</script>' . $orig_value;
}
zp_error(gettext('Front_end_edit could not save changes!'));
}
/**
* Prints a playlist using jPlayer. Several playlists per page supported.
*
* The playlist is meant to replace the 'next_image()' loop on a theme's album.php.
* It can be used with a special 'album theme' that can be assigned to media albums with with .flv/.mp4/.mp3s, although Flowplayer 3 also supports images
* Replace the entire 'next_image()' loop on album.php with this:
* <?php printjPlayerPlaylist("playlist"); ?> or <?php printjPlayerPlaylist("playlist-audio"); ?>
*
* @param string $option "playlist" use for pure video and mixed video/audio playlists or if you want to show the poster/videothumb with audio only playlists,
* "playlist-audio" use for pure audio playlists (m4a,mp3,fla supported only) if you don't need the poster/videothumb to be shown only.
* @param string $albumfolder album name to get a playlist from directly
*/
function printjPlayerPlaylist($option = "playlist", $albumfolder = "")
{
global $_zp_current_album, $_zp_current_search;
if (empty($albumfolder)) {
if (in_context(ZP_SEARCH)) {
$albumobj = $_zp_current_search;
} else {
$albumobj = $_zp_current_album;
}
} else {
$albumobj = newAlbum($albumfolder);
}
$entries = $albumobj->getImages(0);
if (($numimages = count($entries)) != 0) {
switch ($option) {
case 'playlist':
$suffixes = array('m4a', 'm4v', 'mp3', 'mp4', 'flv', 'fla');
break;
case 'playlist-audio':
$suffixes = array('m4a', 'mp3', 'fla');
break;
default:
// an invalid option parameter!
return;
}
$id = $albumobj->getID();
?>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_<?php
echo $id;
?>
",
cssSelectorAncestor: "#jp_container_<?php
echo $id;
?>
"
}, [
<?php
$count = '';
$number = '';
foreach ($entries as $entry) {
$count++;
if (is_array($entry)) {
$ext = getSuffix($entry['filename']);
} else {
$ext = getSuffix($entry);
}
$numbering = '';
if (in_array($ext, $suffixes)) {
$number++;
if (getOption('jplayer_playlist_numbered')) {
$numbering = '<span>' . $number . '</span>';
}
$video = newImage($albumobj, $entry);
$videoThumb = '';
$this->setModeAndSuppliedFormat($ext);
if ($option == 'playlist' && getOption('jplayer_poster')) {
$videoThumb = ',poster:"' . $video->getCustomImage(null, $this->width, $this->height, $this->width, $this->height, null, null, true) . '"';
}
$playtime = '';
if (getOption('jplayer_playlist_playtime')) {
$playtime = ' (' . $video->get('VideoPlaytime') . ')';
}
?>
{
title:"<?php
echo $numbering . html_encode($video->getTitle()) . $playtime;
?>
",
<?php
if (getOption('jplayer_download')) {
?>
free:true,
<?php
}
?>
<?php
echo $this->supplied;
?>
:"<?php
echo html_encode(pathurlencode($url = $video->getFullImageURL(FULLWEBPATH)));
?>
"
<?php
echo $this->getCounterpartFiles($url, $ext);
//.........这里部分代码省略.........
/** Prints the jQuery jCarousel HTML setup to be replaced by JS
*
* @param int $minitems The minimum number of thumbs to be visible always if resized regarding responsiveness.
* @param int $maxitems not supported
* @param int $width Width Set to NULL if you want to use the backend plugin options.
* @param int $height Height Set to NULL if you want to use the backend plugin options.
* @param int $cropw Crop width Set to NULL if you want to use the backend plugin options.
* @param int $croph Crop heigth Set to NULL if you want to use the backend plugin options.
* @param bool $crop TRUE for cropped thumbs, FALSE for un-cropped thumbs. $width and $height then will be used as maxspace. Set to NULL if you want to use the backend plugin options.
* @param bool $fullimagelink Set to TRUE if you want the thumb link to link to the full image instead of the image page. Set to NULL if you want to use the backend plugin options.
* @param string $vertical 'horizontal','vertical', 'fade'
* @param int $speed not supported
*/
function printThumbNav($minitems = NULL, $maxitems = NULL, $width = NULL, $height = NULL, $cropw = NULL, $croph = NULL, $fullimagelink = NULL, $vertical = NULL, $speed = NULL, $thumbscroll = NULL)
{
global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_search, $_zp_gallery_page;
// Just incase the theme has not set the option, at least second try will work!
setOptionDefault('slideshow_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page), 1);
$items = "";
if (is_object($_zp_current_album) && $_zp_current_album->getNumImages() >= 2) {
if (is_null($thumbscroll)) {
$thumbscroll = getOption('jcarousel_scroll');
} else {
$thumbscroll = sanitize_numeric($thumbscroll);
}
if (is_null($width)) {
$width = getOption('jcarousel_width');
} else {
$width = sanitize_numeric($width);
}
if (is_null($height)) {
$height = getOption('jcarousel_height');
} else {
$height = sanitize_numeric($height);
}
if (is_null($cropw)) {
$cropw = getOption('jcarousel_cropw');
} else {
$cropw = sanitize_numeric($cropw);
}
if (is_null($croph)) {
$croph = getOption('jcarousel_croph');
} else {
$croph = sanitize_numeric($croph);
}
if (is_null($fullimagelink)) {
$fullimagelink = getOption('jcarousel_fullimagelink');
} else {
$fullimagelink = sanitize($fullimagelink);
}
if (is_null($vertical)) {
$vertical = getOption('jcarousel_vertical');
} else {
$vertical = sanitize($vertical);
}
if ($vertical) {
$vertical = 'true';
} else {
$vertical = 'false';
}
if (in_context(ZP_SEARCH_LINKED)) {
if ($_zp_current_search->getNumImages() === 0) {
$searchimages = false;
} else {
$searchimages = true;
}
} else {
$searchimages = false;
}
if (in_context(ZP_SEARCH_LINKED) && $searchimages) {
$jcarousel_items = $_zp_current_search->getImages();
} else {
$jcarousel_items = $_zp_current_album->getImages();
}
if (count($jcarousel_items) >= 2) {
foreach ($jcarousel_items as $item) {
if (is_array($item)) {
$imgobj = newImage($_zp_current_album, $item['filename']);
} else {
$imgobj = newImage($_zp_current_album, $item);
}
if ($fullimagelink) {
$link = $imgobj->getFullImageURL();
} else {
$link = $imgobj->getLink();
}
if (!is_null($_zp_current_image)) {
if ($_zp_current_album->isDynamic()) {
if ($_zp_current_image->filename == $imgobj->filename && $_zp_current_image->getAlbum()->name == $imgobj->getAlbum()->name) {
$active = 'active';
} else {
$active = '';
}
} else {
if ($_zp_current_image->filename == $imgobj->filename) {
$active = 'active';
} else {
$active = '';
}
}
//.........这里部分代码省略.........
/**
* returns the hitcounter for the current page or for the object passed
*
* @param object $obj the album or page object for which the hitcount is desired
* @return string
*/
function getHitcounter($obj = NULL)
{
global $_zp_current_album, $_zp_current_image, $_zp_gallery_page, $_zp_current_article, $_zp_current_page, $_zp_current_category;
if (is_null($obj)) {
switch ($_zp_gallery_page) {
case 'album.php':
$obj = $_zp_current_album;
break;
case 'image.php':
$obj = $_zp_current_image;
break;
case 'pages.php':
$obj = $_zp_current_page;
break;
case 'news.php':
if (in_context(ZP_ZENPAGE_NEWS_CATEGORY)) {
$obj = $_zp_current_category;
} else {
$obj = $_zp_current_article;
if (is_null($obj)) {
return 0;
}
}
break;
case 'search.php':
return NULL;
default:
$page = stripSuffix($_zp_gallery_page);
return getOption('Page-Hitcounter-' . $page);
}
}
return $obj->getHitcounter();
}
请发表评论