Example #1
0
     }
     $content = (string) $_POST['content'];
     $md5 = md5($content);
 }
 if ($md5 === null) {
     $response->sendCallError('URL ou contenu manquant');
 }
 // Start print to PDF : get an older print if it exists
 try {
     $api_print = ApiPrint::retrieveByUserAndMd5($api_user, $md5);
 } catch (Exception $e) {
     $response->sendCallError('Impossible to get content');
 }
 // New print...
 if ($api_print === null) {
     $api_print = new ApiPrint();
     $api_print->setIdUser($api_user->getId());
     if ($url !== null) {
         $api_print->setUrl($url);
     } elseif ($content !== null) {
         $api_print->setContent($content);
     } else {
         $response->sendDisastrousError('Logical error : no content, no url');
     }
     $api_print->setMd5($md5);
     $api_print->setNb(0);
 }
 // Print to PDF
 try {
     // Check the options
     if (isset($_POST['options']) === true && is_array($_POST['options']) === true) {
 /**
  * Generate the PDF filename according to md5 and options
  * 
  * @param   string  $md5      The md5 of the URL or content
  * @param   array   $options  The options table
  * @return  string            The absolute PDF file (with path)
  * @access  private
  * @static
  * @since   1.0.0
  */
 private static function getPdfTmpFilename($md5, $options = array())
 {
     $folder = ApiPrint::getPdfTmpFolder();
     $filename = sha1($md5 . serialize($options));
     return $folder . '/' . $filename . '.pdf';
 }