[interchange-cvs] interchange - heins modified 2 files

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Thu Aug 29 09:44:07 2002


User:      heins
Date:      2002-08-29 07:59:26 GMT
Modified:  dist/lib/UI/pages/include/menus Content.txt
Added:     dist/lib/UI/pages/admin content_push.html
Log:
* Add page to clone (push) sets of components to like sets of pages, i.e.
  edit one to get the components like you want them and then select the
  pages that that setup should be copied to.

Revision  Changes    Path
1.1                  interchange/dist/lib/UI/pages/admin/content_push.html


rev 1.1, prev_rev 1.0
Index: content_push.html
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
[set page_perm]page[/set]
[set page_title][L]Clone component sets to multiple pages[/L][/set]
[set ui_class]Content[/set]
[set help_name]page.editor[/set]
[set icon_name]icon_pages.gif[/set]
@_UI_STD_HEAD_@

<!-- ----- BEGIN REAL STUFF ----- -->

[if cgi push]
[perl]
	my $source =3D $CGI->{source};
	my @things =3D split /\0/, $CGI->{target};
	my $out =3D 'cloning ';
=09

	if(! $CGI->{source}) {
		return "<blockquote class=3Dcerror> No source! </blockquote>";
	}
	elsif(! $CGI->{target}) {
		return "<blockquote class=3Dcerror> No targets! </blockquote>";
	}

	my $sfile =3D $Tag->file($source);
	$sfile =3D~ m{(\[control\s+reset=3D1\].*?\[control\s+reset=3D1\])}si;
	my $scomp =3D $1;

	my $count =3D 0;
	for(@things) {
		$Tag->backup_file($_) if $CGI->{backup};
		my $dat =3D $Tag->file($_);
		$dat =3D~ s{\[control\s+reset=3D1\].*?\[control\s+reset=3D1\]}{$scomp}si;
		$Tag->write_relative_file($_, $dat)
			and $count++;
	}

	return "<blockquote class=3Dcmessage>$count files updated.</blockquote>";
[/perl]
[/if]

<form action=3D"[area @@MV_PAGE@@]" method=3DPOST name=3Dpushform>
<input type=3Dhidden name=3Dmv_session_id value=3D"[data session id]">
<input type=3Dhidden name=3Dmv_action value=3Dback>
<table>
<tr>
	<td>
		<b>Source</b> <select name=3Dsource onChange=3D"doType(this)">
			<option value=3D""> -- select source file --
		</select>
	</td>
	<td id=3Dmessagebox style=3D"font-size: larger">
		Select page to clone. Only pages matching the template type of
		the source page will be allowed.
	</td>
</table>

<br>
<b>Targets</b><br>
<script>
	var files =3D [

[calc]
	my $files =3D $Tag->list_pages( { arrayref =3D> 1 });
	my $dir =3D $Config->{PageDir};
	$dir =3D~ s{^$Config->{VendRoot}/}{};
	my $suf =3D $Config->{HTMLsuffix};
	my @things =3D map { [ "$dir/$_$suf", $_ ] } @$files;

	my @out;
	@qualify =3D ();
	for my $ref (@things) {
		my ($fn, $lab) =3D @$ref;
		my $dat =3D $Tag->file($fn);
		$dat =3D~ m{\nui_(?:page_template|template_name):\s*(.*)}
			or next;
		my $type =3D $1;
		push @$ref, $type;
		push @qualify, [$fn, $lab, $type];
		$fn =3D~ s/'/\\'/g;
		$lab =3D~ s/'/\\'/g;
		$type =3D~ s/'/\\'/g;
		push @out, qq{[ '$fn', '$lab', '$type' ]};
	}
	return join ",\n", @out;
[/calc]

	];

	function setBox (idx, active) {
		if(idx < 0)=20
			return;
		var dis =3D active =3D=3D 1 ? 0 : 1;
		var weight =3D active =3D=3D 1 ? 'bold' : 'normal';

		var w =3D document.getElementById('target' + idx);
		var el =3D document.getElementById('lab' + idx);

		el.style.fontWeight =3D weight;
		if(dis) {
			w.checked =3D 0;
			w.disabled =3D 1;
		}
		else {
			w.disabled =3D 0;
		}
		return;
	}

	function doType (wid) {
		if(wid =3D=3D undefined)
			return;
		if(wid.options =3D=3D undefined)
			return;
		var idx =3D wid.selectedIndex;
		if(idx <=3D 0)
			return;
		var l =3D files[idx - 1];
		var type =3D l[2];
		for(var i =3D 0; i < files.length; i++) {
		    var f =3D files[i];
			var active =3D 0;
			if(type =3D=3D f[2])=20
				active =3D 1;
			if(i =3D=3D idx - 1) {
				setBox(i, 0);
			}
			else {
				setBox(i, active);
			}
		}
		var d =3D document.getElementById('messagebox');
		d.innerHTML =3D 'Type <i>' + type + '</i> selected, others disabled.';
		return;
	}

	function populateSelect (wid) {
		if(wid =3D=3D undefined)
			return;
		if(wid.options =3D=3D undefined)
			return;
		wid.options.length =3D 0;
		wid.options[0] =3D new Option;
		wid.options[0].value =3D '';
		wid.options[0].text =3D '--select source--';
		for(var i =3D 0; i < files.length; i++) {
			var o =3D new Option;
			var f =3D files[i];
			o.value =3D f[0];
			o.text =3D f[1];
			wid.options[i + 1] =3D o;
		}
		return;
	}

	populateSelect(document.pushform.source);
</script>

<table>
[table-organize columns=3D3 columnize=3D1 interplate=3D1]
[calc]
	my $i =3D 0;
	for(@qualify) {
		my ($fn, $lab, $type) =3D @$_;
		push @out, <<EOF;
<TD id=3Dlab$i width=3D"33%"><input name=3Dtarget type=3Dcheckbox id=3Dtarg=
et$i value=3D"$fn">$lab</TD>
EOF
		$i++;
	}
	return join "", @out;
[/calc]
[/table-organize]
</table>

<br>
<input type=3Dsubmit name=3Dpush value=3D"[L]Push components[/L]">
<br>
<input type=3Dcheckbox name=3Dbackup value=3D1 CHECKED> Back files up
</form>


<!-- ----- END REAL STUFF ----- -->

@_UI_STD_FOOTER_@
<!-- page: @@MV_PAGE@@ -->



1.2       +1 -1      interchange/dist/lib/UI/pages/include/menus/Content.txt


rev 1.2, prev_rev 1.1
Index: Content.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/dist/lib/UI/pages/include/menus/Content.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Content.txt	7 Aug 2002 08:11:00 -0000	1.1
+++ Content.txt	29 Aug 2002 07:59:25 -0000	1.2
@@ -1,4 +1,4 @@
 code	mgroup	msort	next_line	indicator	exclude_on	depends_on	page	form	name=
	super	inactive	description	help_name	img_dn	img_up	img_sel	img_icon	url
 0027	01	x					admin/content		Content Edit		0=09=09=09=09=09=09=09
-001							admin/genconfig YES!=09=09=09=09=09=09=09=09=09=09=09
+0028	02						admin/content_push		Clone component sets=09=09=09=09=09=09=09=
=09=09
 0029	03	Content					admin/file_transfer		File Transfer		0=09=09=09=09=09=
=09=09