[show modes: view edit news] [begin preamble] if(title2id(_title) != _id) _bestlink = {id=[_id]} else if(strcount(_title, "&")) _bestlink = {id=[_id]} else _bestlink = urlencode(_title); universe_dropdown = function { <select name="unvid" style="width: 80%;"> [foreach (query_run("id", query("universes", 0, "title collate utf8mb4_general_ci", "template", title2id("Universe"), "parent", 23))) _data = {<option value="[_data]">[get_title(_data)]</option>} ] </select> }; [end preamble] [begin mode create_group] [ if($_group == 0) {[ $g = new_group($_title); set_group(_id, $g); mute set_founder($g, $_author); mute set_group_profile_id($g, $_id); $gr = new_grouping($_author, $g); mute set_grouping_permissions($_author, $g, "cadre"); var hcount = 1; var hsum = 0; while(hcount > 0) {[ command({update entries as A inner join entries as B on A.parent = B.id set A.group = [$g] where B.group = [$g]; }); $remaining = retrieve({ select count(A.id) as e from entries as A inner join entries as B on A.parent = B.id where B.group = [$g] and A.group = 0; }); hcount = $remaining[0]["e"]; debug($remaining); debug("hcount: " & hcount & " children of " & $g); hsum += hcount; ]}; { Group created! [if(hsum > 0) {[hsum] child pages added to the group.}] <a href="/?id=[_id]&mode=edit">Click here to go back to the editor.</a> }; ]} else { This project already has a group! <a href="/?[_bestlink]">Click here to go back.</a> }; ] [end mode create_group] [begin mode abbr] [msg_start()] <span style="float: right; font-size: 60%; text-align: right"> [if(_body == "") {lacks description + synopsis} else if(getv("body") == "") {lacks description}] </span> [if(getv("image") != "") { [$e = {/pictures/universes/[$_title]/[getv("image")]}] <img src="[$e]" style="max-height: 100px; float: left; margin-right: 10px;"> } else if(file_exists({[_globals.VROOT]/avatars/[_owner.id].jpg})) { <img src="/pictures/avatars/[_owner.id].jpg" style="max-height: 100px; float: left; margin-right: 10px;"> } else { <img src="/pictures/default-avatar.png" style="max-height: 100px; float: left; margin-right: 10px;"> }] <div style="font-size: 140%"><a href="/?[_bestlink]">[$_title]</a></div> <div style="font-size: 70%">[ if(_group != 0) groupies = retrieve({select users.name, users.profile_id from groups inner join groupings on groups.id = groupings.group inner join users on groupings.user = users.id where groups.id = [_group] order by users.name asc}); founder = retrieve({select users.id, users.name, users.profile_id from groups inner join users on groups.founder = users.id where groups.id = [_group]}); if(count(groupies) > 1) { contributors: [x = foreach(groupies) (_data = (if(_data.profile_id == 0) _data.name else page("link", _data.profile_id) & ",")); substr(x, 0, -1)]<br> }; if(count(groupies)) { founder: [if(founder.0.profile_id == 0) founder.0.name else page("link", founder.0.profile_id)] [if(_owner.id != founder.0.id) {<br> maintainer: [if(_owner.profile_id == 0) _owner.name else page("link", _owner.profile_id)] }] }; ] </div> [_wiki_format(getv("summary"), "inline")] <div style="clear: both;"></div> [msg_end()] [end mode abbr] [begin mode css] [ banner = getv("banner"); if(banner) { <style type="text/css"> #site_title { background: url('/pictures/universes/[$_title]/[banner]')[if(getv("text_color") == "white") { black }]; } #site_title a, #site_title { color: [getv("text_color")] !important; } #site_title #title_text img { display: none; } </style> } ] [end mode css] [begin mode view] [ _css(); page("view", 278); ] <div style="float: right; margin-left: 10px; font-size: 80%; text-align: right; max-width: 300px;"> [ if(getv("image") != "") { [$e = {/pictures/universes/[$_title]/[getv("image")]}] <img src="[$e]" style="max-width: 100%; margin-bottom: 10px; display: block; margin-left: auto;"> }; if(_group != 0) {[ groupies = retrieve({select users.name, users.profile_id from groups inner join groupings on groups.id = groupings.group inner join users on groupings.user = users.id where groups.id = [_group] order by users.name asc}); founder = retrieve({select users.id, users.name, users.profile_id from groups inner join users on groups.founder = users.id where groups.id = [_group]}) ]}; subs = getv("universes"); uids = split(subs, "<&>"); if(getv("hide_stats") < 1) {[ if(count(groupies)) { [if(count(groupies) > 1) {contributors: [x = foreach(groupies) (_data = (if(_data.profile_id == 0) _data.name else page("link", _data.profile_id) & ",")); substr(x, 0, -1)]<br>} ] founder: [if(founder.0.profile_id == 0) founder.0.name else page("link", founder.0.profile_id)]<br> [if(_owner.id != founder.0.id) { maintainer: [if(_owner.profile_id == 0) _owner.name else page("link", _owner.profile_id)]<br> }] }; ]}; ] </div> [ if (subs != "") { [bod = getv("body"); if(bod != "") _wiki_format(bod) else if(can_edit()) {<i>This universe doesn't have an introduction yet. <a href="/?id=[_id]&mode=edit">Click here to start editing</a>.</i><br>}; ] <br> <table class="front_table"> [ foreach (uids) _data = search("table", "parent", $_data, "template", title2id("Book")); ] </table> <br> <table class="front_table"> [ foreach (uids) _data = search("table", "parent", $_data, "template", title2id("Language Family")); foreach (uids) _data = search("table", "parent", $_data, "template", title2id("Language")); ] </table> <br> <table class="front_table"> [ foreach (uids) _data = search("table", "parent", $_data, "template", title2id("Universe List")); ] </table> } else { <p>This metaverse is empty! Add universes to it.</p> }; [if(getv("blog_rss") == "") { [ $q = query("blog", 3, "id desc, title", "parent", $_id, "template", title2id("News Post")); if(query_count($q) > 0) {<h1><a href="/?id=[$_id]&mode=news">[iif(getv("blog_title"), getv("blog_title"), "News")]</a></h1>}; query_view("abbr", $q, list("no_icon")); if(can_comment()) {<center> <a href="/?id=[$_id]&mode=add_news">Create news post</a> </center>} ] <center> <a href="/?id=[$_id]&mode=news">More...</a> </center> } else { <h1><a href="[getv("blog_url")]">[iif(getv("blog_title"), getv("blog_title"), "News")]</a></h1> [ show("view", slice(get_rss(title2id("Tumblr Entry"), getv("blog_rss") ), 0, 3)) ] <center> <a href="[getv("blog_url")]">More...</a> </center> }] ] [end mode view] [begin mode edit] [ if (can_edit()) {[ if($_params.submit == "edit") { [ if(_params.universe_title != _title) {[ ut = replace(replace(_params.universe_title, ".", ""), "/", ""); if(not(can_direct())) {[ msg("You don't have permission to rename this universe."); ]} else if(ut == "") {[ msg("You can't rename the universe to an empty title."); ]} else if(search("id", "title", ut, "template", _template) != "") {[ msg("That title is already taken!"); ]} else {[ old_title = _title; upath = _globals.VROOT & "/universes/"; if(not(dir_exists({[$_globals.VROOT]/universes/[$_title]})) || mv(upath & old_title, upath & ut)) {[ msg({Done! [old_title] renamed to [ut].}); _title = ut; set_group_name(_group, ut); if(title2id(_title) != _id) _bestlink = {id=[_id]} else _bestlink = urlencode(_title); ]} else msg("Failure! Time to call the admin."); ]}; ]}; putv("no_mail", $_params.no_mail); putv("hide_stats", $_params.hide_stats); putv("summary", $_params.summary); putv("body", $_params.desc); putv("image", info_display($_params.image)); putv("blog_title", $_params.blog_title); putv("blog_url", $_params.blog_url); putv("blog_rss", $_params.blog_rss); putv("banner", info_display($_params.banner)); if($_params.text_color == "white") putv("text_color", _params.text_color) else if($_params.text_color == "black") putv("text_color", _params.text_color); msg_start(); ] Page updated! <a href="/?[_bestlink]">Click here</a> to see the results. [ msg_end(); ] }; if($_params.create == 1) {[msg_start(); if($_params.unvid == "") { <p><b>Couldn't add Universe</b>: you didn't specify a name or id!</p> } else {[ conv = title2id(_params.unvid); if(not(conv)) {[ conv = _params.unvid ]}; if (can_edit(conv)) {[ subs = getv("universes"); subcount = getv("u_count"); if(subcount == "") {[ subcount = 0; ]}; matching = query_count(search("table", "id", conv, "template", title2id("Universe"))); if(not(matching)) { <p>Page [_params.unvid] is not a universe!</p> } else {[ if (subcount >= 5) { <p>You already have five universes in this metaverse.</p> } else {[ if(subs) {[ subs = subs & "<&>" & conv; ]} else {[ subs = conv; ]}; subcount += 1;] <p>Universe added.</p> }; ]}; putv("universes", subs); putv("u_count", subcount); ]} else { <p>You do not have permission to add this universe</p> }]}; msg_end();]}; if($_params.remove != "") {[msg_start(); subs = getv("universes"); subcount = getv("u_count"); if (strpos(subs, $_params.remove) != -1) {[ if (can_direct() || can_direct($_params.unvid)) {[ if (strpos(subs, $_params.remove & "<&>") != -1) {[ subs = replace(subs, $_params.remove & "<&>", ""); ]} else if(strpos(subs, "<&>" & $_params.remove) != -1) {[ subs = replace(subs, "<&>" & $_params.remove, ""); ]} else {[ subs = replace(subs, $_params.remove, ""); ]} putv("universes", subs); putv("u_count", subcount-1);] <p>Universe [$_params.remove] successfully removed.</p> } else { <p>You do not have permission to remove this universe.</p> } ]} else { <p>[$_params.remove] is not a universe of this metaverse.</p> }; msg_end();] }; ] <form method="post" action="/"> <input type="hidden" name="id" value="[$_id]"> <input type="hidden" name="mode" value="edit"> <input type="hidden" name="submit" value="edit"> <table style="width: 100%"> <tr><th>Title: <td><input type="text" name="universe_title" value="[edit_display(_title)]"> <br><small>Any links to universe images or attached files will be broken if you rename the universe. Periods and slashes are not allowed.</small> <tr><th>Summary: <td><textarea name="summary" style="width: 100%;">[edit_display(getv("summary"))]</textarea> <br><small>Displayed on your profile page and the <a href="/?Universes">Universes</a> index.</small> <tr><th>Description: <td><textarea name="desc" style="width: 100%;" rows="7">[edit_display(getv("body"))]</textarea> <br><small>Displayed on the universe's main page.</small> <tr><th>Hide Stats: <td><input type="checkbox" name="hide_stats" id="hs" value="1" [if(getv("hide_stats")) {checked}]><label for="hs">Hide universe statistics</label> <tr><th>Image: <td> [ if(dir_exists({[$_globals.VROOT]/universes/[$_title]})) _select(getv("image"), "<!>(none)" & chr(10) & dirlist({/universes/[$_title]/}), "image", {width: 100%;}) else { <i>No image portfolio defined. </i> } ] <tr><th>Banner Image: <td> [ if(dir_exists({[$_globals.VROOT]/universes/[$_title]})) _select(getv("banner"), "<!>(none)" & chr(10) & dirlist({/universes/[$_title]/}), "banner", {width: 100%;}) else { <i>No image portfolio defined. </i> } ] <a href="/?id=[$_id]&mode=pictures" target="_blank">Manage pictures for this universe...</a> <tr><th valign="top">Banner Text Colour: <td>[ _select(getv("text_color"), {black[chr(10)]white}, "text_color"); ]<br> <tr><th valign="top">Blog Name: <td><input type="text" name="blog_title" value="[edit_display(getv("blog_title"))]"><br> <tr><th valign="top">Blog URL: <td><input type="text" name="blog_url" value="[edit_display(getv("blog_url"))]"><br> <tr><th valign="top">Blog RSS: <td><input type="text" name="blog_rss" value="[edit_display(getv("blog_rss"))]"><br> Input the URL to a blog's front page and RSS feed to use it for your profile. <a href="http://tumblr.com">Tumblr</a> and <a href="http://wordpress.com">Wordpress</a> blogs have been confirmed to work properly. If you prefer, however, you may leave this blank and use a built-in Cadre blog. A Cadre blog will let you automatically limit comments according to the site's controls, but a Tumblr or Wordpress blog may be better for sharing your work with others outside of our community.<br><br>If you provide a name for your blog, it will be used either way. <tr><th>Group: <td>[ if($_group == 0) { <a href="/?id=[$_id]&mode=create_group" target="_blank">Click here to initialize this universe's group</a>. This will let you give others the ability to participate in your project. } else { <a href="/edit_group.star?id=[$_group]" target="_blank">Click here to manage this universe's group</a>. This defines who is allowed to contribute to the metaverse, and how. In particular, this lets others add their universes. } ] <tr><th>Discussion Messages: <td><input type="checkbox" name="no_mail" value="1" [if(getv("no_mail")) {checked}] id="no_mail"> <label for="no_mail">Do not notify group members of posts on discussion pages within this universe.</label> <tr><th>Deletion: <td><a href="/?id=[$_id]&mode=delete">Click here to initiate deletion of the metaverse</a>. (Confirmation is required.) Be careful with this! </table> <br><br> <center><input type="submit" value="Save Changes to Metaverse"></center> <br> </form> <div> <h1>Universes</h1> <table class="front_table"> [subs = getv("universes"); if(subs != "") {[ foreach (split(subs, "<&>")) _data = { <form method="post" action="/"> <input type="hidden" name="id" value="[$_id]"> <input type="hidden" name="mode" value="edit"> <input type="hidden" name="remove" value="[$_data]"> <tr><nobr><th><a href="/?id=[$_data]">[get_title($_data)]</a> <td><input type="submit" value="-"></nobr> </form> }; ]} ] </table> </div> <div> <h2>Add Universes</h2> <p>Add universes here. You must have permission to direct the universe to add it. To display a collaborator's universe here, you can add them to the group and have them add their universe.</p> <table class="front_table"> [ if(can_comment()) { <form method="post" action="/"> <input type="hidden" name="id" value="[$_id]"> <input type="hidden" name="create" value="1"> <input type="hidden" name="mode" value="edit"> <tr> <td>[universe_dropdown()]<label for="submit"><input type="submit" id="submit" value="+">Add a new Universe.</label> </tr> </form> } ] </table> </div> }] [end mode edit] [begin mode pictures] [ $fn = {/universes/[$_title]/}; $fullfn = {[$_globals.VROOT][$fn]}; if(dir_exists($fullfn)) {[_gallery({universes/[$_title]}, 150, iif(can_direct(), 1, 0), $_id);]} else {[msg_start({text-align: center; padding-top: 30px; padding-bottom: 30px;})]<i>No image portfolio yet for this universe. [if(can_edit()) {Upload some pictures!};]</i>[msg_end()]}; if(can_edit()) { [ if(dir_exists($fullfn)) {[ $cc = strcount(dirlist({/universes/[$_title]}), chr(10)) + 1; if(dirlist({/universes/[$_title]}) == "") $cc = 0; ]} else {[ $cc = 0; ]}; if($cc < 50) { <form action="/" method="post" enctype="multipart/form-data"> <input type="file" name="ufile"> <input type="hidden" name="id" value="[$_id]"> <input type="hidden" name="mode" value="picture_submit"> <input type="submit" value="Upload" name="button"> <input type="submit" value="Upload and Rename" name="button"> </form> <p>You may not have more than 50 pictures. You have [$cc] picture(s).</p> } else {<p>You have too many ([$cc]) pictures to add more.</p>};] <p><a href="/?id=[$_id]&mode=edit">Return to editing [$_title]</a></p> };] [end mode pictures] [begin mode picture_rename] [ if(can_edit()) {[ $pp = $_params.picture; $pp = replace($pp, "/", ""); if(file_exists({[$_globals.VROOT]/universes/[$_title]/[$pp]})) { [msg_start()] <h3>Rename Image</h3> <center><img src="/pictures/universes/[$_title]/[$pp]"> <form method="post" action="/"> <input type="hidden" name="mode" value="picture_rename_submit"> <input type="hidden" name="id" value="[$_id]"> <input type="hidden" name="from" value="[$pp]"> <table> <tr> <th>From:<td>[substr($pp, 0, strrpos($pp, "."));] <tr> <th>To:<td><input type="text" name="to" value="[ substr($pp, 0, strrpos($pp, ".")); ]"> <tr><td><td> <input type="submit" value="Rename"> <a href="/?id=[$_id]&mode=pictures">Cancel</a> </table> </form> </center> [msg_end()] } else { Bad file name. This renaming has probably already been done. <a href="/?id=[$_id]&mode=pictures">Go back to the gallery.</a> }; ]} else { This is not your universe. <a href="/?id=[$_id]&mode=pictures">Go back to the gallery.</a> }; ] [end mode picture_rename] [begin mode picture_rename_submit] [ if(can_edit()) {[ $pp = $_params.from; $pp = replace($pp, "/", ""); $pt = $_params.to; $pt = replace($pt, "/", "") & substr($pp, strrpos($pp, ".")); if($_params.from == $params.to) { No? Alright...<br><br> <a href="/?id=[$_id]&mode=pictures">Go back to the gallery.</a> } else if(file_exists({[$_globals.VROOT]/universes/[$_title]/[$pt]})) { Destination file already exists. Perhaps you already renamed the file?<br><br> <a href="/?id=[$_id]&mode=pictures">Go back to the gallery.</a> } else if(file_exists({[$_globals.VROOT]/universes/[$_title]/[$pp]})) {[ $fpp = {[$_globals.VROOT]/universes/[$_title]/[$pp]}; $fpt = {[$_globals.VROOT]/universes/[$_title]/[$pt]}; if(mv($fpp, $fpt)) { File renamed! [refresh_to({/?id=[$_id]&mode=pictures}, 0)] <script type="javascript"><!-- document.location = "/?id=[$_id]&mode=pictures"; --></script> } else { File could not be renamed. }] <br><br> <a href="/?id=[$_id]&mode=pictures">Go back to the gallery.</a> } else { Bad file name. The source file was deleted.<br><br> <a href="/?id=[$_id]&mode=pictures">Go back to the gallery.</a> }; ]} else { This is not your universe. <a href="/?id=[$_id]&mode=pictures">Go back to the gallery.</a> }; ] [end mode picture_rename_submit] [begin mode picture_submit] <p> [ $fn = {/universes/[$_title]/}; $fullfn = {[$_globals.VROOT][$fn]}; if(dir_exists($fullfn)) {} else {[ if(mkdir($fullfn)) { Creating the universe's image portfolio for the first time. } else { Could not create the image portfolio. Expect a bunch of horrible error messages. }; ]}; $na = file_upload("ufile", $fn, 10485760); $fn = slice($na, 2, 1); if($fn != "null") { [// file_crop($fn, 150, 150);] Done. Upload successful! <br><br> Now that the image is uploaded, please go and make sure it has a name that will be easy to remember. [if($_params.button == "Upload") { [refresh_to({/?id=[$_id]&mode=pictures}, 2)] <script type="javascript"><!-- document.location = "/?id=[$_id]&mode=pictures"; --></script> } else { [refresh_to({/?id=[$_id]&mode=picture_rename&picture=[basename($fn)]}, 2)] <script type="javascript"><!-- document.location = "/?id=[$_id]&mode=picture_rename&picture=[basename($fn)]"; --></script> }] } else { File upload failed. Why is anyone's guess. Contact <a href="mailto:hexadecima@gmail.com">an administrator</a> if you want it fixed. }; ] <a href="/?id=[$_id]&mode=pictures">Go back</a>.</p> <p><a href="/?Settings">Or, return to Settings</a>.</p> [end mode picture_submit] [begin mode picture_delete] <p> [if(can_edit()) {[ $fn = {[$_globals.VROOT]/universes/[$_title]/[$_params.picture]}; if(file_exists($fn)) { [if(rm($fn)) {Deleted!} else {Not deleted! Oh no!}] } else { Not deleted because it doesn't exist! What's up with that? }; ]} else { This isn't your universe. Where did your life go so wrong? };] </p> <p><a href="/?id=[$_id]&mode=pictures">Go back</a>.</p> [end mode picture_delete] [begin mode add_news] [ $p = new_page({Untitled Entry}, $_id); set_template($p, title2id("News Post")); set_permissions($p, "cadrecadrec--r-c--r-"); set_group($p, 2); page("edit", $p); ] [end mode add_news] [begin mode news] [if(getv("blog_url") == "") { [ override_title(getv("blog_title"), {[$_title] News}); override_parent({./?[_bestlink]}, $_title); $pagesize = 10; $q = query("news", $pagesize, "id DESC, title", "parent", $_id, "template", title2id("News Post")); query_view("abbr", $q, list("no_icon")); $qc = query_count($q); if($qc > $pagesize) {<center>[ $np = next_page($q); $pp = previous_page($q); if($pp) {<br><br><a href="[$pp]">Previous</a> }; if($np) { <a href="[$np]">Next</a><br>}; page_list($q); ]</center>}; if(can_comment()) {<center><br> <a href="/?id=[$_id]&mode=add_news">Create news post</a> </center>}; ] } else { [suppress_title()] Transferring you to <a href="[getv("blog_url")]">[getv("blog_title")]</a>... [refresh_to(getv("blog_url"), 1)] }] [end mode news]