Source of trunk/cp_skin.php at revision 363 (05/07/2008 10:05:26, 3609 bytes, 100 lines, language: php) [download]:
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | ** Control Panel :: Skin Editor |
| 5 | ** for CodewiseBlog Multi-User |
| 6 | ** |
| 7 | |
| 8 | ** Copyright (c) 2005-2008 Codewise.org |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | ** This file is part of CodewiseBlog |
| 13 | ** |
| 14 | ** CodewiseBlog is free software; you can redistribute it and/or modify |
| 15 | ** it under the terms of the GNU General Public License as published by |
| 16 | ** the Free Software Foundation; either version 2 of the License, or |
| 17 | ** (at your option) any later version. |
| 18 | ** |
| 19 | ** CodewiseBlog is distributed in the hope that it will be useful, |
| 20 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | ** GNU General Public License for more details. |
| 23 | ** |
| 24 | ** You should have received a copy of the GNU General Public License |
| 25 | ** along with CodewiseBlog; if not, write to the Free Software |
| 26 | ** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 27 | */ |
| 28 | |
| 29 | $current = "skin"; |
| 30 | |
| 31 | if(isset($_POST['go_baby_go'])) |
| 32 | { |
| 33 | $db->update("skin", array($_POST['section'] => $_POST['section_content']), array("blogid" => BLOGID)); |
| 34 | $GLOBALS['NOTIFY'] = "Skin Updated"; |
| 35 | $_POST['section_sel'] = $_POST['section']; // redisplay the current one |
| 36 | } elseif(isset($_POST['revert'])) { |
| 37 | $db->update("skin", array($_POST['section'] => NULL), array("blogid" => BLOGID)); |
| 38 | $GLOBALS['NOTIFY'] = "Reverted to Master Skin"; |
| 39 | $_POST['section_sel'] = $_POST['section']; // redisplay the current one |
| 40 | } |
| 41 | |
| 42 | $q = $db->issue_query("DESCRIBE skin"); |
| 43 | $desc = $db->fetch_all($q, L1SQL_ASSOC); |
| 44 | |
| 45 | if(isset($_POST['resize'])) |
| 46 | $_POST['section_sel'] = $_POST['section']; // hack to get the section edit box to redisplay |
| 47 | |
| 48 | $sectionlist = ""; |
| 49 | foreach($desc as $col) |
| 50 | { |
| 51 | if($col['Field'] == "blogid") |
| 52 | continue; |
| 53 | elseif($col['Field'] == $_POST['section_sel']) |
| 54 | $sectionlist .= skinvoodoo("controlpanel_skin", "sectionlist_current", array("section" => $col['Field'])); |
| 55 | else |
| 56 | $sectionlist .= skinvoodoo("controlpanel_skin", "sectionlist_entry", array("section" => $col['Field'])); |
| 57 | } |
| 58 | |
| 59 | if(isset($_POST['section_sel'])) |
| 60 | { |
| 61 | $q = $db->issue_query("SELECT ".$db->prepare_value($_POST['section_sel'], FALSE)." FROM skin WHERE blogid = '".BLOGID."'"); |
| 62 | $skin = $db->fetch_var($q); |
| 63 | if($skin === NULL) |
| 64 | { |
| 65 | $using_master = TRUE; |
| 66 | $q = $db->issue_query("SELECT ".$db->prepare_value($_POST['section_sel'], FALSE)." FROM skin WHERE blogid = '1'"); |
| 67 | $skin = $db->fetch_var($q); |
| 68 | } else { |
| 69 | $using_master = FALSE; |
| 70 | } |
| 71 | |
| 72 | // special case when using the root controlpanel |
| 73 | if(BLOGID == 1) |
| 74 | $using_master = TRUE; |
| 75 | |
| 76 | $content = skinvoodoo("controlpanel_skin", "section_edit", array( |
| 77 | "section_name" => $_POST['section_sel'], |
| 78 | "using_master" => $using_master, |
| 79 | "autoresize" => INDEX_URL . "?autoresize.js", |
| 80 | "rows" => $_POST['rows'] ? $_POST['rows'] : 30, |
| 81 | "cols" => $_POST['cols'] ? $_POST['cols'] : 80, |
| 82 | "section_content" => str_replace( |
| 83 | array("%{", "\${" ), |
| 84 | array("%{", "${" ), |
| 85 | htmlspecialchars($skin)), |
| 86 | )); |
| 87 | |
| 88 | $varlist = "<iframe src=\"http://" . DEFAULT_SUBDOMAIN . BASE_DOMAIN . INSTALLED_PATH . "doc/voodoo/localvars.html#". $_POST['section_sel'] . "\" height=\"100%\" width=\"300\" /></iframe>"; |
| 89 | } |
| 90 | |
| 91 | $body = skinvoodoo("controlpanel_skin", "", array( |
| 92 | "posturl" => INDEX_URL . "?controlpanel:skin", |
| 93 | "sectionlist" => $sectionlist, |
| 94 | "varlist" => $varlist, |
| 95 | "content" => $content, |
| 96 | "section_name" => isset($_POST['section_sel']) ? $_POST['section_sel'] : FALSE, |
| 97 | )); |
| 98 | |
| 99 | ?> |
| 100 |