partia duużych zmian
[watermeloncms.git] / wtrmln / modules / views / pages / new.php
blobcb1b9c968c76c7c58b6170f0127dc10bd97c18bd
1 <?php if(!defined('WTRMLN_IS')) exit;
2 /********************************************************************
4 Watermelon CMS
6 Copyright 2008-2009 Radosław Pietruszewski
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ********************************************************************/
24 <a href="$/">Panel Admina</a> &gt; <a href="$/pages">Strony</a> &gt; Nowa
26 <?php
27 Controller::addMeta(
28 '<style type="text/css">.newpage_box label{float:left;width:100px;display:block}'.
29 '.newpage_box #title, .newpage_box #name{width:60%}'.
30 '.newpage_box #text{width: 100%; height:250px;}</style>');
33 <script type="text/javascript">
35 function trim(str)
37 // bazowane na http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_trim/
38 // na licencji MIT
39 // no i trochę edytowane przeze mnie ;)
41 for(i = 0; i < str.length; i++)
43 if(str.charAt(i) != ' ')
45 str = str.substring(i);
46 break;
50 for(i = str.length - 1; i >= 0; i--)
52 if(str.charAt(i) != ' ')
54 str = str.substring(0, i + 1);
55 break;
59 return str.charAt(0) == ' ' ? '' : str;
62 function UpdatePageName()
64 title = document.getElementById("title").value;
65 title = trim(title);
66 document.getElementById("title").value = title;
68 name = document.getElementById("name");
69 title = title.toLowerCase();
70 title = title.replace(/ę/g, "e");
71 title = title.replace(/ó/g, "o");
72 title = title.replace(/ą/g, "a");
73 title = title.replace(/ś/g, "s");
74 title = title.replace(/ł/g, "l");
75 title = title.replace(/ż/g, "z");
76 title = title.replace(/ź/g, "z");
77 title = title.replace(/ć/g, "c");
78 title = title.replace(/ń/g, "n");
79 title = title.replace(/ /g, "-");
81 var res = [];
83 while(title.length > 0)
85 res[res.length] = title.substring(0, 1);
86 title = title.substring(1);
89 title2 = '';
91 var j = 0;
93 for(k in res) j++;
95 for(i = 0; i < j; i++)
97 c = res[i].charCodeAt(0);
98 if(c >= 97 && c <= 122) title2 += String.fromCharCode(c);
99 if(c >= 48 && c <= 57) title2 += String.fromCharCode(c);
100 if(c == 45) title2 += String.fromCharCode(c);
103 title2 = title2.replace(/-+/g, "-");
104 name.value = title2;
106 </script>
108 <form action="$/pages/post/<$tkey>/<$tvalue>" method="POST">
109 <fieldset class="newpage_box">
110 <legend>Nowa strona</legend>
112 <label for="title">Temat:</label>
113 <input type="text" name="title" id="title" onchange="UpdatePageName()">
115 <br>
117 <label for="name">Nazwa:</label>
118 <input type="text" name="name" id="name">
120 <br>
122 <label for="text">Treść:</label><br>
124 <textarea name="text" id="text"></textarea>
126 <br>
128 <input type="submit" id="submit" value="Wyślij!">
130 </fieldset>
131 </form>