<?php
/*
 * Copyright (c) 2013, webvariants GbR, http://www.webvariants.de
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

if ($article->isStartArticle()) {
	$sprite = 'article-startpage';
}
else {
	$sprite = 'article';
}

$viewURL      = $_router->getPlainUrl('content', null, array('article_id' => $article->getId(), 'clang' => $this->clangId));
$editParams   = array('category_id' => $article->getCategoryId(), 'clang' => $this->clangId, 'edit_id' => $article->getId());
$status       = $statusTypes[$article->getStatus()][0];
$status_class = $statusTypes[$article->getStatus()][1];

$service  = sly_Service_Factory::getArticleTypeService();
$type     = $article->getType();

if ($type) {
	if ($service->exists($type)) $type = sly_translate($service->getTitle($type));
	else $type = '('.$type.')';
}
else {
	$type = t('no_articletype');
}

if ($this->canPublishCategory($this->categoryId) && $this->categoryId != $article->getId()) {
	$status = '<a href="'.$_router->getUrl(null, 'editStatusArticle', $editParams).'" class="'.$status_class.' sly-postlink">'.$status.'</a>';
}
else {
	$status_class .= ' sly-na';
	$status = '<span class="'.$status_class.'">'.$status.'</span>';
}
?>
<tr data-slyid="<?php echo $article->getId() ?>" data-slystatus="<?php echo $article->getStatus() ?>" data-slytype="<?php echo $article->getType() ?>">
	<td class="sly-col-icon sly-icon"><?php echo sly_Util_HTML::getSpriteLink($viewURL, $article->getName(), $sprite) ?></td>
	<td class="sly-col-name"><a href="<?php echo sly_html($viewURL) ?>"><?php echo sly_html($article->getName()) ?></a></td>
	<td class="sly-col-arttype"><?php echo sly_html($type) ?></td>
	<?php if ($isActive): ?>
	<td class="sly-col-pos"><?php echo sly_html($article->getPosition()) ?></td>
	<?php endif ?>
	<td class="sly-col-status">
		<?php
		if ($canEdit) {
			echo '<a href="'.$_router->getUrl(null, 'editArticle', $editParams).'">'.t('change').'</a>&nbsp;';
		}
		else {
			echo '<span class="sly-na">'.t('change').'</span>&nbsp;';
		}

		if ($canEdit && !$article->isStartArticle()) {
			echo '<a href="'.$_router->getUrl(null, 'deleteArticle', $editParams).'" class="sly-delete sly-postlink">'.t('delete').'</a>';
		}
		else {
			echo '<span class="sly-na">'.t('delete').'</span>';
		}
		?>
		&nbsp;<?php echo $status ?>
	</td>
</tr>
