Example #1
0
 /**
  * Generate download attributes
  *
  * @param \Isotope\Interfaces\IsotopeProduct $objProduct
  * @param array $arrOptions
  * @return string
  */
 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     $objContentModel = new \ContentModel();
     $objContentModel->type = 'downloads';
     $objContentModel->multiSRC = (array) $this->getValue($objProduct);
     $objContentModel->sortBy = $this->sortBy;
     $objContentModel->orderSRC = $objProduct->{$this->field_name . '_order'};
     $objContentModel->cssID = serialize(array('', $this->field_name));
     $objElement = new \ContentDownloads($objContentModel);
     return $objElement->generate();
 }
 /**
  * Return if there are no files
  * @return string
  */
 public function generate()
 {
     $this->multiSRC = deserialize($this->multiSRC);
     // Use the home directory of the current user as file source
     if ($this->useHomeDir && FE_USER_LOGGED_IN) {
         $this->import('FrontendUser', 'User');
         if ($this->User->assignDir && is_dir(TL_ROOT . '/' . $this->User->homeDir)) {
             $this->multiSRC = array($this->User->homeDir);
         }
     }
     // Add groups home directory as sources
     if ($this->useGroupDir && FE_USER_LOGGED_IN) {
         $this->import('FrontendUser', 'User');
         if (count($this->User->groups)) {
             $aSources = $this->multiSRC;
             foreach ($this->User->groups as $groupID) {
                 $objGroup = $this->Database->prepare("SELECT * FROM tl_member_group WHERE id=?")->execute($groupID);
                 $sGrpHomeDir = (string) $objGroup->homeDir;
                 if (strlen($sGrpHomeDir)) {
                     $aSources[] = $sGrpHomeDir;
                 }
             }
             $this->multiSRC = $aSources;
             #echo '<pre>'.print_r($aSources,1).'</pre>';
         }
     }
     // Return if there are no files
     if (!is_array($this->multiSRC) || count($this->multiSRC) < 1) {
         return '';
     }
     $file = $this->Input->get('file', true);
     // Send the file to the browser
     if ($file != '' && (in_array($file, $this->multiSRC) || in_array(dirname($file), $this->multiSRC)) && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) {
         $this->sendFileToBrowser($file);
     }
     return parent::generate();
 }