Beispiel #1
0
 public function deletefavorites()
 {
     //测试数据
     //$this->input['id'] = 467;
     //实例化收藏类
     $favorites = new favorites();
     //传递参数
     $status_id = $this->input['id'];
     $favorites->deletefavorites($status_id);
     //print_r($ret);
 }
/**
 * Smarty {get_favorites} function plugin
 *
 * Type:     function<br>
 * Name:     get_favorites<br>
 * Purpose:  get and assign favorites
 *
 * @param         $params
 * @param \Smarty $smarty
 * @return bool
 */
function smarty_function_get_favorites($params, &$smarty)
{
    global $user;
    $uid = empty($params['user_id']) ? $user->id : $params['user_id'];
    $id = empty($params['id']) ? null : $params['id'];
    $smarty->assign($params['assign'], favorites::get($params['module'], $id, $uid));
}
Beispiel #3
0
 public function show()
 {
     global $gScriptName, $gScriptNameArray;
     if ($this->user['id'] > 0) {
         $info = new user();
         $user_info = $info->getUserById($this->user['id']);
         $user_info = $user_info[0];
         $favorites = new favorites();
         //传递参数
         $u_id = $this->input['user_id'];
         $status_id = $this->input['statusid'];
         $count = 50;
         $total = 'gettotal';
         $page = intval($this->input['pp']) / $count;
         $statusline = $favorites->favorites($total, $page, $count, $u_id);
         if (is_array($statusline)) {
             $data['totalpages'] = $statusline[0]['total'];
             unset($statusline[0]);
             $data['perpage'] = $count;
             $data['curpage'] = $this->input['pp'];
             $showpages = hg_build_pagelinks($data);
         }
         $topic_follow = $this->status->getTopicFollow();
     }
     $topic = $this->status->getTopic();
     $this->page_title = $this->lang['pageTitle'];
     $gScriptName = SCRIPTNAME;
     hg_add_head_element('js-c', "\r\n\t\t\tvar re_back = 'favorites.php';\r\n\t\t\tvar re_back_login = '******';\r\n\t\t");
     hg_add_head_element('js', RESOURCE_DIR . 'scripts/' . 'favorites.js');
     hg_add_head_element('js', RESOURCE_DIR . 'scripts/' . 'dispose.js');
     hg_add_head_element('js', RESOURCE_DIR . 'scripts/' . 'rotate.js');
     $this->tpl->addVar('user_info', $user_info);
     $this->tpl->addVar('status_id', $status_id);
     $this->tpl->addVar('statusline', $statusline);
     $this->tpl->addVar('showpages', $showpages);
     $this->tpl->addVar('no_result', $no_result);
     $this->tpl->addVar('have_followers', $have_followers);
     $this->tpl->addVar('showpages', $showpages);
     $this->tpl->addVar('topic_follow', $topic_follow);
     $this->tpl->addVar('topic', $topic);
     $this->tpl->addHeaderCode(hg_add_head_element('echo'));
     $this->tpl->setTemplateTitle($this->page_title);
     $this->tpl->outTemplate('favorites');
     //数据写入粉丝模板
 }
Beispiel #4
0
 /**
  * 取消收藏
  */
 public function del_collect()
 {
     include_once ROOT_PATH . 'lib/video/video.class.php';
     $this->mVideo = new video();
     $id = $this->input['id'] ? $this->input['id'] : 0;
     $cid = $this->input['cid'] ? $this->input['cid'] : 0;
     $type = $this->input['type'] ? $this->input['type'] : 0;
     if (!$id && !$cid) {
         echo json_encode('');
         exit;
     } else {
         include_once ROOT_PATH . 'lib/favorites/favorites.class.php';
         $fa = new favorites();
         $fa->del($id);
         switch ($type) {
             case 0:
                 $this->mVideo->video_favorite_count($cid, 0);
                 $ret = $this->mVideo->del_collect($id, $cid, $type);
                 break;
             case 1:
                 $this->mVideo->station_favorite_count($cid, 0);
                 $uid = $this->input['uid'];
                 $ret = $this->mVideo->del_station_concern($id, $uid);
                 $ret['relation'] = $this->get_relation($this->user['id'], $uid);
                 break;
             case 2:
                 $this->mVideo->user_favorite_count($cid, 0);
                 break;
             case 3:
                 $this->mVideo->album_favorite_count($cid, 0);
                 $ret = $this->mVideo->del_collect($id, $cid, $type);
                 break;
             default:
                 break;
         }
         ob_end_clean();
         echo json_encode($ret);
         exit;
     }
 }
Beispiel #5
0
/**
 * Prints the Galleria slideshow for albums or search results.
 *
 * Two ways to use (see readme/documentation):
 * a) Used on the included theme slideshow.php page and called via printSlideShowLink() from the core slideshow plugin:
 * b) Calling directly via printGslideshow() function in a template file or codeblock.
 *
 * @param obj $albumobj The object of the album to show the slideshow of. Not needed if calling slideshow from album, image, or search.
 * @param obj $imageobj The object of the image to start the slideshow with. If not set the slideshow starts with the first image of the album, or current image if called from image.php. Not needed if calling slideshow from album, image, or search.
 * @param bool $linkslides Set to true if you want the slides to be linked to their image pages
 * @param mixed $autoplay true to autoplay slideshow with interval set in options, false to start with slideshow stopped.  Set integer in milliseconds to autoplay at that interval (Ex. 4000), overriding plugin option set.
 * @param bool $shuffle Set to true if you want random (shuffled) order of the slides
 *
 * */
function printGslideshow($albumobj = null, $imageobj = null, $linkslides = true, $autoplay = true, $forceheight = false, $shuffle = false)
{
    $data = 'data';
    // no POST data from slidehow link and $albumobj provided is not valid, exit
    if (!isset($_POST['albumid']) and !is_object($albumobj)) {
        echo "<div class=\"errorbox\" id=\"message\"><h2>" . gettext("Invalid linking to the slideshow page.") . "</h2></div>";
        echo "</div></body></html>";
        exitZP();
    }
    global $_zp_current_image, $_zp_current_album, $_zp_gallery, $_myFavorites, $_zp_conf_vars;
    $imagenumber = 0;
    //getting the image to start with
    if (!empty($_POST['imagenumber']) and !is_object($imageobj)) {
        $imagenumber = sanitize_numeric($_POST['imagenumber']) - 1;
        // slideshows starts with 0, but zp with 1.
    } elseif (is_object($imageobj)) {
        makeImageCurrent($imageobj);
        $imagenumber = imageNumber() - 1;
    }
    // set pagenumber to 0 if not called via POST link
    if (isset($_POST['pagenr'])) {
        $pagenumber = sanitize_numeric($_POST['pagenr']);
    } else {
        $pagenumber = 1;
    }
    // getting the number of images
    if (!empty($_POST['numberofimages'])) {
        $numberofimages = sanitize_numeric($_POST['numberofimages']);
    } elseif (is_object($albumobj)) {
        $numberofimages = $albumobj->getNumImages();
    } else {
        $numberofimages = 0;
    }
    if ($imagenumber < 2 || $imagenumber > $numberofimages) {
        $imagenumber = 0;
    }
    //getting the album to show
    if (!empty($_POST['albumid']) && !is_object($albumobj)) {
        $albumid = sanitize_numeric($_POST['albumid']);
        $embedded = false;
    } elseif (is_object($albumobj)) {
        $albumid = $albumobj->getID();
        $embedded = true;
    } else {
        $albumid = 0;
        $embedded = false;
    }
    if ($numberofimages == 0) {
        return NULL;
    }
    // get slideshow data
    if (isset($_POST['preserve_search_params'])) {
        // search page
        $search = new SearchEngine();
        $params = sanitize($_POST['preserve_search_params']);
        $search->setSearchParams($params);
        $images = $search->getImages(0);
        $searchwords = $search->getSearchWords();
        $searchdate = $search->getSearchDate();
        $searchfields = $search->getSearchFields(true);
        $page = $search->page;
        $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
        $albumtitle = gettext('Search');
    } else {
        if (isset($_POST['favorites_page'])) {
            $album = $_myFavorites;
            $albumtitle = gettext('My Favorites');
            $images = $album->getImages(0);
            $returnpath = rewrite_path(favorites::getFavorites_link() . '/' . $pagenumber, FULLWEBPATH . '/index.php?p=favorites' . '&page=' . $pagenumber);
        } else {
            $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
            $album = newAlbum($albumq['folder']);
            $albumtitle = $album->getTitle();
            if (!$album->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumq['folder'])) {
                echo gettext("This album is password protected!");
                exitZP();
            }
            $dynamic = $album->isDynamic();
            $images = $album->getImages(0);
            // return path to get back to the page we called the slideshow from
            if (empty($_POST['imagenumber'])) {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/page/' . $pagenumber, '/index.php?album=' . urlencode($album->name) . '&page=' . $pagenumber);
            } else {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/' . rawurlencode(sanitize($_POST['imagefile'])) . getOption('mod_rewrite_image_suffix'), '/index.php?album=' . urlencode($album->name) . '&image=' . urlencode($_POST['imagefile']));
            }
        }
    }
    if ($shuffle) {
        shuffle($images);
    }
    // slideshow display section
    ?>

			<script>
				var data = [
				<?php 
    for ($imgnr = 0, $cntr = 0, $idx = 0; $imgnr < $numberofimages; $imgnr++, $idx++) {
        if (is_array($images[$idx])) {
            $filename = $images[$idx]['filename'];
            $album = newAlbum($images[$idx]['folder']);
            $image = newImage($album, $filename);
        } else {
            $filename = $images[$idx];
            $image = newImage($album, $filename);
        }
        $ext = isImagePhoto($image);
        if ($ext) {
            makeImageCurrent($image);
            echo '{' . "\n";
            echo 'thumb: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_thumbsize'), getOption('gslideshow_thumbsize')) . '\',' . "\n";
            echo 'image: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_mediumsize'), getOption('gslideshow_mediumsize')) . '\',' . "\n";
            echo 'big: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_bigsize'), getOption('gslideshow_bigsize')) . '\',' . "\n";
            echo 'title: \'' . js_encode($image->getTitle()) . '\',' . "\n";
            $desc = $image->getDesc();
            $desc = str_replace("\r\n", '<br />', $desc);
            $desc = str_replace("\r", '<br />', $desc);
            echo 'description: \'' . js_encode($desc) . '\',' . "\n";
            if ($linkslides) {
                echo 'link: \'' . html_encode($image->getLink()) . '\'' . "\n";
            }
            if ($imgnr == $numberofimages - 1) {
                echo '}' . "\n";
            } else {
                echo '},' . "\n";
            }
        }
    }
    echo "\n";
    ?>
				];
			</script>
			<?php 
    printGalleriaRun($data, $linkslides, $autoplay, $embedded, $forceheight, $imagenumber, $albumtitle, $returnpath);
    //restore_context(); // needed if the slideshow is for example called directly via album object before the next_album loop on index.php
}
Beispiel #6
0
        function printAddToFavorites($obj, $add = NULL, $remove = NULL)
        {
            global $_myFavorites, $_zp_current_admin_obj, $_zp_gallery_page, $_myFavorites_button_count;
            if (!zp_loggedin() || $_myFavorites->getOwner() != $_zp_current_admin_obj->getUser() || !is_object($obj) || !$obj->exists) {
                return;
            }
            $v = 1;
            if (is_null($add)) {
                $add = get_language_string(getOption('favorites_add_button'));
            }
            if (is_null($remove)) {
                $remove = get_language_string(getOption('favorites_remove_button'));
            } else {
                $add = $remove;
            }
            $table = $obj->table;
            $target = array('type' => $table);
            if ($_zp_gallery_page == 'favorites.php') {
                //	 only need one remove button since we know the instance
                $multi = false;
                $list = array($_myFavorites->instance);
            } else {
                if ($multi = getOption('favorites_multi')) {
                    $list = $_myFavorites->list;
                } else {
                    $list = array('');
                }
                if (extensionEnabled('tag_suggest') && !$_myFavorites_button_count) {
                    $_myFavorites_button_count++;
                    $favList = array_slice($list, 1);
                    ?>
					<script type="text/javascript">
						// <!-- <![CDATA[
						var _favList = ['<?php 
                    echo implode("','", $favList);
                    ?>
'];
						$(function() {
							$('.favorite_instance').tagSuggest({tags: _favList})
						});
						// ]]> -->
					</script>
					<?php 
                }
            }
            $seen = array_flip($list);
            switch ($table) {
                case 'images':
                    $id = $obj->imagefolder . '/' . $obj->filename;
                    foreach ($list as $instance) {
                        $_myFavorites->instance = $instance;
                        $images = $_myFavorites->getImages(0);
                        $seen[$instance] = false;
                        foreach ($images as $image) {
                            if ($image['folder'] == $obj->imagefolder && $image['filename'] == $obj->filename) {
                                $seen[$instance] = true;
                                favorites::ad_removeButton($obj, $id, 0, $remove, $instance, $multi);
                                break;
                            }
                        }
                    }
                    if ($multi || in_array(false, $seen)) {
                        favorites::ad_removeButton($obj, $id, 1, $add, NULL, $multi);
                    }
                    break;
                case 'albums':
                    $id = $obj->name;
                    foreach ($list as $instance) {
                        $_myFavorites->instance = $instance;
                        $albums = $_myFavorites->getAlbums(0);
                        $seen[$instance] = false;
                        foreach ($albums as $album) {
                            if ($album == $id) {
                                $seen[$instance] = true;
                                favorites::ad_removeButton($obj, $id, 0, $remove, $instance, $multi);
                                break;
                            }
                        }
                    }
                    if ($multi || in_array(false, $seen)) {
                        favorites::ad_removeButton($obj, $id, 1, $add, NULL, $multi);
                    }
                    break;
                default:
                    //We do not handle these.
                    return;
            }
        }
 /**
  * Delete the entire album PERMANENTLY. Be careful! This is unrecoverable.
  * Returns true if successful
  *
  * @return bool
  */
 function remove()
 {
     if ($rslt = parent::remove()) {
         @chmod($this->localpath, 0777);
         $rslt = @unlink($this->localpath);
         clearstatcache();
     }
     $this->_removeCache(substr($this->localpath, strlen(ALBUM_FOLDER_SERVERPATH)));
     return $rslt;
 }
Beispiel #8
0
            $mem[$values['id']] = $values;
        }
        //博客信息和用户信息合并
        $this->setXmlNode('statuses', 'status');
        foreach ($blog as $key => $values) {
            $values['user'] = $mem[$values['member_id']];
            $all[$values['id']] = $values;
        }
        return $all;
    }
    public function getMedia($id)
    {
        include_once ROOT_DIR . 'lib/class/status.class.php';
        $status = new status();
        if (is_array($id)) {
            $ids = implode(",", $id);
        } else {
            $ids = $id;
        }
        return $status->getMediaByStatusId($ids);
    }
    /**
     * 入口
     */
    public function show()
    {
        $this->favorites();
    }
}
$out = new favorites();
$out->show();
Beispiel #9
0
printAdminHeader('edit', gettext('dynamic'));
echo "\n</head>";
echo "\n<body>";
printLogoAndLinks();
echo "\n" . '<div id="main">';
printTabs();
echo "\n" . '<div id="content">';
zp_apply_filter('admin_note', 'albums', 'dynamic');
echo "<h1>" . gettext("Create Favorites Album") . "</h1>\n";
if (isset($_POST['savealbum'])) {
    // we fell through, some kind of error
    echo "<div class=\"errorbox space\">";
    echo "<h2>" . gettext("Failed to save the album file") . "</h2>";
    echo "</div>\n";
}
$source = new favorites($user);
if ($favorite) {
    $source->instance = $favorite;
} else {
    $favorite = gettext('favorite');
}
$albumlist = array();
$albumname = $user . '-' . $favorite;
genAlbumList($albumlist);
$images = $source->getImages(0);
foreach ($images as $image) {
    $folder = $image['folder'];
    $filename = $image['filename'];
    $imagelist[] = '/' . $folder . '/' . $filename;
}
$subalbums = $source->getAlbums(0);
    static function showWatchers($html, $obj, $prefix)
    {
        if (!trim($prefix, '-')) {
            //	only on single item tabs
            $watchers = favorites::getWatchers($obj);
            $multi = false;
            foreach ($watchers as $key => $aux) {
                $array = getSerializedArray($aux);
                if (array_key_exists(1, $array)) {
                    $multi = true;
                    break;
                }
            }
            if (!empty($watchers)) {
                ?>
				<tr>
					<td>
						<?php 
                echo gettext('Users watching:');
                ?>
					</td>
					<td class="top">
						<?php 
                if ($multi) {
                    ?>
							<dl class="userlist">
								<dh>
									<dt><em><?php 
                    echo gettext('User');
                    ?>
</em></dt>
									<dd><em><?php 
                    echo gettext('instance');
                    ?>
</em></dd>
								</dh>
								<?php 
                    favorites::listWatchers($obj, array('<dt>', '</dt><dd>', '</dd>'));
                    ?>
							</dl>
							<?php 
                } else {
                    ?>
							<ul class="userlist">
								<?php 
                    favorites::listWatchers($obj, array('<li>', '', '</li>'));
                    ?>
							</ul>
							<?php 
                }
                ?>
					</td>
				</tr>
				<?php 
            }
        }
        return $html;
    }