]> git.p6c8.net - jirafeau_project.git/blobdiff - lib/functions.php
modularization date_int
[jirafeau_project.git] / lib / functions.php
index b87f6c3b17e8649b71b7a8523f1d004e055383e2..fd0fe2c657957848c6e6251a18956379b45d2eeb 100644 (file)
@@ -1720,3 +1720,159 @@ function jirafeau_write_download_stats($hash, $ip)
     fwrite($handle, $count . NL . time() . NL . $ip);
     fclose($handle);
 }
+
+function jirafeau_create_upload_finished_box($preview = true) {
+    ?>
+
+    <div id="upload_finished">
+    <p><?php echo t('FILE_UP') ?></p>
+
+    <div id="upload_finished_download_page">
+    <p>
+        <a id="upload_link" href=""><?php echo t('DL_PAGE') ?></a>
+        <a id="upload_link_email" href=""><img id="upload_image_email"/></a>
+    </p><p>
+        <code id=upload_link_text></code>
+        <button id="upload_link_button">&#128203;</button>
+    </p>
+    </div>
+
+    <?php if ($preview == true) {
+    ?>
+    <div id="upload_finished_preview">
+    <p>
+        <a id="preview_link" href=""><?php echo t('VIEW_LINK') ?></a>
+    </p><p>
+        <code id=preview_link_text></code>
+        <button id="preview_link_button">&#128203;</button>
+    </p>
+    </div>
+    <?php
+} ?>
+
+    <div id="upload_direct_download">
+    <p>
+        <a id="direct_link" href=""><?php echo t('DIRECT_DL') ?></a>
+    </p><p>
+        <code id=direct_link_text></code>
+        <button id="direct_link_button">&#128203;</button>
+    </p>
+    </div>
+
+    <div id="upload_delete">
+    <p>
+        <a id="delete_link" href=""><?php echo t('DELETE_LINK') ?></a>
+    </p><p>
+        <code id=delete_link_text></code>
+        <button id="delete_link_button">&#128203;</button>
+    </p>
+    </div>
+
+    <div id="upload_validity">
+    <p><?php echo t('VALID_UNTIL'); ?>:</p>
+    <p id="date"></p>
+    </div>
+</div>
+<?php 
+}
+
+function jirafeau_get_expiration_time_options() {
+    return 
+    array(
+        array(
+          'value' => 'minute',
+          'label' => '1_MIN'
+        ),
+        array(
+          'value' => 'hour',
+          'label' => '1_H'
+        ),
+        array(
+          'value' => 'day',
+          'label' => '1_D'
+        ),
+        array(
+          'value' => 'week',
+          'label' => '1_W'
+        ),
+        array(
+            'value' => 'fortnight',
+            'label' => '2_W'
+        ),
+        array(
+          'value' => 'month',
+          'label' => '1_M'
+        ),
+        array(
+          'value' => 'quarter',
+          'label' => '1_Q'
+        ),
+        array(
+          'value' => 'year',
+          'label' => '1_Y'
+        ),
+        array(
+          'value' => 'none',
+          'label' => 'NONE'
+        )
+      );
+}
+
+
+
+ /**
+  * 
+  * creates the time selection field
+  * @param mixed $cfg 
+  * @return void 
+  */
+  function jirafeau_create_selection_array($cfg) {
+    echo 
+    '<select name="time" id="select_time">';
+        
+        
+        $expirationTimeOptions = jirafeau_get_expiration_time_options();
+
+        foreach ($expirationTimeOptions as $expirationTimeOption) {
+            $selected = ($expirationTimeOption['value'] === $cfg['availability_default'])? 'selected="selected"' : '';
+            if (true === $cfg['availabilities'][$expirationTimeOption['value']]) {
+                echo '<option value="' . $expirationTimeOption['value'] . '" ' .
+              $selected . '>' . t($expirationTimeOption['label']) . '</option>';
+            }
+        }
+        echo '</select>';
+ }
+
+ function jirafeau_datestr_to_int ($time_str) {
+    $time = time();
+    switch ($time_str) {
+        case 'minute':
+            $time += JIRAFEAU_MINUTE;
+            break;
+        case 'hour':
+            $time += JIRAFEAU_HOUR;
+            break;
+        case 'day':
+            $time += JIRAFEAU_DAY;
+            break;
+        case 'week':
+            $time += JIRAFEAU_WEEK;
+            break;
+        case 'fortnight':
+            $time += JIRAFEAU_FORTNIGHT;
+            break;
+        case 'month':
+            $time += JIRAFEAU_MONTH;
+            break;
+        case 'quarter':
+            $time += JIRAFEAU_QUARTER;
+            break;
+        case 'year':
+            $time += JIRAFEAU_YEAR;
+            break;
+       default:
+            $time = JIRAFEAU_INFINITY;
+            break;
+    }
+    return $time;
+}

patrick-canterino.de