{* $Id: tiki-admin_categories.tpl 23814 2009-12-10 20:49:00Z marclaporte $ *}
{popup_init src="lib/overlib.js"}

{title help="Categories+Admin" admpage="category"}{tr}Admin Categories{/tr}{/title}

<div class="navbar">
	{button href="tiki-browse_categories.php?parentId=$parentId" _text="{tr}Browse Category{/tr}" _title="{tr}Browse the category system{/tr}"}
</div>

{if !empty($errors)}
	<div class="simplebox highlight">{section name=ix loop=$errors}{$errors[ix]}{/section}</div>
{/if}

<div class="tree" id="top">
	<div class="treetitle">{tr}Current category{/tr}: 
		<a href="tiki-admin_categories.php?parentId=0" class="categpath">{tr}Top{/tr}</a>
		{section name=x loop=$path}
			&nbsp;::&nbsp;
			<a class="categpath" href="tiki-admin_categories.php?parentId={$path[x].categId}">{$path[x].name|escape}</a>
		{/section}
		<br />
		{tr}Current Category ID:{/tr} {$parentId}
	</div>
</div>

{section name=dx loop=$catree}
	{assign var=after value=$smarty.section.dx.index_next}
	{assign var=before value=$smarty.section.dx.index_prev}
	{if $smarty.section.dx.index > 0 and $catree[dx].deep > $catree[$before].deep}
		<div id="id{$catree[$before].categId}" style="display:{if $catree[$before].incat eq 'y'}inline{else}none{/if};">
	{/if}
	<div class="treenode{if $catree[dx].categId eq $smarty.request.parentId}select{/if}">
		<!-- {$catree[dx].parentId} :: {$catree[dx].categId} :: -->
		{if $catree[dx].children > 0}
			<i class="mini">{$catree[dx].children} {tr}Child categories{/tr}</i>
		{/if}
		
		{if $catree[dx].objects > 0}
			<i class="mini">{$catree[dx].objects} {tr}Child categories{/tr}</i>
		{/if}
		
		<a class="link" href="tiki-admin_categories.php?parentId={$catree[dx].parentId}&amp;categId={$catree[dx].categId}" title="{tr}Edit{/tr}">{icon _id='page_edit' hspace="5" vspace="1"}</a>
		<a class="link" href="tiki-admin_categories.php?parentId={$catree[dx].categId}" title="{tr}View{/tr}">{icon _id='magnifier' hspace="5" vspace="1"}</a>
		<a class="link" href="tiki-admin_categories.php?parentId={$catree[dx].parentId}&amp;removeCat={$catree[dx].categId}" title="{tr}Delete{/tr}">{icon _id='cross' hspace="5" vspace="1"}</a>
		
		{if $catree[dx].has_perm eq 'y'}
			<a title="{tr}Edit permissions for this category{/tr}" href="tiki-objectpermissions.php?objectType=category&amp;objectId={$catree[dx].categId}&amp;objectName={$catree[dx].name|escape:'urlencode'}&amp;permType=all">{icon hspace="5" vspace="1" _id='key_active' alt="{tr}Edit permissions for this category{/tr}"}</a>
		{else}
			<a title="{tr}Assign Permissions{/tr}" href="tiki-objectpermissions.php?objectType=category&amp;objectId={$catree[dx].categId}&amp;objectName={$catree[dx].name|escape:'urlencode'}&amp;permType=all">{icon hspace="5" vspace="1" _id='key' alt="{tr}Assign Permissions{/tr}"}</a>
		{/if}
		
		<div style="display: inline; padding-left:{$catree[dx].deep*30+5}px;">
			<a class="catname" href="tiki-admin_categories.php?parentId={$catree[dx].categId}">{$catree[dx].name|escape}</a>
			{if $smarty.section.dx.last}
				{repeat count=$catree[dx].deep}</div>{/repeat}
			{elseif $catree[dx].deep < $catree[$after].deep}
				<a href="javascript:toggle('id{$catree[dx].categId}');" class="linkmenu">&gt;&gt;&gt;</a>
				</div>
			{elseif $catree[dx].deep eq $catree[$after].deep}
				</div>
			{else}
				</div>
				{repeat count=$catree[dx].deep-$catree[$after].deep}</div>{/repeat}
			{/if}
		</div>
	{/section}

<a name="editcreate"></a>
<div class="cbox">
	<div class="cbox-title">
		{if $categId > 0}
			{tr}Edit this category:{/tr} <b>{$name}</b> [<a href="tiki-admin_categories.php?parentId={$parentId}#editcreate" class="cboxtlink">{tr}Create New{/tr}</a>]
		{else}
			{tr}Add new category{/tr}
		{/if}
	</div>
	<div class="cbox-data">
		<form action="tiki-admin_categories.php" method="post">
			<input type="hidden" name="categId" value="{$categId|escape}" />
			<table class="normal">
				<tr class="formcolor">
					<td class="form">{tr}Parent{/tr}:</td>
					<td class="form">
						<select name="parentId">
							<option value="0">{tr}Top{/tr}</option>
							{section name=ix loop=$catree}
								<option value="{$catree[ix].categId|escape}" {if $catree[ix].categId eq $parentId}selected="selected"{/if}>{$catree[ix].categpath|escape}</option>
							{/section}
						</select>
					</td>
				</tr>
				<tr class="formcolor">
					<td class="form">{tr}Name{/tr}:</td>
					<td class="form"><input type="text" size="40" name="name" value="{$name|escape}" /></td>
				</tr>
				<tr class="formcolor">
					<td class="form">{tr}Description{/tr}:</td>
					<td class="form"><textarea rows="2" cols="40" name="description">{$description|escape}</textarea></td>
				</tr>
				<tr class="formcolor">
					<td class="form" align="center" colspan="2"><input type="submit" name="save" value="{tr}Save{/tr}" /></td>
				</tr>
			</table>
		</form>
	</div>
</div>

{if $categId <= 0}
	<div class="cbox">
		<div class="cbox-title">
			{tr}Batch upload (CSV file):{/tr} <a {popup text='category,description,parent&lt;br /&gt;vegetable,vegetable&lt;br /&gt;potato,,vegetable'}>{icon _id='help'}</a>
		</div> 
		<div class="cbox-data">
			<form action="tiki-admin_categories.php" method="post" enctype="multipart/form-data">
				<input type="file" name="csvlist" /><br />
				<input type="submit" name="import" value="{tr}Add{/tr}" />
			</form>
		</div>
	</div>
{/if}

<a name="objects"></a>
	<div class="cbox">
		<div class="cbox-title">
			{tr}Objects in category{/tr} <b>{$categ_name|escape}</b>
		</div>
		<div class="cbox-data">
			{if $objects}
				<table class="findtable">
					<tr>
						<td class="findtable">{tr}Find{/tr}</td>
						<td class="findtable">
							<form method="get" action="tiki-admin_categories.php">
								<input type="text" name="find" />
								<input type="hidden" name="parentId" value="{$parentId|escape}" />
								<input type="submit" value="{tr}Find{/tr}" name="search" />
								<input type="hidden" name="sort_mode" value="{$sort_mode|escape}" />
								<input type="hidden" name="find_objects" value="{$find_objects|escape}" />
							</form>
						</td>
					</tr>
				</table>
			{/if}
			<table class="normal">
				<tr>
					<th>&nbsp;</th>
					<th>
						<a href="tiki-admin_categories.php?parentId={$parentId}&amp;offset={$offset}&amp;sort_mode={if $sort_mode eq 'name_desc'}name_asc{else}name_desc{/if}#objects">{tr}Name{/tr}</a>
					</th>
					<th>
						<a href="tiki-admin_categories.php?parentId={$parentId}&amp;offset={$offset}&amp;sort_mode={if $sort_mode eq 'type_desc'}type_asc{else}type_desc{/if}#objects">{tr}Type{/tr}</a>
					</th>
				</tr>
				{section name=ix loop=$objects}
					<tr>
						<td class="even">
							<a class="link" href="tiki-admin_categories.php?parentId={$parentId}&amp;removeObject={$objects[ix].catObjectId}&amp;fromCateg={$parentId}" title="{tr}Remove from this Category{/tr}">{icon _id='link_delete' alt="{tr}Remove from this Category{/tr}"}</a>
						</td>
						<td class="even">
							<a class="link" href="{$objects[ix].href}" title="{$objects[ix].name}">{$objects[ix].name|truncate:80:"(...)":true|escape}</a>
						</td>
						<td class="even">{tr}{$objects[ix].type}{/tr}</td>
					</tr>
				{sectionelse}
					<tr>
						<td class="even" colspan="3"><strong>{tr}No records found.{/tr}</strong></td>
					</tr>
				{/section}
			</table>

			{pagination_links cant=$cant_pages step=$prefs.maxRecords offset=$offset }{/pagination_links}
		</div>
	</div>

	{if $parentId != 0}
		<div class="cbox">
			<div class="cbox-title">
				{tr}Add objects to category{/tr} <b>{$categ_name|escape}</b>
			</div>
			<div class="cbox-data">
				<table class="findtable">
					<tr>
						<td class="findtable">{tr}Find{/tr}</td>
						<td>
							<form method="get" action="tiki-admin_categories.php">
								<input type="text" name="find_objects" />
								<input type="hidden" name="parentId" value="{$parentId|escape}" />
								<input type="submit" value="{tr}Filter{/tr}" name="search_objects" />
								<input type="hidden" name="sort_mode" value="{$sort_mode|escape}" />
								<input type="hidden" name="offset" value="{$offset|escape}" />
								<input type="hidden" name="find" value="{$find|escape}" />
							</form>
						</td>
					</tr>
				</table>
				<form action="tiki-admin_categories.php" method="post">
					<input type="hidden" name="parentId" value="{$parentId|escape}" />
					<table>
						{if $prefs.feature_wiki eq 'y'}
							<tr>
								<td class="form">{tr}page:{/tr}</td>
								<td class="form">
									<select name="pageName[]" multiple="multiple" size="5">
										{section name=ix loop=$pages}
											<option value="{$pages[ix].pageName|escape}">{$pages[ix].pageName|truncate:80:"(...)":true|escape}</option>
										{/section}
									</select>
								</td>
								<td class="form">
									<input type="submit" name="addpage" value="{tr}Add{/tr}" />
								</td>
							</tr>
						{/if}
						
						{if $prefs.feature_articles eq 'y'}
							<tr>
								<td class="form">{tr}Article:{/tr}</td>
								<td class="form">
									<select name="articleId">
										{section name=ix loop=$articles}
											<option value="{$articles[ix].articleId|escape}">{$articles[ix].title|truncate:80:"(...)":true|escape}</option>
										{/section}
									</select>
								</td>
								<td class="form"><input type="submit" name="addarticle" value="{tr}Add{/tr}" /></td>
							</tr>
						{/if}
						
						{if $prefs.feature_blogs eq 'y'}
							<tr>
								<td class="form">{tr}Blog:{/tr}</td>
								<td class="form">
									<select name="blogId">
										{section name=ix loop=$blogs}
											<option value="{$blogs[ix].blogId|escape}">{$blogs[ix].title|truncate:80:"(...)":true|escape}</option>
										{/section}
									</select>
								</td>
								<td class="form"><input type="submit" name="addblog" value="{tr}Add{/tr}" /></td>
							</tr>
						{/if}
						
						{if $prefs.feature_directory eq 'y'}
							<tr>
								<td class="form">{tr}Directory:{/tr}</td>
								<td class="form">
									<select name="directoryId">
										{section name=ix loop=$directories}
											<option value="{$directories[ix].categId|escape}">{$directories[ix].name|truncate:40:"(...)":true|escape}</option>
										{/section}
									</select>
								</td>
								<td class="form"><input type="submit" name="adddirectory" value="{tr}Add{/tr}" /></td>
							</tr>
						{/if}

						{if $prefs.feature_galleries eq 'y'}
							<tr>
								<td class="form">{tr}image gal:{/tr}</td>
								<td class="form">
									<select name="galleryId">
										{section name=ix loop=$galleries}
											<option value="{$galleries[ix].galleryId|escape}">{$galleries[ix].name|truncate:80:"(...)":true|escape}</option>
										{/section}
									</select>
								</td>
								<td class="form"><input type="submit" name="addgallery" value="{tr}Add{/tr}" /></td>
							</tr>
						{/if}
				
						{if $prefs.feature_file_galleries eq 'y'}
							<tr>
								<td class="form">{tr}file gal:{/tr}</td>
								<td class="form">
									<select name="file_galleryId">
										{section name=ix loop=$file_galleries}
											<option value="{$file_galleries[ix].id|escape}">{$file_galleries[ix].name|truncate:80:"(...)":true|escape}</option>
										{/section}
									</select>
								</td>
								<td class="form"><input type="submit" name="addfilegallery" value="{tr}Add{/tr}" /></td>
							</tr>
						{/if}
				
						{if $prefs.feature_forums eq 'y'}
							<tr>
								<td class="form">{tr}Forum:{/tr}</td>
								<td class="form">
									<select name="forumId">
										{section name=ix loop=$forums}
											<option value="{$forums[ix].forumId|escape}">{$forums[ix].name|truncate:80:"(...)":true|escape}</option>
										{/section}
									</select>
								</td>
								<td class="form"><input type="submit" name="addforum" value="{tr}Add{/tr}" /></td>
							</tr>
						{/if}
				
						{if $prefs.feature_polls eq 'y'}
							<tr>
								<td class="form">{tr}Poll:{/tr}</td>
								<td class="form">
									<select name="pollId">
										{section name=ix loop=$polls}
											<option value="{$polls[ix].pollId|escape}">{$polls[ix].title|truncate:80:"(...)":true|escape}</option>
										{/section}
									</select>
								</td>
								<td class="form"><input type="submit" name="addpoll" value="{tr}Add{/tr}" /></td>
							</tr>
						{/if}
						
						{if $prefs.feature_faqs eq 'y'}
							<tr>
								<td class="form">{tr}FAQ:{/tr}</td>
								<td class="form">
									<select name="faqId">
										{section name=ix loop=$faqs}
											<option value="{$faqs[ix].faqId|escape}">{$faqs[ix].title|truncate:80:"(...)":true|escape}</option>
										{/section}
									</select>
								</td>
								<td class="form"><input type="submit" name="addfaq" value="{tr}Add{/tr}" /></td>
							</tr> 
						{/if}
				
						{if $prefs.feature_trackers eq 'y'}
							<tr>
								<td class="form">{tr}Tracker:{/tr}</td>
								<td class="form">
									<select name="trackerId">
										{section name=ix loop=$trackers}
											<option value="{$trackers[ix].trackerId|escape}">{$trackers[ix].name|truncate:80:"(...)":true|escape}</option>
										{/section}
									</select>
								</td>
								<td class="form"><input type="submit" name="addtracker" value="{tr}Add{/tr}" /></td>
							</tr>
						{/if}
						
						{if $prefs.feature_quizzes eq 'y'}
							<tr>
								<td class="form">{tr}quiz:{/tr}</td>
								<td class="form">
									<select name="quizId">
										{section name=ix loop=$quizzes}
											<option value="{$quizzes[ix].quizId|escape}">{$quizzes[ix].name|truncate:80:"(...)":true|escape}</option>
										{/section}
									</select>
								</td>
								<td class="form"><input type="submit" name="addquiz" value="{tr}Add{/tr}" /></td>
							</tr>
						{/if}

					</table>
				</form>
			</div>
		</div>
{/if}
