summaryrefslogtreecommitdiffstats
path: root/lib/functions.stories.php
blob: a8102c32b115177f35830078b27a037816375107 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/*
 * functions.stories.php
 */
 

function visibleName($nameWithUnderscore) {
    //return str_replace('_', ' ', $nameWithUnderscore);
    return urldecode($nameWithUnderscore);
}

function generateDirectoryName($storyName) {
    return urlencode($storyName);
}

function createEntity($path, $description, $file, $filename) {
    if (!dir_exists($path)) {
        // create directory for story
        if (mkdir($path)) {
            // create description file
            if (file_put_contents($path.DIRECTORY_SEPARATOR.'description.txt', $description) === FALSE) {
                // Error on writing description file
            }
            // move uploaded logo
            if (NULL === $file || move_uploaded_file($file['tmp_name'], $path.DIRECTORY_SEPARATOR.$filename)) {
                return TRUE;
            }
        } else {
            // Error on directory creation
        }
    }
}
?>