]> 91.132.146.200 Git - insipid.git/commitdiff
removed ifset and replaced it with Null coalescing operator
authorBanana <mail@bananas-playground.net>
Wed, 22 Nov 2023 13:20:57 +0000 (14:20 +0100)
committerBanana <mail@bananas-playground.net>
Wed, 22 Nov 2023 13:20:57 +0000 (14:20 +0100)
TODO
webroot/lib/summoner.class.php
webroot/view/editlink.php
webroot/view/home.php

diff --git a/TODO b/TODO
index 0795fe373885aeb0d58f5ecc1398c118bfc61653..be9776840b6a3b7e5384daf58cb980935a9ed57c 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,7 +1,7 @@
 TODO / Feature list
-+ Replace ifset https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op
-  from summoner.class.php
++ combine category and tag class into one.
++ installer
 + Whole Page snapshot
 + view table really still needed?
 + theme support
-+ combine category and tag class into one.
+
index fa9b2929a9f92773f7dada4ca5f354d548398979..b1b33b8d1786a35fd13289871a0691968c7888a5 100644 (file)
@@ -207,20 +207,7 @@ class Summoner {
 
         return $ret;
     }
-
-    /**
-     * simulate the Null coalescing operator in php5
-     * this only works with arrays and checking if the key is there and echo/return it.
-     * http://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op
-     *
-     * @param array $array
-     * @param string $key
-     * @return mixed
-     */
-    static function ifset(array $array, string $key): mixed {
-        return $array[$key] ?? false;
-    }
-
+    
     /**
      * try to gather meta information from given URL
      *
index 5523a1f80c87b27f0524f74d73293e6fb46228d8..1ae23b6e3f2e00978df30d321812ecabdf46b1f2 100644 (file)
@@ -36,7 +36,7 @@
        <div class="columns">
                <div class="column">
                        <h1 class="is-size-2"><?php echo $linkData['title']; ?></h1>
-                       <h3><a href="index.php?p=linkinfo&id=<?php echo Summoner::ifset($formData, 'hash'); ?>">
+                       <h3><a href="index.php?p=linkinfo&id=<?php echo $formData['hash'] ?? ''; ?>">
                                <i class="icon ion-md-return-left"></i></a></h3>
                </div>
        </div>
@@ -61,7 +61,7 @@
                                <p><?php echo $T->t('view.title'); ?></p>
                        </div>
                        <div class="column">
-                               <input class="input" type="text" name="data[title]" value="<?php echo Summoner::ifset($formData, 'title'); ?>" />
+                               <input class="input" type="text" name="data[title]" value="<?php echo $formData['title'] ?? ''; ?>" />
                        </div>
                </div>
                <div class="columns">
@@ -69,7 +69,7 @@
                                <p><?php echo $T->t('view.description'); ?></p>
                        </div>
                        <div class="column">
-                               <input class="input" type="text" name="data[description]" value="<?php echo Summoner::ifset($formData, 'description'); ?>" />
+                               <input class="input" type="text" name="data[description]" value="<?php echo $formData['description'] ?? ''; ?>" />
                        </div>
                </div>
                <div class="columns">
                                <p>
                                        <img class="linkthumbnail" src="<?php echo $linkData['imageToShow']; ?>" alt="<?php echo $T->t('view.image.noimage'); ?>">
                                </p>
-                               <input class="input" type="text" name="data[image]" value="<?php echo Summoner::ifset($formData, 'image'); ?>" /><br />
+                               <input class="input" type="text" name="data[image]" value="<?php echo $formData['image'] ?? ''; ?>" /><br />
                                <br />
                                <label class="checkbox">
-                                       <input type="checkbox" name="data[localImage]" value="1" <?php if(Summoner::ifset($formData, 'localImage')) echo "checked"; ?> />
+                                       <input type="checkbox" name="data[localImage]" value="1" <?php if(isset($formData['localImage'])) echo "checked"; ?> />
                                        <?php echo $T->t('edit.link.image.save'); ?>
                                </label>
                        </div>
                                <p><a href="<?php echo $linkData['snapshotLink']; ?>" target="_blank"><?php echo $T->t('edit.link.thumbnail.view'); ?></a></p>
                                <?php } ?>
                                <label class="checkbox">
-                                       <input type="checkbox" name="data[snapshot]" value="1" <?php if(Summoner::ifset($formData, 'snapshot')) echo "checked"; ?>  />
+                                       <input type="checkbox" name="data[snapshot]" value="1" <?php if(isset($formData['snapshot'])) echo "checked"; ?>  />
                                        <?php echo $T->t('edit.link.thumbnail.save'); ?>
                                </label>
                        </div>
                                <p><a href="<?php echo $linkData['pagescreenshotLink']; ?>" target="_blank"><?php echo $T->t('edit.link.full.screenshot.view'); ?></a></p>
                                <?php } ?>
                                <label class="checkbox">
-                                       <input type="checkbox" name="data[pagescreenshot]" value="1" <?php if(Summoner::ifset($formData, 'pagescreenshot')) echo "checked"; ?>  />
+                                       <input type="checkbox" name="data[pagescreenshot]" value="1" <?php if(isset($formData['pagescreenshot'])) echo "checked"; ?>  />
                                        <?php echo $T->t('edit.link.full.screenshot.save'); ?>
                                </label>
                        </div>
                        </div>
                        <div class="column">
                                <label class="checkbox">
-                                       <input type="checkbox" name="data[private]" value="1" <?php if(Summoner::ifset($formData, 'private')) echo "checked"; ?> />
+                                       <input type="checkbox" name="data[private]" value="1" <?php if(isset($formData['private'])) echo "checked"; ?> />
                                        <?php echo $T->t('view.private'); ?>
                                </label>
                        </div>
index 5c830c621338835000a349db6a2cdedfa8b2413e..5f5a3f1ff441912d856d30c2526f81fe0031e5c3 100644 (file)
@@ -88,7 +88,7 @@
                                <div class="field has-addons">
                                        <div class="control is-expanded">
                                                <div class="control has-icons-left">
-                                                       <input type="url" name="data[url]" class="input" value="<?php echo Summoner::ifset($formData, 'url'); ?>" />
+                                                       <input type="url" name="data[url]" class="input" value="<?php echo $formData['url'] ?? ''; ?>" />
                                                        <span class="icon is-small is-left">
                                                                <i class="ion-link"></i>
                                                        </span>
                                <div class="field">
                                        <label class="label"><?php echo $T->t('view.title'); ?></label>
                                        <div class="control">
-                                               <input class="input" type="text" name="data[title]" value="<?php echo Summoner::ifset($formData, 'title'); ?>" />
+                                               <input class="input" type="text" name="data[title]" value="<?php echo $formData['title'] ?? ''; ?>" />
                                        </div>
                                </div>
                        </div>
                                <div class="field">
                                        <label class="label"><?php echo $T->t('view.description'); ?></label>
                                        <div class="control">
-                                               <input class="input" type="text" name="data[description]" value="<?php echo Summoner::ifset($formData, 'description'); ?>" />
+                                               <input class="input" type="text" name="data[description]" value="<?php echo $formData['description'] ?? ''; ?>" />
                                        </div>
                                </div>
                        </div>
 
                <div class="columns">
                        <div class="column is-half">
-                               <img class="linkthumbnail" src="<?php echo Summoner::ifset($formData, 'imageToShow'); ?>" alt="<?php echo $T->t('view.image.of.link'); ?>" />
+                               <img class="linkthumbnail" src="<?php echo $formData['imageToShow'] ?? ''; ?>" alt="<?php echo $T->t('view.image.of.link'); ?>" />
                        </div>
                        <div class="column is-half">
                                <div class="field">
                                        <label class="label"><?php echo $T->t('view.image.link'); ?></label>
                                        <div class="control">
-                                               <input class="input" type="url" name="data[image]" value="<?php echo Summoner::ifset($formData, 'image'); ?>" />
+                                               <input class="input" type="url" name="data[image]" value="<?php echo $formData['image'] ?? ''; ?>" />
                                        </div>
                                </div>
                        </div>
                <div class="columns">
                        <div class="column is-half">
                                <label class="checkbox is-pulled-right">
-                                       <input type="checkbox" name="data[private]" value="1" <?php if(Summoner::ifset($formData, 'private')) echo "checked"; ?> />
+                                       <input type="checkbox" name="data[private]" value="1" <?php if(isset($formData['private'])) echo "checked"; ?> />
                                        <?php echo $T->t('view.private'); ?>
                                </label>
                        </div>