Commits

Anonymous committed 2ca3c82

Added Multi-edit capability to the css page, and fixed a delete bug.

Comments (0)

Files changed (3)

textpattern/include/txp_css.php

 			case 'css_save': css_save();               break;
 			case 'css_copy': css_copy();               break;
 			case 'css_save_as': css_save_as();         break;
-			case 'css_delete': css_delete();           break;
+//			case 'css_delete': css_delete();           break;
 			case 'css_edit': css_edit();               break;
 		}
 	}
 //-------------------------------------------------------------
 
 	function css_list($current, $default) {
-		$out[] = startTable('list', 'left');
 
 		$rs = safe_rows_start('theme, name', 'blurb', "type='css' 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);
-			
+
+				$delete = ($name != $default) ? finput('checkbox','css_delete[]',$name) : '';
+				//dLink('css', 'css_delete', 'name', $name, '', 'theme', $theme) : '';
 				$edit = ($current != $name) ?	eLink('css', '', 'name', $name, $name, 'theme', $theme) : $name;
-				$delete = ($name != $default) ? dLink('css', 'css_delete', 'name', $name, '', 'theme', $theme) : '';
 
-				$out[] = tr(td($edit).td($delete));
+				$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="css-list"').n.t;
 		}
 	}
 
 //-------------------------------------------------------------
 
 	function css_edit($message='') {
+
+		global $step,$prefs;
 		
-		pagetop(gTxt("edit_css"),$message);
+		$name		= gps('name');
+		$theme 		= gps('theme');
+		$editArray	= gps('css_delete');
+		// go button
+		$action		= gps('css_multi_edit');
+		// select field
+		$selected 	= gps('edit_method');
 		
-		echo n.t.'<div id="content" class="clearfix">'.n.
-			   t.'<h1>'.gTxt('tab_style').'</h1>'.n;
+		$theme = empty($theme) ? 'default' : $theme;
 		
-		global $step,$prefs;
-
-		$name = gps('name');
-		$theme = gps('theme');
-
+		if(strlen($action) > 0 && $selected == 'delete') {
+			$message = css_delete($editArray,$theme);
+			$name = (!in_array($name,$editArray)) ? $name : '';
+		}
+		
 		$default_name = safe_field('css', 'txp_section', "name = 'default'");
-
+		
 		$name = (!$name or $step == 'css_delete') ? $default_name : $name;
-		$theme = empty($theme) ? 'default' : $theme;
 
 		if (gps('copy') && trim(preg_replace('/[<>&"\']/', '', gps('newname'))) )
 			$name = gps('newname');
 		}
 
 		if ($step!='pour') {
-
+			
+			$right = graf(sLink('css', 'pour', gTxt('bulkload_existing_css')));
+			
 			$copy = gTxt('copy_css_as').sp.fInput('text', 'newname', '', 'edit').sp.
 				fInput('submit', 'copy', gTxt('copy'), 'smallerbox');
-			
-			$left = 
-				n.t.div(fInput('submit','save',gTxt('save'),"publish", '', '', '', 4,'publish-button'),'','publish').
-				eInput('css').sInput('css_save').
-				hInput('name',$name).
-				$copy.
-				graf(sLink('css', 'pour', gTxt('bulkload_existing_css')));
-
 		} else {
-			$left = '&nbsp;';
+			$right = '&nbsp;';
 			$copy = '';
 		}
 
-		$right = hed(gTxt('all_stylesheets'),2).
-			css_list($name, $default_name);
+		$right .=	hed(gTxt('all_stylesheets'),2).
+					css_list($name, $default_name);
+			
+		$multiedit = selectInput('edit_method', array('delete'=>gTxt('delete')), '', 1) . 
+					 gTxt('selected') .
+					 t3.fInput('submit', 'css_multi_edit', gTxt('go'));
+			
+		echo pagetop(gTxt("edit_css"),$message).
+			 n.t.'<div id="content" class="clearfix">'.n.
+			   t.'<h1>'.gTxt('tab_style').'</h1>'.n;
 
 		echo
-		  form(
-			div(
-				graf($buttons).
-				graf(gTxt('you_are_editing_css').sp.strong($name)).
-				'<textarea id="css" class="code" name="css" rows="32">'.htmlspecialchars($thecss).'</textarea>'.br,
-				'', 'col-1').
-				div($left, '', 'col-2').
-			div($right, '','right')
-			),	
-		'</div>';
+			form(
+				div(	   
+					t4.graf($buttons).
+					graf(gTxt('you_are_editing_css').sp.strong($name)).
+					'<textarea id="css" class="code" name="css">'.htmlspecialchars($thecss).'</textarea>'.br.
+					t4.hInput('name',$name)
+					.$copy
+				,'','col-1').
+				div(
+					n.t.div(fInput('submit','save',gTxt('save'),"publish", '', '', '', 4,'publish-button'),'','publish').
+					t4.eInput('css').t4.sInput('css_save').
+					div(
+						$right.
+						$multiedit,
+						'list'
+						)
+				,'','col-2')
+			).
+			 '</div>';
 	}
 
 // -------------------------------------------------------------
 
 //-------------------------------------------------------------
 
-	function css_delete()
+	function css_delete($editArray,$theme)
 	{
-		$name  = ps('name');
-		$theme = ps('theme');
 
-		$count = safe_count('txp_section', "css = '".doSlash($name)."'");
-
-		if ($count)
-		{
-			$message = gTxt('css_used_by_section', array('{name}' => $name, '{count}' => $count));
+		foreach($editArray as $name) {
+			$count = safe_count('txp_section', "css = '".doSlash($name)."'");
+	
+			if ($count)
+			{
+				$message[] = gTxt('css_used_by_section', array('{name}' => $name, '{count}' => $count));
+			}
+	
+			else
+			{
+				delete_blurb($name, 'css', $theme);
+				
+				if (css_static_enabled())
+				{
+					css_delete_static($name);
+				}
+	
+				$message[] = $name;
+			}
+			
 		}
-
-		else
-		{
-			delete_blurb($name, 'css', $theme);
-			
-			if (css_static_enabled())
-			{
-				css_delete_static($name);
-			}
-
-			$message = gTxt('css_deleted', array('{name}' => $name));
-		}
-
-		css_edit($message);
+		
+		$name = join(' and ', $message);
+		return gTxt('css_deleted', array('{name}' => $name));
 	}
 
 ?>

textpattern/lang/en-gb.txt

 cannot_delete_default_css => Style <strong>default</strong> cannot be 
 deleted.
 copy_css_as => &#8230;or copy style as
+copy_js_as =>  &#8230;or copy javascript as
 create_new_css => Create new 
 style
 css_already_exists => Stylesheet <strong>{name}</strong> already 
 css_property_value => Property : 
 Value
 css_selector => Selector
-css_updated => Style <strong>{name}</strong> 
-updated.
+css_updated => Style <strong>{name}</strong> updated.
 css_used_by_section => Style <strong>{name}</strong> not deleted; used 
 by {count} section(s).
 delete_declaration => Delete this 

textpattern/styles/cp/reno.css

 	width: 55px;
 }
 
-textarea#body, textarea#html, textarea#css {
+textarea#body, textarea#html, textarea#css, textarea#js-code {
 	font-size: 12px;
 	padding: 5px;
 	width: 99%;
 	text-align: 0 auto;
 	}
 	
+/* CSS 
+---------------------------------------------- */
+
+.css-list LI, .css-list UL
+	{
+	list-style: none;
+	clear: both;
+	margin-left: -4em;
+	}
+.action
+	{
+	display: block;
+	width: 20px;
+	height: 25px;
+	float: left;
+	}
+.item
+	{
+	display: block;
+	width: 150px;
+	overflow: hidden;
+	height: 25px;
+	float: left;
+	text-align: left;
+	}
+.list
+	{
+	padding: 10px;
+	border: 1px solid #ddd;
+	}
+	
+	
+	
 /* Clearfix
 ---------------------------------------------- */
 .clearfix:after {
 	-moz-border-radius: 10px;
 	-webkit-border-radius: 10px;
 	}
+
+.copyas
+	{
+	border-bttom: 1px solid #000;
+	}
+
 	
 /* Hides from IE-mac \*/
 * html .clearfix {height: 1%;}