76 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			76 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/*****************************************************************************
 | 
						|
 * ManageAlbums.php
 | 
						|
 * Contains the controller for admin album management.
 | 
						|
 *
 | 
						|
 * Kabuki CMS (C) 2013-2017, Aaron van Geffen
 | 
						|
 *****************************************************************************/
 | 
						|
 | 
						|
class ManageAlbums extends HTMLController
 | 
						|
{
 | 
						|
	public function __construct()
 | 
						|
	{
 | 
						|
		// Ensure it's just admins at this point.
 | 
						|
		if (!Registry::get('user')->isAdmin())
 | 
						|
			throw new NotAllowedException();
 | 
						|
 | 
						|
		$options = [
 | 
						|
			'form' => [
 | 
						|
				'action' => BASEURL . '/editalbum/',
 | 
						|
				'method' => 'get',
 | 
						|
				'class' => 'col-md-6 text-end',
 | 
						|
				'buttons' => [
 | 
						|
					'add' => [
 | 
						|
						'type' => 'submit',
 | 
						|
						'caption' => 'Add new album',
 | 
						|
					],
 | 
						|
				],
 | 
						|
			],
 | 
						|
			'columns' => [
 | 
						|
				'id_album' => [
 | 
						|
					'value' => 'id_tag',
 | 
						|
					'header' => 'ID',
 | 
						|
					'is_sortable' => true,
 | 
						|
				],
 | 
						|
				'tag' => [
 | 
						|
					'header' => 'Album',
 | 
						|
					'is_sortable' => true,
 | 
						|
					'link' => BASEURL . '/editalbum/?id={ID_TAG}',
 | 
						|
					'value' => 'tag',
 | 
						|
				],
 | 
						|
				'slug' => [
 | 
						|
					'header' => 'Slug',
 | 
						|
					'is_sortable' => true,
 | 
						|
					'link' => BASEURL . '/editalbum/?id={ID_TAG}',
 | 
						|
					'value' => 'slug',
 | 
						|
				],
 | 
						|
				'count' => [
 | 
						|
					'header' => '# Photos',
 | 
						|
					'is_sortable' => true,
 | 
						|
					'value' => 'count',
 | 
						|
				],
 | 
						|
			],
 | 
						|
			'default_sort_order' => 'tag',
 | 
						|
			'default_sort_direction' => 'up',
 | 
						|
			'start' => $_GET['start'] ?? 0,
 | 
						|
			'sort_order' => $_GET['order'] ?? '',
 | 
						|
			'sort_direction' => $_GET['dir'] ?? '',
 | 
						|
			'title' => 'Manage albums',
 | 
						|
			'no_items_label' => 'No albums meet the requirements of the current filter.',
 | 
						|
			'items_per_page' => 9999,
 | 
						|
			'index_class' => 'col-md-6',
 | 
						|
			'base_url' => BASEURL . '/managealbums/',
 | 
						|
			'get_data' => function($offset, $limit, $order, $direction) {
 | 
						|
				return Tag::getOffset($offset, $limit, $order, $direction, true);
 | 
						|
			},
 | 
						|
			'get_count' => function() {
 | 
						|
				return Tag::getCount(false, 'Album', true);
 | 
						|
			}
 | 
						|
		];
 | 
						|
 | 
						|
		$table = new GenericTable($options);
 | 
						|
		parent::__construct('Album management - Page ' . $table->getCurrentPage() .' - ' . SITE_TITLE);
 | 
						|
		$this->page->adopt(new TabularData($table));
 | 
						|
	}
 | 
						|
}
 |