Example #1
0
 static function content($idGroup, $notices, $modo)
 {
     $pdf = new GenerarPDF($modo);
     $pdf->Portada($idGroup);
     $pdf->SetFont('Times', '', 12);
     $i = 1;
     $authorAndNotice = array();
     $authors = array();
     $days = array();
     $date = '';
     foreach ($notices as $notice) {
         $dateTmp = substr($notice->created, 0, 10);
         if ($dateTmp != $date) {
             $date = $dateTmp;
             $pdf->Ln(10);
             $pdf->SetFont('Arial', 'BU', 12);
             // Escribimos la fecha
             $pdf->Write(5, $date);
             $pdf->Ln(5);
             $tags = NotesPDF::getTopTagsInADay($idGroup, $dateTmp);
             //Escribimos los tags
             $pdf->SetFont('Arial', 'I', 12);
             // Escribimos la fecha
             $pdf->Write(5, 'Top tags:  ' . implode(', ', $tags));
             $pdf->Ln(5);
             $pdf->SetFont('Times', '', 12);
         }
         $pdf->Ln(10);
         $filterContent = $pdf->filtrarContenido($notice->content);
         $filterContent = $filterContent . " [" . $i . "]";
         $pdf->Write(5, $filterContent);
         $authorAndNotice[$i] = strtoupper($notice->getProfile()->getBestName());
         $authors[] = strtoupper($notice->getProfile()->getBestName());
         $i = $i + 1;
     }
     $pdf->Fuentes($authorAndNotice, array_unique($authors));
     $pdf->Output('apuntes.pdf', 'D');
 }
Example #2
0
 /**
  * Class handler.
  *
  * @param array $args query arguments
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (!common_logged_in()) {
         $this->clientError(_('Not logged in.'));
         return;
     }
     $user = common_current_user();
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         common_redirect(common_local_url('all', array('nickname' => $user->nickname)));
         return;
     }
     $idGroup = $this->trimmed('idGroup');
     $token = $this->trimmed('token-' . $idGroup);
     if (!$token || $token != common_session_token()) {
         $this->clientError(_('There was a problem with your session token. Try again, please.'));
         return;
     }
     if ($this->trimmed('submit-auto') != null) {
         $groupids = NotesPDF::getNoticeIDsInAGroupModeAuto($idGroup);
         $notices = Notice::multiGet('id', $groupids)->fetchAll();
         GenerarPDF::content($idGroup, $notices, 'Automáticos');
     } else {
         if ($this->trimmed('submit-custom') != null) {
             $tag = $this->trimmed('combo-tag') == 'Todos' ? '%' : $this->trimmed('combo-tag');
             $nick = $this->trimmed('combo-user') == 'Todos' ? '%' : $this->trimmed('combo-user');
             $grade = $this->trimmed('combo-grade') == 'Todos' ? '%' : $this->trimmed('combo-grade');
             $noticeIds = NotesPDF::getNoticesInModeCustom(array('idGroup' => $idGroup, 'tag' => $tag, 'nick' => $nick, 'grade' => $grade));
             $notices = Notice::multiGet('id', $noticeIds)->fetchAll();
             GenerarPDF::content($idGroup, $notices, 'Personalizados');
         } else {
             $this->showForm('Error al generar los apuntes. Inténtelo de nuevo en unos minutos.');
         }
     }
 }