summaryrefslogtreecommitdiffstats
path: root/lib/functions.stories.inc.php
blob: 5e0527e2f2afe58907b76ec9127bef88805b2c5f (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
38
39
<?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) || $file['error'] == UPLOAD_ERR_NO_FILE) {
                return TRUE;
            } else {
                return 3;
            }
        } else {
            // Error on directory creation
            // return 'Could not create directory "'.$path;
            return 2;
        }
    } else {
        return 1;
    }
}
?>