+ Adapted some new PHP code formatting
+ Fixed some translations
+ Updated bulma css
+ + Added random link page
version 2.6 - Hypostyle (2021-03-21)
TODO / Feature list
++ random link or link of the day
+ view table really still needed?
+ stats cleanup. Management functions should be standalone
+ theme support
view.edit.tags = "Edit tags"
view.edit.categories = "Edit categories"
view.links = "Links"
+view.random.headline = "Surprise"
+view.random.link = "Link"
stats.view.all = "View all"
stats.moderation = "Moderation"
view.nav.all.tags = "Tags"
view.nav.all.categories = "Categories"
view.nav.back.home = "back home"
+view.nav.random = "Random link"
stats.storage.clean.fail = "Something went wrong while storage cleaning"
stats.import.missing.file = "Please provide a import file"
view.edit.tags = "Tags bearbeiten"
view.edit.categories = "Kategorien bearbeiten"
view.links = "Links"
+view.random.headline = "Überraschung"
+view.random.link = "Link"
stats.view.all = "Alle"
stats.moderation = "Moderation"
view.nav.all.tags = "Tags"
view.nav.all.categories = "Kategorien"
view.nav.back.home = "zurück nach Hause"
+view.nav.random = "Zufallslink"
stats.storage.clean.fail = "Ein Fehler bei der Speicherplatzlöschung trat auf"
stats.import.missing.file = "Bitte eine Importdatei angeben"
const LINK_QUERY_STATUS = 2;
- const COMBINED_SELECT_VALUES = "`id`,
- `link`,
- `created`,
- `status`,
- `description`,
- `title`,
- `image`,
- `hash`,
- `tag`,
- `category`,
- `categoryId`,
- `tagId`";
-
/**
* the database object
*
return $ret;
}
+ /**
+ * Return a random entry from link table.
+ * Slow but does the trick for now. If there is way more entries
+ * re-think this solution
+ *
+ * @param int $limit
+ * @return array
+ */
+ public function randomLink($limit=1): array {
+ $ret = array();
+
+ $queryStr = "SELECT `title`, `link`, `hash` FROM `".DB_PREFIX."_link` AS t";
+ $queryStr .= " WHERE ".$this->_decideLinkTypeForQuery();
+ $queryStr .= " ORDER BY RAND()";
+ if(!empty($limit)) {
+ $queryStr .= " LIMIT $limit";
+ }
+ $query = $this->DB->query($queryStr);
+ if(!empty($query) && $query->num_rows > 0) {
+ $ret = $query->fetch_all(MYSQLI_ASSOC);
+ }
+
+ return $ret;
+ }
+
+ public function randomCategory($limit=1): array {
+ $ret = array();
+
+ $queryStr = "SELECT `id`, `name` FROM `".DB_PREFIX."_category`";
+ $queryStr .= " ORDER BY RAND()";
+ if(!empty($limit)) {
+ $queryStr .= " LIMIT $limit";
+ }
+ $query = $this->DB->query($queryStr);
+ if(!empty($query) && $query->num_rows > 0) {
+ $ret = $query->fetch_all(MYSQLI_ASSOC);
+ }
+
+ return $ret;
+ }
+
+ public function randomTag($limit=1): array {
+ $ret = array();
+
+ $queryStr = "SELECT `id`, `name` FROM `".DB_PREFIX."_tag`";
+ $queryStr .= " ORDER BY RAND()";
+ if(!empty($limit)) {
+ $queryStr .= " LIMIT $limit";
+ }
+ $query = $this->DB->query($queryStr);
+ if(!empty($query) && $query->num_rows > 0) {
+ $ret = $query->fetch_all(MYSQLI_ASSOC);
+ }
+
+ return $ret;
+ }
+
/**
* get all the categories ordered by link added date
*
* Insipid
* Personal web-bookmark-system
*
- * Copyright 2016-2021 Johannes Keßler
+ * Copyright 2016-2022 Johannes Keßler
*
* Development starting from 2011: Johannes Keßler
* https://www.bananas-playground.net/projekt/insipid/
<a href="index.php" title="<?php echo $T->t('view.nav.back.home'); ?>" class="button">
<span class="icon"><i class="ion-md-home"></i></span>
</a>
+ <a href="index.php?p=random" title="<?php echo $T->t('view.nav.random'); ?>" class="button">
+ <span class="icon"><i class="ion-md-shuffle"></i><span>
+ </a>
</p>
</div>
--- /dev/null
+<?php
+/**
+ * Insipid
+ * Personal web-bookmark-system
+ *
+ * Copyright 2016-2022 Johannes Keßler
+ *
+ * Development starting from 2011: Johannes Keßler
+ * https://www.bananas-playground.net/projekt/insipid/
+ *
+ * creator:
+ * Luke Reeves <luke@neuro-tech.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
+ *
+ */
+
+$randomLink = $Management->randomLink(10);
+$randomCategory = $Management->randomCategory(10);
+$randomTag = $Management->randomTag(10);
--- /dev/null
+<?php
+/**
+ * Insipid
+ * Personal web-bookmark-system
+ *
+ * Copyright 2016-2022 Johannes Keßler
+ *
+ * Development starting from 2011: Johannes Keßler
+ * https://www.bananas-playground.net/projekt/insipid/
+ *
+ * creator:
+ * Luke Reeves <luke@neuro-tech.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
+ *
+ */
+?>
+<section class="section">
+ <div class="columns">
+ <?php require('_headNavIcons.inc.php'); ?>
+ </div>
+
+ <div class="columns">
+ <div class="column">
+ <h2 class="is-size-2"><?php echo $T->t('view.random.headline'); ?></h2>
+ </div>
+ </div>
+</section>
+<section class="section">
+ <div class="columns">
+ <div class="column">
+
+ <h3 class="is-size-3"><?php echo $T->t('view.random.link'); ?></h3>
+ <div class="field is-grouped is-grouped-multiline">
+ <?php foreach ($randomLink as $sr) { ?>
+ <div class="control">
+ <div class="tags has-addons">
+ <a class="tag is-dark" href="<?php echo $sr['link']; ?>" target="_blank" ><?php echo $sr['title']; ?></a>
+ <a class="tag is-info" title="<?php echo $T->t('view.more.details'); ?>" href="index.php?p=linkinfo&id=<?php echo $sr['hash']; ?>" ><i class="ion-md-information-circle-outline"></i></a>
+ </div>
+ </div>
+ <?php } ?>
+ </div>
+
+ <h3 class="is-size-3"><?php echo $T->t('view.tag'); ?></h3>
+ <div>
+ <?php foreach ($randomTag as $sr) { ?>
+ <a href="index.php?p=overview&m=tag&id=<?php echo $sr['id']; ?>"" class="button is-small">
+ <span class="icon"><i class="ion-md-pricetag"></i></span>
+ <span><?php echo $sr['name']; ?></span>
+ </a>
+ <?php } ?>
+ </div>
+
+ <h3 class="is-size-3"><?php echo $T->t('view.category'); ?></h3>
+ <div>
+ <?php foreach ($randomCategory as $sr) { ?>
+ <a href="index.php?p=overview&m=category&id=<?php echo $sr['id']; ?>"" class="button is-small">
+ <span class="icon"><i class="ion-md-filing"></i></span>
+ <span><?php echo $sr['name']; ?></span>
+ </a>
+ <?php } ?>
+ </div>
+
+ </div>
+ </div>
+</section>