jreklund / php4dvd

php4dvd is an open source php/mysql powered movie database. Catalog your video collection with ease. Automatic update of information and images.
GNU General Public License v3.0
82 stars 44 forks source link

Netsted Formats #8

Open Bloodsoul opened 7 years ago

Bloodsoul commented 7 years ago

Sometimes it could be handy to have a specific hierarchy for formats to filter by. As a small example, there are the formats "DVD", "Blu-ray" and "Blu-ray 3D". One could select to filter for Blu-rays only, but he does not see the 3D Blu-rays, because it is a format by itself.

Maybe this can be done in one of the following ways:

1 Text Input: The format could be separated by a divide symbol (";" for example). Movie A: "Blu-rays;Blu-ray 3D" Movie B: "Blu-rays;Blu-ray" This would result in the following format filters:

The first Movie would be displayed, when "Blu-rays" or "Blu-ray 3D" is selected, the second will be displayed when "Blu-rays" or "Blu-ray" is selected. The disadvantage is, that this isn't clearly readable and it is more complicated to deal with the different levels when editing a movie.

2 Nested Array in Settings: Maybe it would be more easy to define a type and the possible formats in the configuration. Example:

$settings["formats"] = array(
    "Blu-rays" => array(
        "Blu-ray",
        "Blu-ray 3D",
    ),
    "DVD"
);

This would need changing the text input to a drop-down of what is configured. It would unfortunately force some headache when updating to this I assume. :( For new installations it could come preset for "DVD" and "Blu-ray" without the nested array maybe.

jreklund commented 7 years ago

Nesting formats (and multiple formats) will result in hours of coding to get it working (properly). At the moment it's stored in a single column and distinct values are retrieved. Need to separate formats into it's own table's so that we don't end up with another genres column.

public function getCategories() {
    $categories = array();
    foreach(R::getCol("SELECT `genres` FROM `movies`") as $category) {
        // Split by , or newlines
        foreach(preg_split("/,|\n/", $category) as $category) {
            $category = trim($category);
            if(strlen($category) > 0)
                $categories[$category] = $category;
        }
    }
    $categories = array_keys($categories);
    sort($categories);
    return $categories;
}
  1. Won't be user friendly. You only want to select Blu-ray and the system should know what parent format it belongs to.

  2. User supplied data should be entered from the UI and not locked.

You can technically take the array from 2 and configure how the select in the sidebar should look and what children to search for if the parent have been selected. But I won't recommend doing that, due to the fact you still need to open it up every time you saved a different value in the database.

Somewhere in the future, we are talking like V4. You should be able to set every configuration from the UI. Like nesting formats. And activating/disabling functionality. Change properties etc.

System settings like database will remain in config.default.php and config.php.

Bloodsoul commented 7 years ago

This will be very nice improvements on v4! Thanks.