<commit_before>#!/usr/bin/php
<?php
/*!
* LinnDS-jukebox
*
* Copyright (c) 2012-2013 <NAME>, http://tolbøl.dk
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*/

require_once("setup.php");
require_once("MakePlaylists.php");
require_once("album.php");
require_once("FileUtils.php");



// ########## CLASS: DIDLPreset  ##########################################################

class DIDLPreset 
{
    private static $NoInstances = 0;
    private $Value = array();

    public function __construct($FileName, $RootMenuNo = -1)
    {
	self::$NoInstances++;
	$this->Value[InstanceNo] = self::$NoInstances;
	$this->Value[File] = new SplFileInfo($FileName);
	if ($this->Value[File]->getExtension() == "dpl")
	{
	    $this->Value[Info] = explode("+", $this->Value[File]->getBasename('.dpl'));
	    $this->Value[Path] = explode("/", RelativePath($this->Value[File]->getPath()));
	}
	else
	{
	    $xml = simplexml_load_file(ProtectPath($this->Value[File]->getPathname()));

	    foreach ($xml->children() as $info) {
		$this->Value[$info->getName()]  = (string) $info;
	    }
	    $this->Value[Path] = explode("/", RelativePath($this->Value[Playlist]));
	}
	$this->Value[RootMenuNo] = $RootMenuNo;
	//print_r($this->Value);
    }

    public function PlaylistFileName()
    {
	if ($this->Value[File]->getExtension() == "dpl")
	    return $this->Value[File]->getPathname();
	else
	    return $this->Value[Playlist];
    }

    public function ImageFileName()
    {
	if ($this->Value[File]->getExtension() == "dpl")
	    return $this->Value[File]->getPath() . "/folder.jpg";
	else
	    return $this->Value[Art];
    }

    public function setSequenceNo($No)
    {
	$this->Value[SequenceNo] = $No;
    }

    public function SequenceNo()
    {
	return $this->Value[SequenceNo];
    }

    public function TopDirectory()
    {
	return $this->Value[Path][1];
    }

    public function RootMenuNo()
    {
	global $NL;
	global $TopDirectory;

	if ($this->Value[RootMenuNo] != -1)
	    return $this->Value[RootMenuNo];

	foreach ($TopDirectory as $Dir => $RootMenuNo)
	{
	    $RelDir = str_replace("LINN_JUKEBOX_URL/", "", RelativePath($Dir));
	    if ($RelDir == $this->TopDirectory())
		return $RootMenuNo;
	}
	return 0;
    }

    public function dump()
    {
	print_r($this->Value);
    }

    public function URI()
    {
	return RelativePath($this->PlaylistFileName());
    }

    public function ImageURI()
    {
	return RelativePath($this->ImageFileName());
    }

    public function Artist()
    {
	if ($this->Value[File]->getExtension() == "dpl")
	    return $this->Value[Info][0];
	else
	    return $this->Value[Artist];
    }
    public function ArtistFirst()
    {
	$F = strtoupper(substr($this->SortSkipWords($this->Artist()), 0, 1));

	if ($F >= "A" && $F < "Z")
	    return $F;<commit_msg>count Z as a seperate category...<commit_after>#!/usr/bin/php
<?php
/*!
* LinnDS-jukebox
*
* Copyright (c) 2012-2013 <NAME>, http://tolbøl.dk
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*/

require_once("setup.php");
require_once("MakePlaylists.php");
require_once("album.php");
require_once("FileUtils.php");



// ########## CLASS: DIDLPreset  ##########################################################

class DIDLPreset 
{
    private static $NoInstances = 0;
    private $Value = array();

    public function __construct($FileName, $RootMenuNo = -1)
    {
	self::$NoInstances++;
	$this->Value[InstanceNo] = self::$NoInstances;
	$this->Value[File] = new SplFileInfo($FileName);
	if ($this->Value[File]->getExtension() == "dpl")
	{
	    $this->Value[Info] = explode("+", $this->Value[File]->getBasename('.dpl'));
	    $this->Value[Path] = explode("/", RelativePath($this->Value[File]->getPath()));
	}
	else
	{
	    $xml = simplexml_load_file(ProtectPath($this->Value[File]->getPathname()));

	    foreach ($xml->children() as $info) {
		$this->Value[$info->getName()]  = (string) $info;
	    }
	    $this->Value[Path] = explode("/", RelativePath($this->Value[Playlist]));
	}
	$this->Value[RootMenuNo] = $RootMenuNo;
	//print_r($this->Value);
    }

    public function PlaylistFileName()
    {
	if ($this->Value[File]->getExtension() == "dpl")
	    return $this->Value[File]->getPathname();
	else
	    return $this->Value[Playlist];
    }

    public function ImageFileName()
    {
	if ($this->Value[File]->getExtension() == "dpl")
	    return $this->Value[File]->getPath() . "/folder.jpg";
	else
	    return $this->Value[Art];
    }

    public function setSequenceNo($No)
    {
	$this->Value[SequenceNo] = $No;
    }

    public function SequenceNo()
    {
	return $this->Value[SequenceNo];
    }

    public function TopDirectory()
    {
	return $this->Value[Path][1];
    }

    public function RootMenuNo()
    {
	global $NL;
	global $TopDirectory;

	if ($this->Value[RootMenuNo] != -1)
	    return $this->Value[RootMenuNo];

	foreach ($TopDirectory as $Dir => $RootMenuNo)
	{
	    $RelDir = str_replace("LINN_JUKEBOX_URL/", "", RelativePath($Dir));
	    if ($RelDir == $this->TopDirectory())
		return $RootMenuNo;
	}
	return 0;
    }

    public function dump()
    {
	print_r($this->Value);
    }

    public function URI()
    {
	return RelativePath($this->PlaylistFileName());
    }

    public function ImageURI()
    {
	return RelativePath($this->ImageFileName());
    }

    public function Artist()
    {
	if ($this->Value[File]->getExtension() == "dpl")
	    return $this->Value[Info][0];
	else
	    return $this->Value[Artist];
    }
    public function ArtistFirst()
    {
	$F = strtoupper(substr($this->SortSkipWords($this->Artist()), 0, 1));

	if ($F >= "A" && $F <= "Z")
	    return $F;
{'fraction_non_alphanumeric': 0.21213720316622692, 'fraction_numerical': 0.005628847845206684, 'mean_word_length': 3.679835390946502, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2571559', 'n_tokens_mistral': 2017, 'n_tokens_neox': 1900, 'n_words': 342}