コード例 #1
0
 function start($conf, $piVars, $cObj)
 {
     // config
     $this->conf = $conf;
     $this->piVars = $piVars;
     $this->cObj = $cObj;
     $this->pi_loadLL();
     $this->div = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_wtgallery_div');
     // Create new instance for div class
     $this->dynamicMarkers = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_wtgallery_dynamicmarkers');
     // Create new instance for dynamicmarker function
     $this->pagebrowser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_wtgallery_list_pagebrowser');
     // Create new instance for pagebrowser function
     $this->tmpl = $this->markerArray = $this->outerMarkerArray = $subpartArray = array();
     $content_item = '';
     // init
     $this->tmpl[$this->mode]['all'] = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['template.'][$this->mode]), '###WTGALLERY_LIST###');
     // Load HTML Template
     $this->tmpl[$this->mode]['item'] = $this->cObj->getSubpart($this->tmpl[$this->mode]['all'], '###ITEM###');
     // work on subpart 2
     // let's go
     $startpath = $this->div->validatePicturePath($this->piVars['category'] ? $this->div->hash2folder($this->piVars['category'], $this->conf['main.']['path']) : $this->conf['main.']['path']);
     // startpath from piVars or from ts
     if (strpos($startpath, ':')) {
         $storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
         $f = $storageRepository->findByUid(explode(':', $startpath)[0]);
         $startpath = $f->getConfiguration()['basePath'] . explode(':', $startpath)[1];
     }
     $pictures = $this->div->getFiles($this->conf, $startpath, $this->conf[$this->mode . '.']['order'], $this->conf[$this->mode . '.']['limit']);
     // get all pictures from current folder
     $pictures_current = array_chunk((array) $pictures, $this->conf[$this->mode . '.']['rows'] * $this->conf[$this->mode . '.']['columns']);
     // split array in parts for pagebrowser
     $this->overall = count($pictures);
     // count all pictures
     $pointer = $this->piVars['listpointer'] > 0 ? $this->piVars['listpointer'] : 0;
     // pointer
     //var_dump($pictures);
     if (count($pictures_current[$pointer]) > 0) {
         // if there are pictures
         for ($i = 0; $i < count($pictures_current[$pointer]); $i++) {
             // one loop for every picture in current folder
             // let's start
             $row = array('picture' => $pictures_current[$pointer][$i], 'tstamp' => filemtime($pictures_current[$pointer][$i]), 'filename' => $this->div->fileInfo($pictures_current[$pointer][$i], 'filename'), 'dirname' => $this->div->fileInfo($pictures_current[$pointer][$i], 'dirname'), 'basename' => $this->div->fileInfo($pictures_current[$pointer][$i], 'basename'), 'extension' => $this->div->fileInfo($pictures_current[$pointer][$i], 'extension'), 'currentfolder' => $this->div->fileInfo($pictures_current[$pointer][$i], 'currentfolder'), 'picturehash' => $this->div->hashCode($pictures_current[$pointer][$i]), 'pid_single' => $this->conf['single.']['pid_single'] > 0 ? $this->conf['single.']['pid_single'] : $GLOBALS['TSFE']->id, 'link_single' => tslib_pibase::pi_linkTP_keepPIvars_url(array('show' => $this->div->hashCode($pictures_current[$pointer][$i])), 1, 0, $this->conf['single.']['pid_single'] > 0 ? $this->conf['single.']['pid_single'] : 0));
             $metarow = $this->div->EXIForTXT($row['picture'], $this->conf[$this->mode . '.']['metainformation']);
             // get metainformation
             $row = array_merge((array) $row, (array) $metarow);
             // add array from txt or exif to normal row
             $this->cObj->start($row, 'tt_content');
             // enable .field in typoscript for singleview
             $this->markerArray = $this->div->markersClassStyle($i, $this->mode, $this->conf);
             // fill ###CLASS###
             if ($this->piVars['show'] == $this->div->hashCode($pictures_current[$pointer][$i]) || !isset($this->piVars['show']) && $i == 0) {
                 $this->markerArray['###CLASS###'] .= ' wtgallery_list_current';
             }
             // add string to div if current picture
             if (!empty($this->conf[$this->mode . '.']['width'])) {
                 $this->conf[$this->mode . '.']['image.']['file.']['width'] = $this->conf[$this->mode . '.']['width'];
             }
             // set width from config (e.g. flexform if not empty)
             if (!empty($this->conf[$this->mode . '.']['height'])) {
                 $this->conf[$this->mode . '.']['image.']['file.']['height'] = $this->conf[$this->mode . '.']['height'];
             }
             // set height from config (e.g. flexform if not empty)
             foreach ($this->conf[$this->mode . '.'] as $key => $value) {
                 // one loop for every main level in typoscript (single.image, single.text, single.listviewlink, etc...)
                 if ($key != 'pagebrowser' && !is_array($this->conf[$this->mode . '.'][$key])) {
                     // don't use pagebrowser here but everything else
                     $this->markerArray['###' . strtoupper($key) . '###'] = $this->cObj->cObjGetSingle($this->conf[$this->mode . '.'][$key], $this->conf[$this->mode . '.'][$key . '.']);
                     // values from ts
                 }
             }
             foreach ($row as $key => $value) {
                 // one loop for every row entry
                 $this->markerArray['###' . strtoupper($key) . '###'] = $value;
                 // fill marker with value of row
             }
             $this->wrappedSubpartArray['###SINGLELINK###'][0] = '<a href="' . tslib_pibase::pi_linkTP_keepPIvars_url(array('show' => $this->div->hashCode($row['picture'])), 1, 0, $this->conf['single.']['pid_single'] > 0 ? $this->conf['single.']['pid_single'] : 0) . '">';
             // Link with piVars "show"
             $this->wrappedSubpartArray['###SINGLELINK###'][1] = '</a>';
             // postfix for linkwrap
             $this->hook_inner();
             // add hook
             $content_item .= $this->div->rowWrapper($this->cObj->substituteMarkerArrayCached($this->tmpl[$this->mode]['item'], $this->markerArray, array(), $this->wrappedSubpartArray), $i, $this->mode, count($pictures_current[$pointer]), $this->conf);
             // add inner html to variable
         }
     }
     $this->num = $i;
     // current pictures for pagebrowser
     $subpartArray['###CONTENT###'] = $content_item;
     // work on subpart 3
     $this->outerMarkerArray['###PAGEBROWSER###'] = $this->pagebrowser->start($this->conf, $this->piVars, $this->cObj, array('overall' => $this->overall, 'overall_cur' => $this->conf[$this->mode . '.']['rows'] * $this->conf[$this->mode . '.']['columns'], 'pointer' => $pointer, 'perPage' => $this->conf[$this->mode . '.']['rows'] * $this->conf[$this->mode . '.']['columns']));
     // includes pagebrowser function
     $this->outerMarkerArray = array_merge((array) $this->markerArray, (array) $this->outerMarkerArray);
     // add all markers of last picture to the outermarker Array
     $this->hook_outer();
     // add hook
     $this->content = $this->cObj->substituteMarkerArrayCached($this->tmpl[$this->mode]['all'], $this->outerMarkerArray, $subpartArray);
     // Get html template
     $this->content = $this->dynamicMarkers->main($this->conf, $this->cObj, $this->content);
     // Fill dynamic locallang or typoscript markers
     $this->content = preg_replace("|###.*?###|i", "", $this->content);
     // Finally clear not filled markers
     if (!empty($this->content) && $i > 0) {
         return $this->content;
     }
     // return HTML if $content is not empty and if there are pictures
 }
コード例 #2
0
 function browser()
 {
     $this->filearray = $this->div->getFiles($this->conf, $this->startpath, $this->conf[$this->mode . '.']['order'], $this->conf['list.']['limit'], 1);
     // get picture array with hash code
     if (is_array($this->filearray)) {
         // if is array
         $this->curPicNo = !isset($this->piVars['show']) ? 0 : array_search($this->piVars['show'], $this->filearray);
         // Number of current picture (key in array)
         if (array_key_exists($this->curPicNo + 1, $this->filearray)) {
             // if next exists in array
             $this->hash['next'] = $this->filearray[$this->curPicNo + 1];
             // hash of next pic in array
             $this->wrappedSubpartArray['###NEXT###'][0] = '<a href="' . tslib_pibase::pi_linkTP_keepPIvars_url(array('show' => $this->hash['next']), 1, 0, 0) . '">';
             // Link with new "show" vars
             $this->wrappedSubpartArray['###NEXT###'][1] = '</a>';
             // postfix for linkwrap
         }
         if (array_key_exists($this->curPicNo - 1, $this->filearray)) {
             // if previous exists in array
             $this->hash['previous'] = $this->filearray[$this->curPicNo - 1];
             // hash of previous pic in array
             $this->wrappedSubpartArray['###PREVIOUS###'][0] = '<a href="' . tslib_pibase::pi_linkTP_keepPIvars_url(array('show' => $this->hash['previous']), 1, 0, 0) . '">';
             // Link with new "show" vars
             $this->wrappedSubpartArray['###PREVIOUS###'][1] = '</a>';
             // postfix for linkwrap
         }
     }
 }