Пример #1
0
 /**
  * Everything is done in the constructor
  *
  * @param int $id The id of the item we want
  * @param string $type 'experiments' or 'items'
  * @param bool|null $toFile Do we want to write it to a file ?
  */
 public function __construct($id, $type, $toFile = false)
 {
     $this->pdo = Db::getConnection();
     $this->id = $id;
     $this->validateId();
     // assign and check type
     $this->type = $this->checkType($type);
     $this->checkVisibility($this->id);
     // build the pdf content
     $this->initData();
     $this->setAuthor();
     $this->setCleanTitle();
     $this->setTags();
     $this->buildBody();
     $this->buildContent();
     // create the pdf
     $mpdf = new \mPDF();
     $mpdf->SetAuthor($this->author);
     $mpdf->SetTitle($this->title);
     $mpdf->SetSubject('eLabFTW pdf');
     $mpdf->SetKeywords($this->tags);
     $mpdf->SetCreator('www.elabftw.net');
     $mpdf->WriteHTML($this->content);
     // output
     if ($toFile) {
         $this->fileName = $this->getFileName();
         $this->filePath = $this->getFilePath($this->fileName);
         $mpdf->Output($this->filePath, 'F');
     } else {
         $mpdf->Output($this->getCleanName(), 'I');
     }
 }
Пример #2
0
 /**
  * Everything is done in the constructor
  *
  * @param int $id The id of the item we want
  * @param string $type 'experiments' or 'items'
  * @param bool|null $toFile Do we want to write it to a file ?
  */
 public function __construct($id, $type, $toFile = false)
 {
     $this->pdo = Db::getConnection();
     $this->id = $id;
     $this->validateId();
     // assign and check type
     $this->type = $this->checkType($type);
     $this->checkVisibility($this->id);
     // build the pdf content
     $this->initData();
     $this->setAuthor();
     $this->setCleanTitle();
     $this->setTags();
     $this->buildContent();
     // create the pdf
     $mpdf = new \mPDF('utf-8', 'A4');
     // make sure header and footer are not overlapping the body text
     $mpdf->setAutoTopMargin = 'stretch';
     $mpdf->setAutoBottomMargin = 'stretch';
     // set meta data
     $mpdf->SetAuthor($this->author);
     $mpdf->SetTitle($this->title);
     $mpdf->SetSubject('eLabFTW pdf');
     $mpdf->SetKeywords($this->tags);
     $mpdf->SetCreator('www.elabftw.net');
     $mpdf->WriteHTML($this->content);
     // output
     if ($toFile) {
         $this->fileName = $this->getFileName();
         $this->filePath = $this->getFilePath($this->fileName);
         $mpdf->Output($this->filePath, 'F');
     } else {
         $mpdf->Output($this->getCleanName(), 'I');
     }
 }
Пример #3
0
 /**
  * Assign item type
  *
  */
 public function __construct()
 {
     $this->pdo = Db::getConnection();
     $this->checkFileReadable();
     $this->checkMimeType();
     $this->itemType = $this->getTarget();
     $this->openFile();
     $this->readCsv();
 }
Пример #4
0
 /**
  * Give me an experiment id and a db and I make good pdf for you
  *
  * @param $id The id of the experiment
  */
 public function __construct($id)
 {
     $this->pdo = Db::getConnection();
     // will be used in sqlUpdate()
     $this->id = $id;
     $this->generatePdf();
     // initialize with info from config
     $this->stampParams = $this->getTimestampParameters();
 }
Пример #5
0
 /**
  * Give me a list of id+id+id and a type, I make good csv for you
  *
  * @param string $idList 1+4+5+2
  * @param string $type 'experiments' or 'items'
  */
 public function __construct($idList, $type)
 {
     $this->pdo = Db::getConnection();
     $this->fileName = $this->getFileName();
     $this->filePath = $this->getTempFilePath($this->fileName);
     $this->idList = $idList;
     // assign and check type
     $this->type = $this->checkType($type);
     // set the column names
     $this->list[] = $this->populateFirstLine();
     // main loop
     $this->loopIdArr();
 }
Пример #6
0
 /**
  * Give me an id list and a type, I make good zip for you
  *
  * @param string $idList 1+3+5+8
  * @param string $type 'experiments' or 'items'
  * @throws Exception if we don't have ZipArchive extension
  */
 public function __construct($idList, $type)
 {
     $this->pdo = Db::getConnection();
     // we check first if the zip extension is here
     if (!class_exists('ZipArchive')) {
         throw new Exception(_("You are missing the ZipArchive class in php. Uncomment the line extension=zip.so in php.ini file."));
     }
     $this->idList = $idList;
     $this->type = $this->checkType($type);
     $this->fileName = $this->getFileName();
     $this->filePath = $this->getTempFilePath($this->fileName);
     $this->createZipArchive();
     $this->loopIdArr();
 }
Пример #7
0
 /**
  * Need the path to zip tmp_name, the type and the db object
  *
  */
 public function __construct()
 {
     $this->pdo = Db::getConnection();
     $this->checkFileReadable();
     $this->checkMimeType();
     $this->target = $this->getTarget();
     // this is where we will extract the zip
     $this->tmpPath = ELAB_ROOT . 'uploads/tmp/' . uniqid();
     if (!mkdir($this->tmpPath)) {
         throw new Exception('Cannot create temporary folder');
     }
     $this->openFile();
     $this->readJson();
     $this->importAll();
 }
Пример #8
0
    require_once 'config.php';
} elseif (is_readable('../config.php')) {
    // we might be called from app folder
    require_once '../config.php';
} else {
    header('Location: install');
    exit;
}
// check for maintenance mode
if (file_exists(ELAB_ROOT . 'maintenance')) {
    die('Maintenance mode is enabled. Check back later.');
}
require_once ELAB_ROOT . 'vendor/autoload.php';
// SQL CONNECT
try {
    $pdo = \Elabftw\Elabftw\Db::getConnection();
} catch (Exception $e) {
    die('Error connecting to the database : ' . $e->getMessage());
}
// END SQL CONNECT
// require common stuff
require_once ELAB_ROOT . 'inc/functions.php';
// i18n (gettext)
if (isset($_SESSION['prefs']['lang'])) {
    $locale = $_SESSION['prefs']['lang'] . '.utf8';
} else {
    $locale = get_config('lang') . '.utf8';
}
$domain = 'messages';
putenv("LC_ALL={$locale}");
$res = setlocale(LC_ALL, $locale);
Пример #9
0
 /**
  * Just give me the Db object and I'm good to go
  *
  */
 public function __construct()
 {
     $this->pdo = Db::getConnection();
 }
Пример #10
0
 /**
  * Create the pdo object and check itemType and id
  * @param string $itemType Type of item (experiments or items)
  * @param int $itemId Id of our item
  *
  */
 public function __construct($itemType, $itemId)
 {
     $this->pdo = Db::getConnection();
     $this->itemType = $this->checkType($itemType);
     $this->checkItemId($itemId);
 }