<?php
require_once APPLICATION_PATH . '/modules/alw/views/helpers/Loadingimage.php';

$loadCdnImage = new Alw_View_Helper_Loadingimage();
$newsLgCdnPath = (APPLICATION_ENV != 'development') ? $loadCdnImage->getCdnAlwImagePath('news_lg.svg') : '/images/icons/news_lg.svg';
$editCdnPath = (APPLICATION_ENV != 'development') ? $loadCdnImage->getCdnAlwImagePath('Edit.svg') : '/images/icons/Edit.svg';
?>
<div id="content" class="content-div">
    <div id="bread">
        <a href="/artist"><?=$this->translate('All Artists')?></a>
    </div>
    <h1><span><?=$this->artistImages($this->artist->artist_id, $this->artist->name);?></span> <?=(isset($this->artist) ? \Orchard\XSSFilter::h($this->artist->name) : 'Create Artist')?>
    </h1>
    <!-- Start Artist Builder Wrap-->
    <div id="artistBuilderWrap">
        <!-- Start Left Content-->
        <div id="contentLeftsm">
            <?=$this->artistBuilderNavigation('news', 'navigateAway', $this->performanceArtistIndexEnabled);?>
        </div>
        <!-- End Left Content-->
        <!-- Start Right Content-->
        <div id="contentRightlg">
            <div id="artistFormWrap">
            <!-- Start No news-->
                <?php $notDisplay = ($this->news->count() ? 'notDisplay' : ''); ?>
                <div class="<?=$notDisplay?>">
                    <h2><?=$this->translate('Artist News')?></h2>
                    <div class="noNewReleases marginTop press no-data-frame">
                        <img src="<?= $newsLgCdnPath ?>" />
                        <h3 class="no-data-title top-space bottom-space"><?=$this->translate('You currently have no news items.')?></h3>
                        <br />
                        <table>
                            <tr>
                                <td>
                                    <a class="btn btn-primary add-data-plus" onclick="modalWindow0({'add_or_edit':'Add', 'querystring':'<?=$this->querystring?>', 'artist_id':<?=(isset($this->artist) ? $this->artist->artist_id : 0)?>})"><?=$this->translate('Add A News Story')?></a>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <!-- End No news-->
                <div style="<?=($this->news->count() ? '' : 'display:none')?>">
                    <h2 class="withdata-title"><?=$this->translate('Artist News')?></h2>
                    <div class="addButton withdata-btn">
                        <a class="btn btn-primary pageFormBtn add-data-plus" onclick="modalWindow0({'querystring':'<?=$this->querystring?>', 'artist_id':<?=(isset($this->artist) ? $this->artist->artist_id : 0)?>})"><?=$this->translate('Add A News Story')?></a>
                    </div>
                    <div class="clear"></div>
                    <ul class="press-story marginTop">
                    <?php
                    if ($this->news->count()) {
                        foreach ($this->news as $k => $each_news) {?>
                            <li class="press-story-list">
                                <div class="press-story-inner">
                                    <h3 class="press-story-title">
                                        <?php if (strlen($each_news->link) > 0) { ?>
                                            <a target="_blank" href="<?=\Orchard\XSSFilter::h($each_news->link)?>"><?=\Orchard\XSSFilter::h($each_news->link_text)?></a>
                                        <?php } else {
                                            echo \Orchard\XSSFilter::h($each_news->link_text);
                                        } ?>
                                    </h3>
                                    <div class="press-story-desc top-space">
                                        <p><?=$each_news->blurb?></p>
                                    </div>
                                </div>
                                <div class="press-story-footer">
                                    <p class="press-story-source bold">
                                        <span class="smalltext"><?=\Orchard\XSSFilter::h(substr($each_news->source, 0, 70) . (strlen($each_news->source) >= 70 ? '...' : ''))?></span>
                                    </p>
                                    <p class="editDelete">
                                        <img src="<?= $editCdnPath ?>" onclick="modalWindow0({'add_or_edit':'Edit','querystring':'<?=$this->querystring?>','news_id':<?=$each_news->id?>,'artist_id':<?=(isset($this->artist) ? $this->artist->artist_id : 0)?>})" style="cursor:pointer" />
                                        <a class="trash-icon" onclick="modalWindow1({'news_id':<?=$each_news->id?>})">
                                            <?=$this->translate('Delete News')?>
                                        </a>
                                    </p>
                                </div>
                            </li>
                    <?php
                        }
                    } ?>
                    </ul>
                    <?=$this->paginationpanel('/artistnews/index/artist_id/'.$this->artist->artist_id, $this->currentPage, 3, $this->total, 'page', null, $this->featureVendorContext)?>
                </div>
            </div>
            <!-- End Right Content-->
        </div>
        <!-- End Artist Builder Wrap-->
    </div>
</div>
<script type="text/javascript">

function deleteNews(news_id){
    if(confirm('<?=$this->escapejs($this->translate('Are you sure?'))?>')){
        document.location.href = '/artistnews/deletenews?news_id='+news_id;
    }
}
</script>

<?php
$options = array(
                array(
                    'url' => '/artistnews/editnewsmodal',
                    'closeOnEsc' => false,
                    'closeOnClick' => false,
                    'loadSpeed' => 100,
                    'top' => 10,
                    'bindEvent' => false,
                    'loadingbar' => false
                ),
                array(
                    'url' => '/artistnews/deletenewsmodal',
                    'closeOnEsc' => false,
                    'closeOnClick' => false,
                    'loadSpeed' => 100,
                    'top' => 10,
                    'bindEvent' => false,
                    'loadingbar' => false
                )
           );
echo $this->modalwindow($options, $this->featureVendorContext)?>
