<metal:block define-macro="page" extend-macro="python:here.getSite().getFormsTool().getForm('folder_index').macros['page']">

<metal:block fill-slot="page-middle">

	<div class="folder_social">
		<tal:block content="structure here/set_content_rating" />
		<div class="folder_social_icons">
		<tal:block define="list_expired request/list_expired|nothing;
			list_all_events request/list_all_events|nothing;
			channel python:test(list_expired, here.getSyndicationTool().pastevents_rdf, here.getSyndicationTool().upcomingevents_rdf)">
				<a tal:condition="not:list_all_events" class="feed_link"
				tal:attributes="href channel/absolute_url" alt="RSS Feed"
				title="RSS Feed" i18n:attributes="alt; title">
					&nbsp;</a>
				<a tal:condition="list_all_events" class="feed_link"
					tal:attributes="href string:${here/absolute_url}/index_atom"
					alt="RSS Feed" title="RSS Feed" i18n:attributes="alt; title">
					&nbsp;</a>
		</tal:block>
		<a class="facebook_link" tal:attributes="href string:http://www.facebook.com/sharer.php?u=${here/absolute_url}">&nbsp;</a>
		<a class="twitter_link" tal:attributes="href string:http://twitter.com/intent/tweet?text=${here/absolute_url}">&nbsp;</a>
		</div>
	</div>

    <h1 tal:define="site_object_index python:here.getFormsTool()['site_object_index']">
        <metal:block use-macro="site_object_index/macros/icon"/>
        <tal:block tal:replace="here/title_or_id" />
        <tal:block tal:condition="python: here.can_be_seen() and here.has_restrictions()" i18n:translate="">
            [Limited access]
        </tal:block>
        <tal:block tal:condition="python:not here.can_be_seen()" i18n:translate="">
            [Restricted access]
        </tal:block>
        <span class="available_langs" tal:condition="python:here.item_has_title(here, here.title)">
            <span i18n:translate="">Item only translated in </span>
            <span tal:repeat="lang here/gl_get_languages_map">
                <a tal:content="python:' %s' % lang['title']"
                    tal:condition="python:not lang['selected'] and here.getLocalProperty('title', lang['id'])"
                    tal:attributes="href python:'gl_changeLanguage?old_lang=%s' % (lang['id'])" />
            </span>
        </span>
    </h1>

    <p tal:condition="python:here.description!=''"
        tal:content="structure here/description" />
	<tal:block  tal:define="listing_info python: here.folder_listing_info(sort_on='start_date');
	objects_list python:listing_info['objects'];
	all_events python:[x for x in objects_list if x['self'].meta_type=='Naaya Event'];
	upcoming_events python:[x for x in all_events if getattr(x['self'], 'start_date', here.utGetTodayDate()) >= here.utGetTodayDate()];
	dummy python:all_events.reverse();
	expired_events python:[x for x in all_events if getattr(x['self'], 'end_date', here.utGetTodayDate()) and getattr(x['self'], 'start_date', here.utGetTodayDate())  < here.utGetTodayDate()];
	list_expired python:request.get('list_expired', '');
	list_all_events python:request.get('list_all_events', '');
	global object_list_custom python:test(list_expired, expired_events, test(list_all_events, all_events, upcoming_events))">
	<metal:block use-macro="python:here.getFormsTool().getForm('folder_listing').macros['listing']">
		<metal:block fill-slot="menu_extension">
			<div class="admin_this_folder">
				<a class="buttons"
				   tal:attributes="href string:${here/absolute_url}?list_all_events=True"
				   tal:condition="python: len(all_events)>0 and not list_all_events" i18n:translate="">Show all events</a>&nbsp;
				<a class="buttons"
				   tal:attributes="href string:${here/absolute_url}?list_expired=True"
				   tal:condition="python: len(all_events)>0 and (not list_expired or list_all_events)" i18n:translate="">Show past events</a>
				<a class="buttons"
				   tal:attributes="href string:${here/absolute_url}"
				   tal:condition="python: len(all_events)>0 and (list_expired or list_all_events)" i18n:translate="">Show upcoming events</a>
			</div>
			<h2 tal:condition="python:list_all_events and len(all_events)>0"
				i18n:translate="">
				All events:</h2>
			<h2 tal:condition="python:len(all_events)==0"
				i18n:translate="">
				There are no events.</h2>
			<tal:block condition="python: len(all_events)>0 and not list_all_events">
				<h2 tal:condition="python:list_expired and len(object_list_custom)>0"
					i18n:translate="">
					Past events:</h2>
				<h2 tal:condition="python:list_expired and len(object_list_custom)==0"
					i18n:translate="">
					There are no past events.</h2>
				<h2 tal:condition="python: not list_expired and len(object_list_custom)>0"
					i18n:translate="">
					Upcoming events:</h2>
				<h2 tal:condition="python: not list_expired and len(object_list_custom)==0"
					i18n:translate="">
					There are no upcoming events.</h2>
			</tal:block>
			<span tal:replace="structure here/menusubmissions" />
		</metal:block>
		<metal:block fill-slot="toolbar" tal:condition="python:len(object_list_custom)>0">
		<div id="toolbar"
			tal:condition="python:btn_select or btn_copy or btn_cut or btn_paste or btn_delete">
			<input type="submit" value="Copy" class="action-button" name="copyObjects:method"
				i18n:attributes="value"
				tal:condition="btn_copy" />
			<input type="submit" value="Cut" class="action-button" name="cutObjects:method"
				i18n:attributes="value"
				tal:condition="btn_cut" />
			<input type="submit" value="Paste" class="action-button" name="pasteObjects:method"
				i18n:attributes="value"
				tal:condition="btn_paste" />
			<input type="submit" value="Delete" class="action-button" name="deleteObjects:method"
				i18n:attributes="value"
				tal:condition="btn_delete" />
			<input type="submit" value="Rename" class="action-button" name="renameobject_html:method"
				i18n:attributes="value"
				tal:condition="python: here.rename_id and btn_delete" />
		</div>
		</metal:block>
		<metal:block fill-slot="table_head"
			tal:condition="python:len(object_list_custom)>0">
			<tr>
				<th class="checkbox" style="width: 4%;"
					tal:condition="btn_select">
					<input type="checkbox" class="select-all" />
				</th>
				<th class="type" style="width: 4%;" i18n:translate="Type (translate as a noun)">Type</th>
				<th class="title-column" i18n:translate="">Title</th>
				<th i18n:translate="">Location</th>
				<th tal:condition="can_operate" class="checkin" i18n:translate="">Version</th>
				<th tal:condition="can_operate" class="edit" i18n:translate="">Edit</th>
				<th tal:condition="can_operate" class="onfront" i18n:translate="">On front</th>
			</tr>
		</metal:block>
		<metal:block fill-slot="table_objects_default">
			<tal:block define="
				del_permission object_info/del_permission;
				copy_permission object_info/copy_permission;
				edit_permission object_info/edit_permission;
				versionable object_info/versionable;
				editable object_info/editable;
				object object_info/self;
				">
				<td class="checkbox" tal:condition="btn_select"
					style="width: 4%; vertical-align: top;">
					<input tal:condition="python:del_permission or copy_permission"
						type="checkbox" name="id" tal:attributes="value object/id" />
				</td>
				<td class="type" style="width: 4%;">
					<img tal:attributes="
						src python:test(object.approved, object.icon, object.icon_marked);
						alt python:test(hasattr(object, 'get_meta_label'), object.get_meta_label(), object.meta_type);
						title python:test(hasattr(object, 'get_meta_label'), object.get_meta_label(), object.meta_type)" />
				</td>
				<td class="title-column" tal:define="start_date python: getattr(object, 'start_date')">
					<tal:block condition="start_date">
						<span class="object-date" tal:condition="python: getattr(object,'end_date', None) and start_date != object.end_date"
							  tal:content="python: '[' + str(start_date.strftime('%d/%m/%Y')) + ' - ' + str(object.end_date.strftime('%d/%m/%Y')) + ']'">
						</span>
						<span class="object-date" tal:condition="python: not (getattr(object,'end_date', None) and start_date != object.end_date)"
							  tal:content="python: '[' + str(start_date.strftime('%d/%m/%Y')) + ']'">
						</span>
					</tal:block>
					<a tal:attributes="href object/absolute_url" tal:content="object/title_or_id" />
					<span class="available_langs" tal:condition="python:here.item_has_title(object, object.title)">
						<span i18n:translate="">Item only translated in </span>
						<span tal:repeat="lang here/gl_get_languages_map">
							<a tal:content="python:' %s' % lang['title']"
								tal:condition="python:not lang['selected'] and object.getLocalProperty('title', lang['id'])"
								tal:attributes="href python:'gl_changeLanguage?old_lang=%s' % (lang['id'])" />
						</span>
					</span>
					<tal:block condition="object/discussion">
					<tal:block define="count_comments object/count_comments" condition="count_comments">
						[<span tal:replace="count_comments" />
						<span tal:omit-tag="" i18n:translate="">comment(s)</span>]
					</tal:block>
					</tal:block>
				</td>
				<td class="location">
					<span tal:replace="object/location" />
				</td>
				<td class="checkin" tal:condition="edit_permission">
					<tal:block condition="not:versionable">n/a</tal:block>
					<a tal:condition="python:versionable and editable" tal:attributes="href string:${object/absolute_url}/startVersion">
						<img src="misc_/Naaya/checkout" alt="Checkout - start new versionable" i18n:attributes="alt" />
					</a>
					<a tal:condition="python:versionable and not editable" tal:attributes="href string:${object/absolute_url}/edit_html">
						<img src="misc_/Naaya/checkin" alt="Version control" i18n:attributes="alt" />
					</a>
				</td>
				<td class="edit" tal:condition="edit_permission">
					<a tal:condition="editable" tal:attributes="href string:${object/absolute_url}/edit_html">
						<img src="misc_/Naaya/edit" alt="Edit" i18n:attributes="alt" />
					</a>
					<tal:block condition="not:editable">n/a</tal:block>
				</td>
				<td tal:condition="ratings" class="type" style="width: 10%;">
					<tal:block define="user_rating object/user_rating_stars|nothing"
						condition="object/is_ratable" replace="structure user_rating"/>
				</td>
				<td class="onfront" tal:condition="edit_permission">
					<a tal:condition="object/topitem"
						tal:attributes="href string:${object/absolute_url}/change_topitem_status" i18n:attributes="title" title="Click to hide event from the front page">
						<img src="misc_/Naaya/yes.gif" alt="Click to hide event from the front page" i18n:attributes="alt" />
					</a>
					<a tal:condition="not: object/topitem"
						tal:attributes="href string:${object/absolute_url}/change_topitem_status" i18n:attributes="title" title="Click to show event on the front page">
						<img src="misc_/Naaya/no.gif" alt="Click to show event on the front page" i18n:attributes="alt" />
					</a>
				</td>
			</tal:block>
		</metal:block>
	</metal:block>
	</tal:block>
</metal:block>
<metal:block fill-slot="folder_footer">
	<div id="folder_footer" class="folder_footer">
		<a class="download_link"
			rel="nofollow" href="./zip_export/do_export"
			title="Download the contents of this folder to a Zip file"
			tal:condition="python: here.checkPermission('Naaya - Zip export') and len(object_list_custom) > 0"
			i18n:attributes="title"
			i18n:translate="">Zip download</a>
	</div>
</metal:block>
</metal:block>
