Beispiel #1
0
    /**
     * Shows the chart system
     * 
     * @author Ross Carlson
     * @version 01/26/05
     * @since 01/26/05
     * @param $node The node we are viewing so we can filter
     * @param $types The charts to display. Comma seperated list of:
     * topplayalbum, topplayartist, topdownalbum, newalbums, newartists, newtracks
     * recentplayalbum, recentplayartist, recentplaytrack,
     * topratedalbum, topratedartist, topviewartist, topplaytrack
     * @param $numItems The number of items we want to return (defaults to 5)
     * @param $format Should we format this or return raw data (defaults to true)
     * @param $opts an array of extra options (transitioning to new parameter scheme)
     * 
     */
    function showCharts($node, $types = false, $numItems = false, $format = true, $vertAlign = false, $opts = false)
    {
        global $album_name_truncate, $img_tiny_play, $img_tiny_play_dis, $jzUSER, $img_rss, $root_dir, $advanced_tooltips, $rss_in_charts, $num_items_in_charts, $chart_timeout_days, $chart_types;
        $be = new jzBackend();
        if ($be->hasFeature('charts') === false) {
            return;
        }
        // Let's setup our objects
        $blocks = new jzBlocks();
        $display = new jzDisplay();
        $nobr = true;
        if ($opts !== false) {
            if (isset($opts['allow_breaks'])) {
                $nobr = false;
            } else {
                $nobr = true;
            }
        }
        // Now let's do a loop creating all our blocks
        if ($types === false || $types == "") {
            if (isset($chart_types) && !isNothing($chart_types)) {
                $b = $chart_types;
            } else {
                $b = "topplayalbum,topplayartist,topviewartist,newalbums";
            }
        } else {
            $b = $types;
        }
        $bArray = explode(",", $b);
        for ($e = 0; $e < count($bArray); $e++) {
            // Now let's create our blocks
            $showPlays = false;
            switch ($bArray[$e]) {
                case "topplayalbum":
                    $func = "getMostPlayed";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "played-albums";
                    $title = word("Top Played Albums");
                    $distance = "album";
                    $showPlays = true;
                    $showDownload = false;
                    $rss = "most-played";
                    break;
                case "topplayartist":
                    $func = "getMostPlayed";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "played-artists";
                    $title = word("Top Played Artists");
                    $distance = "artist";
                    $showPlays = true;
                    $showDownload = false;
                    $rss = "most-played-artist";
                    break;
                case "topdownalbum":
                    $func = "getMostDownloaded";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "downloaded-albums";
                    $title = word("Top Downloaded Albums");
                    $distance = "album";
                    $showDownload = true;
                    $rss = "most-downloaded";
                    break;
                case "newalbums":
                    $func = "getRecentlyAdded";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "new-albums";
                    $title = word("New Albums");
                    $distance = "album";
                    $showDownload = false;
                    $rss = "last-added";
                    break;
                case "newartists":
                    $func = "getRecentlyAdded";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "new-artists";
                    $title = word("New Artists");
                    $distance = "artist";
                    $showDownload = false;
                    $rss = "last-added-artists";
                    break;
                case "newtracks":
                    $func = "getRecentlyAdded";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "new-tracks";
                    $title = word("New Tracks");
                    $distance = "track";
                    $showDownload = false;
                    $rss = "last-added-tracks";
                    break;
                case "recentplaytrack":
                    $func = "getRecentlyPlayed";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "recentplayed-tracks";
                    $title = word("Recently Played Tracks");
                    $distance = "track";
                    $showDownload = false;
                    $rss = "recentplayed-track";
                    break;
                case "topplaytrack":
                    $func = "getMostPlayed";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "played-tracks";
                    $title = word("Top Played Tracks");
                    $distance = "track";
                    $showDownload = false;
                    $rss = "most-played-tracks";
                    break;
                case "recentplayalbum":
                    $func = "getRecentlyPlayed";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "recentplayed-albums";
                    $title = word("Recently Played Albums");
                    $distance = "album";
                    $showDownload = false;
                    $rss = "recentplayed-album";
                    break;
                case "recentplayartist":
                    $func = "getRecentlyPlayed";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "recentplayed-artists";
                    $title = word("Recently Played Artists");
                    $distance = "artist";
                    $showDownload = false;
                    $rss = "recentplayed-artist";
                    break;
                case "topratedalbum":
                    $func = "getTopRated";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "toprated-albums";
                    $title = word("Top Rated Albums");
                    $distance = "album";
                    $showDownload = false;
                    $rss = "toprated-album";
                    break;
                case "topratedartist":
                    $func = "getTopRated";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "toprated-artists";
                    $title = word("Top Rated Artists");
                    $distance = "artist";
                    $showDownload = false;
                    $rss = "toprated-artist";
                    break;
                case "topviewartist":
                    $func = "getMostViewed";
                    $arr['action'] = "popup";
                    $arr['ptype'] = "topstuff";
                    $arr['tptype'] = "topviewed-artists";
                    $title = word("Most Viewed Artists");
                    $distance = "artist";
                    $showDownload = false;
                    $rss = "topviewed-artist";
                    break;
                default:
                    continue;
            }
            // Now let's get the data
            if ($distance == "track") {
                $returnType = "tracks";
            } else {
                $returnType = "nodes";
            }
            if ($numItems) {
                $num_items_in_charts = $numItems;
            }
            if ($chart_timeout_days > 0) {
                $be = new jzBackend();
                $data_id .= pathize('chart-' . $node->getPath("String")) . "-{$func}-{$distance}-{$num_items_in_charts}";
                if (($recent = $be->loadData($data_id, true)) === false) {
                    $recent = $node->{$func}($returnType, distanceTo($distance, $node), $num_items_in_charts);
                    $be->storeData($data_id, $recent, $chart_timeout_days);
                }
            } else {
                $recent = $node->{$func}($returnType, distanceTo($distance, $node), $num_items_in_charts);
            }
            // Now let's see if we got data
            if (count($recent) == 0) {
                continue;
            }
            ?>
			<td width="25%" valign="top">
				<?php 
            if ($format) {
                echo '<div id="slickMainBlockBody">';
            }
            ?>
				<table width="95%" cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td width="100%" valign="middle">
				   <?php 
            if ($nobr) {
                echo '<nobr>';
            }
            ?>
							<?php 
            if ($format) {
                // Now let's display the link to the FULL top played list
                echo '<a onclick="openPopup(this, 300, 450); return false;" title="' . $title . '" href="' . urlize($arr) . '"><strong>' . $title . '</strong></a>';
                // Let's link to the RSS feed
                if ($rss_in_charts == "true") {
                    echo ' - <a href="' . $root_dir . '/rss.php?type=' . $rss;
                    if ($node->getLevel() != 0) {
                        echo '&root=' . $node->getPath("String");
                    }
                    echo '">' . $img_rss . '</a>';
                }
                echo '<br>';
            }
            // Now let's loop through the results
            for ($i = 0; $i < count($recent); $i++) {
                // Now let's create our node and get the properties
                $item = $artnode = $recent[$i];
                $album = $item->getName();
                $parent = $item->getAncestor("artist");
                if ($parent !== false) {
                    $artist = $parent->getName();
                }
                $albumDLCount = $item->getDownloadCount();
                $year = $item->getYear();
                $dispYear = "";
                if ($year != "-") {
                    $dispYear = " (" . $year . ")";
                }
                // Now let's create our links
                if ($distance == "track") {
                    $artnode = $item->getAncestor("album");
                    if (is_object($artnode)) {
                        $albumArr['jz_path'] = $artnode->getPath("String");
                        $gp = $item->getAncestor("artist");
                        if (is_object($gp)) {
                            $artistArr['jz_path'] = $gp->getPath("String");
                        } else {
                            $artistArr['jz_path'] = '';
                        }
                    } else {
                        $albumArr['jz_path'] = '';
                        $artistArr['jz_path'] = '';
                    }
                } else {
                    $albumArr['jz_path'] = $item->getPath("String");
                    if ($parent !== false) {
                        $artistArr['jz_path'] = $parent->getPath("String");
                    }
                }
                // Now let's create our short names
                $artistTitle = returnItemShortName($artist, $album_name_truncate);
                $albumTitle = returnItemShortName($album, $album_name_truncate);
                // Now let's display it
                if ($nobr) {
                    echo "<nobr>";
                }
                if (!$jzUSER->getSetting('stream')) {
                    echo $img_tiny_play_dis;
                } else {
                    $display->playLink($item, $img_tiny_play, $album);
                }
                // Ok, did they want advanced tooltips?
                if ($advanced_tooltips == "true") {
                    // Now let's set the hover code
                    $innerOver = "";
                    $showTip = false;
                    if (($art = $artnode->getMainArt("75x75")) != false) {
                        $innerOver .= $display->returnImage($art, $artnode->getName(), 75, 75, "limit", false, false, "left", "3", "3");
                        $showTip = true;
                        $bTitle = $artist . " - " . $album . $dispYear;
                    } else {
                        // Ok, no art so let's make this look better
                        $innerOver .= "<strong>" . $artist . "<br>" . $album . $dispYear . "</strong><br>";
                        $bTitle = $album . $dispYear;
                    }
                    $desc_truncate = 200;
                    $desc = $item->getDescription();
                    if (!isNothing($desc)) {
                        $innerOver .= $display->returnShortName($desc, $desc_truncate);
                        $showTip = true;
                    }
                    // Now let's fix up
                    $innerOver = str_replace("'", "", str_replace('"', "", $innerOver));
                    $bTitle = str_replace("'", "", str_replace('"', "", $bTitle));
                    if ($showTip) {
                        $title = $display->returnToolTip($innerOver, $bTitle);
                    } else {
                        $title = ' title="' . $artist . ' - ' . $album . $dispYear . '"';
                    }
                } else {
                    // Standard tooltips
                    $title = ' title="' . $artist . ' - ' . $album . $dispYear . '"';
                }
                echo ' <a ' . $title . ' href="' . urlize($albumArr) . '">' . $albumTitle;
                if ($showPlays) {
                    if ($bArray[$e] == "topplayalbum") {
                        $albumPlayCount = $item->getSubNodeCount('tracks', -1);
                        if ($albumPlayCount > 0) {
                            $albumPlayCount = ceil($item->getPlayCount() / $albumPlayCount);
                        }
                    } else {
                        $albumPlayCount = $item->getPlayCount();
                    }
                    echo ' (' . $albumPlayCount . ')';
                }
                if ($showDownload) {
                    echo ' (' . $albumDLCount . ')';
                }
                echo "</a><br>";
                if ($nobr) {
                    echo "</nobr>";
                }
            }
            if ($nobr) {
                echo '</nobr>';
            }
            ?>
						</td>
					</tr>
				</table>
				<?php 
            if ($format) {
                echo '</div>';
            }
            ?>
			</td>
			    <?php 
            if ($vertAlign) {
                echo '</tr><tr>';
            }
            ?>
		<?php 
        }
    }
Beispiel #2
0
    ?>
								</nobr>
							</td>
							<td width="70%" valign="top">
								<input type="text" name="edit_item_year" value="<?php 
    echo $node->getYear();
    ?>
" class="jz_input" size="4">
							</td>
						</tr>
								    <?php 
} else {
    echo '<input type="hidden" name="edit_item_year" value="' . $node->getYear() . '" class="jz_input" size="4">';
}
$be = new jzBackend();
if ($be->hasFeature('setID')) {
    ?>
									    
						<tr class="<?php 
    echo $row_colors[$i];
    $i = 1 - $i;
    ?>
">
							<td width="30%" valign="top">
								    
								<nobr>
									<?php 
    echo word("Item ID");
    ?>
								</nobr>
							</td>
Beispiel #3
0
 /**
  * Shows the Slick formated chart system
  * 
  * @author Ross Carlson
  * @version 01/26/05
  * @since 01/26/05
  * @param $node The node we are viewing so we can filter
  */
 function showSlickCharts($node, $types = false)
 {
     global $album_name_truncate, $img_tiny_play, $display_charts, $chart_timeout_days;
     $be = new jzBackend();
     if ($be->hasFeature('charts') === false) {
         return;
     }
     $display = new jzDisplay();
     if ($display->startCache("showSlickCharts", $node, $chart_timeout_days)) {
         return;
     }
     // First let's make sure they even want the charts
     if ($display_charts != "true") {
         return;
     }
     $smarty = smartySetup();
     $title = word("Charts");
     if ($node->getName() != "") {
         $title = word("Charts") . " :: " . $node->getName();
     }
     $smarty->assign('title', $title);
     $smarty->display(SMARTY_ROOT . 'templates/slick/block-charts.tpl');
     // Now lets finish out the cache
     $display->endCache();
 }
Beispiel #4
0
 function moveMedia($element, $newpath)
 {
     $root = new jzMediaNode();
     $be = new jzBackend();
     $playpath = $element->getFilePath();
     $type = $element->isLeaf() ? "leaf" : "node";
     if (is_string($newpath)) {
         $path = explode("/", $newpath);
     } else {
         if (is_array($newpath)) {
             $path = $newpath;
         } else {
             return false;
         }
     }
     if ($type == "node") {
         return false;
     }
     $pc = $element->getPlayCount();
     $dc = $element->getDownloadCount();
     $vc = $element->getViewCount();
     $desc = $element->getDescription();
     $sdesc = $element->getShortDescription();
     $art = $element->getMainArt();
     $discussion = $element->getDiscussion();
     $rating = $element->getRating();
     $rating_count = $element->getRatingCount();
     if ($be->hasFeature('setID')) {
         $mid = $element->getID();
     }
     // TODO:
     // This does not work correctly with nodes yet.
     // You should pull the above data, then recursively move children,
     // then remove me, and finally set the data as below.
     // I did not do this yet (8/11/05) because I would not have been
     // able to test it. (for things like collisions,
     // and also how to handle the filesystem)
     // If the backend has a lookup file, update it.
     if ($element->isLeaf()) {
         $media_path = getMediaDir($element);
         $be = new jzBackend();
         $rl_name = 'reverse_lookup-' . str_replace(':', '', str_replace('\\', '-', str_replace('/', '-', $media_path)));
         $LOOKUP = $be->loadData($rl_name);
         if (is_array($LOOKUP)) {
             if (isset($LOOKUP[$element->getFilename("host")])) {
                 $LOOKUP[$element->getFilename("host")] = implode('/', $path);
                 $be->storeData($rl_name, $LOOKUP);
             }
         }
     }
     $this->removeMedia($element);
     if (false !== ($new = $root->inject($path, $playpath))) {
         $new->setPlayCount($pc);
         $new->setDownloadCount($dc);
         $new->setViewCount($vc);
         $new->addRating($rating, $rating_count);
         if ($be->hasFeature('setID')) {
             $new->setID($mid);
         }
         if (!isNothing($desc)) {
             $new->addDescription($desc);
         }
         if (!isNothing($sdesc)) {
             $new->addShortDescription($sdesc);
         }
         if (!isNothing($art)) {
             $new->addMainArt($art);
         }
         if ($discussion != array() && !isNothing($discussion)) {
             $new->addFullDiscussion($discussion);
         }
         return $new;
     }
 }