<?php

/********************************************************************
GLOBAL CALL
********************************************************************/

$cpanel['name'] = 'mytheme';
$cpanel['lib'] = TEMPLATEPATH.'/cpanel/lib.php';
$cpanel['cpanel'] = TEMPLATEPATH.'/cpanel/cpanel.php';
$cpanel['modules_dir'] = TEMPLATEPATH.'/cpanel/modules/';
$cpanel['img_dir'] = get_template_directory_uri().'/cpanel/img/';
$cpanel['js_dir'] = get_template_directory_uri().'/cpanel/js/';
$cpanel['css_dir'] = get_template_directory_uri().'/cpanel/css/';
require_once $cpanel['lib'];
require_once $cpanel['cpanel'];

/********************************************************************
*********************************************************************
********************************************************************/

/********************************************************************
register sidebar widgets
********************************************************************/
if (function_exists('register_sidebar'))

register_sidebar(array(
'name' => 'Left Sidebar',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2>',
'after_title' => '</h2>'
));

register_sidebar(array(
'name' => 'Right Sidebar',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2>',
'after_title' => '</h2>'
));

/********************************************************************
loading a custom archive for (category)
********************************************************************/
function get_custom_archive($c) {

	global $options;
	
	$the_cat = get_category_parents($c, FALSE, ' ', FALSE);

	$video = get_cat_name($options['videos_id']);
	$gallery = get_cat_name($options['photos_id']);

	$search_a = '/^'. $video .'/';
	$search_b = '/^'. $gallery .'/';
	
	if (preg_match($search_a, $the_cat)) {
		include TEMPLATEPATH. '/category_videos.php';
	} elseif (preg_match($search_b, $the_cat)) {
		include TEMPLATEPATH. '/category_photos.php';
	} else {
		include TEMPLATEPATH. '/category_news.php';
	}
	
}

/********************************************************************
loading a custom single post template
********************************************************************/
function get_custom_post() {

	global $post, $options;
	$get_post_cat = wp_get_post_categories($post->ID);
	foreach($get_post_cat as $catid ) {
	$cat = get_category($catid);
	$the_cat = get_category_parents($cat->cat_ID, FALSE, ' ', FALSE);
	}
	
	$video = get_cat_name($options['videos_id']);
	$gallery = get_cat_name($options['photos_id']);
	
	$search_a = '/^'. $video .'/';
	$search_b = '/^'. $gallery .'/';
	
	if (preg_match($search_a, $the_cat)) {
		include TEMPLATEPATH. '/single_videos.php';
	} elseif (preg_match($search_b, $the_cat)) {
		include TEMPLATEPATH. '/single_photos.php';
	} else {
		include TEMPLATEPATH. '/single_news.php';
	}
	
}

/********************************************************************
excluded photos and videos IDs
********************************************************************/
$excluded = array();
$included_vid = array();
$included_pic = array();

$video_childs = get_categories('child_of='.$options['videos_id']);
$pic_childs = get_categories('child_of='.$options['photos_id']);

foreach($video_childs as $video_child) {
array_push($excluded, $video_child->cat_ID);
}

foreach($video_childs as $video_child) {
array_push($included_vid, $video_child->cat_ID);
}

foreach($pic_childs as $pic_child) {
array_push($included_pic, $pic_child->cat_ID);
}

array_push($excluded, $options['photos_id']);
array_push($excluded, $options['videos_id']);
array_push($included_vid, $options['videos_id']);
array_push($included_pic, $options['photos_id']);

/********************************************************************
custom comment display
********************************************************************/
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">

	<div id="comment-<?php comment_ID(); ?>">

		<div class="comment-author vcard">
		<?php echo get_avatar($comment,$size='48',$default=''); ?>
		<cite class="fn"><?php print get_comment_author_link(); ?></cite>
		</div>

		<div class="comment-meta commentmetadata">
		<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">Posted on <?php print get_comment_date(); ?> at <?php print get_comment_time(); ?></a><?php edit_comment_link(__('(Edit)'),'  ','') ?>
		</div>

		<?php comment_text() ?>

		<div class="reply">
		<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
		</div>

	</div><div class="clear"></div>
<?php
}

?>
buyur hocam