Permalink
Browse files

Added possibility to set the base url

  • Loading branch information...
1 parent 99cb9f6 commit b87c076a783a2bdf5f120b5b3597dc814390bdf8 @lsolesen lsolesen committed May 3, 2012
@@ -6,13 +6,25 @@ abstract class VIH_Lectures_Pdf_Base extends TCPDF {
protected $sub_title = 'Kom og høre med!';
protected $description = 'description';
protected $logo;
- protected $events;
+ protected $events = array();
+ protected $link = '';
+ protected $base_url = '';
+ protected $author;
+
+ function setBaseUrl($base_url) {
+ $this->base_url = $base_url;
+ }
+
+ function setAuthor($author) {
+ $this->author = $author;
+ }
/**
* @param string $logo Path to the logo
*/
- function setLogo($logo) {
+ function setLogo($logo, $link = null) {
$this->logo = $logo;
+ $this->link = $link;
}
function setHeading($title) {
@@ -72,7 +72,7 @@ class VIH_Lectures_Pdf_Portrait_pictures extends VIH_Lectures_Pdf_Base {
$this->SetFont($this->frontpage_font, 'B', 40);
$this->MultiCell(0, 0, $this->sub_title, null, 'C');
if (!empty($this->logo) && file_exists($this->logo)) {
- $this->Image($this->logo, 55, 230, 100, 0, '', 'http://vih.dk/');
+ $this->Image($this->logo, 55, 230, 100, 0, '', $this->link);
}
}
@@ -89,7 +89,7 @@ class VIH_Lectures_Pdf_Portrait_pictures extends VIH_Lectures_Pdf_Base {
$this->writeHtmlCell(190, 10, $this->GetX(), $this->GetY(), $this->description, 0);
$this->Line(0, 245, 220, 245);
if (!empty($this->logo) && file_exists($this->logo)) {
- $this->Image($this->logo, 150, 255, 50, 0, '', 'http://vih.dk/');
+ $this->Image($this->logo, 150, 255, 50, 0, '', $this->link);
}
}
@@ -102,7 +102,7 @@ class VIH_Lectures_Pdf_Portrait_pictures extends VIH_Lectures_Pdf_Base {
$picture_filename = drupal_realpath(image_style_path('sidepicture', $picture[0]['uri']));
$location = trim($event->field_location['und'][0]['safe_value']);
$price = trim($event->field_price['und'][0]['value']);
- $tilmelding = 'http://vih.dk/node/' . $event->nid;
+ $tilmelding = $this->base_url . '/node/' . $event->nid;
$start_date = new DateTime($event->field_date['und'][0]['value'], new DateTimeZone($event->field_date['und'][0]['timezone']));
$end_date = new DateTime($event->field_date['und'][0]['value2'], new DateTimeZone($event->field_date['und'][0]['timezone']));
$date = ucfirst($this->t($start_date->format('l')) . ', ' . $start_date->format('j.') . $this->t($start_date->format('F')) . ', ' . $start_date->format('Y H:i') . '-' . $end_date->format('H:i'));
@@ -132,7 +132,7 @@ class VIH_Lectures_Pdf_Portrait_pictures extends VIH_Lectures_Pdf_Base {
$this->Image($qr_file, 4, 250, 35, 0, '');
}
if (!empty($this->logo) && file_exists($this->logo)) {
- $this->Image($this->logo, 150, 255, 50, 0, '', 'http://vih.dk/');
+ $this->Image($this->logo, 150, 255, 50, 0, '', $this->link);
}
$x = 40;
$this->setY(252);
@@ -157,7 +157,7 @@ class VIH_Lectures_Pdf_Portrait_pictures extends VIH_Lectures_Pdf_Base {
public function render() {
$this->SetTitle($this->heading);
$this->SetSubject($this->sub_title);
- $this->SetAuthor('Vejle Idrætshøjskole');
+ $this->SetAuthor($this->author);
$this->SetAutoPageBreak(false);
foreach ($this->events as $event) {
$this->addEventPage($event);
@@ -17,8 +17,9 @@ function vih_lectures_pdf_menu() {
'type' => MENU_LOCAL_ACTION,
);
- $items['admin/vih/lectures'] = array(
+ $items['admin/config/vih/lectures'] = array(
'title' => 'Lectures',
+ 'description' => 'Settings for printout of the lectures',
'page callback' => 'drupal_get_form',
'page arguments' => array('vih_lectures_pdf_admin_settings'),
'access arguments' => array('access content'),
@@ -91,6 +92,7 @@ function vih_lectures_pdf_layouts() {
}
function vih_lectures_pdf_admin_settings() {
+ global $base_url;
$options = array();
foreach (vih_lectures_pdf_get_layouts() as $key => $layout) {
$options[$key] = $key;
@@ -116,6 +118,15 @@ function vih_lectures_pdf_admin_settings() {
'#upload_location' => 'public://logo/',
);
+ $form['vih_lectures_pdf']['link'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Link'),
+ '#default_value' => variable_get('vih_lectures_pdf_link', $base_url),
+ '#description' => t("Link to use for the logo"),
+ '#required' => TRUE,
+ );
+
+
$form['#submit'][] = 'vih_lectures_pdf_admin_settings_submit';
return system_settings_form($form);
}
@@ -126,6 +137,7 @@ function vih_lectures_pdf_admin_settings_validate($form, &$form_state) {
function vih_lectures_pdf_admin_settings_submit($form, &$form_state) {
variable_set('vih_lectures_pdf_layout', $form_state['values']['layout']);
+ variable_set('vih_lectures_pdf_link', $form_state['values']['link']);
// @see http://drupal.org/node/1090198
global $user;
@@ -160,7 +172,7 @@ function vih_lectures_pdf_admin_settings_submit($form, &$form_state) {
function vih_lectures_pdf_booklet($lecture) {
require_once libraries_get_path('tcpdf') . '/tcpdf.php';
-
+ global $base_url;
$events = array();
$layout = variable_get('vih_lectures_pdf_layout', 'portrait');
ctools_include('Layout', 'vih_lectures_pdf', 'plugins/layouts/' . $layout);
@@ -178,7 +190,9 @@ function vih_lectures_pdf_booklet($lecture) {
$events[] = $lecture;
}
$pdf = new $class($events);
+ $pdf->setBaseUrl($base_url);
$pdf->setHeading($lecture->title);
+ $pdf->setAuthor(variable_get('site_name', "Vejle Idrætshøjskole"));
if ($logo = file_load(variable_get('vih_lectures_pdf_logo', ''))) {
$pdf->setLogo(drupal_realpath($logo->uri));
}

0 comments on commit b87c076

Please sign in to comment.