Пример #1
0
 /**
  * @param int $pid
  * @return string
  */
 private function getSubalbumsAsUnorderedList($pid = 0)
 {
     $dbContent = $this->Database->prepare('SELECT * FROM tl_content WHERE id=?')->execute($this->Input->get('id'));
     $selectedAlbums = $dbContent->gc_publish_albums != '' ? deserialize($dbContent->gc_publish_albums) : array();
     $level = \MCupic\GalleryCreator\GcHelpers::getAlbumLevel($pid);
     $db = $this->Database->prepare('SELECT * FROM tl_gallery_creator_albums WHERE pid=? AND published=? ORDER BY sorting')->execute($pid, 1);
     while ($db->next()) {
         $checked = in_array($db->id, $selectedAlbums) ? ' checked' : '';
         $list .= '<li class="album-list-item"><input type="checkbox" name="gc_publish_albums[]" class="album-control-field" id="albumControlField-' . $db->id . '" value="' . $db->id . '"' . $checked . '>' . $db->name;
         $list .= $this->getSubalbumsAsUnorderedList($db->id);
         $list .= '</li>';
     }
     if ($list != '') {
         $paddingLeft = $level == 0 ? '0' : '10px';
         $list = '<ul style="padding-left:' . $paddingLeft . '" class="level_' . $level . '">' . $list . '</ul>';
     }
     return $list;
 }
 /**
  * label-callback for the albumlisting
  * @param array
  * @param string
  * @return string
  */
 public function labelCb($row, $label)
 {
     $mysql = $this->Database->prepare('SELECT count(id) as countImg FROM tl_gallery_creator_pictures WHERE pid=?')->execute($row['id']);
     $label = str_replace('#count_pics#', $mysql->countImg, $label);
     $label = str_replace('#datum#', date('Y-m-d', $row['date']), $label);
     $image = $row['published'] ? 'picture_edit.png' : 'picture_edit_1.png';
     $label = str_replace('#icon#', "system/modules/gallery_creator/assets/images/" . $image, $label);
     $href = sprintf("contao/main.php?do=gallery_creator&table=tl_gallery_creator_albums&id=%s&act=edit&rt=%s&ref=%s", $row['id'], REQUEST_TOKEN, TL_REFERER_ID);
     $label = str_replace('#href#', $href, $label);
     $label = str_replace('#title#', sprintf($GLOBALS['TL_LANG']['tl_gallery_creator_albums']['edit_album'][1], $row['id']), $label);
     $level = \MCupic\GalleryCreator\GcHelpers::getAlbumLevel($row["pid"]);
     $padding = $this->isNode($row["id"]) ? 3 * $level : 20 + 3 * $level;
     $label = str_replace('#padding-left#', 'padding-left:' . $padding . 'px;', $label);
     return $label;
 }