<?php

//Copyright by Mathias Milus
//* licensed under the MIT license:
//http://www.opensource.org/licenses/mit-license.php

$cs_lang = cs_translate('multislide');
$data = array();

$data['options'] = cs_sql_option(__FILE__,'multislide');

cs_scriptload('multislide', 'javascript', 'js/jqFancyTransitions.js');
cs_scriptload('multislide', 'stylesheet', 'css/styles.css');

$where = " multislide_access <= '" . $account['access_multislide'] . "'";
if(!empty($_GET['cat_id'])) {
  $cat_id = (int) $_GET['cat_id'];
  $cat_multislide = cs_sql_count(__FILE__, 'categories', "categories_id = '" . $cat_id . "' AND categories_mod = 'multislide'");
  if(!empty($cat_multislide)) $where = " AND categories_id = '" . $cat_id . "'";
}

$data['multislide'] = cs_sql_select(__FILE__,'multislide','multislide_picture, multislide_description, multislide_link',$where,'multislide_id DESC','',$data['options']['max_navslide']);
$multislide_loop = count($data['multislide']);

if(empty($data['multislide'])) {
  echo $cs_lang['no_multislide'];
}
else {
  for($run=0; $run<$multislide_loop; $run++){
		$data['multislide'][$run]['if']['extern'] = cs_substr($data['multislide'][$run]['multislide_picture'],0,7) == 'uploads' ? true : false;	
		}
  echo cs_subtemplate(__FILE__,$data,'multislide','navslide');
}