Procházet zdrojové kódy

* theme forms in separate files.

Victor De la Rocha před 15 roky
rodič
revize
b3b04187fb
5 změnil soubory, kde provedl 35 přidání a 296 odebrání
  1. 20 13
      admin/index.php
  2. 1 269
      admin/themes/admin/index.htm
  3. 4 5
      classes/functions.php
  4. 10 7
      classes/themes.class.php
  5. 0 2
      index.php

+ 20 - 13
admin/index.php Zobrazit soubor

@@ -170,34 +170,41 @@ if ($user->isAuthenticated()) {
170 170
 
171 171
                 if (!isset($_GET['new'])) $_GET['new'] = 'post';
172 172
 
173
-                $theme->set('date',$date);
174
-                $theme->set('id_user',$_SESSION['user_id']);
175
-                $theme->set('type',$_GET["new"]);
176
-                $theme->set('editBody',$body);
177
-
173
+				$form = new themes;
174
+                $form->set('date',$date);
175
+                $form->set('id_user',$_SESSION['user_id']);
176
+                $form->set('type',$_GET["new"]);
177
+				$form->set('editBody',$body);
178 178
                 switch ($_GET["new"]) {
179 179
                         case "post":
180
-                                $theme->set('editTitle',$title);
180
+                                $form->set('editTitle',$title);
181
+                                $theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_post.htm'));
181 182
                                 break;
182 183
                         case "photo":
183 184
                                 $url = str_replace("../", $conf->urlGelato."/", $url);
184
-                                $theme->set('editUrl',$url);
185
+                                $form->set('editUrl',$url);
186
+                                $theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_photo.htm'));
185 187
                                 break;
186 188
                         case "quote":
187
-                                $theme->set('editTitle',$title);
189
+                                $form->set('editTitle',$title);
190
+                                $theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_quote.htm'));
188 191
                                 break;
189 192
                         case "url":
190
-                                $theme->set('editTitle',$title);
191
-                                $theme->set('editUrl',$url);
193
+                                $form->set('editTitle',$title);
194
+                                $form->set('editUrl',$url);
195
+                                $theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_link.htm'));
192 196
                                 break;
193 197
                         case "conversation":
194
-                                $theme->set('editTitle',$title);
198
+                                $form->set('editTitle',$title);
199
+                                $theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_conversation.htm'));
195 200
                                 break;
196 201
                         case "video":
197
-                                $theme->set('editUrl',$url);
202
+                                $form->set('editUrl',$url);
203
+                                $theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_video.htm'));
198 204
                                 break;
199 205
                         case "mp3":
200
-                                $theme->set('editUrl',$url);
206
+                                $form->set('editUrl',$url);
207
+                                $theme->set('form',$form->fetch(Absolute_Path.'admin/themes/admin/template_add_mp3.htm'));
201 208
                                 break;
202 209
                         }
203 210
 

+ 1 - 269
admin/themes/admin/index.htm Zobrazit soubor

@@ -72,275 +72,7 @@
72 72
 					<form action="index.php" method="post" {if {$new}=='photo'}enctype="multipart/form-data"{/if} name="frmAdd" id="autosave" class="newpost">
73 73
 						<fieldset>
74 74
 							{if {$postId}}<input type="hidden" name="id_post" id="id_post" value="{postId}" />{/if}
75
-							{if {$type}=='post'}
76
-								<div>
77
-									<label for="title" style="display:block;">Title <span class="option">(optional)</span></label>
78
-									<br /><input class="txt" type="text" name="title" id="title" value="{editTitle}" size="80" />
79
-								</div>
80
-								<div>
81
-									<label for="description" style="display:block;">Body</label>
82
-									<textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
83
-								</div>
84
-
85
-								<input type="hidden" name="url" id="url" value="" />
86
-								<input type="hidden" name="type" id="type" value="{type}" />
87
-								<input type="hidden" name="date" id="date" value="{date}" />
88
-								<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
89
-
90
-								<script>
91
-									$("#autosave").validate({
92
-										rules: {
93
-											description: "required"
94
-										},
95
-										errorElement: "span",
96
-										errorClass: "validate_span",
97
-										errorPlacement: function(label, element) {
98
-											label.prependTo(element.prev())
99
-										}
100
-									});
101
-								</script>
102
-							{elseif {$type}=='photo'}
103
-								<div id="photo_upload">
104
-									<label for="description">Photo</label>
105
-									<br /><input type="file" name="photo" id="photo" accept="image/gif,image/jpeg,image/jpg,image/png"/>
106
-									<div style="font-size:11px; color:#666; margin-top:5px;">
107
-										Supports JPEG, GIF and PNG.&nbsp; <strong>Max size is 10 MB.</strong>
108
-									</div>
109
-									<div style="font-size:11px; color:#666; margin-top:5px;">
110
-										<a href="#" class="linkFrm">Use a URL instead</a>
111
-									</div>
112
-								</div>
113
-
114
-								<div id="photo_url">
115
-									<label for="description">Photo URL</label>
116
-									<br /><input class="input-text" type="text" name="url" id="url" size="80" value="{editUrl}" />
117
-									<div style="font-size:11px; color:#666; margin-top:5px;">
118
-										<a href="#" class="linkFrm">Use a upload form instead</a>
119
-									</div>
120
-								</div>
121
-
122
-								<div>
123
-									<label for="description" style="display:block;">Caption <span class="option">(optional)</span></label>
124
-									<textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
125
-								</div>
126
-
127
-								<input type="hidden" name="title" id="title" value="" />
128
-								<input type="hidden" name="MAX_FILE_SIZE" value="10485760" />
129
-								<input type="hidden" name="type" id="type" value="{type}" />
130
-								<input type="hidden" name="date" id="date" value="{date}" />
131
-								<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
132
-
133
-								<script>
134
-									$('#photo_url').css('display','none');
135
-									$("#autosave").validate({
136
-										rules: {
137
-											photo: {
138
-												required:  function() {
139
-							 						return ($('#photo_upload').css('display')!= 'none') ? true : false;
140
-							  					},
141
-												accept: "(jpe?g|gif|png)"
142
-											},
143
-							 				url: {
144
-												required:  function() {
145
-							 						return ($('#photo_url').css('display')!= 'none') ? true : false;
146
-							  					},
147
-												url: true
148
-											}
149
-										},
150
-										errorElement: "span",
151
-										errorClass: "validate_span",
152
-										errorPlacement: function(label, element) {
153
-											label.prependTo(element.prev())
154
-										}
155
-									});
156
-
157
-									$("#photo_upload a.linkFrm").click( function() {
158
-											$('#photo_upload').css('display','none');
159
-											$('#photo_url').css('display','block');
160
-											$('#photo').val('');
161
-											return false;
162
-										}
163
-									);
164
-
165
-									$("#photo_url a.linkFrm").click( function() {
166
-											$('#photo_url').css('display','none');
167
-											$('#photo_upload').css('display','block');
168
-											$('#url').val('');
169
-											return false;
170
-										}
171
-									);
172
-								</script>
173
-							{elseif {$type}=='quote'}
174
-								<div>
175
-									<label for="description">Quote</label>
176
-									<br /><textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
177
-								</div>
178
-								<div>
179
-									<label for="title">Source <span class="option">(optional)</span></label>
180
-									<br /><input class="txt" type="text" name="title" id="title" value="{editTitle}" size="80" />
181
-								</div>
182
-
183
-								<input type="hidden" name="url" id="url" value="" />
184
-								<input type="hidden" name="type" id="type" value="{type}" />
185
-								<input type="hidden" name="date" id="date" value="{date}" />
186
-								<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
187
-
188
-								<script>
189
-									$("#autosave").validate({
190
-										rules: {
191
-											description: "required"
192
-										},
193
-										errorElement: "span",
194
-										errorClass: "validate_span",
195
-										errorPlacement: function(label, element) {
196
-											label.prependTo(element.prev())
197
-										}
198
-									});
199
-								</script>
200
-							{elseif {$type}=='url'}
201
-								<div>
202
-									<label for="title">Name <span class="option">(optional)</span></label>
203
-									<br /><input class="txt" type="text" name="title" id="title" value="{editTitle}" size="80" />
204
-								</div>
205
-								<div>
206
-									<label for="url">URL</label>
207
-									<br /><input class="txt" type="text" name="url" id="url" value="{editUrl}" size="80" />
208
-								</div>
209
-								<div>
210
-									<div id="add_link_description" style="margin-top:5px;">
211
-										<a class="linkFrm" href="#" onclick="document.getElementById('link_description').style.display = ''; document.getElementById('add_link_description').style.display = 'none'; return false;" style="font-size:11px;">Add a description</a><br /><br />
212
-									</div>
213
-									<div id="link_description" style="display:none;">
214
-										<label for="description">Description</label><br />
215
-										<textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
216
-									</div>
217
-								</div>
218
-								<input type="hidden" name="type" id="type" value="{type}" />
219
-								<input type="hidden" name="date" id="date" value="{date}" />
220
-								<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
221
-
222
-								<script>
223
-									$("#autosave").validate({
224
-										rules: {
225
-											url: {
226
-												required: true,
227
-												url: true
228
-											}
229
-										},
230
-										errorElement: "span",
231
-										errorClass: "validate_span",
232
-										errorPlacement: function(label, element) {
233
-											label.prependTo(element.prev())
234
-										}
235
-									});
236
-								</script>
237
-							{elseif {$type}=='conversation'}
238
-								<div>
239
-									<label for="title">Title <span class="option">(optional)</span></label><br />
240
-									<input class="txt" type="text" name="title" id="title" value="{editTitle}" size="80" />
241
-								</div>
242
-
243
-								<div>
244
-									<label for="description">Conversation</label>
245
-									<div style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;">
246
-										<span style="font-weight: bold;">Example</span><br>
247
-										<span style="font-style: italic;">
248
-											Geek: Wow an open source tumblelog CMS!!.<br>
249
-											Normal: Tumble... what??<br>
250
-											Geek: Read the wikipedia!!
251
-										</span>
252
-									</div>
253
-									<textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
254
-								</div>
255
-
256
-								<input type="hidden" name="url" id="url" value="" />
257
-								<input type="hidden" name="type" id="type" value="{type}" />
258
-								<input type="hidden" name="date" id="date" value="{date}" />
259
-								<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
260
-
261
-								<script>
262
-									$("#autosave").validate({
263
-										rules: {
264
-											description: "required"
265
-										},
266
-										errorElement: "span",
267
-										errorClass: "validate_span",
268
-										errorPlacement: function(label, element) {
269
-											label.prependTo(element.parent().children("label"))
270
-										}
271
-									});
272
-								</script>
273
-							{elseif {$type}=='video'}
274
-								<div>
275
-									<label for="url">Video URL</label>
276
-									<br /><input class="txt" type="text" name="url" id="url" value="{editUrl}" size="80" />
277
-									<div style="color: rgb(136, 136, 136); margin-bottom: 5px; font-size: 11px; font-weight: bold;">
278
-										This is the URL from the video sites YouTube, Vimeo, Yahoo, Daily Motion <br />
279
-										or even an Slide Share Presentation.<br />
280
-										<span style="font-size: 10px; font-weight: normal;">(ie. http://youtube.com/watch?v=HcBFLN9cli0)</span>
281
-									</div>
282
-								</div>
283
-								<div>
284
-									<label for="description">Caption <span class="option">(optional)</span></label><br />
285
-									<textarea rows="12" cols="84" name="description" id="description" tabindex="2">{editBody}</textarea>
286
-								</div>
287
-
288
-								<input type="hidden" name="title" id="title" value="" />
289
-								<input type="hidden" name="type" id="type" value="{type}" />
290
-								<input type="hidden" name="date" id="date" value="{date}" />
291
-								<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
292
-
293
-								<script>
294
-									$("#autosave").validate({
295
-										rules: {
296
-											url: {
297
-												required: true,
298
-												url: true
299
-											}
300
-										},
301
-										errorElement: "span",
302
-										errorClass: "validate_span",
303
-										errorPlacement: function(label, element) {
304
-											label.prependTo(element.prev())
305
-										}
306
-									});
307
-								</script>
308
-							{elseif {$type}=='mp3'}
309
-								<div>
310
-									<label for="url">MP3 URL</label>
311
-									<br /><input class="txt" type="text" name="url" id="url" value="{editUrl}" size="80" />
312
-									<div style="color: rgb(136, 136, 136); margin-bottom: 5px; font-size: 11px; font-weight: bold;">
313
-										This is the MP3 file URL or a GoEar URL or an Odeo URL.<br>
314
-										<span style="font-size: 10px; font-weight: normal;">(ie. http://www.goear.com/listen.php?v=c0a2c85)</span>
315
-									</div>
316
-								</div>
317
-								<div>
318
-									<label for="description">Caption <span class="option">(optional)</span></label><br />
319
-									<textarea rows="12" cols="84" name="description" id="description" tabindex="2">{editBody}</textarea>
320
-								</div>
321
-
322
-								<input type="hidden" name="title" id="title" value="" />
323
-								<input type="hidden" name="type" id="type" value="{type}" />
324
-								<input type="hidden" name="date" id="date" value="{date}" />
325
-								<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
326
-
327
-								<script>
328
-									$("#autosave").validate({
329
-										rules: {
330
-											url: {
331
-												required: true,
332
-												url: true
333
-											}
334
-										},
335
-										errorElement: "span",
336
-										errorClass: "validate_span",
337
-										errorPlacement: function(label, element) {
338
-											label.prependTo(element.prev())
339
-										}
340
-									});
341
-								</script>
342
-							{/if}
343
-
75
+							{form}
344 76
 							<p>
345 77
 								<span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;">
346 78
 		                            				{__("Some HTML allowed")}:<br />

+ 4 - 5
classes/functions.php Zobrazit soubor

@@ -487,12 +487,11 @@ if(!defined('entry') || !entry) die('Not a valid page');
487 487
 		return $tmpStr;
488 488
 	}
489 489
 
490
-	function trimString($string, $len = "") {
491
-		if($len>strlen($string) or $len<1 or strlen($string)<1) {		
490
+	function trimString($string, $len=50) {
491
+		if($len>strlen(strip_tags($string)) or $len<1 or strlen(strip_tags($string))<1)
492 492
 			return strip_tags($string);
493
-		}
494 493
 		$string = strip_tags($string);
495
-		$len = (empty($len)) ? "50" : $len ;
496
-		return ( strpos($string, " ", $len) ) ? substr_replace($string, "...", $len) : $string ;
494
+
495
+		return (strpos($string," ",$len))?substr_replace($string, "...", $len):$string;
497 496
 	}
498 497
 ?>

+ 10 - 7
classes/themes.class.php Zobrazit soubor

@@ -13,7 +13,7 @@ class themes{
13 13
 	var $vars=array(); //variable para apilar las variables que se asignan a la plantilla
14 14
 
15 15
 	function themes(){
16
-		#$this->l10n = l10n::getInstance();
16
+
17 17
 	}
18 18
 
19 19
 	function set($name, $value){
@@ -46,6 +46,7 @@ class themes{
46 46
 		$this->registrar_vars();
47 47
 		$this->__();
48 48
 		$this->eval_control_structures();
49
+
49 50
 		//evaluate All as PHP code
50 51
 		ob_start();eval($this->output);
51 52
 		$this->output = stripslashes(ob_get_clean());
@@ -67,9 +68,6 @@ class themes{
67 68
 		//Converting the $this->vars[\'variable\'] format to {$this->vars['variable']}
68 69
 		$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']['$2']}",$this->output);
69 70
 		$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']}",$this->output);
70
-
71
-		//Converting the {__(\'word\')} format to {__('word')}
72
-		#$this->output = preg_replace("/[\$]this->vars\[\\\'([^ \.\\\]+)\\\'\]/","{\$this->vars['$1']}",$this->output);
73 71
 	}
74 72
 
75 73
 	//sustituye las variables en el output del template
@@ -90,13 +88,18 @@ class themes{
90 88
 		//replacing {$key} format by $this->vars['key']
91 89
 		//replacing  {$array.key} format by $this->vars['array']['key']
92 90
 		$patrones = array(
93
-			'/{\$([^ \.}]+)}/s',
94
-			'/{\$([^ \.}]+)\.([^ \.}]+)}/s'
91
+			#'/{\$([^ \.}]+)}/s',
92
+			#'/{\$([^ \.}]+)\.([^ \.}]+)}/s'
93
+			'/{\$(\w+)}/s',
94
+			'/{\$(\w+)\.(\w+)}/s',
95
+			'/\$(\W)/s'
95 96
 		);
96 97
 		$reemplazos = array(
97 98
 			"\$this->vars['$1']",
98
-			"\$this->vars['$1']['$2']"
99
+			"\$this->vars['$1']['$2']",
100
+			"\\\\$$1"
99 101
 		);
102
+
100 103
 		$this->output = preg_replace($patrones, $reemplazos, $this->output);
101 104
 	}
102 105
 

+ 0 - 2
index.php Zobrazit soubor

@@ -112,8 +112,6 @@ $theme = new themes;
112 112
 
113 113
 								$conversation = $register["description"];
114 114
 
115
-								$register["description"] = $register["description"];
116
-
117 115
                                 $register["title"] = stripslashes($register["title"]);
118 116
                                 $register["description"] = stripslashes($register["description"]);
119 117