<?php
	$title = $this->translate('My Stitch Patterns');
	$this->headTitle($title);
?>
<div class="container container-items">
<h2><?=$this->translate('My Patterns');?></h2>

<a class="btn btn-primary" href="<?php echo $this->url('stitchpattern', array('action'=>'add'));?>">
<span class="glyphicon glyphicon-plus"></span>
<?= $this->translate('New Pattern'); ?></a>

<section class="list cf">
<?php $iterated = false; foreach ($mySP as $key=>$stitchpattern) {  $iterated = true;?>
	<article>
		<div class="cf">
			<img src="/<?php echo $this->escapeHtml($stitchpattern->previewDir);?>"/>
			<h4><?php echo $this->escapeHtml($stitchpattern->title);?></h4>
			<p><time><?= $this->TimeAgo()->getTime($stitchpattern->update_date); ?></time></p>

			<?php if($this->isAllowed($stitchpattern, $this->identity(),'edit')) :?>
			<a class="btn btn-default btn-xs" href="<?php echo $this->url('stitchpattern',
				array('action'=>'edit', 'id' => $stitchpattern->id));?>" title="<?=$this->translate('Edit');?>">
				<span class="glyphicon glyphicon-pencil"></span>
			</a>
			<?php endif; if($this->isAllowed($stitchpattern, $this->identity(),'share')) :?>
			<a class="btn btn-<? if($stitchpattern->shared) echo 'primary'; else echo 'default'; ?> btn-xs" href="<?php echo $this->url('stitchpattern',
				array('action'=>'share', 'id' => $stitchpattern->id));?>" title="<? if($stitchpattern->shared) echo $this->translate('Unshare'); else echo $this->translate('Share');?>">
				<span class="glyphicon glyphicon-share-alt"></span>
			</a>
			<?php endif; if($this->isAllowed($stitchpattern, $this->identity(),'delete')) :?>
			<a class="btn btn-danger btn-xs" href="<?php echo $this->url('stitchpattern',
				array('action'=>'delete', 'id' => $stitchpattern->id));?>" title="<?=$this->translate('Delete');?>">
				<span class="glyphicon glyphicon-remove"></span>
			</a>
			<? endif; ?>

			<?php if($this->isAllowed($stitchpattern, $this->identity(),'convert')) :?>
			<a class="btn btn-success btn-xs" href="<?php echo $this->url('stitchpattern',
				array('action'=>'convert', 'id' => $stitchpattern->id));?>">
				<?= $this->translate('Knit it'); ?> »
			</a>
			<? endif; ?>
		</div>
	</article>
<?php } ?>
<?php if(!$iterated) :?>
	<article>
	<p><?=$this->translate('Can\'t find any! Why don\'t you add one?');?></p>
	</article>
<?php endif; ?>
</section>

<h2><?=$this->translate('Shared Patterns');?></h2>
<?php echo $this->partial('stitch-pattern/stitch-pattern/public_list.phtml', array('stitchpatterns' => $this->sharedSP)); ?>