public function setData($array)
 {
     $itens = '';
     if ($array['categoria'] == '') {
         $criteria = array("posicao_id = {$array['posicao']} AND categoria_id = '0'");
     } else {
         $criteria = array("posicao_id = {$array['posicao']} AND categoria_id = '{$array['categoria']}'");
     }
     $criteria['order'] = 'ordem asc';
     $banner = Banners::find($criteria);
     foreach ($banner as $key => $value) {
         $arr = array();
         for ($i = 0; $i < count(unserialize($value->imagens)); $i++) {
             $imagem = unserialize($value->imagens);
             $img = Imagens::findFirst("id = " . $imagem[$i])->toArray();
             $arr[] = $img;
         }
         if ($this->options['background'] && count($arr) > 1) {
             $img = "<img src='" . $this->url_base . $arr[1]['url'] . "' class='img-responsive'/>";
         } else {
             if (!$this->options['background']) {
                 $img = "<img src='" . $this->url_base . $arr[0]['url'] . "' class='img-responsive'/>";
             } else {
                 $img = '';
             }
         }
         $replaces = array($array['slide_item_id'], $array['slide_item_class'], $img, $array['caption'] ? $this->setCaption($value, $key) : '');
         $itens .= parent::replaceWraper(4, $replaces, str_replace('BACKGROUND', 'style="background-image:url(' . $this->url_base . $arr[0]['url'] . ');"', $array['slide_item_wrap']));
     }
     return $itens;
 }
 public function setData($array)
 {
     $itens = '';
     if ($array['categoria'] == '') {
         $criteria = array("posicao_id = {$array['posicao']} AND categoria_id = '0'");
     } else {
         $criteria = array("posicao_id = {$array['posicao']} AND categoria_id = '{$array['categoria']}'");
     }
     $criteria['order'] = 'ordem asc';
     $banner = Banners::find($criteria);
     foreach ($banner as $key => $value) {
         $imagem = Imagens::findFirst("id in (" . implode(',', unserialize($value->imagens)) . ")")->url;
         $replaces = array($array['slide_item_id'], $array['slide_item_class'], "<img src='" . $this->url_base . $imagem . "' class='img-responsive'/>", $array['caption'] ? $this->setCaption($value, $key) : '');
         $itens .= parent::replaceWraper(4, $replaces, $array['slide_item_wrap']);
     }
     return $itens;
 }
 public function deleteAction($id)
 {
     $model = Banners::findById($id);
     $exec = $model->delete();
     parent::notifica($exec, array('controller' => 'banner', 'action' => 'index'));
 }