<?php
class AnUikitStoryActionStory extends AnUikitActionMixin
{
/**
* The view within which these action will show. It's used to create the route the controller
*/
protected $_view;
/**
*
* @return
* @param $options Object
*/
public function __construct($options)
{
$this->_view = $options['view'];
parent::__construct($options);
$actions = array();
if( $this->_mixer->getAcl()->canDelete() ) {
$actions[] = AnUikitHtmlTag::link( JText::_('AN-SE-ACTION-DELETE'),
$this->_view->createRoute('view=story&action=delete&id='.$this->_mixer->id))
->setTitle(JText::_('AN-SE-ACTION-DELETE'))
->setClass('an-se-remove-handle an-se-confirm-remove')
->setRemoveOptions(array('title'=> JText::_('AN-SE-PROMPT-CONFIRMATION-DELETE-ITEM'), 'point'=>11));
}
if( $this->_mixer->getAcl()->canAddComment() ) {
$actions[] = AnUikitHtmlTag::link( JText::_('AN-SE-ACTION-COMMENT'), '#')
->setTitle(JText::_('AN-SE-ACTION-COMMENT'))
->setClass('an-se-story-action-comment an-se-action-comment')
->setStoryId($this->_mixer->id)
;
}
if ( $this->_mixer->numOfComments > 0 )
$this->_mixer->comments->order('creationTime', 'ASC');
//if comments limit is not set set it to 3
if ( $this->_mixer->numOfComments == 0 )
$this->_mixer->comments = array();
else if ( !($this->_mixer->comments->getLimit() === null || $this->_mixer->comments->getLimit()) )
$this->_mixer->comments->limit(3);
foreach($this->_mixer->comments as $comment)
{
$comment->mixin( KFactory::tmp('lib.anahita.uikit.story.action.comment', array('mixer'=>$comment, 'view'=>$this->_view)) );
}
$this->setActions($actions);
}
}