Advertisement
Guest User

Untitled

a guest
Oct 31st, 2012
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.09 KB | None | 0 0
  1. <?php
  2. require_once(PATH_tslib.'class.tslib_pibase.php');
  3.  
  4.  
  5. class tx_btmp_pi1 extends tslib_pibase {
  6.     var $prefixId      = 'tx_btmp_pi1';     // Same as class name
  7.     var $scriptRelPath = 'pi1/class.tx_btmp_pi1.php';   // Path to this script relative to the extension dir.
  8.     var $extKey        = 'bt_mp';   // The extension key.
  9.     var $pi_checkCHash = true;
  10.  
  11.     function main($content,$conf) {
  12.         $this->conf=$conf;
  13.         $this->pi_setPiVarDefaults();
  14.         $this->pi_loadLL();
  15.  
  16.         if (!empty($this->piVars['submit_pdf']))
  17.             return $this->getPdf();
  18.  
  19.         return $this->renderForm();
  20.     }
  21.  
  22.     function renderForm() {
  23.         //Shows Form
  24.     }
  25.  
  26.     function getPdf() {
  27.  
  28.         require(t3lib_extMgm::extPath('bt_mp') . 'pi1/config/tcpdf_config.php');
  29.         require(t3lib_extMgm::extPath('tcpdf') . 'class.tx_tcpdf.php');
  30.         require(t3lib_extMgm::extPath('bt_mp') . 'pi1/class.tx_btmp_pi1_pdf.php');
  31.  
  32.         $pdf = new btmp_pdf('P', 'mm', 'A4', true, 'UTF-8', false);
  33.         $pdf->setPDFVersion('1.6');
  34.  
  35.         if ($image = $this->uploadImage()) {
  36.             $pdf->setSourceFile(str_replace('EXT:bt_mp',
  37.                 t3lib_extMgm::extPath('bt_mp'),
  38.                 $this->conf['pdfTemplateWithoutDummyImage']));
  39.         } else {
  40.             $pdf->setSourceFile(str_replace('EXT:bt_mp',
  41.                 t3lib_extMgm::extPath('bt_mp'),
  42.                 $this->conf['pdfTemplate']));
  43.         }
  44.         $pdf->SetImageScale(3.53);
  45.         $pdf->AddFont('bradley');
  46.  
  47.         $pdf->SetTextColor(35,130,192);
  48.         $pdf->SetFont('bradley', 'b', 18);
  49.         $pdf->AddPage();
  50.  
  51.         if ($image)
  52.             $pdf->Image($image, 32, 160);
  53.  
  54.         $pdf->SetXY(22,215);
  55.         $pdf->Write(20, $this->piVars['firstname'] . ' ' . $this->piVars['lastname']);
  56.  
  57.         $pdf->SetXY(22,236);
  58.         $pdf->Write(20, $this->piVars['children']);
  59.  
  60.         $pdf->SetXY(113,232);
  61.         $pdf->Write(20, date('d.m.Y'));
  62.  
  63.         return $pdf->Output('medienpass.pdf', 'D');
  64.     }
  65.  
  66.     function fetchLLMarkers($subpart) {
  67.         preg_match_all("/###(LL\w+)###/", $subpart, $matches);
  68.  
  69.         $markerArray = array();
  70.  
  71.         foreach ($matches[0] as $key => $value)
  72.             $markerArray[$value] = $this->pi_getLL(strtolower($matches[1][$key]));
  73.  
  74.         return $markerArray;
  75.     }
  76.  
  77.     function uploadImage() {
  78.         $pathinfo = pathinfo($_FILES['tx_btmp_pi1']['name']['image']);
  79.         $allowedExtensions = explode(',', $this->conf['allowedImageExtensions']);
  80.  
  81.         if (!empty($_FILES['tx_btmp_pi1']['name']['image']) &&
  82.             $pathinfo &&
  83.             in_array($pathinfo['extension'], $allowedExtensions)) {
  84.  
  85.             $destinationPath = PATH_site . 'uploads/tx_btmp/';
  86.             $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
  87.             $fileName = $fileFunc->getUniqueName($_FILES['tx_btmp_pi1']['name']['image'], $destinationPath);
  88.  
  89.             t3lib_div::upload_copy_move($_FILES['tx_btmp_pi1']['tmp_name']['image'],  $fileName);
  90.  
  91.             $this->conf['pdfImage.']['file.']['10.']['file'] = 'uploads/tx_btmp/' . basename($fileName);
  92.  
  93.             return $this->cObj->IMG_RESOURCE($this->conf['pdfImage.']);
  94.         } else {
  95.             return false;
  96.         }
  97.     }
  98. }
  99.  
  100. if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/bt_mp/pi1/class.tx_btmp_pi1.php']) {
  101.     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/bt_mp/pi1/class.tx_btmp_pi1.php']);
  102. }
  103. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement