aboutsummaryrefslogtreecommitdiff
path: root/class
diff options
context:
space:
mode:
Diffstat (limited to 'class')
-rw-r--r--class/class.w.aff.php194
-rw-r--r--class/class.w.app.php93
-rw-r--r--class/class.w.art.php28
-rw-r--r--class/class.w.media.php51
-rw-r--r--class/class.w.opt.php49
5 files changed, 267 insertions, 148 deletions
diff --git a/class/class.w.aff.php b/class/class.w.aff.php
index 198f61e..d47ca7a 100644
--- a/class/class.w.aff.php
+++ b/class/class.w.aff.php
@@ -79,7 +79,7 @@ class Aff
color: <?= $art->couleurlien() ?>;
}
- section a[target="_blank"] {
+ section a.external {
color: <?= $art->couleurlienblank() ?>;
}
<?= $art->csstemplate($app) ?>
@@ -161,8 +161,10 @@ class Aff
<input type="hidden" name="id" value="<?= $art->id() ?>">
</form>
<div id="submit">
+ <a href="./">β†–</a>
<input type="submit" name="action" value="update" accesskey="s" onclick="document.getElementById('artedit').submit();" form="artedit">
<input type="submit" name="action" value="delete" onclick="confirmSubmit(event, 'Delete this article', 'artedit')" form="artedit">
+ <a href="?id=<?= $art->id() ?>" target="_blank">πŸ‘</a>
</div>
@@ -221,7 +223,7 @@ public function head($title, $tool)
}
-public function arthead(Art $art, $cssread = '', $edit = 0)
+public function arthead(Art $art, $cssdir, $cssread = '', $edit = 0)
{
?>
<head>
@@ -230,7 +232,7 @@ public function arthead(Art $art, $cssread = '', $edit = 0)
<meta name="viewport" content="width=device-width" />
<link rel="shortcut icon" href="../media/logo.png" type="image/x-icon">
<link href="/css/stylebase.css" rel="stylesheet" />
- <?= $edit == 0 ? '<link href="/css/lecture/' . $cssread . '" rel="stylesheet" />' : '<link href="/css/styleedit.css" rel="stylesheet" />' ?>
+ <?= $edit == 0 ? '<link href="' . $cssdir . $cssread . '" rel="stylesheet" />' : '<link href="/css/styleedit.css" rel="stylesheet" />' ?>
<title><?= $edit == 1 ? '✏' : '' ?> <?= $art->titre() ?></title>
<script src="../rsc/js/app.js"></script>
</head>
@@ -311,30 +313,50 @@ public function header()
}
-public function home2table(App $app, $getlist)
+public function home2table(App $app, $getlist, $masslist)
{
+ echo '<div id="main">';
+ echo '<h2>Articles</h2>';
echo '<form action="./" method="post">';
?>
<div id="massedit">
+ <h3>Mass Edit</h3>
<select name="massedit" required>
+ <option value="public">set as public</option>
+ <option value="private">set as private</option>
+ <option value="not published">set as not published</option>
+ <option value="erasetag">erase all tags</option>
+ <option value="erasetemplate">erase template</option>
<option value="delete">delete</option>
- <option value="0">set as public</option>
- <option value="1">set as private</option>
- <option value="2">set as not published</option>
</select>
- <input type="submit" value="submit" onclick="confirmSubmit(event, 'Are you sure')" >
+
+ <input type="submit" name="massaction" value="do" onclick="confirmSubmit(event, 'Are you sure')" >
+
+ <input type="text" name="targettag" placeholder="add tag">
+ <input type="submit" name="massaction" value="add tag" onclick="confirmSubmit(event, 'Are you sure')" >
+
+ <select name="masstemplate">
+ <?php
+ foreach ($masslist as $art) {
+ echo '<option value="' . $art->id() . '">' . $art->id() . '</option>';
+ }
+ ?>
+ </select>
+
+ <input type="submit" name="massaction" value="set template" onclick="confirmSubmit(event, 'Are you sure')" >
+
<input type="hidden" name="action" value="massedit">
</div>
<?php
if ($app->session() >= $app::EDITOR) {
echo '<table id="home2table">';
- echo '<tr><th>x</th><th>title</th><th>tag</th><th>summary</th><th>β†˜ to</th><th>β†— from</th><th>last modification</th><th>date of creation</th><th>privacy</th><th>βš™ edit</th></tr>';
+ echo '<tr><th>x</th><th>title</th><th>tag</th><th>summary</th><th>β†˜ to</th><th>β†— from</th><th>last modification</th><th>date of creation</th><th>privacy</th><th>display</th></tr>';
foreach ($getlist as $item) {
echo '<tr>';
- echo '<td><input type="checkbox" name="id[]" value='.$item->id().'></td>';
- echo '<td><a href="?id=' . $item->id() . '">' . $item->titre() . '</a></td>';
+ echo '<td><input type="checkbox" name="id[]" value=' . $item->id() . '></td>';
+ echo '<td><a href="?id=' . $item->id() . '&edit=1">' . $item->titre() . '</a></td>';
echo '<td>' . $item->tag('sort') . '</td>';
echo '<td>' . $item->intro() . '</td>';
echo '<td><a href="?lien=' . $item->id() . '">' . $item->liento('sort') . '</a></td>';
@@ -342,19 +364,21 @@ public function home2table(App $app, $getlist)
echo '<td>' . $item->datemodif('hrdi') . '</td>';
echo '<td>' . $item->datecreation('hrdi') . '</td>';
echo '<td>' . $item->secure('string') . '</td>';
- echo '<td><a href="?id=' . $item->id() . '&edit=1">edit</a></td>';
+ echo '<td><a href="?id=' . $item->id() . '" target="_blank">πŸ‘</a></td>';
echo '</tr>';
}
echo ' </table> ';
echo ' </form> ';
+ echo '</div>';
}
}
public function option(App $app, Opt $opt)
{
if ($app->session() >= $app::EDITOR) {
- echo '<div id="options"><form action="./" method="get" >';
-
+ echo '<div id="options">';
+ echo '<h2>Options</h2>';
+ echo '<form action="./" method="get" >';
echo '<input type="submit" name="submit" value="filter">';
echo 'β¬…<input type="submit" name="submit" value="reset">';
@@ -363,7 +387,12 @@ public function option(App $app, Opt $opt)
$this->optionprivacy($opt);
$this->optiontag($opt);
-
+ if ($opt->invert() == 1) {
+ echo '<input type="checkbox" name="invert" value="1" id="invert" checked>';
+ } else {
+ echo '<input type="checkbox" name="invert" value="1" id="invert">';
+ }
+ echo '<label for="invert">invert</></br>';
echo '<input type="submit" name="submit" value="filter">';
@@ -389,11 +418,11 @@ public function optiontag(Opt $opt)
foreach ($opt->taglist() as $tagfilter => $count) {
if ($count > $limit && $in == false) {
- echo '<details open><summary>>'.$limit.'</summary>';
+ echo '<details open><summary>>' . $limit . '</summary>';
$in = true;
}
if ($count == $limit && $in == true && $out == false) {
- echo '</details><details><summary>'.$limit.'</summary>';
+ echo '</details><details><summary>' . $limit . '</summary>';
$out = true;
}
@@ -404,7 +433,7 @@ public function optiontag(Opt $opt)
echo '<li><input type="checkbox" name="tagfilter[]" id="' . $tagfilter . '" value="' . $tagfilter . '" /><label for="' . $tagfilter . '">' . $tagfilter . ' (' . $count . ')</label></li>';
}
}
- if($in = true || $out = true) {
+ if ($in = true || $out = true) {
echo '</details>';
}
echo '</ul></fieldset>';
@@ -551,51 +580,49 @@ public function nav($app)
}
}
- public function medialist(App $app, $dir = "../media/")
+ public function medialist(array $getlistermedia, $dir)
{
- echo '<details open>';
- echo '<summary>Media List</summary>';
-
- echo '<article class="gest">';
-
- echo '<form action="" method="post">';
-
- echo '<ul class="grid">';
-
- foreach ($app->getlistermedia($dir) as $item) {
- echo '<li class="little">';
- ?>
- <input type="checkbox" id="<?= $item->id() ?>" name="<?= $item->id() ?>" value="1">
- <label for="<?= $item->id() ?>"><?= $item->id() ?></label>
- <input type="hidden" name="id" value="<?= $item->id() ?>">
-
- <?php
-
- $filepath = $dir . DIRECTORY_SEPARATOR . $item->id() . '.' . $item->extension();
-
- echo '<label for="' . $item->id() . '"><img class="thumbnail" src="' . $filepath . '" alt="' . $item->id() . '"></label>';
+ ?>
+ <details open>
+ <summary>Media List</summary>
- echo '<span class="infobulle">';
- echo 'width = ' . $item->width() . ' px';
- echo '<br/>';
- echo 'height = ' . $item->height() . ' px';
- echo '<br/>';
- echo 'filesize = ' . readablesize($item->size());
- echo '<br/>';
+ <form action="" method="post">
- echo '<input type="text" value="![' . $item->id() . '](/' . $item->id() . '.' . $item->extension() . ')">';
- echo '<br/>';
+ <table id=mediatable>
+ <tr><th>x</th><th>Name</th><th>extension</th><th>width</th><th>height</th><th>size</th><th>code</th><th>thumbnail</th></tr>
+ <?php
- echo '<a href="' . $filepath . '" target="_blank" ><img src="' . $filepath . '" alt="' . $item->id() . '"></a>';
- echo '</span>';
+ foreach ($getlistermedia as $item) {
+ $filepath = $dir . $item->id() . '.' . $item->extension();
+ echo '<tr>';
+ echo '<td><input type="checkbox" name="id[]" value=' . $item->id() . ' id="' . $item->id() . '"></td>';
+ echo '<td><label for="' . $item->id() . '">' . $item->id() . '</label></td>';
+ echo '<td>' . $item->extension() . '</td>';
+ echo '<td>' . $item->width() . '</td>';
+ echo '<td>' . $item->height() . '</td>';
+ echo '<td>' . readablesize($item->size()) . '</td>';
+ if ($item->type() == 'image') {
+ echo '<td><input type="text" value="![' . $item->id() . '](/' . $item->id() . '.' . $item->extension() . ')"></td>';
+ echo '<td class="tooltip">πŸ‘<span class="infobulle"><a href="' . $filepath . '" target="_blank" ><img class="thumbnail" src="' . $filepath . '" alt="' . $item->id() . '"></a></span></td>';
+ } elseif ($item->type() == 'sound') {
+ echo '<td><input type="text" value="[' . $item->id() . '](' . $filepath . ')"></td>';
+ echo '<td><a href="' . $filepath . '" target="_blank" >β™ͺ</a></td>';
+ } else {
+ echo '<td><input type="text" value="[' . $item->id() . '](' . $filepath . ')"></td>';
+ echo '<td><a href="' . $filepath . '" target="_blank" >∞</a></td>';
+ }
+ echo '</tr>';
+ echo '';
- echo '</li>';
}
- echo '</ul>';
?>
+
+
+ </table>
+
<select name="action" id="">
<option value="">compress /2</option>
<option value="">downscale /2</option>
@@ -606,13 +633,10 @@ public function nav($app)
</form>
</div>
-
- <?php
+ </details>
- echo '</article>';
- echo '</details>';
-
+ <?php
}
@@ -704,6 +728,8 @@ public function nav($app)
<details colse>
<summary>Default CSS</summary>
+ <p>This CSS will apply to all your articles.</p>
+
<form action="?aff=admin" method="post" >
<input type="hidden" name="action" value="editconfig">
<select name="cssread" required>
@@ -730,7 +756,7 @@ public function nav($app)
echo '<details>';
echo '<summary>Edit current CSS</summary>';
echo '<form>';
- echo '<textarea style="height:400px;">' . $cssread . '</textarea>';
+ echo '<textarea id="cssarea">' . $cssread . '</textarea>';
echo '<input type="submit" value="edit">';
echo '</form>';
echo '</details>';
@@ -764,21 +790,24 @@ public function nav($app)
<details>
<summary>Database credentials</summary>
+ <p>Fill this sections with the database settings you want to connect to</p>
+
<form action="./" method="post">
<input type="hidden" name="action" value="editconfig">
- <input title="host" type="text" name="host" id="host" value="<?= $config->host() ?>" placeholder="host">
- <input title="dbname" type="text" name="dbname" id="dbname" value="<?= $config->dbname() ?>" placeholder="dbname">
- <input title="user" type="text" name="user" id="user" value="<?= $config->user() ?>" placeholder="user">
- <input title="password" type="text" name="password" id="user" value="<?= $config->password() ?>" placeholder="password">
+ <label for="host">Host</label>
+ <input title="host" type="text" name="host" id="host" value="<?= $config->host() ?>">
+ <label for="dbname">DataBase name</label>
+ <input title="dbname" type="text" name="dbname" id="dbname" value="<?= $config->dbname() ?>">
+ <label for="user">User name</label>
+ <input title="user" type="text" name="user" id="user" value="<?= $config->user() ?>">
+ <label for="password">Password</label>
+ <input title="password" type="text" name="password" id="password" value="<?= $config->password() ?>">
<input type="submit" value="edit" id="">
</form>
</details>
-
-
-
</article>
<?php
@@ -795,9 +824,12 @@ public function nav($app)
<details>
<summary>Admin</summary>
+ <p>Edit your own admin password. You can find it in the config.json file, in the root of your website folder.</p>
+
<form action="./" method="post">
<input type="hidden" name="action" value="editconfig">
- <input title="admin password" type="password" name="admin" id="admin" value="<?= $config->admin() ?>" placeholder="admin">
+ <label for="admin">Administrator password (10)</label>
+ <input title="admin password" type="password" name="admin" id="admin" value="<?= $config->admin() ?>" >
<input type="submit" value="edit" id="">
</form>
@@ -805,11 +837,16 @@ public function nav($app)
<details>
<summary>Others</summary>
+ <p>Use this section to set all the others users passwords. They cant access this page, so they cant change it by themselves.</p>
+
<form action="./" method="post">
<input type="hidden" name="action" value="editconfig">
- <input title="editor" type="text" name="editor" id="editor" value="<?= $config->editor() ?>" placeholder="editor">
- <input title="invite" type="text" name="invite" id="invite" value="<?= $config->invite() ?>" placeholder="invite">
- <input title="read" type="text" name="read" id="read" value="<?= $config->read() ?>" placeholder="read">
+ <label for="editor">Editor password (3)</label>
+ <input title="editor" type="text" name="editor" id="editor" value="<?= $config->editor() ?>">
+ <label for="invite">Invite password (2)</label>
+ <input title="invite" type="text" name="invite" id="invite" value="<?= $config->invite() ?>" >
+ <label for="read">Reader password (1)</label>
+ <input title="read" type="text" name="read" id="read" value="<?= $config->read() ?>">
<input type="submit" value="edit" id="">
</form>
@@ -823,9 +860,19 @@ public function nav($app)
}
- public function admintable(Config $config, array $arttables)
+ public function admintable(Config $config, string $status, array $arttables)
{
?>
+
+ <article>
+
+ <h2>Table</h2>
+
+
+
+ <p>Database status : <strong><?= $status ?></strong></p>
+
+
<p>Current Table : <strong><?= $config->arttable(); ?></strong></p>
<details>
<summary>Select Table</summary>
@@ -857,11 +904,14 @@ public function nav($app)
<form action="./" method="post">
<input type="hidden" name="actiondb" value="addtable">
- <input type="text" name="tablename" maxlength="30" required>
+ <input type="text" name="tablename" placeholder="table name" maxlength="30" required>
<input type="submit" value="create">
</form>
</details>
+
+ </article>
+
<?php
}
diff --git a/class/class.w.app.php b/class/class.w.app.php
index 5e1ddb0..29d3fef 100644
--- a/class/class.w.app.php
+++ b/class/class.w.app.php
@@ -7,8 +7,10 @@ class App
const CONFIG_FILE = '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config.json';
- const CSS_READ_DIR = '..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'lecture' . DIRECTORY_SEPARATOR;
+ const CSS_READ_DIR = '..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'read' . DIRECTORY_SEPARATOR;
const SQL_READ_DIR = '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR;
+ const MEDIA_DIR = '..' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR;
+ const MEDIA_EXTENSIONS = array('jpeg', 'jpg', 'JPG', 'png', 'gif', 'mp3', 'mp4', 'mov', 'wav', 'flac', 'pdf');
const ADMIN = 10;
@@ -207,6 +209,8 @@ class App
public function getlister(array $selection = ['id'], array $opt = [])
{
+ // give an array using SELECTION columns and sort and desc OPTIONS
+
$default = ['tri' => 'id', 'desc' => 'DESC'];
$opt = array_update($default, $opt);
@@ -283,15 +287,15 @@ class App
$filteredlist = [];
foreach ($artlist as $art) {
- if(empty($tagchecked)) {
+ if (empty($tagchecked)) {
$filteredlist[] = $art->id();
} else {
$inter = (array_intersect($art->tag('array'), $tagchecked));
- if($tagcompare == 'OR') {
+ if ($tagcompare == 'OR') {
if (!empty($inter)) {
$filteredlist[] = $art->id();
}
- } elseif($tagcompare == 'AND') {
+ } elseif ($tagcompare == 'AND') {
if (!array_diff($tagchecked, $art->tag('array'))) {
$filteredlist[] = $art->id();
}
@@ -430,12 +434,12 @@ class App
if (isset($file) and $file['media']['error'] == 0 and $file['media']['size'] < $maxsize) {
$infosfichier = pathinfo($file['media']['name']);
$extension_upload = $infosfichier['extension'];
- $extensions_autorisees = array('jpeg', 'jpg', 'JPG', 'png', 'gif', 'mp3', 'mp4', 'mov', 'wav', 'flac');
+ $extensions_autorisees = $this::MEDIA_EXTENSIONS;
if (in_array($extension_upload, $extensions_autorisees)) {
- if (!file_exists('..' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload)) {
+ if (!file_exists($this::MEDIA_DIR . $id . '.' . $extension_upload)) {
$extension_upload = strtolower($extension_upload);
- $uploadok = move_uploaded_file($file['media']['tmp_name'], '..' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload);
+ $uploadok = move_uploaded_file($file['media']['tmp_name'], $this::MEDIA_DIR . $id . '.' . $extension_upload);
if ($uploadok) {
$message = 'uploadok';
} else {
@@ -455,25 +459,21 @@ class App
}
- public function getmedia($entry)
+ public function getmedia($entry, $dir)
{
$fileinfo = pathinfo($entry);
$filepath = $fileinfo['dirname'] . '.' . $fileinfo['extension'];
- list($width, $height, $type, $attr) = getimagesize($filepath);
-
- echo 'filepath : ' . $filepath;
-
- $donnes = array(
+ $donnees = array(
'id' => str_replace('.' . $fileinfo['extension'], '', $fileinfo['filename']),
- 'path' => $fileinfo['dirname'],
+ 'path' => $dir,
'extension' => $fileinfo['extension']
);
- return new Art($donnees);
+ return new Media($donnees);
}
@@ -483,23 +483,33 @@ class App
$list = [];
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
- $fileinfo = pathinfo($entry);
- $filepath = $dir . $fileinfo['filename'] . '.' . $fileinfo['extension'];
- list($width, $height, $type, $attr) = getimagesize($filepath);
- $filesize = filesize($filepath);
+ // var_dump($entry);
- $donnees = array(
- 'id' => str_replace('.' . $fileinfo['extension'], '', $fileinfo['filename']),
- 'path' => $fileinfo['dirname'],
- 'extension' => $fileinfo['extension'],
- 'size' => $filesize,
- 'width' => $width,
- 'height' => $height
- );
+ // $fileinfo = pathinfo($entry);
+
+ // var_dump($fileinfo);
- $list[] = new Media($donnees);
+
+ // $filepath = $dir . $fileinfo['filename'] . '.' . $fileinfo['extension'];
+
+ // list($width, $height, $type, $attr) = getimagesize($filepath);
+ // $filesize = filesize($filepath);
+
+ // $donnees = array(
+ // 'id' => str_replace('.' . $fileinfo['extension'], '', $fileinfo['filename']),
+ // 'path' => dirname($entry),
+ // 'extension' => $fileinfo['extension']
+ // );
+
+ // $media = new Media($donnees);
+
+ $media = $this->getmedia($entry, $dir);
+
+
+ $media->analyse();
+ $list[] = $media;
}
}
@@ -552,17 +562,17 @@ class App
//_________________________________________________________ A D M ________________________________________________________
- public function changecss($lecturecss)
- {
- if (file_exists(self::CONFIG_FILE)) {
- $current = file_get_contents(self::CONFIG_FILE);
- $current = str_replace($this->lecturecss(), $lecturecss, $current);
- file_put_contents(self::CONFIG_FILE, $current);
- return 'ccss_change_ok';
- } else {
- return 'ccss_change_error';
- }
- }
+ // public function changecss($lecturecss)
+ // {
+ // if (file_exists(self::CONFIG_FILE)) {
+ // $current = file_get_contents(self::CONFIG_FILE);
+ // $current = str_replace($this->lecturecss(), $lecturecss, $current);
+ // file_put_contents(self::CONFIG_FILE, $current);
+ // return 'css_change_ok';
+ // } else {
+ // return 'css_change_error';
+ // }
+ // }
public function addcss(array $file, $maxsize = 2 ** 24, $id)
{
@@ -574,10 +584,10 @@ class App
$extension_upload = $infosfichier['extension'];
$extensions_autorisees = array('css');
if (in_array($extension_upload, $extensions_autorisees)) {
- if (!file_exists('..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'lecture' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload)) {
+ if (!file_exists($this::CSS_READ_DIR . $id . '.' . $extension_upload)) {
$extension_upload = strtolower($extension_upload);
- $uploadok = move_uploaded_file($file['css']['tmp_name'], '..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'lecture' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload);
+ $uploadok = move_uploaded_file($file['css']['tmp_name'], $this::CSS_READ_DIR . $id . '.' . $extension_upload);
if ($uploadok) {
$message = 'uploadok';
} else {
@@ -594,6 +604,7 @@ class App
}
return $message;
+
}
public function dirlist($dir, $extension)
diff --git a/class/class.w.art.php b/class/class.w.art.php
index ffdb670..2238f71 100644
--- a/class/class.w.art.php
+++ b/class/class.w.art.php
@@ -56,12 +56,12 @@ class Art
$now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
$this->settitre($this->id());
- $this->setsoustitre($this->id());
- $this->setintro('resumΓ©');
- $this->settag('sans tag,');
+ $this->setsoustitre('');
+ $this->setintro('');
+ $this->settag('');
$this->setdatecreation($now);
$this->setcss('');
- $this->sethtml('contenu');
+ $this->sethtml('');
$this->setsecure(2);
$this->setcouleurtext('#000000');
$this->setcouleurbkg('#FFFFFF');
@@ -206,6 +206,7 @@ class Art
}
$html = str_replace('href="=', 'href="?id=', $html);
+ $html = str_replace('href="../media/', ' class="file" target="_blank" href="../media/', $html);
$html = str_replace('href="http', ' class="external" target="_blank" href="http', $html);
$html = str_replace('<img src="/', '<img src="../media/', $html);
$html = str_replace('<iframe', '<div class="iframe"><div class="container"><iframe class="video" ', $html);
@@ -314,14 +315,19 @@ class Art
public function settag($tag)
{
- if (strlen($tag) < self::LEN and is_string($tag)) {
- $tag = strip_tags(trim(strtolower($tag)));
- $tag = str_replace('*', '', $tag);
- $tag = str_replace(' ', '', $tag);
+ if(is_string($tag)) {
- $taglist = explode(",", $tag);
- $taglist = array_filter($taglist);
- $this->tag = $taglist;
+ if (strlen($tag) < self::LEN and is_string($tag)) {
+ $tag = strip_tags(trim(strtolower($tag)));
+ $tag = str_replace('*', '', $tag);
+ $tag = str_replace(' ', '', $tag);
+
+ $taglist = explode(",", $tag);
+ $taglist = array_filter($taglist);
+ $this->tag = $taglist;
+ }
+ } elseif (is_array($tag)) {
+ $this->tag = $tag;
}
}
diff --git a/class/class.w.media.php b/class/class.w.media.php
index e5056c9..2d27be7 100644
--- a/class/class.w.media.php
+++ b/class/class.w.media.php
@@ -9,6 +9,11 @@ class Media
private $size;
private $width;
private $height;
+ private $length;
+
+ const IMAGE = array('jpg', 'jpeg', 'gif', 'png');
+ const SOUND = array('mp3', 'flac');
+ const VIDEO = array('mp4', 'mov', 'avi');
@@ -31,6 +36,24 @@ class Media
}
+ public function analyse()
+ {
+ $this->settype();
+
+ $filepath = $this->path . $this->id . '.' . $this->extension;
+
+ $this->size = filesize($filepath);
+
+ if ($this->type == 'image') {
+ list($width, $height, $type, $attr) = getimagesize($filepath);
+ $this->width = $width;
+ $this->height = $height;
+ }
+
+
+ }
+
+
// _________________________________________________ G E T ____________________________________________________
@@ -69,6 +92,11 @@ class Media
return $this->height;
}
+ public function length()
+ {
+ return $this->length;
+ }
+
// ___________________________________________________ S E T __________________________________________________
public function setid($id)
@@ -92,6 +120,21 @@ class Media
}
}
+ public function settype()
+ {
+ if (isset($this->extension)) {
+ if (in_array($this->extension, $this::IMAGE)) {
+ $this->type = "image";
+ } elseif (in_array($this->extension, $this::SOUND)) {
+ $this->type = "sound";
+ } elseif (in_array($this->extension, $this::VIDEO)) {
+ $this->type = "video";
+ } else {
+ $this->type = "other";
+ }
+ }
+ }
+
public function setsize($size)
{
if (40 and is_int($size)) {
@@ -113,6 +156,14 @@ class Media
}
}
+ public function setlength($length)
+ {
+ if ($this->type == 'sound') {
+ $this->length = $length;
+ }
+ }
+
+
diff --git a/class/class.w.opt.php b/class/class.w.opt.php
index fc71312..684cb09 100644
--- a/class/class.w.opt.php
+++ b/class/class.w.opt.php
@@ -10,6 +10,7 @@ class Opt
private $lienfrom = ['min' => '0', 'max' => '0'];
private $col = ['id'];
private $taglist = [];
+ private $invert = 0;
private $artvarlist;
@@ -40,15 +41,6 @@ class Opt
}
}
- public function dump()
- {
- var_dump($this);
- }
-
-
-
-
-
// _______________________________________________ G E T _______________________________________________
public function sortby()
@@ -95,14 +87,19 @@ class Opt
}
}
- public function artvarlist()
+ public function taglist()
{
- return $this->artvarlist;
+ return $this->taglist;
}
- public function taglist()
+ public function invert()
{
- return $this->taglist;
+ return $this->invert;
+ }
+
+ public function artvarlist()
+ {
+ return $this->artvarlist;
}
@@ -126,19 +123,13 @@ class Opt
public function settagfilter($tagfilter)
{
if (is_array($tagfilter)) {
- // $tagfilterlist = [];
- // foreach ($tagfilter as $tag) {
- // if (array_key_exists($tag, $this->taglist())) {
- // $tagfilterlist[] = $tag;
- // }
- // }
$this->tagfilter = $tagfilter;
}
}
public function settagcompare($tagcompare)
{
- if(in_array($tagcompare, ['OR', 'AND'])) {
+ if (in_array($tagcompare, ['OR', 'AND'])) {
$this->tagcompare = $tagcompare;
}
}
@@ -187,10 +178,6 @@ class Opt
}
}
- public function setartvarlist(array $artvarlist)
- {
- $this->artvarlist = $artvarlist;
- }
public function settaglist(array $artlist)
{
@@ -208,6 +195,20 @@ class Opt
$this->taglist = $taglist;
}
+ public function setinvert(int $invert)
+ {
+ if ($invert == 0 || $invert == 1) {
+ $this->invert = $invert;
+ }
+ }
+
+
+ public function setartvarlist(array $artvarlist)
+ {
+ $this->artvarlist = $artvarlist;
+ }
+
+
}