td#pdf_logo {
text-align: right;
width: 25%;
+}
+
+div[dir=\'rtl\'] td#pdf_logo {
+ text-align: left;
+ width: 0%;
+}
+
+div[dir=rtl] td#pdf_assoname {
+ width: 100%;
+ margin-left: 25%;
}',
'model_parent' => null
),
* @package Galette
*
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2007-2018 The Galette Team
+ * @copyright 2007-2020 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @version SVN: $Id$
* @link http://galette.tuxfamily.org
* @name i18n
* @package Galette
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2007-2014 The Galette Team
+ * @copyright 2007-2020 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.7dev - 2007-07-06
private $dir = 'lang/';
private $path;
+ private $rtl_langs = [
+ 'ar',
+ 'az',
+ 'fa',
+ 'he',
+ 'ur'
+ ];
+
/**
* Default constructor.
* Initialize default language and set environment variables
$this->langs = $langs;
return $this->langs;
}
+
+ /**
+ * Is current language RTL?
+ *
+ * @return boolean
+ */
+ public function isRTL()
+ {
+ return in_array(
+ $this->getAbbrev(),
+ $this->rtl_langs
+ );
+ }
}
*/
require_once GALETTE_CONFIG_PATH . 'galette_tcpdf_config.php';
-/**
- * Require TCPDF class
- */
-require_once GALETTE_TCPDF_PATH . '/tcpdf.php';
-
/**
* PDF class for galette
*
const FONT_SIZE = 10;
protected $preferences;
+ protected $i18n;
private $model;
private $paginated = false;
protected $filename;
*/
public function __construct(Preferences $prefs, $model = null)
{
+ global $i18n;
+
$this->preferences = $prefs;
+ $this->i18n = $i18n;
parent::__construct('P', 'mm', 'A4', true, 'UTF-8');
//set some values
$this->SetCreator(PDF_CREATOR);
$name . ' (using Galette ' . GALETTE_VERSION . ')'
);
+ if ($this->i18n->isRTL()) {
+ $this->setRTL(true);
+ }
+
if ($model !== null) {
if ($model instanceof PdfModel) {
$this->model = $model;
'/' . $this->getAliasNbPages(),
0,
1,
- 'R'
+ ($this->i18n->isRTL() ? 'L' : 'R')
);
}
}
if (trim($this->model->hstyles) !== '') {
$html .= "<style>\n" . $this->model->hstyles . "\n</style>\n\n";
}
- $html .= $this->model->hheader;
+ $html .= "<div dir=\"".($this->i18n->isRTL() ? 'rtl' : 'ltr')."\">" . $this->model->hheader . "</div>";
$this->writeHtml($html, true, false, true, false, '');
if ($title !== null) {
6,
$this->preferences->pref_nom,
0,
- 'L'
+ ($this->i18n->isRTL() ? 'R' : 'L')
);
$this->SetFont(self::FONT, 'B', self::FONT_SIZE + 2);
if ($title !== null) {
- $this->Cell(0, 6, $title, 0, 1, 'L', 0);
+ $this->Cell(0, 6, $title, 0, 1, ($this->i18n->isRTL() ? 'R' : 'L'), 0);
}
$yend = $this->getY();//store position at the end of the text
$this->SetY($ystart);
- $x = 190 - $wlogo; //right align
+ if ($this->i18n->isRTL()) {
+ $x = $this->getX();
+ } else {
+ $x = 190 - $wlogo; //right align
+ }
$this->Image($logofile, $x, $this->GetY(), $wlogo, $hlogo);
$this->y += $hlogo + 3;
//if position after logo is < than position after text,
$mcount = 0;
foreach ($members as $m) {
$mcount++;
- $this->Cell(10, 16, $mcount, 'LTB', 0, 'R');
+ $this->Cell(10, 16, $mcount, ($this->i18n->isRTL() ? 'R' : 'L') . 'TB', 0, 'R');
if ($m->hasPicture() && $this->wimages) {
$p = $m->picture->getPath();
$y = $this->getY() + 1;
$x = $this->getX() + 1;
- $this->Cell($wlogo+2, 16, '', 'LTB', 0);
- $this->Image($p, $x, $y, $wlogo, $hlogo);
+ $ximg = $x;
+ if ($this->i18n->isRTL()) {
+ $ximg = $this->getPageWidth() - $x - $wlogo;
+ }
+ $this->Cell($wlogo+2, 16, '', ($this->i18n->isRTL() ? 'R' : 'L') . 'TB', 0);
+ $this->Image($p, $ximg, $y, $wlogo, $hlogo);
} else {
$x = $this->getX() + 1;
- $this->Cell(1, 16, '', 'LTB', 0);
+ $this->Cell(1, 16, '', ($this->i18n->isRTL() ? 'R' : 'L') . 'TB', 0);
}
$xs = $this->getX() - $x + 1;
- $this->Cell(100 - $xs, 16, $m->sname, 'RTB', 0, 'L');
- $this->Cell(80, 16, '', 1, 1, 'L');
+ $this->Cell(100 - $xs, 16, $m->sname, ($this->i18n->isRTL() ? 'L' : 'R') . 'TB', 0, ($this->i18n->isRTL() ? 'R' : 'L'));
+ $this->Cell(80, 16, '', 1, 1, ($this->i18n->isRTL() ? 'R' : 'L'));
}
$this->Cell(190, 0, '', 'T');
}
_T("Managers:") . ' ' . implode(', ', $managers),
0,
1,
- 'R'
+ ($this->i18n->isRTL() ? 'L' : 'R')
);
}
$this->ln(3);
$members = $group->getMembers();
foreach ($members as $m) {
- $this->Cell(80, 7, $m->sname, 1, 0, 'L');
- $this->Cell(50, 7, $m->email, 1, 0, 'L');
- $this->Cell(30, 7, $m->phone, 1, 0, 'L');
- $this->Cell(30, 7, $m->gsm, 1, 1, 'L');
+ $align = ($this->i18n->isRTL() ? 'R' : 'L');
+ $this->Cell(80, 7, $m->sname, 1, 0, $align);
+ $this->Cell(50, 7, $m->email, 1, 0, $align);
+ $this->Cell(30, 7, $m->phone, 1, 0, $align);
+ $this->Cell(30, 7, $m->gsm, 1, 1, $align);
}
$this->Cell(190, 0, '', 'T');
$first = false;
public function __construct(Preferences $prefs)
{
parent::__construct($prefs);
+ $this->setRTL(false);
$this->filename = __('cards') . '.pdf';
$this->init();
}
public function __construct(Preferences $prefs)
{
parent::__construct($prefs);
+ $this->setRTL(false);
$this->filename = __('labels_print_filename') . '.pdf';
$this->init();
}