Commits

Anonymous committed 1d46d13

Corrected Javascript page. Works&Saves as it should. Implemented default JS page.

Comments (0)

Files changed (4)

textpattern/include/txp_javascript.php

 	if ($event == 'javascript') {
 		require_privs('javascript');
 
-		if ($step == '')
-			$step = 'create';
-
 		switch ($step) {
-			case 'create': javascript_edit();	            break;
-			case 'save': javascript_save();               break;
-			case 'copy': javascript_copy();               break;
-			case 'save_as': javascript_save_as();         break;
-			case 'delete': javascript_delete();           break;
-			case 'edit': javascript_edit();               break;
+			case '': javascript_edit(); break;
+			case 'pour': javascript_edit();	               break;
+			case 'javascript_save': javascript_save();               break;
+			case 'javascript_copy': javascript_copy();               break;
+			case 'javascript_save_as': javascript_save_as();         break;
+//			case 'javascript_delete': javascript_delete();           break;
+			case 'javascript_edit': javascript_edit();               break;
 		}
 	}
 
 //-------------------------------------------------------------
 
 	function javascript_list($current, $default) {
-		$out[] = startTable('list', 'left');
 
 		$rs = safe_rows_start('theme, name', 'blurb', "type='javascript' order by theme, name");
 
 			while ($a = nextRow($rs)) {
 				if ($theme != $a['theme'])
 				{
-					$out[] = tr('<td colspan="2">'.htmlspecialchars($theme).'</td>');
+					$out[] = htmlspecialchars($theme);
 				}
 				extract($a);
-			
-				$edit = ($current != $name) ?	eLink('javascript', 'edit', 'name', $name, $name, 'theme', $theme) : $name;
-				$delete = ($name != $default) ? dLink('javascript', 'delete', 'name', $name, '', 'theme', $theme) : '';
 
-				$out[] = tr(td($edit).td($delete));
+				$delete = ($name != $default) ? finput('checkbox','javascript_delete[]',$name) : '';
+
+				$edit = ($current != $name) ?	eLink('javascript', '', 'name', $name, $name, 'theme', $theme) : $name;
+
+				$out[] = t3.tag(
+							'<span class="action">'.$delete.'</span>'.
+							'<span class="item">'.$edit.'</span>'
+							,'li');
 			}
 
-			$out[] =  endTable();
-
-			return join('', $out);
+			return t2.tag(join('', $out).t2,'ul','class="item-list"').n.t;
 		}
 	}
 
 //-------------------------------------------------------------
 
 	function javascript_edit($message='') {
-		pagetop(gTxt("edit_javascript"),$message);
+
 		global $step,$prefs;
-
-		$name = gps('name');
-		$theme = gps('theme');
 		
-		if ($step == 'delete')
-		{
-			$step = 'create';
-			$name = '';
-			$theme = 'default';
-		}
-		else if (!$name)
-		{
-			$name = gps('newname');
-			$theme = gps('newtheme');
+		$name		= gps('name');
+		$theme 		= gps('theme');
+		$editArray	= gps('javascript_delete');
+		// go button
+		$action		= gps('javascript_multi_edit');
+		// select field
+		$selected 	= gps('edit_method');
+		
+		$theme = empty($theme) ? 'default' : $theme;
+		
+		if(strlen($action) > 0 && $selected == 'delete') {
+			$message = javascript_delete($editArray,$theme);
+			$name = (!in_array($name,$editArray)) ? $name : '';
 		}
 		
-		$theme = empty($theme) ? 'default' : $theme;
+		$name = (!$name or $step == 'javascript_delete') ? 'default' : $name;
 
 		if (gps('copy') && trim(preg_replace('/[<>&"\']/', '', gps('newname'))) )
 			$name = gps('newname');
 
-		if ($step=='create')
+		if ($step=='pour')
 		{
 			$buttons =
-			gTxt('name_for_this_script').': '
+			gTxt('name_for_this_style').': '
 			.fInput('text','newname','','edit','','',20).
 			hInput('savenew','savenew');
-			$thejs = '';
+			$thejavascript = '';
 
 		} else {
 			$buttons = '';
 			$blurb = get_blurb($name, 'javascript', $theme);
-			$thejs = !empty($blurb) ? $blurb['content'] : '';
+			$thejavascript = !empty($blurb) ? $blurb['content'] : '';
 		}
 
-		if ($step!='create') {
+		if ($step!='pour') {
 			
-			$left = graf(gTxt('you_are_editing').br.strong($name)).
-				graf(sLink('javascript', 'create', gTxt('create_new')));
-
+			$right = graf(sLink('javascript', 'pour', gTxt('bulkload_existing_js')));
 			
-			$copy = gTxt('copy_as').sp.fInput('text', 'newname', '', 'edit').sp.
+			$copy = gTxt('copy_js_as').sp.fInput('text', 'newname', '', 'edit').sp.
 				fInput('submit', 'copy', gTxt('copy'), 'smallerbox');
 		} else {
-			$left = '&nbsp;';
+			$right = '&nbsp;';
 			$copy = '';
 		}
 
-		$right = hed(gTxt('all_javascript'),2).
-			javascript_list($name, '');
+		$right .=	hed(gTxt('all_javascript'),2).
+					javascript_list($name, 'default');
+			
+		$multiedit = selectInput('edit_method', array('delete'=>gTxt('delete')), '', 1) . 
+					 gTxt('selected') .
+					 t3.fInput('submit', 'javascript_multi_edit', gTxt('go'));
+			
+		echo pagetop(gTxt("edit_javascript"),$message).
+			 n.t.'<div id="content" class="clearfix">'.n.
+			   t.'<h1>'.gTxt('tab_javascript').'</h1>'.n;
 
-		echo div(
-			div($left, '', 'left').
-			div(
-				form(
-					graf($buttons).
-					'<textarea id="content" class="code" name="content" rows="32">'.htmlspecialchars($thejs).'</textarea>'.br.
-					fInput('submit','',gTxt('save'),'publish').
-					eInput('javascript').sInput('save').
-					hInput('name',$name)
+		echo
+			form(
+				div(	   
+					t4.graf($buttons).
+					graf(gTxt('you_are_editing_js').sp.strong($name)).
+					'<textarea id="javascript" class="code" name="javascript">'.htmlspecialchars($thejavascript).'</textarea>'.br.
+					t4.hInput('name',$name)
 					.$copy
-				), '', 'center').
-			div($right, '','right'), 
-
-			'', 'container'	);
+				,'','col-1').
+				div(
+					n.t.div(fInput('submit','save',gTxt('save'),"publish", '', '', '', 4,'publish-button'),'','publish').
+					t4.eInput('javascript').t4.sInput('javascript_save').
+					div(
+						$right.
+						$multiedit,
+						'list'
+						)
+				,'','col-2')
+			).
+			 '</div>';
 	}
 
 // -------------------------------------------------------------
 			$newname = sanitizeForUrl($newname);
 	
 			set_blurb($newname, 'javascript', $newtheme, $blurb['content'], $blurb['mime_type']);
-			
+	
 			javascript_edit(
 				gTxt('javascript_created', array('{name}' => $newname))
 			);
 
 	function javascript_save()
 	{
-		extract(gpsa(array('name','theme','content','savenew','newname','copy')));
+		extract(gpsa(array('name','theme','javascript','savenew','newname','copy')));
 
 		if ($savenew or $copy)
 		{
 
 			elseif ($newname)
 			{
-				set_blurb($newname, 'javascript', $theme, $content, 'text/javascript');
-				
+				set_blurb($newname, 'javascript', $theme, $javascript, 'text/javascript');
+
 				// update site last mod time
 				update_lastmod();
 
 		{
 			$name = sanitizeForUrl($name);
 
-			set_blurb($name, 'javascript', $theme, $content, 'text/javascript');
-			
+			set_blurb($name, 'javascript', $theme, $javascript, 'text/javascript');
+
 			// update site last mod time
 			update_lastmod();
 
 
 //-------------------------------------------------------------
 
-	function javascript_delete()
+	function javascript_delete($editArray,$theme)
 	{
-		$name  = ps('name');
-		$theme = ps('theme');
 
-		$count = safe_count('txp_section', "css = '".doSlash($name)."'");
+		foreach($editArray as $name) {
+			
+			delete_blurb($name, 'javascript', $theme);				
+	
+			$message[] = $name;
 
-		if ($count)
-		{
-			$message = gTxt('javascript_used_by_section', array('{name}' => $name, '{count}' => $count));
 		}
-
-		else
-		{
-			delete_blurb($name, 'javascript', $theme);
-			
-			$message = gTxt('javascript_deleted', array('{name}' => $name));
-		}
-
-		javascript_edit($message);
+		
+		$name = join(' and ', $message);
+		return gTxt('javascript_deleted', array('{name}' => $name));
 	}
 
 ?>

textpattern/lang/en-gb.txt

 deleted.
 copy_css_as => &#8230;or copy style as
 copy_js_as =>  &#8230;or copy javascript as
-create_new_css => Create new 
-style
+create_new_css => Create new style
 css_already_exists => Stylesheet <strong>{name}</strong> already 
 exists.
 css_created => Style <strong>{name}</strong> created.
 publishing tools
 #@javascript
 all_javascript => All Scripts
-copy_as => copy 
-as
-name_for_this_script => Name for this script:
-you_are_editing => You are 
-editing
+copy_as => copy as
+name_for_this_script => Name for this script :
+you_are_editing_js => You are editing script :
+bulkload_existing_js => Create or load 
 #@link
 edit_links => Links
 linkcategory => Link Categories

textpattern/setup/txpsql.php

 
 
 $create_sql[] = "INSERT INTO `".PFX."blurb` (`name`, `type`, `mime_type`, `content`) VALUES ('default', 'css', 'text/css', '".doSlash(base64_decode('LyogYmFzZQ0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0gKi8NCg0KYm9keSB7DQoJbWFyZ2luOiAwOw0KCXBhZGRpbmc6IDA7DQoJZm9udC1m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S0tLS0tLS0tLS0gKi8NCg0KLmVycm9yLXN0YXR1cyB7DQoJZm9udDogMS4zZW0gR2VvcmdpYSwgVGltZXMsIHNlcmlmOw0KfQ=='))."')";
-
+$create_sql[] = "INSERT INTO `".PFX."blurb` (`name`, `type`, `mime_type`, `content`) VALUES ('default', 'css', 'text/css', ' ')";
 $create_sql[] = "INSERT INTO `".PFX."blurb` (`name`, `type`, `content`) VALUES ('links', 'form', '<p><txp:link /><br />\n<txp:link_description /></p>')";
 $create_sql[] = "INSERT INTO `".PFX."blurb` (`name`, `type`, `content`) VALUES ('lofi', 'form', '<h3 class=\"entry-title\"><txp:title /> <txp:permlink>#</txp:permlink></h3>\n\n<p class=\"published\"><txp:posted /></p>\n\n<div class=\"entry-content\">\n<txp:body />\n</div>\n\n<hr />\n\n')";
 $create_sql[] = "INSERT INTO `".PFX."blurb` (`name`, `type`, `content`) VALUES ('single', 'form', '<h3 class=\"entry-title\"><txp:permlink><txp:title /></txp:permlink></h3>\n\t<p class=\"published\"><txp:posted /></p>\n\n<div class=\"entry-content\">\n<txp:body />\n</div>\n\n')";

textpattern/styles/cp/reno.css

 	width: 55px;
 }
 
-textarea#body, textarea#html, textarea#css, textarea#js-code {
+textarea#body, textarea#html, textarea#css, textarea#javascript {
 	font-size: 12px;
 	padding: 5px;
 	width: 99%;
 	text-align: 0 auto;
 	}
 	
-/* CSS 
+/* CSS && Javascript
 ---------------------------------------------- */
 
-.css-list LI, .css-list UL
+.item-list LI, .item-list UL
 	{
 	list-style: none;
 	clear: both;