pub / rememori

Simple file-based bookmarking and notes application
git clone src.jayvii.de/pub/rememori.git
Home | Log | Files | Exports | Refs | README | RSS

show.php (3961B)


      1 <?php
      2 
      3 function show_note(
      4     string $user,
      5     string $category,
      6     string $filename
      7 ) {
      8 
      9     /* Read Note: if it does not exist yet, use empty string */
     10     $content = read_note($user, $category, $filename);
     11 
     12     /* generate old filename. leave empty if there was none */
     13     if (!empty($category) && !empty($filename)) {
     14         $filepath_t1 = $category . "/" . $filename;
     15     } else {
     16         $filepath_t1 = "";
     17     }
     18 
     19 ?>
     20 
     21 <!-- Show Text Note Form -->
     22 <form action="/" target="_self" method="post">
     23     <label for="content"><?php echo $GLOBALS["i18n_note"]; ?></label>
     24     <textarea id="content" name="content"><?php echo $content; ?></textarea>
     25     <label for="category"><?php echo $GLOBALS["i18n_category"]; ?></label>
     26     <input
     27         id="category"
     28         name="category"
     29         type="text"
     30         value="<?php echo $category; ?>"
     31     >
     32     <label for="filename"><?php echo $GLOBALS["i18n_filename"]; ?></label>
     33     <input
     34         id="filename"
     35         name="filename"
     36         type="text"
     37         value="<?php echo $filename; ?>"
     38     >
     39     <input
     40         id="filepath_t1"
     41         name="filepath_t1"
     42         type="hidden"
     43         value="<?php echo $filepath_t1; ?>"
     44     >
     45     <input
     46         id="action"
     47         name="action"
     48         type="hidden"
     49         value="edit"
     50     >
     51     <input type="submit" value="<?php echo $GLOBALS["i18n_save"]; ?>">
     52 </form>
     53 
     54 <!-- delete button -->
     55 <form action="/" method="post" id="delete">
     56     <input
     57         id="category"
     58         name="category"
     59         type="hidden"
     60         value="<?php echo $category; ?>"
     61     >
     62     <input
     63         id="filename"
     64         name="filename"
     65         type="hidden"
     66         value="<?php echo $filename; ?>"
     67     >
     68     <input
     69         id="action"
     70         name="action"
     71         type="hidden"
     72         value="delete"
     73     >
     74     <input
     75         class="danger"
     76         type="button"
     77         value="<?php echo $GLOBALS["i18n_delete"]; ?>"
     78         onclick="deletion_confirm('delete');"
     79     >
     80 </form>
     81 
     82 <?php
     83 
     84     /* check whether any category is given and print a button for it */
     85     if (!empty($category)) {
     86 
     87 ?>
     88 
     89 <!-- related notes -->
     90 <div class="related">
     91 
     92     <stretch class="inline"><?php echo $GLOBALS["i18n_related"]; ?>:</stretch>
     93 
     94     <!-- current category button -->
     95     <form action="/" method="post" class="inline">
     96         <input
     97             id="category"
     98             name="category"
     99             type="hidden"
    100             value="<?php echo $category; ?>"
    101         >
    102         <input
    103             id="action"
    104             name="action"
    105             type="hidden"
    106             value="list"
    107         >
    108         <input
    109             class="likenavitem"
    110             type="submit"
    111             value="<?php echo $category; ?>"
    112         >
    113     </form>
    114 
    115 </div>
    116 
    117 <?php
    118 
    119     } // if-statement
    120 
    121 ?>
    122 
    123 <!-- all other categories -->
    124 
    125 <div class="categories">
    126 
    127     <stretch><?php echo $GLOBALS["i18n_categories"]; ?>:</stretch><br>
    128 
    129 
    130 <?php
    131     $categories = gather_categories($user);
    132     foreach ($categories as $category) {
    133 
    134         /* Skip empty categories */
    135         if ($category["matches"] < 1) {
    136             continue;
    137         }
    138 
    139         /* construct button label */
    140         if (!empty($category["name"])) {
    141             $cat_label = $category["name"] .
    142                 " (" . $category["matches"] . ")";
    143         } else {
    144             $cat_label = $GLOBALS["i18n_list"] .
    145                 " (" . $category["matches"] . ")";
    146         }
    147 ?>
    148 
    149     <!-- other category button -->
    150     <form action="/" method="post" class="inline">
    151         <input
    152             id="category"
    153             name="category"
    154             type="hidden"
    155             value="<?php echo $category["name"]; ?>"
    156         >
    157         <input
    158             id="action"
    159             name="action"
    160             type="hidden"
    161             value="list"
    162         >
    163         <input
    164             class="likenavitem"
    165             type="submit"
    166             value="<?php echo $cat_label; ?>"
    167         >
    168     </form>
    169 
    170 <?php
    171     } // foreach loop
    172 ?>
    173 
    174 </div>
    175 
    176 <?php
    177 
    178 } // function
    179 
    180 ?>