summaryrefslogtreecommitdiffstats
path: root/lib/functions.stories.inc.php
blob: b882869c157baa0a173adad9852a5791c80b3f64 (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
34
35
36
37
<?php
/*
 * functions.stories.php
 */
 

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

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

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
            // return 'Could not create directory "'.$path;
            return 2;
        }
    } else {
        return 1;
    }
}
?>