diff --git a/.gitignore b/.gitignore index 00530e1c83fc6858a098fb4c55d71090643c9b7f..3f02437e02e80eb03aa1bdc0a0c90ad51a2a112e 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,7 @@ stage # Ignore packaged plugins and language packs *.phar + +# Ignore mPDF temp files +include/mpdf/ttfontdata +include/mpdf/tmp diff --git a/css/filedrop.css b/css/filedrop.css index fc2b96d910b6980cb107af06f3bbb3f1c79e5709..96dca339e9736b699b9249ef44c799c0584eacd7 100644 --- a/css/filedrop.css +++ b/css/filedrop.css @@ -26,15 +26,19 @@ margin: 0; border-radius: 5px; } +.rtl .filedrop .files .file { + padding-left: 10px; + padding-right: 20px; +} .filedrop .files .file:hover { background-color: rgba(0, 0, 0, 0.05); } .filedrop .files .file .filesize { - margin-left: 1em; + margin: 0 1em; color: #999; } .filedrop .files .file .upload-rate { - margin-right: 10px; + margin: 0 10px; color: #aaa; } .filedrop .files .file .trash { @@ -55,6 +59,11 @@ float: left; padding-right: 10px; } +.rtl .filedrop .preview { + padding-right: initial; + padding-left: 10px; + float: right; +} .redactor_box + .filedrop .dropzone, .redactor_box + div > .filedrop .dropzone, .redactor_box + div > .filedrop .files { @@ -113,6 +122,9 @@ -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); } +.rtl .progress-bar { + float: right; +} .progress-bar:not(.active) { -webkit-transition: width .6s ease; -o-transition: width .6s ease; diff --git a/css/redactor.css b/css/redactor.css index cd84755209f82d0407b68f368cbd8978c48346a8..e6123e23e60353cf93e5282574538fee093b7fec 100644 --- a/css/redactor.css +++ b/css/redactor.css @@ -187,7 +187,6 @@ body .redactor_box_fullscreen { .redactor_editor img { height: auto; } -.redactor_editor div, .redactor_editor p, .redactor_editor ul, .redactor_editor ol, @@ -207,10 +206,14 @@ body .redactor_box_fullscreen { margin-bottom: 15px !important; } .redactor_editor blockquote { - margin-left: 1.5em !important; - padding-left: 0 !important; color: #777; + padding: 10px 20px; font-style: italic !important; + border-left: 5px solid #eeeeee; +} +[dir="rtl"] .redactor_editor blockquote { + border-left: none; + border-right: 5px solid #eeeeee; } .redactor_editor ul, .redactor_editor ol { diff --git a/css/rtl.css b/css/rtl.css index b784117a74cc7cabc839483a06b252bd0892b7a1..b66cbe61a1c7ca17d6ef3cdd7ec5181bcbd7cd44 100644 --- a/css/rtl.css +++ b/css/rtl.css @@ -49,6 +49,7 @@ } .rtl #msg_notice, .rtl #warning_bar, +.rtl #msg_warning, .rtl #msg_error, .rtl .error-banner { background-position: 99% 50%; @@ -69,3 +70,74 @@ right: initial; left: 0.5em; } +.rtl #sequences .manage-buttons { + margin-right: initial; + margin-left: 60px; +} +.rtl .row-item .button-group { + right: initial; + left: 0; +} +.rtl .row-item .button-group div { + padding-left: 9px; + padding-right: 12px; +} +.rtl .row-item .delete { + border-left: none; + border-right: 1px solid rgba(0,0,0,0.7); +} +.rtl [class^="icon-"].pull-left, [class*=" icon-"].pull-left { + margin-right: 0; + margin-left: 0.3em; +} +.rtl ul.tabs { + padding-left: 4px; + padding-right: 20px; + text-align:right; +} +.rtl #response_options ul.tabs { + padding-right:190px; + padding-left: 4px; +} +.rtl .action-button i.icon-caret-down { + border-left: none; + border-right: 1px solid #aaa; + margin-left: 0; + margin-right: 5px; + padding-left: 0; + padding-right: 5px; +} +.rtl .action-dropdown ul { + text-align: right; +} +.rtl .file { + padding-left: initial; + padding-right: 20px; + margin-right: initial; + margin-left: 20px; + background: url(../scp/images/icons/file.gif) 100% 50% no-repeat; +} +.rtl .floating-options { + right: auto; + left: 0; + padding-right: initial; + padding-left: 5px; +} +.rtl .quicknote .header .header-right { + right: auto; + left: 1em; +} +.rtl .quicknote .header .options { + border-right: 1px solid rgba(0,0,0,0.2); + border-left: none; + padding-right: 10px; + padding-left: initial; + margin-right: 5px; + margin-left: initial; +} +.rtl i.note-type { + border-left: 1px solid rgba(0, 0, 0, 0.2); + border-right: none; + padding-left: 8px; + padding-right: initial; +} diff --git a/css/thread.css b/css/thread.css index 049165780c799beed80f45e1e4fc8f1f24a0cb65..cdf25a7200d7b0365283e88a2fe6760c66c86fa7 100644 --- a/css/thread.css +++ b/css/thread.css @@ -394,7 +394,7 @@ .thread-body blockquote, .thread-body pre { font-size: 14px; - line-height: 1.25rem; + line-height: 1.4rem; } /* Adjust plain/text messages posted as <pre> in the thread body to show in diff --git a/include/class.i18n.php b/include/class.i18n.php index d3362e5d33b66ff5eaf401de17278cc54a894f0c..4a9540520c26816b0c405ccfe318402ecf6ef840 100644 --- a/include/class.i18n.php +++ b/include/class.i18n.php @@ -332,6 +332,29 @@ class Internationalization { return self::getDefaultLanguage(); } + static function getTtfFonts() { + if (!class_exists('Phar')) + return; + $fonts = $subs = array(); + foreach (self::availableLanguages() as $code=>$info) { + if (!$info['phar'] || !isset($info['fonts'])) + continue; + foreach ($info['fonts'] as $simple => $collection) { + foreach ($collection as $type => $name) { + list($name, $url) = $name; + $ttffile = 'phar://' . $info['path'] . '/fonts/' . $name; + if (file_exists($ttffile)) + $fonts[$simple][$type] = $ttffile; + } + if (@$collection[':sub']) + $subs[] = $simple; + } + } + $rv = array($fonts, $subs); + Signal::send('config.ttfonts', null, $rv); + return $rv; + } + static function bootstrap() { require_once INCLUDE_DIR . 'class.translation.php'; diff --git a/include/client/faq.inc.php b/include/client/faq.inc.php index 6d5950058945c483058605dbfdbefe630ef1e1e2..2ccc475e0349e3e83e5a80eab71a0c9eba9ab156 100644 --- a/include/client/faq.inc.php +++ b/include/client/faq.inc.php @@ -9,10 +9,10 @@ $category=$faq->getCategory(); <a href="index.php"><?php echo __('All Categories');?></a> » <a href="faq.php?cid=<?php echo $category->getId(); ?>"><?php echo $category->getName(); ?></a> </div> -<div style="width:700px;padding-top:2px; float:left;"> +<div style="width:700px;padding-top:2px;" class="pull-left"> <strong style="font-size:16px;"><?php echo $faq->getQuestion() ?></strong> </div> -<div style="float:right;text-align:right;padding-top:5px;padding-right:5px;"></div> +<div class="pull-right flush-right" style="padding-top:5px;padding-right:5px;"></div> <div class="clear"></div> <p> <?php echo Format::safe_html($faq->getAnswerWithImages()); ?> diff --git a/include/client/view.inc.php b/include/client/view.inc.php index 1867ac467ab9b3ac50496c6f00c63c0abad3d150..dc3a0419f97a353471b6a87f7dc4ad1453b5b881 100644 --- a/include/client/view.inc.php +++ b/include/client/view.inc.php @@ -36,7 +36,7 @@ if ($thisclient && $thisclient->isGuest() <?php if ($cfg->allowClientUpdates() // Only ticket owners can edit the ticket details (and other forms) && $thisclient->getId() == $ticket->getUserId()) { ?> - <a class="action-button" href="tickets.php?a=edit&id=<?php + <a class="action-button pull-right" href="tickets.php?a=edit&id=<?php echo $ticket->getId(); ?>"><i class="icon-edit"></i> Edit</a> <?php } ?> </h1> diff --git a/include/i18n/langs.php b/include/i18n/langs.php index 205ba63fdcfb82b0bf9d77bb791c3dd5c7543b74..f48058009fb70d51aabcd144716a8972ea8baa1a 100644 --- a/include/i18n/langs.php +++ b/include/i18n/langs.php @@ -641,7 +641,22 @@ return array( ), "th" => array( "name" => "Thai", - "nativeName" => "ไทย" + "nativeName" => "ไทย", + "fonts" => array( + "garuda" => array( + 'R' => array("Garuda.ttf","http://www.osticket.com/sites/default/files/fonts/Garuda.ttf"), + 'B' => array("Garuda-Bold.ttf","http://www.osticket.com/sites/default/files/fonts/Garuda-Bold.ttf"), + 'I' => array("Garuda-Oblique.ttf","http://www.osticket.com/sites/default/files/fonts/Garuda-Oblique.ttf"), + 'BI' => array("Garuda-BoldOblique.ttf","http://www.osticket.com/sites/default/files/fonts/Garuda-BoldOblique.ttf"), + ':sub' => true, + ), + "norasi" => array( + 'R' => array("Norasi.ttf","http://www.osticket.com/sites/default/files/fonts/Norasi.ttf"), + 'B' => array("Norasi-Bold.ttf","http://www.osticket.com/sites/default/files/fonts/Norasi-Bold.ttf"), + 'I' => array("Norasi-Oblique.ttf","http://www.osticket.com/sites/default/files/fonts/Norasi-Oblique.ttf"), + 'BI' => array("Norasi-BoldOblique.ttf","http://www.osticket.com/sites/default/files/fonts/Norasi-BoldOblique.ttf"), + ), + ), ), "ti" => array( "name" => "Tigrinya", diff --git a/include/mpdf/classes/cssmgr.php b/include/mpdf/classes/cssmgr.php index c6eff8e9eafdd3d1a377c89e74c90c9252c10c14..aef74542d44b0ab9019f40841162b59464151750 100755 --- a/include/mpdf/classes/cssmgr.php +++ b/include/mpdf/classes/cssmgr.php @@ -221,9 +221,8 @@ function ReadCSS($html) { } } - // mPDF 5.5.13 // Replace any background: url(data:image... with temporary image file reference - preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*)\))/si", $CSSstr, $idata); + preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*?)\))/si", $CSSstr, $idata); // mPDF 5.7.2 if (count($idata[0])) { for($i=0;$i<count($idata[0]);$i++) { $file = _MPDF_TEMP_PATH.'_tempCSSidata'.RAND(1,10000).'_'.$i.'.'.$idata[2][$i]; @@ -699,6 +698,13 @@ function fixCSS($prop) { } else { $newprop[$k] = $v; } } + else if ($k == 'LIST-STYLE') { // mPDF 5.7.2 + if (preg_match('/(lower-roman|upper-roman|lower-latin|lower-alpha|upper-latin|upper-alpha|none|decimal|disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao)/i',$v,$m) + || preg_match('/U\+([a-fA-F0-9]+)/i',$v,$m)) { + $newprop['LIST-STYLE-TYPE'] = strtolower(trim($m[1])); + } + } + else { $newprop[$k] = $v; @@ -1241,8 +1247,13 @@ function MergeCSS($inherit,$tag,$attr) { } //=============================================== /*-- TABLES --*/ + // mPDF 5.7.3 + // cellSpacing overwrites TABLE default but not specific CSS set on table + if ($tag=='TABLE' && isset($attr['CELLSPACING'])) { + $p['BORDER-SPACING-H'] = $p['BORDER-SPACING-V'] = $attr['CELLSPACING']; + } // cellPadding overwrites TD/TH default but not specific CSS set on cell - if (($tag=='TD' || $tag=='TH') && isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']) && ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding'] || $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']===0)) { + if (($tag=='TD' || $tag=='TH') && isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']) && ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding'] || $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']==='0')) { // mPDF 5.7.3 $p['PADDING-LEFT'] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']; $p['PADDING-RIGHT'] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']; $p['PADDING-TOP'] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cell_padding']; diff --git a/include/mpdf/config.php b/include/mpdf/config.php index 55c64b648720b27311818dee1b3944a3bf401a6e..fa4fc26e7036b6bec38fe8da4bbdc9c433192d80 100755 --- a/include/mpdf/config.php +++ b/include/mpdf/config.php @@ -60,7 +60,7 @@ $this->maxTTFFilesize = 2000; // and/or Can set at runtime $this->percentSubset = 30; -$this->useAdobeCJK = false; // Uses Adobe CJK fonts for CJK languages +$this->useAdobeCJK = true; // Uses Adobe CJK fonts for CJK languages // default TRUE; only set false if you have defined some available fonts that support CJK // If true this will not stop use of other CJK fonts if specified by font-family: // and vice versa i.e. only dictates behaviour when specified by lang="" incl. AutoFont() @@ -77,7 +77,7 @@ $this->biDirectional=false; // automatically determine BIDI text in LTR page $this->autoFontGroupSize = 2; // 1: individual words are spanned; 2: words+; 3: as big chunks as possible. $this->useLang = true; // Default changed in mPDF 4.0 -$this->useSubstitutions = false; // Substitute missing characters in UTF-8(multibyte) documents - from other fonts +$this->useSubstitutions = true; // Substitute missing characters in UTF-8(multibyte) documents - from other fonts $this->falseBoldWeight = 5; // Weight for bold text when using an artificial (outline) bold; value 0 (off) - 10 (rec. max) // CONFIGURATION @@ -561,10 +561,10 @@ $this->fontsizes = array('XX-SMALL'=>0.7, 'X-SMALL'=>0.77, 'SMALL'=>0.86, 'MEDIU $this->allowedCSStags = 'DIV|P|H1|H2|H3|H4|H5|H6|FORM|IMG|A|BODY|TABLE|HR|THEAD|TFOOT|TBODY|TH|TR|TD|UL|OL|LI|PRE|BLOCKQUOTE|ADDRESS|DL|DT|DD'; $this->allowedCSStags .= '|ARTICLE|ASIDE|FIGURE|FIGCAPTION|FOOTER|HEADER|HGROUP|NAV|SECTION|MARK|DETAILS|SUMMARY|METER|PROGRESS|TIME'; // mPDF 5.5.09 $this->allowedCSStags .= '|SPAN|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|STRIKE|S|U|DEL|INS|Q|FONT'; -$this->allowedCSStags .= '|SELECT|INPUT|TEXTAREA|CAPTION|FIELDSET|LEGEND'; // mPDF 5.4.18 -$this->allowedCSStags .= '|TEXTCIRCLE|DOTTAB'; // mPDF 5.5.23 // mPDF 5.6.33 +$this->allowedCSStags .= '|SELECT|INPUT|TEXTAREA|CAPTION|FIELDSET|LEGEND'; +$this->allowedCSStags .= '|TEXTCIRCLE|DOTTAB|MAIN'; // mPDF 5.7.3 -$this->outerblocktags = array('DIV','FORM','CENTER','DL','FIELDSET','ARTICLE','ASIDE','FIGURE','FIGCAPTION', 'FOOTER','HEADER','HGROUP','NAV','SECTION','DETAILS','SUMMARY'); // mPDF 5.5.09 // mPDF 5.5.22 +$this->outerblocktags = array('DIV','FORM','CENTER','DL','FIELDSET','ARTICLE','ASIDE','FIGURE','FIGCAPTION', 'FOOTER','HEADER','HGROUP','MAIN','NAV','SECTION','DETAILS','SUMMARY'); // mPDF 5.7.3 $this->innerblocktags = array('P','BLOCKQUOTE','ADDRESS','PRE','H1','H2','H3','H4','H5','H6','DT','DD','CAPTION'); diff --git a/include/mpdf/config_fonts.php b/include/mpdf/config_fonts.php index ab6c8a7247299b92484904e755c0ce1635e2987f..31c4e3015c289a003309130f9731ec82d52bf257 100755 --- a/include/mpdf/config_fonts.php +++ b/include/mpdf/config_fonts.php @@ -129,7 +129,7 @@ $this->fontdata = array( 'R' => "ocrb10.ttf", ), -/* Thai fonts */ +/* Thai fonts "garuda" => array( 'R' => "Garuda.ttf", 'B' => "Garuda-Bold.ttf", @@ -301,4 +301,12 @@ $this->mono_fonts = array('dejavusansmono','freemono','liberationmono','courier' 'couriernew','monotypecorsiva' ); -?> \ No newline at end of file +// Add fonts from language packs + +list($phar_fonts, $phar_subs) = Internationalization::getTtfFonts(); +$this->fontdata += $phar_fonts; +foreach ($phar_subs as $simple) { + if (!in_array($simple, $this->backupSubsFont)) + $this->backupSubsFont[] = $simple; +} +?> diff --git a/include/mpdf/includes/functions.php b/include/mpdf/includes/functions.php index 91e75da4a8ef1ad076f9c56055d22009e62ad275..ce88e6f476d467a77548094dd35d01762c0d90ec 100755 --- a/include/mpdf/includes/functions.php +++ b/include/mpdf/includes/functions.php @@ -1,5 +1,13 @@ <?php +// mPDF 5.7 +// Replace a section of an array with the elements in reverse +function array_splice_reverse(&$arr, $offset, $length) { + $tmp = (array_reverse(array_slice($arr, $offset, $length))); + array_splice($arr, $offset, $length, $tmp); +} + + // mPDF 5.6.23 function array_insert(&$array, $value, $offset) { if (is_array($array)) { @@ -92,12 +100,30 @@ function PreparePreText($text,$ff='//FF//') { if(!function_exists('strcode2utf')){ function strcode2utf($str,$lo=true) { //converts all the &#nnn; and &#xhhh; in a string to Unicode - if ($lo) { $lo = 1; } else { $lo = 0; } - $str = preg_replace('/\&\#([0-9]+)\;/me', "code2utf('\\1',{$lo})",$str); - $str = preg_replace('/\&\#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\\1',{$lo})",$str); + // mPDF 5.7 + if ($lo) { + $str = preg_replace_callback('/\&\#([0-9]+)\;/m', 'code2utf_lo_callback', $str); + $str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', 'codeHex2utf_lo_callback', $str); + } + else { + $str = preg_replace_callback('/\&\#([0-9]+)\;/m', 'code2utf_callback', $str); + $str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', 'codeHex2utf_callback', $str); + } return $str; } } +function code2utf_callback($matches) { + return code2utf($matches[1], 0); +} +function code2utf_lo_callback($matches) { + return code2utf($matches[1], 1); +} +function codeHex2utf_callback($matches) { + return codeHex2utf($matches[1], 0); +} +function codeHex2utf_lo_callback($matches) { + return codeHex2utf($matches[1], 1); +} if(!function_exists('code2utf')){ function code2utf($num,$lo=true){ diff --git a/include/mpdf/mpdf.php b/include/mpdf/mpdf.php index 91d310dda8dc9c810d5697873de236a2f5a7b3a1..af04fa3b483c53e838bd8f4835d2443dbe073764 100755 --- a/include/mpdf/mpdf.php +++ b/include/mpdf/mpdf.php @@ -2,10 +2,10 @@ // ****************************************************************************** // Software: mPDF, Unicode-HTML Free PDF generator * -// Version: 5.7 based on * +// Version: 5.7.3 based on * // FPDF by Olivier PLATHEY * // HTML2FPDF by Renato Coelho * -// Date: 2013-07-14 * +// Date: 2013-09-01 * // Author: Ian Back <ianb@bpm1.com> * // License: GPL * // * @@ -13,7 +13,7 @@ // ****************************************************************************** -define('mPDF_VERSION','5.7'); +define('mPDF_VERSION','5.7.3'); //Scale factor define('_MPDFK', (72/25.4)); @@ -269,6 +269,7 @@ var $directw; ////////////////////// // INTERNAL VARIABLES ////////////////////// +var $uniqstr; // mPDF 5.7.2 var $writingToC; // mPDF 5.6.38 // mPDF 5.6.01 var $layers; @@ -336,6 +337,10 @@ var $pdf_version; var $noImageFile; var $lastblockbottommargin; var $baselineC; +// mPDF 5.7.3 inline text-decoration parameters +var $baselineSup; +var $baselineSub; +var $baselineS; var $subPos; var $subArrMB; var $ReqFontStyle; @@ -613,7 +618,6 @@ var $divheight; var $divrevert; var $spanbgcolor; -var $spanlvl; var $listlvl; var $listnum; var $listtype; @@ -850,6 +854,7 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1 $this->useSubstitutionsMB =& $this->useSubstitutions; $this->writingToC = false; // mPDF 5.6.38 + $this->uniqstr = '20110230'; // mPDF 5.7.2 // mPDF 5.6.01 $this->layers = array(); $this->current_layer = 0; @@ -977,6 +982,11 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1 $this->baselineC = 0.35; // Baseline for text + // mPDF 5.7.3 inline text-decoration parameters + $this->baselineSup = 0.5; // Sets default change in baseline for <sup> text bas factor of preceeding fontsize + $this->baselineSub = -0.2; // Sets default change in baseline for <sub> text bas factor of preceeding fontsize + $this->baselineS = 0.3; // Sets default height for <strike> text as factor of fontsize + $this->noImageFile = str_replace("\\","/",dirname(__FILE__)) . '/includes/no_image.jpg'; $this->subPos = 0; $this->forceExactLineheight = false; @@ -1146,7 +1156,7 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1 $optcore = false; $onlyCoreFonts = false; if (preg_match('/([\-+])aCJK/i',$mode, $m)) { - preg_replace('/([\-+])aCJK/i','',$mode); + $mode = preg_replace('/([\-+])aCJK/i','',$mode); if ($m[1]=='+') { $this->useAdobeCJK = true; } else { $this->useAdobeCJK = false; } } @@ -1210,7 +1220,9 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1 $this->useSubstitutions = true; $this->SetSubstitutions(); } - else { $this->useSubstitutions = false; } + // osTicket custom — seems that substitions are necessary for eastern + // languages to work with packaged fonts + //else { $this->useSubstitutions = false; } /*-- HTML-CSS --*/ @@ -1682,8 +1694,8 @@ function SetAlpha($alpha, $bm='Normal', $return=false, $mode='B') { $alpha = 1; } $a = array('BM'=>'/'.$bm); - if ($mode=='F' || $mode='B') $a['ca'] = $alpha; - if ($mode=='S' || $mode='B') $a['CA'] = $alpha; + if ($mode=='F' || $mode=='B') $a['ca'] = $alpha; // mPDF 5.7.2 + if ($mode=='S' || $mode=='B') $a['CA'] = $alpha; // mPDF 5.7.2 $gs = $this->AddExtGState($a); if ($return) { return sprintf('/GS%d gs', $gs); } else { $this->_out(sprintf('/GS%d gs', $gs)); } @@ -1765,7 +1777,7 @@ function Close() { $s .= $this->PrintBodyBackgrounds(); $s .= $this->PrintPageBackgrounds(); - $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', "\n".$s."\n".'\\1', $this->pages[$this->page]); + $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$s."\n".'\\1', $this->pages[$this->page]); $this->pageBackgrounds = array(); if($this->visibility!='visible') @@ -2246,9 +2258,124 @@ function PrintTableBackgrounds($adjustmenty=0) { $w = $pb['w']*_MPDFK; $h = -$pb['h']*_MPDFK; if (isset($pb['clippath']) && $pb['clippath']) { $s .= $pb['clippath']."\n"; } - if ($pb['opacity']>0 && $pb['opacity']<1) { $opac = $this->SetAlpha($pb['opacity'],'Normal',true); } - else { $opac = ''; } - $s .= sprintf('q /Pattern cs /P%d scn %s %.3F %.3F %.3F %.3F re f Q', $n, $opac, $x, $y, $w, $h) ."\n"; + + // mPDF 5.7.3 + if (($this->writingHTMLfooter || $this->writingHTMLheader) && (!isset($pb['clippath']) || $pb['clippath']=='') ) { + // Set clipping path + $pb['clippath'] = sprintf(' q 0 w %.3F %.3F m %.3F %.3F l %.3F %.3F l %.3F %.3F l %.3F %.3F l W n ', $x, $y, $x, $y+$h, $x+$w, $y+$h, $x+$w, $y, $x, $y); + } + + if (isset($pb['clippath']) && $pb['clippath']) { $s .= $pb['clippath']."\n"; } + + // mPDF 5.7.3 + if ($this->writingHTMLfooter || $this->writingHTMLheader) { // Write each (tiles) image rather than use as a pattern + $iw = $pb['orig_w']/_MPDFK; + $ih = $pb['orig_h']/_MPDFK; + + $w = $pb['w']; + $h = $pb['h']; + $x0 = $pb['x']; + $y0 = $pb['y']; + + if (isset($pb['bpa']) && $pb['bpa']) { + $w = $pb['bpa']['w']; + $h = $pb['bpa']['h']; + $x0 = $pb['bpa']['x']; + $y0 = $pb['bpa']['y']; + } + + if (isset($pb['size']['w']) && $pb['size']['w']) { + $size = $pb['size']; + + if ($size['w']=='contain') { + // Scale the image, while preserving its intrinsic aspect ratio (if any), to the largest size such that both its width and its height can fit inside the background positioning area. + // Same as resize==3 + $ih = $ih * $pb['bpa']['w']/$iw; + $iw = $pb['bpa']['w']; + if ($ih > $pb['bpa']['h']) { + $iw = $iw * $pb['bpa']['h']/$ih; + $ih = $pb['bpa']['h']; + } + } + else if ($size['w']=='cover') { + // Scale the image, while preserving its intrinsic aspect ratio (if any), to the smallest size such that both its width and its height can completely cover the background positioning area. + $ih = $ih * $pb['bpa']['w']/$iw; + $iw = $pb['bpa']['w']; + if ($ih < $pb['bpa']['h']) { + $iw = $iw * $ih/$pb['bpa']['h']; + $ih = $pb['bpa']['h']; + } + } + else { + if (stristr($size['w'] ,'%')) { + $size['w'] += 0; + $size['w'] /= 100; + $size['w'] = ($pb['bpa']['w'] * $size['w']); + } + if (stristr($size['h'] ,'%')) { + $size['h'] += 0; + $size['h'] /= 100; + $size['h'] = ($pb['bpa']['h'] * $size['h']); + } + if ($size['w']=='auto' && $size['h']=='auto') { + $iw = $iw; + $ih = $ih; + } + else if ($size['w']=='auto' && $size['h']!='auto') { + $iw = $iw * $size['h']/$ih; + $ih = $size['h']; + } + else if ($size['w']!='auto' && $size['h']=='auto') { + $ih = $ih * $size['w']/$iw; + $iw = $size['w']; + } + else { + $iw = $size['w']; + $ih = $size['h']; + } + } + } + + // Number to repeat + if ($pb['x_repeat']) { $nx = ceil($pb['w']/$iw)+1; } + else { $nx = 1; } + if ($pb['y_repeat']) { $ny = ceil($pb['h']/$ih)+1; } + else { $ny = 1; } + + $x_pos = $pb['x_pos']; + if (stristr($x_pos ,'%') ) { + $x_pos += 0; + $x_pos /= 100; + $x_pos = ($pb['bpa']['w'] * $x_pos) - ($iw * $x_pos); + } + $y_pos = $pb['y_pos']; + if (stristr($y_pos ,'%') ) { + $y_pos += 0; + $y_pos /= 100; + $y_pos = ($pb['bpa']['h'] * $y_pos) - ($ih * $y_pos); + } + if ($nx>1) { + while($x_pos>($pb['x']-$pb['bpa']['x'])) { $x_pos -= $iw; } + } + if ($ny>1) { + while($y_pos>($pb['y']-$pb['bpa']['y'])) { $y_pos -= $ih; } + } + for($xi=0;$xi<$nx;$xi++) { + for($yi=0;$yi<$ny;$yi++) { + $x = $x0 + $x_pos + ($iw*$xi); + $y = $y0 + $y_pos + ($ih*$yi); + if ($pb['opacity']>0 && $pb['opacity']<1) { $opac = $this->SetAlpha($pb['opacity'],'Normal',true); } + else { $opac = ''; } + $s .= sprintf("q %s %.3F 0 0 %.3F %.3F %.3F cm /I%d Do Q", $opac,$iw*_MPDFK,$ih*_MPDFK,$x*_MPDFK,($this->h-($y+$ih))*_MPDFK,$pb['image_id']) ."\n"; + } + } + } + else { + if (($pb['opacity']>0 || $pb['opacity']==='0') && $pb['opacity']<1) { $opac = $this->SetAlpha($pb['opacity'],'Normal',true); } + else { $opac = ''; } + $s .= sprintf('q /Pattern cs /P%d scn %s %.3F %.3F %.3F %.3F re f Q', $n, $opac, $x, $y, $w, $h) ."\n"; + } + if (isset($pb['clippath']) && $pb['clippath']) { $s .= 'Q'."\n"; } } } @@ -2344,7 +2471,7 @@ function AddPage($orientation='',$condition='', $resetpagenum='', $pagenumstyle= $s = $this->PrintPageBackgrounds(); // Writes after the marker so not overwritten later by page background etc. - $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); + $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); $this->pageBackgrounds = array(); $family=$this->FontFamily; $style=$this->FontStyle.($this->U ? 'U' : '').($this->S ? 'S' : ''); @@ -2485,7 +2612,7 @@ function AddPage($orientation='',$condition='', $resetpagenum='', $pagenumstyle= $s .= $this->PrintBodyBackgrounds(); $s .= $this->PrintPageBackgrounds(); - $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', "\n".$s."\n".'\\1', $this->pages[$this->page]); + $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$s."\n".'\\1', $this->pages[$this->page]); $this->pageBackgrounds = array(); } @@ -2545,9 +2672,9 @@ function AddPage($orientation='',$condition='', $resetpagenum='', $pagenumstyle= } // Tiling Patterns - $this->_out('___PAGE___START'.date('jY')); - $this->_out('___BACKGROUND___PATTERNS'.date('jY')); - $this->_out('___HEADER___MARKER'.date('jY')); + $this->_out('___PAGE___START'.$this->uniqstr); + $this->_out('___BACKGROUND___PATTERNS'.$this->uniqstr); + $this->_out('___HEADER___MARKER'.$this->uniqstr); $this->pageBackgrounds = array(); //Set line cap style to square @@ -3023,7 +3150,10 @@ function AddFont($family,$style='') { if (!file_exists($ttffile)) { $ttffile = ''; } } if (!$ttffile) { - $ttffile = _MPDF_TTFONTPATH.$this->fontdata[$family][$stylekey]; + $ttffile = $this->fontdata[$family][$stylekey]; + if ($ttffile[0] != '/' && $ttffile[1] != ':' && strpos($ttffile, 'phar://') !== 0) + // Not an absolute path + $ttffile = _MPDF_TTFONTPATH.$ttffile; if (!file_exists($ttffile)) { die("mPDF Error - cannot find TTF TrueType font file - ".$ttffile); } } $ttfstat = stat($ttffile); @@ -3628,9 +3758,8 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre $oldcolumn = $this->CurrCol; // Automatic page break // Allows PAGE-BREAK-AFTER = avoid to work - if (!$this->tableLevel && (($this->y+$this->divheight>$this->PageBreakTrigger) || ($this->y+$h>$this->PageBreakTrigger) || - ($this->y+($h*2)>$this->PageBreakTrigger && $this->blk[$this->blklvl]['page_break_after_avoid'])) and !$this->InFooter and $this->AcceptPageBreak()) { + ($this->y+($h*2)+$this->blk[$this->blklvl]['padding_bottom']+$this->blk[$this->blklvl]['margin_bottom']>$this->PageBreakTrigger && $this->blk[$this->blklvl]['page_break_after_avoid'])) and !$this->InFooter and $this->AcceptPageBreak()) { // mPDF 5.7.2 $x=$this->x;//Current X position @@ -3694,8 +3823,9 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre //Calculate baseline Superscript and Subscript Y coordinate adjustment $bfx = $this->baselineC; $baseline = $bfx*$bfs; - if($this->SUP) { $baseline += ($bfx-1.05)*$this->FontSize; } - else if($this->SUB) { $baseline += ($bfx + 0.04)*$this->FontSize; } + // mPDF 5.7.3 inline text-decoration parameters + if($this->SUP) { $baseline -= $this->textparam['text-baseline']; } // mPDF 5.7.1 + else if($this->SUB) { $baseline -= $this->textparam['text-baseline']; } // mPDF 5.7.1 else if($this->bullet) { $baseline += ($bfx-0.7)*$this->FontSize; } // Vertical align (for Images) @@ -3962,34 +4092,50 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre } } // UNDERLINE - if($this->U) { + if($this->U) { // mPDF 6 $c = strtoupper($this->TextColor); // change 0 0 0 rg to 0 0 0 RG + // mPDF 5.7.3 inline text-decoration parameters + if (isset($this->textparam['u-decoration']['color'])) { + $c = $this->textparam['u-decoration']['color']; + } if($this->FillColor!=$c) { $sub .= ' '.$c.' '; } - if (isset($this->CurrentFont['up'])) { $up=$this->CurrentFont['up']; } + // mPDF 5.7.3 inline text-decoration parameters + $decorationfontkey = $this->textparam['decoration-fontkey']; + $decorationfontsize = $this->textparam['decoration-fontsize']; + if (isset($this->fonts[$decorationfontkey]['up'])) { $up=$this->fonts[$decorationfontkey]['up']; } else { $up = -100; } - $adjusty = (-$up/1000* $this->FontSize); - if (isset($this->CurrentFont['ut'])) { $ut=$this->CurrentFont['ut']/1000* $this->FontSize; } - else { $ut = 60/1000* $this->FontSize; } + $adjusty = (-$up/1000* $decorationfontsize); + if (isset($this->fonts[$decorationfontkey]['ut'])) { $ut=$this->fonts[$decorationfontkey]['ut']/1000* $decorationfontsize; } + else { $ut = 60/1000* $decorationfontsize; } + $ubaseline = $this->baselineC*$bfs - $this->textparam['decoration-baseline']; $olw = $this->LineWidth; $sub .=' '.(sprintf(' %.3F w 0 j 0 J ',$ut*_MPDFK)); - $sub .=' '.$this->_dounderline($this->x+$dx,$this->y+$baseline+$va+$adjusty,$txt); + $sub .=' '.$this->_dounderline($this->x+$dx,$this->y+$ubaseline+$va+$adjusty,$txt,$OTLdata,$textvar); $sub .=' '.(sprintf(' %.3F w 2 j 2 J ',$olw*_MPDFK)); if($this->FillColor!=$c) { $sub .= ' '.$this->FillColor.' '; } } // STRIKETHROUGH - if($this->strike) { + if($this->strike) { // mPDF 6 $c = strtoupper($this->TextColor); // change 0 0 0 rg to 0 0 0 RG + // mPDF 5.7.3 inline text-decoration parameters + if (isset($this->textparam['s-decoration']['color'])) { + $c = $this->textparam['s-decoration']['color']; + } if($this->FillColor!=$c) { $sub .= ' '.$c.' '; } - //Superscript and Subscript Y coordinate adjustment (now for striked-through texts) - if (isset($this->CurrentFont['desc']['CapHeight'])) { $ch=$this->CurrentFont['desc']['CapHeight']; } + // mPDF 5.7.3 inline text-decoration parameters + $decorationfontkey = $this->textparam['decoration-fontkey']; + $decorationfontsize = $this->textparam['decoration-fontsize']; + //Superscript and Subscript Y coordinate adjustment (now for striked-through texts) + if (isset($this->fonts[$decorationfontkey]['desc']['CapHeight'])) { $ch=$this->fonts[$decorationfontkey]['desc']['CapHeight']; } else { $ch = 700; } - $adjusty = (-$ch/1000* $this->FontSize) * 0.35; - if (isset($this->CurrentFont['ut'])) { $ut=$this->CurrentFont['ut']/1000* $this->FontSize; } - else { $ut = 60/1000* $this->FontSize; } + $adjusty = (-$ch/1000* $decorationfontsize) * $this->baselineS; + if (isset($this->fonts[$decorationfontkey]['ut'])) { $ut=$this->fonts[$decorationfontkey]['ut']/1000* $decorationfontsize; } + else { $ut = 60/1000* $decorationfontsize; } + $sbaseline = $this->baselineC*$bfs - $this->textparam['decoration-baseline']; $olw = $this->LineWidth; $sub .=' '.(sprintf(' %.3F w 0 j 0 J ',$ut*_MPDFK)); - $sub .=' '.$this->_dounderline($this->x+$dx,$this->y+$baseline+$va+$adjusty,$txt); + $sub .=' '.$this->_dounderline($this->x+$dx,$this->y+$sbaseline+$va+$adjusty,$txt,$OTLdata,$textvar); $sub .=' '.(sprintf(' %.3F w 2 j 2 J ',$olw*_MPDFK)); if($this->FillColor!=$c) { $sub .= ' '.$this->FillColor.' '; } } @@ -4893,6 +5039,19 @@ function finishFlowingBlock($endofblock=false, $next='') { $mba = max($mba, $oh); } } + // mPDF 5.7.3 inline text-decoration parameters + else if (!$is_table && isset($font[$k]['textparam']['text-baseline'])) { + if ($font[$k]['textparam']['text-baseline'] > 0) { // superscript + $nh = ($maxfontsize * $this->baselineC) + $font[$k]['textparam']['text-baseline'] + ($font[$k]['size'] * (1-$this->baselineC)); + if ($lhfixed && $nh > $def_fontsize) { $this->forceExactLineheight = false; } + $af = max($af, ($nh-$maxfontsize)); + } + else if ($font[$k]['textparam']['text-baseline'] < 0) { // subscript + $nh = ($maxfontsize * (1-$this->baselineC)) - $font[$k]['textparam']['text-baseline'] + ($font[$k]['size'] * $this->baselineC); + if ($lhfixed && $nh > $def_fontsize) { $this->forceExactLineheight = false; } + $bf = max($bf, ($nh-$maxfontsize)); + } + } } if ((!$lhfixed || !$this->forceExactLineheight) && ($af > (($maxlineHeight - $maxfontsize)/2) || $bf > (($maxlineHeight - $maxfontsize)/2))) { $maxlineHeight = $maxfontsize + $af + $bf; @@ -5446,7 +5605,10 @@ function printobjectbuffer($is_table=false, $blockdir=false) { } // IMAGE if ($objattr['type'] == 'image') { - // mPDF 5.6.01 - LAYERS + // mPDF 5.7.3 TRANSFORMS + if (isset($objattr['transform'])) { + $this->_out("\n".'% BTR'); // Begin Transform + } if (isset($objattr['z-index']) && $objattr['z-index'] > 0 && $this->currentlayer==0) { $this->BeginLayer($objattr['z-index']); } @@ -5491,6 +5653,78 @@ function printobjectbuffer($is_table=false, $blockdir=false) { if ($tr) { $tr .= ' '; } $gradmask = ''; + // mPDF 5.7.3 TRANSFORMS + $tr2 = ''; + if (isset($objattr['transform'])) { + $maxsize_x = $w; + $maxsize_y = $h; + $cx = $x + $w/2; + $cy = $y + $h/2; + preg_match_all('/(translatex|translatey|translate|scalex|scaley|scale|rotate|skewX|skewY|skew)\((.*?)\)/is',$objattr['transform'],$m); + if (count($m[0])) { + for($i=0; $i<count($m[0]); $i++) { + $c = strtolower($m[1][$i]); + $v = trim($m[2][$i]); + $vv = preg_split('/[ ,]+/',$v); + if ($c=='translate' && count($vv)) { + $translate_x = $this->ConvertSize($vv[0],$maxsize_x,false,false); + if (count($vv)==2) { $translate_y = $this->ConvertSize($vv[1],$maxsize_y,false,false); } + else { $translate_y = 0; } + $tr2 .= $this->transformTranslate($translate_x, $translate_y, true).' '; + } + else if ($c=='translatex' && count($vv)) { + $translate_x = $this->ConvertSize($vv[0],$maxsize_x,false,false); + $tr2 .= $this->transformTranslate($translate_x, 0, true).' '; + } + else if ($c=='translatey' && count($vv)) { + $translate_y = $this->ConvertSize($vv[1],$maxsize_y,false,false); + $tr2 .= $this->transformTranslate(0, $translate_y, true).' '; + } + else if ($c=='scale' && count($vv)) { + $scale_x = $vv[0] * 100; + if (count($vv)==2) { $scale_y = $vv[1] * 100; } + else { $scale_y = $scale_x; } + $tr2 .= $this->transformScale($scale_x, $scale_y, $cx, $cy, true).' '; + } + else if ($c=='scalex' && count($vv)) { + $scale_x = $vv[0] * 100; + $tr2 .= $this->transformScale($scale_x, 0, $cx, $cy, true).' '; + } + else if ($c=='scaley' && count($vv)) { + $scale_y = $vv[1] * 100; + $tr2 .= $this->transformScale(0, $scale_y, $cx, $cy, true).' '; + } + else if ($c=='skew' && count($vv)) { + $angle_x = $this->ConvertAngle($vv[0], false); + if (count($vv)==2) { $angle_y = $this->ConvertAngle($vv[1], false); } + else { $angle_y = 0; } + $tr2 .= $this->transformSkew($angle_x, $angle_y, $cx, $cy, true).' '; + } + else if ($c=='skewx' && count($vv)) { + $angle = $this->ConvertAngle($vv[0], false); + $tr2 .= $this->transformSkew($angle, 0, $cx, $cy, true).' '; + } + else if ($c=='skewy' && count($vv)) { + $angle = $this->ConvertAngle($vv[0], false); + $tr2 .= $this->transformSkew(0, $angle, $cx, $cy, true).' '; + } + else if ($c=='rotate' && count($vv)) { + $angle = $this->ConvertAngle($vv[0]); + $tr2 .= $this->transformRotate($angle, $cx, $cy, true).' '; + } + } + } + } + // mPDF 5.7.3 TRANSFORMS / BACKGROUND COLOR + // Transform also affects image background + if ($tr2) { $this->_out('q '.$tr2.' '); } + if (isset($objattr['bgcolor']) && $objattr['bgcolor']) { + $bgcol = $objattr['bgcolor']; + $this->SetFColor($bgcol); + $this->Rect($x,$y,$w,$h, 'F'); + $this->SetFColor($this->ConvertColor(255)); + } + if ($tr2) { $this->_out('Q'); } /*-- BACKGROUNDS --*/ if (isset($objattr['GRADIENT-MASK'])) { @@ -5504,29 +5738,37 @@ function printobjectbuffer($is_table=false, $blockdir=false) { /*-- END BACKGROUNDS --*/ /*-- IMAGES-WMF --*/ if (isset($objattr['itype']) && $objattr['itype']=='wmf') { - $outstring = sprintf('q '.$tr.'%.3F 0 0 %.3F %.3F %.3F cm /FO%d Do Q', $sx, -$sy, $objattr['INNER-X']*_MPDFK-$sx*$objattr['wmf_x'], (($this->h-$objattr['INNER-Y'])*_MPDFK)+$sy*$objattr['wmf_y'], $objattr['ID']); + $outstring = sprintf('q '.$tr.$tr2.'%.3F 0 0 %.3F %.3F %.3F cm /FO%d Do Q', $sx, -$sy, $objattr['INNER-X']*_MPDFK-$sx*$objattr['wmf_x'], (($this->h-$objattr['INNER-Y'])*_MPDFK)+$sy*$objattr['wmf_y'], $objattr['ID']); // mPDF 5.7.3 TRANSFORMS } else /*-- END IMAGES-WMF --*/ if (isset($objattr['itype']) && $objattr['itype']=='svg') { - $outstring = sprintf('q '.$tr.'%.3F 0 0 %.3F %.3F %.3F cm /FO%d Do Q', $sx, -$sy, $objattr['INNER-X']*_MPDFK-$sx*$objattr['wmf_x'], (($this->h-$objattr['INNER-Y'])*_MPDFK)+$sy*$objattr['wmf_y'], $objattr['ID']); + $outstring = sprintf('q '.$tr.$tr2.'%.3F 0 0 %.3F %.3F %.3F cm /FO%d Do Q', $sx, -$sy, $objattr['INNER-X']*_MPDFK-$sx*$objattr['wmf_x'], (($this->h-$objattr['INNER-Y'])*_MPDFK)+$sy*$objattr['wmf_y'], $objattr['ID']); // mPDF 5.7.3 TRANSFORMS } else { - $outstring = sprintf("q ".$tr."%.3F 0 0 %.3F %.3F %.3F cm ".$gradmask."/I%d Do Q",$obiw*_MPDFK, $obih*_MPDFK, $objattr['INNER-X'] *_MPDFK, ($this->h-($objattr['INNER-Y'] +$obih ))*_MPDFK,$objattr['ID'] ); + $outstring = sprintf("q ".$tr.$tr2."%.3F 0 0 %.3F %.3F %.3F cm ".$gradmask."/I%d Do Q",$obiw*_MPDFK, $obih*_MPDFK, $objattr['INNER-X'] *_MPDFK, ($this->h-($objattr['INNER-Y'] +$obih ))*_MPDFK,$objattr['ID'] ); // mPDF 5.7.3 TRANSFORMS } $this->_out($outstring); // LINK if (isset($objattr['link'])) $this->Link($objattr['INNER-X'],$objattr['INNER-Y'],$objattr['INNER-WIDTH'],$objattr['INNER-HEIGHT'],$objattr['link']); if (isset($objattr['opacity'])) { $this->SetAlpha(1); } + + // mPDF 5.7.3 TRANSFORMS + // Transform also affects image borders + if ($tr2) { $this->_out('q '.$tr2.' '); } if ((isset($objattr['border_top']) && $objattr['border_top']>0) || (isset($objattr['border_left']) && $objattr['border_left']>0) || (isset($objattr['border_right']) && $objattr['border_right']>0) || (isset($objattr['border_bottom']) && $objattr['border_bottom']>0)) { $this->PaintImgBorder($objattr,$is_table); } + if ($tr2) { $this->_out('Q'); } + if(isset($objattr['visibility']) && $objattr['visibility']!='visible' && $objattr['visibility']) { $this->SetVisibility('visible'); } - // mPDF 5.6.01 - LAYERS if (isset($objattr['z-index']) && $objattr['z-index'] > 0 && $this->currentlayer==0) { $this->EndLayer(); } - + // mPDF 5.7.3 TRANSFORMS + if (isset($objattr['transform'])) { + $this->_out("\n".'% ETR'); // Begin Transform + } } /*-- BARCODES --*/ @@ -6086,6 +6328,17 @@ function WriteFlowingBlock( $s) $savedContent = array_pop( $content ); $savedContentB = array_pop($contentB); // mPDF 5.6.20 $savedFont = array_pop( $font ); + + // mPDF 5.7.2 + // e.g: |first chunk |second chunk |[IndexEntry]|doesntfit + if (isset($this->objectbuffer[(count($content)-1)]) && $this->objectbuffer[(count($content)-1)]['OUTER-WIDTH'] < 0.001) { + $savedObj = $this->objectbuffer[(count($content)-1)]; + array_pop( $content ); + array_pop( $contentB ); + array_pop( $font ); + array_pop( $this->objectbuffer ); + } + // trim any trailing spaces off the last bit of content $currContent =& $content[ count( $content ) - 1 ]; $currContent = rtrim( $currContent ); @@ -6243,6 +6496,19 @@ function WriteFlowingBlock( $s) $mba = max($mba, $oh); } } + // mPDF 5.7.3 inline text-decoration parameters + else if (!$is_table && isset($font[$k]['textparam']['text-baseline'])) { + if ($font[$k]['textparam']['text-baseline'] > 0) { // superscript + $nh = ($maxfontsize * $this->baselineC) + $font[$k]['textparam']['text-baseline'] + ($font[$k]['size'] * (1-$this->baselineC)); + if ($lhfixed && $nh > $def_fontsize) { $this->forceExactLineheight = false; } + $af = max($af, ($nh-$maxfontsize)); + } + else if ($font[$k]['textparam']['text-baseline'] < 0) { // subscript + $nh = ($maxfontsize * (1-$this->baselineC)) - $font[$k]['textparam']['text-baseline'] + ($font[$k]['size'] * $this->baselineC); + if ($lhfixed && $nh > $def_fontsize) { $this->forceExactLineheight = false; } + $bf = max($bf, ($nh-$maxfontsize)); + } + } } if ((!$lhfixed || !$this->forceExactLineheight) && ($af > (($maxlineHeight - $maxfontsize)/2) || $bf > (($maxlineHeight - $maxfontsize)/2))) { $maxlineHeight = $maxfontsize + $af + $bf; @@ -6347,6 +6613,10 @@ function WriteFlowingBlock( $s) $this->keep_block_together = 0; } + if ($this->kwt && !$is_table) { // mPDF 5.7+ + $this->printkwtbuffer(); + $this->kwt = false; + } /*-- COLUMNS --*/ // COLS @@ -6913,7 +7183,7 @@ function Image($file,$x,$y,$w=0,$h=0,$type='',$link='',$paint=true, $constrain=t if ($this->watermarkImgBehind) { $outstring = $this->watermarkImgAlpha . "\n" . $outstring . "\n" . $this->SetAlpha(1, 'Normal', true) . "\n"; - $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', "\n".$outstring."\n".'\\1', $this->pages[$this->page]); + $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', "\n".$outstring."\n".'\\1', $this->pages[$this->page]); } else { $this->_out($outstring); } @@ -6950,7 +7220,7 @@ function Image($file,$x,$y,$w=0,$h=0,$type='',$link='',$paint=true, $constrain=t $this->AddPage($this->CurOrientation); // Added to correct for OddEven Margins $x=$x +$this->MarginCorrection; - $y = $tMargin + $this->margin_header; + $y = $this->tMargin; // mPDF 5.7.3 $changedpage = true; } /*-- COLUMNS --*/ @@ -7387,7 +7657,7 @@ function Output($name='',$dest='') /*-- PROGRESS-BAR --*/ if ($this->progressBar && ($dest=='D' || $dest=='I')) { if($name=='') { $name='mpdf.pdf'; } - $tempfile = '_tempPDF'.RAND(1,10000); + $tempfile = '_tempPDF'.uniqid(rand(1,100000),true); //Save to local file $f=fopen(_MPDF_TEMP_PATH.$tempfile.'.pdf','wb'); if(!$f) $this->Error('Unable to create temporary output file: '.$tempfile.'.pdf'); @@ -7499,10 +7769,10 @@ function Output($name='',$dest='') // DELETE OLD TMP FILES - Housekeeping // Delete any files in tmp/ directory that are >1 hrs old $interval = 3600; - if ($handle = opendir(preg_replace('/\/$/','',_MPDF_TEMP_PATH))) { + if ($handle = @opendir(preg_replace('/\/$/','',_MPDF_TEMP_PATH))) { // mPDF 5.7.3 while (false !== ($file = readdir($handle))) { - if (!is_dir($file) && ((filemtime(_MPDF_TEMP_PATH.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) { // mPDF 5.4.19 - unlink(_MPDF_TEMP_PATH.$file); + if (($file != "..") && ($file != ".") && !is_dir($file) && ((filemtime(_MPDF_TEMP_PATH.$file)+$interval) < time()) && (substr($file, 0, 1) !== '.') && ($file !='dummy.txt')) { // mPDF 5.7.3 + @unlink(_MPDF_TEMP_PATH.$file); } } closedir($handle); @@ -7576,7 +7846,7 @@ function _puthtmlheaders() { else { $pntstr = ''; } $html = str_replace($this->aliasNbPgGp,$pntstr,$html ); // {nbpg} $html = str_replace($this->aliasNbPg,$nb,$html ); // {nb} - $html = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$html ); + $html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback') ,$html ); // mPDF 5.7 $this->HTMLheaderPageLinks = array(); $this->HTMLheaderPageAnnots = array(); @@ -7602,7 +7872,7 @@ function _puthtmlheaders() { // Writes over the page background but behind any other output on page $os = preg_replace('/\\\\/','\\\\\\\\',$os); - $this->pages[$n] = preg_replace('/(___HEADER___MARKER'.date('jY').')/', "\n".$os."\n".'\\1', $this->pages[$n]); + $this->pages[$n] = preg_replace('/(___HEADER___MARKER'.$this->uniqstr.')/', "\n".$os."\n".'\\1', $this->pages[$n]); $lks = $this->HTMLheaderPageLinks; foreach($lks AS $lk) { @@ -7659,7 +7929,7 @@ function _puthtmlheaders() { else { $pntstr = ''; } $html = str_replace($this->aliasNbPgGp,$pntstr,$html ); // {nbpg} $html = str_replace($this->aliasNbPg,$nb,$html ); // {nb} - $html = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$html ); + $html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback') ,$html ); // mPDF 5.7 $this->HTMLheaderPageLinks = array(); @@ -7670,7 +7940,6 @@ function _puthtmlheaders() { $this->writingHTMLfooter = true; $this->InFooter = true; $this->WriteHTML($html , 4); // parameter 4 saves output to $this->headerbuffer - $this->writingHTMLfooter = false; $this->InFooter = false; $this->Reset(); $this->pageoutput[$n] = array(); @@ -7680,6 +7949,7 @@ function _puthtmlheaders() { $s = $this->PrintPageBackgrounds(-$adj); $this->headerbuffer = $s . $this->headerbuffer; + $this->writingHTMLfooter = false; // mPDF 5.7.3 (moved after PrintPageBackgrounds so can adjust position of images in footer) $os = ''; $os .= $this->StartTransform(true)."\n"; @@ -7694,7 +7964,7 @@ function _puthtmlheaders() { $os .= $this->StopTransform(true)."\n"; // Writes over the page background but behind any other output on page $os = preg_replace('/\\\\/','\\\\\\\\',$os); - $this->pages[$n] = preg_replace('/(___HEADER___MARKER'.date('jY').')/', "\n".$os."\n".'\\1', $this->pages[$n]); + $this->pages[$n] = preg_replace('/(___HEADER___MARKER'.$this->uniqstr.')/', "\n".$os."\n".'\\1', $this->pages[$n]); $lks = $this->HTMLheaderPageLinks; foreach($lks AS $lk) { @@ -7876,10 +8146,14 @@ function _putpages() $thispage=str_replace($this->aliasNbPgGpHex,$r,$thispage); } - $thispage = preg_replace('/(\s*___BACKGROUND___PATTERNS'.date('jY').'\s*)/', " ", $thispage); - $thispage = preg_replace('/(\s*___HEADER___MARKER'.date('jY').'\s*)/', " ", $thispage); - $thispage = preg_replace('/(\s*___PAGE___START'.date('jY').'\s*)/', " ", $thispage); - $thispage = preg_replace('/(\s*___TABLE___BACKGROUNDS'.date('jY').'\s*)/', " ", $thispage); + $thispage = preg_replace('/(\s*___BACKGROUND___PATTERNS'.$this->uniqstr.'\s*)/', " ", $thispage); + $thispage = preg_replace('/(\s*___HEADER___MARKER'.$this->uniqstr.'\s*)/', " ", $thispage); + $thispage = preg_replace('/(\s*___PAGE___START'.$this->uniqstr.'\s*)/', " ", $thispage); + $thispage = preg_replace('/(\s*___TABLE___BACKGROUNDS'.$this->uniqstr.'\s*)/', " ", $thispage); + // mPDF 5.7.3 TRANSFORMS + while (preg_match('/(\% BTR(.*?)\% ETR)/is', $thispage, $m)) { + $thispage = preg_replace('/(\% BTR.*?\% ETR)/is', '', $thispage, 1)."\n".$m[2]; + } //Page $this->_newobj(); @@ -7928,10 +8202,13 @@ function _putpages() } $annotsnum = 0; + $embeddedfiles = array(); // mPDF 5.7.2 /EmbeddedFiles + if (isset($this->PageLinks[$n])) { $annotsnum += count($this->PageLinks[$n]); } /*-- ANNOTATIONS --*/ if (isset($this->PageAnnots[$n])) { foreach ($this->PageAnnots[$n] as $k => $pl) { + if (!empty($pl['opt']['file'])) { $embeddedfiles[$annotsnum+1] = true ; } // mPDF 5.7.2 /EmbeddedFiles if (!empty($pl['opt']['popup']) || !empty($pl['opt']['file'])) { $annotsnum += 2 ; } else { $annotsnum++; } $this->PageAnnots[$n][$k]['pageobj'] = $this->n; @@ -7952,7 +8229,7 @@ function _putpages() if ($annotsnum || $formsnum) { $s = '/Annots [ '; for($i=0;$i<$annotsnum;$i++) { - $s .= ($annotid + $i) . ' 0 R '; + if (!isset($embeddedfiles[$i])) { $s .= ($annotid + $i) . ' 0 R '; } // mPDF 5.7.2 /EmbeddedFiles } $annotid += $annotsnum; /*-- FORMS --*/ @@ -7974,7 +8251,7 @@ function _putpages() $this->_putstream($p); $this->_out('endobj'); } - $this->_putannots($n); + $this->_putannots(); // mPDF 5.7.2 //Pages root $this->offsets[1]=strlen($this->buffer); @@ -7991,7 +8268,7 @@ function _putpages() } -function _putannots($n) { +function _putannots() { // mPDF 5.7.2 $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; $nb=$this->page; for($n=1;$n<=$nb;$n++) @@ -9567,13 +9844,13 @@ function _beginpage($orientation,$mgl='',$mgr='',$mgt='',$mgb='',$mgh='',$mgf='' function _setAutoHeaderHeight(&$det, &$htmlh) { if ($this->setAutoTopMargin=='pad') { - if ($htmlh['h']) { $h = $htmlh['h']; } + if (isset($htmlh['h']) && $htmlh['h']) { $h = $htmlh['h']; } // 5.7.3 else if ($det) { $h = $this->_getHFHeight($det,'H'); } else { $h = 0; } $this->tMargin = $this->margin_header + $h + $this->orig_tMargin; } else if ($this->setAutoTopMargin=='stretch') { - if ($htmlh['h']) { $h = $htmlh['h']; } + if (isset($htmlh['h']) && $htmlh['h']) { $h = $htmlh['h']; } // 5.7.3 else if ($det) { $h = $this->_getHFHeight($det,'H'); } else { $h = 0; } $this->tMargin = max($this->orig_tMargin, $this->margin_header + $h + $this->autoMarginPadding); @@ -9583,14 +9860,14 @@ function _setAutoHeaderHeight(&$det, &$htmlh) { function _setAutoFooterHeight(&$det, &$htmlf) { if ($this->setAutoBottomMargin=='pad') { - if ($htmlf['h']) { $h = $htmlf['h']; } + if (isset($htmlf['h']) && $htmlf['h']) { $h = $htmlf['h']; } // 5.7.3 else if ($det) { $h = $this->_getHFHeight($det,'F'); } else { $h = 0; } $this->bMargin = $this->margin_footer + $h + $this->orig_bMargin; $this->PageBreakTrigger=$this->h-$this->bMargin ; } else if ($this->setAutoBottomMargin=='stretch') { - if ($htmlf['h']) { $h = $htmlf['h']; } + if (isset($htmlf['h']) && $htmlf['h']) { $h = $htmlf['h']; } // 5.7.3 else if ($det) { $h = $this->_getHFHeight($det,'F'); } else { $h = 0; } $this->bMargin = max($this->orig_bMargin, $this->margin_footer + $h + $this->autoMarginPadding); @@ -9752,7 +10029,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal if ($this->PDFA && !$this->PDFAauto) { $this->PDFAXwarnings[] = "JPG image may not use CMYK color space - ".$file." - (Image converted to RGB. NB This will alter the colour profile of the image.)"; } $im = @imagecreatefromstring($data); if ($im) { - $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.RAND(1,10000).'.png'; + $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png'; imageinterlace($im, false); $check = @imagepng($im, $tempfile); if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary file ('.$tempfile.') whilst using GD library to parse JPG(CMYK) image'); } @@ -10057,7 +10334,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal if (isset($gd['GIF Read Support']) && $gd['GIF Read Support']) { $im = @imagecreatefromstring($data); if ($im) { - $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.RAND(1,10000).'.png'; + $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png'; imagealphablending($im, false); imagesavealpha($im, false); imageinterlace($im, false); @@ -10102,7 +10379,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal if(isset($gif->m_img->m_gih->m_bLocalClr) && $gif->m_img->m_gih->m_bLocalClr) { $nColors = $gif->m_img->m_gih->m_nTableSize; $pal = $gif->m_img->m_gih->m_colorTable->toString(); - if($bgColor != -1) { + if((isset($bgColor)) and $bgColor != -1) { // mPDF 5.7.3 $bgColor = $gif->m_img->m_gih->m_colorTable->colorIndex($bgColor); } $colspace='Indexed'; @@ -10188,7 +10465,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal if (isset($gd['PNG Support']) && $gd['PNG Support']) { $im = @imagecreatefromstring($data); if (!$im) { return $this->_imageError($file, $firsttime, 'Error parsing image file - image type not recognised, and not supported by GD imagecreate'); } - $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.RAND(1,10000).'.png'; + $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png'; imagealphablending($im, false); imagesavealpha($im, false); imageinterlace($im, false); @@ -10312,10 +10589,10 @@ function _convImage(&$data, $colspace, $targetcs, $w, $h, $dpi, $mask) { $imgdata .= chr($r).chr($g).chr($b); } if ($mask) { - $col = imagecolorsforindex($im, $rgb); - $gammacorr = 2.2; // gamma correction - $gamma = intval((pow((((127 - $col['alpha']) * 255 / 127) / 255), $gammacorr) * 255)); - $mimgdata .= chr($gamma); + // mPDF 5.7.2 Gamma correction + $alpha = ($rgb & 0x7F000000) >> 24; + if ($alpha < 127) { $mimgdata .= chr(255-($alpha * 2)); } + else { $mimgdata .= chr(0); } } } } @@ -10333,7 +10610,7 @@ function _convImage(&$data, $colspace, $targetcs, $w, $h, $dpi, $mask) { $minfo = array('w'=>$w,'h'=>$h,'cs'=>'DeviceGray','bpc'=>8,'f'=>'FlateDecode','data'=>$mimgdata, 'type'=>'png', 'parms'=>'/DecodeParms <</Colors '.$ncols.' /BitsPerComponent 8 /Columns '.$w.'>>'); if ($dpi) { $minfo['set-dpi'] = $dpi; } - $tempfile = '_tempImgPNG'.RAND(1,10000).'.png'; + $tempfile = '_tempImgPNG'.md5($file).RAND(1,10000).'.png'; $imgmask = count($this->images)+1; $minfo['i']=$imgmask ; $this->images[$tempfile] = $minfo; @@ -10396,11 +10673,21 @@ function file_get_contents_by_curl($url, &$data) { function file_get_contents_by_socket($url, &$data) { + // mPDF 5.7.3 $timeout = 1; $p = parse_url($url); $file = $p['path']; + if ($p['scheme']=='https') { + $prefix = 'ssl://'; + $port = ($p['port'] ? $p['port'] : 443); + } + else { + $prefix = ''; + $port = ($p['port'] ? $p['port'] : 80); + } if ($p['query']) { $file .= '?'.$p['query']; } - if(!($fh = @fsockopen($p['host'], 80, $errno, $errstr, $timeout))) { return false; } + if(!($fh = @fsockopen($prefix.$p['host'], $port, $errno, $errstr, $timeout))) { return false; } + $getstring = "GET ".$file." HTTP/1.0 \r\n" . "Host: ".$p['host']." \r\n" . @@ -10425,7 +10712,7 @@ function file_get_contents_by_socket($url, &$data) { function _imageTypeFromString(&$data) { $type = ''; - if (substr($data, 6, 4)== 'JFIF' || substr($data, 6, 4)== 'Exif') { + if (substr($data, 6, 4)== 'JFIF' || substr($data, 6, 4)== 'Exif' || substr($data, 0, 2)== chr(255).chr(216)) { // 0xFF 0xD8 // mpDF 5.7.2 $type = 'jpeg'; } else if (substr($data, 0, 6)== "GIF87a" || substr($data, 0, 6)== "GIF89a") { @@ -11134,7 +11421,11 @@ function GetFullPath(&$path,$basepath='') { if (!$basepath) { $basepath = $this->basepath; } //Fix path value $path = str_replace("\\","/",$path); //If on Windows - $path = preg_replace('/^\/\//','http://',$path); // mPDF 5.6.27 + // mPDF 5.7.2 + if (substr($path,0,2) == "//") { + $tr = parse_url($basepath); + $path = $tr['scheme'].':'.$path; + } $regexp = '|^./|'; // Inadvertently corrects "./path/etc" and "//www.domain.com/etc" $path = preg_replace($regexp,'',$path); @@ -11155,7 +11446,11 @@ function GetFullPath(&$path,$basepath='') { else if( strpos($path,":/") === false || strpos($path,":/") > 10) { //It is a Local Link if (substr($path,0,1) == "/") { $tr = parse_url($basepath); - $root = $tr['scheme'].'://'.$tr['host']; + // mPDF 5.7.2 + $root = ''; + if (!empty($tr['scheme'])) { $root .= $tr['scheme'].'://'; } + $root .= $tr['host']; + $root .= ($tr['port'] ? (':'.$tr['port']) : ''); // mPDF 5.7.3 $path = $root . $path; } else { $path = $basepath . $path; } @@ -11168,6 +11463,8 @@ function GetFullPath(&$path,$basepath='') { function _get_file($path) { // If local file try using local path (? quicker, but also allowed even if allow_url_fopen false) $contents = ''; + // mPDF 5.7.3 + if (strpos($path,"//") === false ) { $path = preg_replace('/\.css\?.*$/', '.css', $path); } $contents = @file_get_contents($path); if ($contents) { return $contents; } if ($this->basepathIsLocal) { @@ -11367,7 +11664,7 @@ function Header($content='') { if (isset($h[$side][$pos]['content']) && $h[$side][$pos]['content']) { $hd = str_replace('{PAGENO}',$pgno,$h[$side][$pos]['content']); $hd = str_replace($this->aliasNbPgGp,$this->nbpgPrefix.$this->aliasNbPgGp.$this->nbpgSuffix,$hd); - $hd = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$hd); + $hd = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback') ,$hd); // mPDF 5.7 if (isset($h[$side][$pos]['font-family']) && $h[$side][$pos]['font-family']) { $hff = $h[$side][$pos]['font-family']; } else { $hff = $this->original_default_font; } if (isset($h[$side][$pos]['font-size']) && $h[$side][$pos]['font-size']) { $hfsz = $h[$side][$pos]['font-size']; } @@ -11438,10 +11735,24 @@ function Header($content='') { /*-- TABLES --*/ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',$horf = 'H',$level, $firstSpread=true, $finalSpread=true) { - if(($horf=='H' || $horf=='F') && !empty($content) && !empty($content[0])) { // mPDF 5.6.61 + if(($horf=='H' || $horf=='F') && !empty($content)) { // mPDF 5.7.2 $table = &$this->table[1][1]; - // Advance down page by half width of top border + // mPDF 5.7.2 + if ($horf=='F') { // Table Footer + $firstrow = count($table['cells']) - $table['footernrows']; + $lastrow = count($table['cells']) - 1; + } + else { // Table Header + $firstrow = 0; + $lastrow = $table['headernrows'] - 1; + } + if(empty($content[$firstrow])) { + if ($this->debug) { $this->Error("<tfoot> must precede <tbody> in a table"); } + else { return; } + } + + // Advance down page by half width of top border if ($horf=='H') { // Only if header if ($table['borders_separate']) { $adv = $table['border_spacing_V']/2 + $table['border_details']['T']['w'] + $table['padding']['T']; } else { $adv = $table['max_cell_border_width']['T'] /2 ; } @@ -11455,14 +11766,6 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='', } } - if ($horf=='F') { // Table Footer - $firstrow = count($table['cells']) - $table['footernrows']; - $lastrow = count($table['cells']) - 1; - } - else { // Table Header - $firstrow = 0; - $lastrow = $table['headernrows'] - 1; - } $topy = $content[$firstrow][0]['y']-$this->y; @@ -12071,7 +12374,7 @@ function _getHtmlHeight($html) { $html = str_replace('{PAGENO}',$this->pagenumPrefix.$this->docPageNum($this->page).$this->pagenumSuffix,$html); $html = str_replace($this->aliasNbPgGp,$this->nbpgPrefix.$this->docPageNumTotal($this->page).$this->nbpgSuffix,$html ); $html = str_replace($this->aliasNbPg,$this->page,$html ); - $html = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$html ); + $html = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback') ,$html ); // mPDF 5.7 $this->HTMLheaderPageLinks = array(); $this->HTMLheaderPageAnnots = array(); $this->HTMLheaderPageForms = array(); @@ -12081,6 +12384,10 @@ function _getHtmlHeight($html) { $this->writingHTMLheader = false; $h = ($this->y - $this->margin_header); $this->Reset(); + // mPDF 5.7.2 - Clear in case Float used in Header/Footer + $this->blk[0]['blockContext'] = 0; + $this->blk[0]['float_endpos'] = 0; + $this->pageoutput[$this->page] = array(); $this->headerbuffer = ''; $this->pageBackgrounds = $savepb; @@ -12204,7 +12511,7 @@ function SetHTMLHeaderByName($name,$side='O',$write=false) { function SetHTMLFooterByName($name,$side='O') { if (!$name) { $name = '_default'; } - $this->SetHTMLFooter($this->pageHTMLfooters[$name],$side,$write); + $this->SetHTMLFooter($this->pageHTMLfooters[$name],$side); } /*-- END HTMLHEADERS-FOOTERS --*/ @@ -12506,7 +12813,7 @@ function Footer() { if (isset($h[$side][$pos]['content']) && $h[$side][$pos]['content']) { $hd = str_replace('{PAGENO}',$pgno,$h[$side][$pos]['content']); $hd = str_replace($this->aliasNbPgGp,$this->nbpgPrefix.$this->aliasNbPgGp.$this->nbpgSuffix,$hd); - $hd = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$hd); + $hd = preg_replace_callback('/\{DATE\s+(.*?)\}/', array($this, 'date_callback') ,$hd); // mPDF 5.7 if (isset($h[$side][$pos]['font-family']) && $h[$side][$pos]['font-family']) { $hff = $h[$side][$pos]['font-family']; } else { $hff = $this->original_default_font; } if (isset($h[$side][$pos]['font-size']) && $h[$side][$pos]['font-size']) { $hfsz = $h[$side][$pos]['font-size']; } @@ -12596,7 +12903,7 @@ function hardHyphenate($word, $maxWidth) { else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') { $p = strpos($word, "-", $offset); } - if ($p !== false) { $poss[] = $p - count($poss); } + if ($p !== false) { $poss[] = $p; } // mPDF 5.7.2 else { break; } $offset = $p+1; } @@ -12651,7 +12958,9 @@ function softHyphenate($word, $maxWidth) { else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') { $p = strpos($word, chr(173), $offset); } - if ($p !== false) { $poss[] = $p - count($poss); } + // mPDF 5.7.2 + //if ($p !== false) { $poss[] = $p - count($poss); } + if ($p !== false) { $poss[] = $p; } else { break; } $offset = $p+1; } @@ -12915,7 +13224,7 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) { /*-- CSS-PAGE --*/ // If page-box is set - if ($this->state==0 && isset($this->cssmgr->CSS['@PAGE']) && $this->cssmgr->CSS['@PAGE'] ) { + if ($this->state==0 && ((isset($this->cssmgr->CSS['@PAGE']) && $this->cssmgr->CSS['@PAGE']) || (isset($this->cssmgr->CSS['@PAGE>>PSEUDO>>FIRST']) && $this->cssmgr->CSS['@PAGE>>PSEUDO>>FIRST'])) ) { // mPDF 5.7.3 $this->page_box['current'] = ''; $this->page_box['using'] = true; list($pborientation,$pbmgl,$pbmgr,$pbmgt,$pbmgb,$pbmgh,$pbmgf,$hname,$fname,$bg,$resetpagenum,$pagenumstyle,$suppress,$marks,$newformat) = $this->SetPagedMediaCSS('', false, 'O'); @@ -12926,7 +13235,7 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) { $this->orig_bMargin = $this->bMargin = $pbmgb; $this->orig_hMargin = $this->margin_header = $pbmgh; $this->orig_fMargin = $this->margin_footer = $pbmgf; - list($pborientation,$pbmgl,$pbmgr,$pbmgt,$pbmgb,$pbmgh,$pbmgf,$hname,$fname,$bg,$resetpagenum,$pagenumstyle,$suppress,$marks,$newformat) = $this->SetPagedMediaCSS('', true, 'O'); // first page + list($pborientation,$pbmgl,$pbmgr,$pbmgt,$pbmgb,$pbmgh,$pbmgf,$hname,$fname,$bg,$resetpagenum,$pagenumstyle,$suppress,$marks,$newformat) = $this->SetPagedMediaCSS('', true, 'O'); // true=first page $this->show_marks = $marks; if ($hname && !preg_match('/^html_(.*)$/i',$hname)) $this->firstPageBoxHeader = $hname; if ($fname && !preg_match('/^html_(.*)$/i',$fname)) $this->firstPageBoxFooter = $fname; @@ -13066,7 +13375,8 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) { $cnt += $this->SubstituteCharsMB($a, $i, $e); } if ($this->biDirectional) { // *RTL* - $e = preg_replace("/([".$this->pregRTLchars."]+)/ue", '$this->ArabJoin(stripslashes(\'\\1\'))', $e); // *RTL* + // mPDF 5.7+ + $e = preg_replace_callback("/([".$this->pregRTLchars."]+)/u", array($this, 'arabJoinPregCallback'), $e ); // *RTL* } // *RTL* // Font-specific ligature substitution for Indic fonts if (isset($this->CurrentFont['indic']) && $this->CurrentFont['indic']) $this->ConvertIndic($e); // *INDIC* @@ -13360,7 +13670,7 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) { if ($old_page != $new_page) { $s = $this->PrintPageBackgrounds(); // Writes after the marker so not overwritten later by page background etc. - $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); + $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); $this->pageBackgrounds = array(); $this->page = $new_page; $this->ResetMargins(); @@ -14278,6 +14588,9 @@ function SetPagedMediaCSS($name='', $first, $oddEven) { else { $zp = array(); } if (isset($zp['SIZE'])) { unset($zp['SIZE']); } if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); } + // Disallow margin-left or -right on :FIRST // mPDF 5.7.3 + if (isset($zp['MARGIN-LEFT'])) { unset($zp['MARGIN-LEFT']); } + if (isset($zp['MARGIN-RIGHT'])) { unset($zp['MARGIN-RIGHT']); } if (is_array($zp) && !empty($zp)) { $p = array_merge($p,$zp); } // If named page @@ -14324,6 +14637,9 @@ function SetPagedMediaCSS($name='', $first, $oddEven) { else { $zp = array(); } if (isset($zp['SIZE'])) { unset($zp['SIZE']); } if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); } + // Disallow margin-left or -right on :FIRST // mPDF 5.7.3 + if (isset($zp['MARGIN-LEFT'])) { unset($zp['MARGIN-LEFT']); } + if (isset($zp['MARGIN-RIGHT'])) { unset($zp['MARGIN-RIGHT']); } if (is_array($zp) && !empty($zp)) { $p = array_merge($p,$zp); } } @@ -14350,6 +14666,7 @@ function SetPagedMediaCSS($name='', $first, $oddEven) { if ($p['SIZE']['W'] > $p['SIZE']['H']) { $p['ORIENTATION'] = 'L'; } else { $p['ORIENTATION'] = 'P'; } } + if (is_array($p['SIZE'])) { if ($p['SIZE']['W'] > $this->fw) { $p['SIZE']['W'] = $this->fw; } // mPD 4.2 use fw not fPt if ($p['SIZE']['H'] > $this->fh) { $p['SIZE']['H'] = $this->fh; } @@ -14443,7 +14760,7 @@ function ClearFloats($clear, $blklvl=0) { if ($old_page != $new_page) { $s = $this->PrintPageBackgrounds(); // Writes after the marker so not overwritten later by page background etc. - $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); + $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); $this->pageBackgrounds = array(); $this->page = $new_page; } @@ -14493,7 +14810,7 @@ function OpenTag($tag,$attr) // Correct tags where HTML specifies optional end tags, // and/or does not allow nesting e.g. P inside P, or if ($this->allow_html_optional_endtags) { - if (($tag == 'P' || $tag == 'DIV' || $tag == 'H1' || $tag == 'H2' || $tag == 'H3' || $tag == 'H4' || $tag == 'H5' || $tag == 'H6' || $tag == 'UL' || $tag == 'OL' || $tag == 'TABLE' || $tag=='PRE' || $tag=='FORM' || $tag=='ADDRESS' || $tag=='BLOCKQUOTE' || $tag=='CENTER' || $tag=='DL' || $tag == 'HR' ) && $this->lastoptionaltag == 'P') { $this->CloseTag($this->lastoptionaltag ); } + if (($tag == 'P' || $tag == 'DIV' || $tag == 'H1' || $tag == 'H2' || $tag == 'H3' || $tag == 'H4' || $tag == 'H5' || $tag == 'H6' || $tag == 'UL' || $tag == 'OL' || $tag == 'TABLE' || $tag=='PRE' || $tag=='FORM' || $tag=='ADDRESS' || $tag=='BLOCKQUOTE' || $tag=='CENTER' || $tag=='DL' || $tag == 'HR' || $tag=='ARTICLE' || $tag=='ASIDE' || $tag=='FIELDSET' || $tag=='HGROUP' || $tag=='MAIN' || $tag=='NAV' || $tag=='SECTION' ) && $this->lastoptionaltag == 'P') { $this->CloseTag($this->lastoptionaltag ); } // mPDF 5.7.3 if ($tag == 'DD' && $this->lastoptionaltag == 'DD') { $this->CloseTag($this->lastoptionaltag ); } if ($tag == 'DD' && $this->lastoptionaltag == 'DT') { $this->CloseTag($this->lastoptionaltag ); } if ($tag == 'DT' && $this->lastoptionaltag == 'DD') { $this->CloseTag($this->lastoptionaltag ); } @@ -14758,7 +15075,6 @@ function OpenTag($tag,$attr) $save_blklvl = $this->blklvl; $save_blk = $this->blk; $save_silp = $this->saveInlineProperties(); - $save_spanlvl = $this->spanlvl; $save_ilp = $this->InlineProperties; // Close any open block tags @@ -14861,7 +15177,6 @@ function OpenTag($tag,$attr) unset($this->blk[$b+1]); $this->OpenTag($tc,$ac); } - $this->spanlvl = $save_spanlvl; $this->InlineProperties = $save_ilp; $this->restoreInlineProperties($save_silp); } @@ -14941,8 +15256,8 @@ function OpenTag($tag,$attr) if (strpos($size,',')) { $size = explode(',',$size); } } else { $size = 'D'; } - if (isset($attr['POS']) && $attr['POS']) { - $pos = $attr['POS']; + if (isset($attr['POSITION']) && $attr['POSITION']) { // mPDF 5.7.2 + $pos = $attr['POSITION']; if (strpos($pos,',')) { $pos = explode(',',$pos); } } else { $pos = 'P'; } @@ -15138,15 +15453,14 @@ function OpenTag($tag,$attr) } /*-- END ANNOTATIONS --*/ - if ($tag == 'SPAN') { - $this->spanlvl++; - $this->InlineProperties['SPAN'][$this->spanlvl] = $this->saveInlineProperties(); - if (isset($annot)) { $this->InlineAnnots[$tag][$this->spanlvl] = $annot; } // *ANNOTATIONS* - } - else { - if (!isset($this->InlineProperties[$tag])) $this->InlineProperties[$tag] = $this->saveInlineProperties(); // mPDF 5.4.13 - if (isset($annot)) { $this->InlineAnnots[$tag] = $annot; } // *ANNOTATIONS* - } + // mPDF 5.7.3 Inline tags + if (!isset($this->InlineProperties[$tag])) { $this->InlineProperties[$tag] = array($this->saveInlineProperties()); } + else { $this->InlineProperties[$tag][] = $this->saveInlineProperties(); } + if (isset($annot)) { // *ANNOTATIONS* + if (!isset($this->InlineAnnots[$tag])) { $this->InlineAnnots[$tag] = array($annot); } // *ANNOTATIONS* + else { $this->InlineAnnots[$tag][] = $annot; } // *ANNOTATIONS* + } // *ANNOTATIONS* + $properties = $this->cssmgr->MergeCSS('INLINE',$tag,$attr); if (!empty($properties)) $this->setCSS($properties,'INLINE'); break; @@ -15290,7 +15604,7 @@ function OpenTag($tag,$attr) $this->meter = new meter(); $svg = $this->meter->makeSVG(strtolower($tag), $type, $value, $max, $min, $optimum, $low, $high); //Save to local file - $srcpath= _MPDF_TEMP_PATH.'_tempSVG'.RAND(1,10000).'_'.strtolower($tag).'.svg'; + $srcpath= _MPDF_TEMP_PATH.'_tempSVG'.uniqid(rand(1,100000),true).'_'.strtolower($tag).'.svg'; file_put_contents($srcpath, $svg); $orig_srcpath = $srcpath; $this->GetFullPath($srcpath); @@ -15418,10 +15732,8 @@ function OpenTag($tag,$attr) case 'DT': case 'DD': case 'FIELDSET': - // mPDF 5.5.22 case 'DETAILS': case 'SUMMARY': - // mPDF 5.5.09 case 'ARTICLE': case 'ASIDE': case 'FIGURE': @@ -15431,6 +15743,7 @@ function OpenTag($tag,$attr) case 'HGROUP': case 'NAV': case 'SECTION': + case 'MAIN': // mPDF 5.7.3 $p = $this->cssmgr->PreviewBlockCSS($tag,$attr); if(isset($p['DISPLAY']) && strtolower($p['DISPLAY'])=='none') { $this->blklvl++; @@ -15484,7 +15797,6 @@ function OpenTag($tag,$attr) /*-- END LISTS --*/ $this->InlineProperties = array(); - $this->spanlvl = 0; $this->listjustfinished=false; $this->divbegin=true; @@ -15527,7 +15839,6 @@ function OpenTag($tag,$attr) $save_blklvl = $this->blklvl; $save_blk = $this->blk; $save_silp = $this->saveInlineProperties(); - $save_spanlvl = $this->spanlvl; $save_ilp = $this->InlineProperties; $this->blklvl++; @@ -15564,7 +15875,6 @@ function OpenTag($tag,$attr) } /*-- END COLUMNS --*/ - // Must Add new page if changed page properties if (isset($properties['PAGE-BREAK-BEFORE'])) { if (strtoupper($properties['PAGE-BREAK-BEFORE']) == 'RIGHT') { $this->AddPage($this->CurOrientation,'NEXT-ODD','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); } @@ -15621,7 +15931,6 @@ function OpenTag($tag,$attr) unset($this->blk[$b+1]); $this->OpenTag($tc,$ac); } - $this->spanlvl = $save_spanlvl; $this->InlineProperties = $save_ilp; $this->restoreInlineProperties($save_silp); } @@ -16749,6 +17058,9 @@ function OpenTag($tag,$attr) $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w']; $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w']; + // mPDF 5.7.3 TRANSFORMS + if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') { $objattr['bgcolor'] = $this->ConvertColor($properties['BACKGROUND-COLOR']); } + /*-- BACKGROUNDS --*/ if(isset($properties['GRADIENT-MASK']) && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/',$properties['GRADIENT-MASK'])) { $objattr['GRADIENT-MASK'] = $properties['GRADIENT-MASK']; @@ -16866,6 +17178,10 @@ function OpenTag($tag,$attr) } } /*-- END CSS-IMAGE-FLOAT --*/ + // mPDF 5.7.3 TRANSFORMS + if (isset($properties['TRANSFORM']) && !$this->ColActive && !$this->kwt) { + $objattr['transform'] = $properties['TRANSFORM']; + } $e = "\xbb\xa4\xactype=image,objattr=".serialize($objattr)."\xbb\xa4\xac"; @@ -17128,7 +17444,7 @@ function OpenTag($tag,$attr) if ($this->cacheTables) { $this->packTableData = true; // required for cacheTables $this->simpleTables = false; // Cannot co-exist with cacheTables - $table['cache'] = _MPDF_TEMP_PATH.'_tempTblCache'.RAND(1,1000000).'.dat'; + $table['cache'] = _MPDF_TEMP_PATH.'_tempTblCache'.uniqid(rand(1,100000),true).'.dat'; $fh = fopen($table['cache'] , "wb") or $this->Error("When using cacheTables, you must have read/write access to cache files (".$table['cache'] .")"); fwrite($fh, "\x00"); fclose($fh); @@ -17168,7 +17484,6 @@ function OpenTag($tag,$attr) $table['decimal_align'] = false; // mPDF 5.6.13 $this->Reset(); $this->InlineProperties = array(); - $this->spanlvl = 0; $table['nc'] = $table['nr'] = 0; $this->tablethead = 0; $this->tabletfoot = 0; @@ -17358,10 +17673,7 @@ function OpenTag($tag,$attr) $table['borders_separate'] = false; } - if (!$table['borders_separate']) { $table['border_spacing_H'] = $table['border_spacing_V'] = 0; } - else if (isset($attr['CELLSPACING'])) { - $table['border_spacing_H'] = $table['border_spacing_V'] = $this->ConvertSize($attr['CELLSPACING'],$this->blk[$this->blklvl]['inner_width']); - } + // mPDF 5.7.3 if (isset($properties['BORDER-SPACING-H'])) { $table['border_spacing_H'] = $this->ConvertSize($properties['BORDER-SPACING-H'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); } @@ -17369,6 +17681,8 @@ function OpenTag($tag,$attr) $table['border_spacing_V'] = $this->ConvertSize($properties['BORDER-SPACING-V'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); } + if (!$table['borders_separate']) { $table['border_spacing_H'] = $table['border_spacing_V'] = 0; } + if (isset($properties['EMPTY-CELLS'])) { $table['empty_cells'] = strtolower($properties['EMPTY-CELLS']); // 'hide' or 'show' } @@ -17604,7 +17918,6 @@ function OpenTag($tag,$attr) $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag $this->cssmgr->tbCSSlvl++; $this->InlineProperties = array(); - $this->spanlvl = 0; $this->tdbegin = true; $this->col++; while (isset($this->cell[$this->row][$this->col])) { $this->col++; } @@ -17966,6 +18279,7 @@ function OpenTag($tag,$attr) for($l=$this->col; $l < $this->col+$cs ;$l++) { if ($l-$this->col) $this->cell[$this->row][$l] = 0; } + if (isset($attr['ROWSPAN']) && $attr['ROWSPAN']>1) $rs = $this->cell[$this->row][$this->col]['rowspan'] = $attr['ROWSPAN']; for ($k=$this->row ; $k < $this->row+$rs ;$k++) { for($l=$this->col; $l < $this->col+$cs ;$l++) { @@ -18254,10 +18568,7 @@ function OpenTag($tag,$attr) function _getListStyle($ls) { if (stristr($ls,'decimal')) { return '1'; } -/* CSS3 list-styles numeric (selected) + I added tamil -arabic-indic | bengali | devanagari | gujarati | gurmukhi | kannada | malayalam | oriya | persian | telugu | thai | urdu -*/ - else if (preg_match('/(disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu)/i',$ls,$m)) { + else if (preg_match('/(disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao)/i',$ls,$m)) { return strtolower(trim($m[1])); } else if (stristr($ls,'lower-roman')) { return 'i'; } @@ -18292,19 +18603,21 @@ function CloseTag($tag) || $tag=='MARK' || $tag=='TIME' || $tag=='PROGRESS' || $tag=='METER' ) { // mPDF 5.5.09 - if ($tag == 'SPAN') { - if (isset($this->InlineProperties['SPAN'][$this->spanlvl]) && $this->InlineProperties['SPAN'][$this->spanlvl]) { $this->restoreInlineProperties($this->InlineProperties['SPAN'][$this->spanlvl]); } - unset($this->InlineProperties['SPAN'][$this->spanlvl]); - if (isset($this->InlineAnnots['SPAN'][$this->spanlvl]) && $this->InlineAnnots['SPAN'][$this->spanlvl]) { $annot = $this->InlineAnnots['SPAN'][$this->spanlvl]; } // *ANNOTATIONS* - unset($this->InlineAnnots['SPAN'][$this->spanlvl]); // *ANNOTATIONS* - $this->spanlvl--; - } - else { + // mPDF 5.7.3 Inline tags + if ($tag=='PROGRESS' || $tag=='METER') { if (isset($this->InlineProperties[$tag]) && $this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); } unset($this->InlineProperties[$tag]); if (isset($this->InlineAnnots[$tag]) && $this->InlineAnnots[$tag]) { $annot = $this->InlineAnnots[$tag]; } // *ANNOTATIONS* unset($this->InlineAnnots[$tag]); // *ANNOTATIONS* } + else { + if (isset($this->InlineProperties[$tag]) && count($this->InlineProperties[$tag])) { + $this->restoreInlineProperties(array_pop($this->InlineProperties[$tag])); + } + if (isset($this->InlineAnnots[$tag]) && count($this->InlineAnnots[$tag])) { // *ANNOTATIONS* + $annot = array_pop($this->InlineAnnots[$tag]); // *ANNOTATIONS* + } // *ANNOTATIONS* + } /*-- ANNOTATIONS --*/ if (isset($annot)) { @@ -18409,13 +18722,12 @@ function CloseTag($tag) // *********** BLOCKS ******************** - // mPDF 5.4.18 if($tag=='P' || $tag=='DIV' || $tag=='H1' || $tag=='H2' || $tag=='H3' || $tag=='H4' || $tag=='H5' || $tag=='H6' || $tag=='PRE' || $tag=='FORM' || $tag=='ADDRESS' || $tag=='BLOCKQUOTE' || $tag=='CENTER' || $tag=='DT' || $tag=='DD' || $tag=='DL' || $tag=='CAPTION' || $tag=='FIELDSET' || $tag=='ARTICLE' || $tag=='ASIDE' || $tag=='FIGURE' || $tag=='FIGCAPTION' || $tag=='FOOTER' || $tag=='HEADER' || $tag=='HGROUP' - || $tag=='NAV' || $tag=='SECTION' || $tag=='DETAILS' || $tag=='SUMMARY' - ) { // mPDF 5.5.09 // mPDF 5.5.22 + || $tag=='MAIN' || $tag=='NAV' || $tag=='SECTION' || $tag=='DETAILS' || $tag=='SUMMARY' + ) { // mPDF 5.7.3 $this->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces $this->blockjustfinished=true; @@ -18487,7 +18799,7 @@ function CloseTag($tag) if ($old_page != $new_page) { $s = $this->PrintPageBackgrounds(); // Writes after the marker so not overwritten later by page background etc. - $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); + $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); $this->pageBackgrounds = array(); $this->page = $new_page; $this->ResetMargins(); @@ -18546,7 +18858,7 @@ function CloseTag($tag) // If width not set, here would need to adjust and output buffer $s = $this->PrintPageBackgrounds(); // Writes after the marker so not overwritten later by page background etc. - $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); + $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); $this->pageBackgrounds = array(); $this->Reset(); $this->pageoutput[$this->page] = array(); @@ -18578,7 +18890,7 @@ function CloseTag($tag) // If width not set, here would need to adjust and output buffer $s = $this->PrintPageBackgrounds(); // Writes after the marker so not overwritten later by page background etc. - $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); + $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); $this->pageBackgrounds = array(); $this->Reset(); $this->pageoutput[$this->page] = array(); @@ -18641,7 +18953,6 @@ function CloseTag($tag) $save_blklvl = $this->blklvl; $save_blk = $this->blk; $save_silp = $this->saveInlineProperties(); - $save_spanlvl = $this->spanlvl; $save_ilp = $this->InlineProperties; if ($this->blklvl>1) { // Close any open block tags @@ -18660,26 +18971,12 @@ function CloseTag($tag) if ($page_break_after == 'RIGHT') { $this->AddPage($this->CurOrientation,'NEXT-ODD','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); } else if ($page_break_after == 'LEFT') { $this->AddPage($this->CurOrientation,'NEXT-EVEN','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); } else { $this->AddPage($this->CurOrientation,'','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); } + // mPDF 5.7.3 if (!$this->restoreBlockPagebreaks) { $this->blklvl = 0; $this->lastblocklevelchange = 0; - $this->blk = array(); - $this->initialiseBlock($this->blk[0]); - $this->blk[0]['width'] =& $this->pgwidth; - $this->blk[0]['inner_width'] =& $this->pgwidth; - $this->blk[0]['blockContext'] = $this->blockContext; - $properties = $this->cssmgr->MergeCSS('BLOCK','BODY',''); - $this->setCSS($properties,'','BODY'); - $this->blklvl++; - $currblk =& $this->blk[$this->blklvl]; - $prevblk =& $this->blk[$this->blklvl-1]; - - $this->initialiseBlock($currblk); - $currblk['tag'] = $tag; - $currblk['attr'] = $attr; - $this->Reset(); - $properties = $this->cssmgr->MergeCSS('BLOCK',$tag,$attr); + $this->restoreInlineProperties($this->blk[0]['InlineProperties']); } /*-- COLUMNS --*/ if ($save_cols) { @@ -18701,7 +18998,6 @@ function CloseTag($tag) unset($this->blk[$b+1]); $this->OpenTag($tc,$ac); } - $this->spanlvl = $save_spanlvl; $this->InlineProperties = $save_ilp; $this->restoreInlineProperties($save_silp); } @@ -18829,6 +19125,46 @@ function CloseTag($tag) unset($this->cssmgr->tablecascadeCSS[$this->cssmgr->tbCSSlvl]); $this->cssmgr->tbCSSlvl--; $this->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces + + // mPDF 5.7.3 + // In case a colspan (on a row after first row) exceeded number of columns in table + for ($k=0; $k < $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nr']; $k++) { + for($l=0; $l < $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nc']; $l++) { + if (!isset($this->cell[$k][$l])) { + for ($n=$l-1; $n>=0; $n--) { + if (isset($this->cell[$k][$n]) && $this->cell[$k][$n]!=0) { break; } + } + $this->cell[$k][$l] = array( + 'a' => 'C', + 'va' => 'M', + 'R' => false, + 'nowrap' => false, + 'bgcolor' => false, + 'padding' => array('L' => false, 'R' => false, 'T' => false, 'B' => false), + 'gradient' => false, + 's' => 0, + 'maxs' => 0, + 'textbuffer' => array(), + 'dfs' => $this->FontSize, + ); + + if (!$this->simpleTables){ + $this->cell[$k][$l]['border'] = 0; + $this->cell[$k][$l]['border_details']['R'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0); + $this->cell[$k][$l]['border_details']['L'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0); + $this->cell[$k][$l]['border_details']['T'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0); + $this->cell[$k][$l]['border_details']['B'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0); + $this->cell[$k][$l]['border_details']['mbw'] = array('BL' =>0,'BR' =>0,'RT' =>0,'RB' =>0,'TL' =>0,'TR' =>0,'LT' =>0,'LB' =>0); + if ($this->packTableData) { + $this->cell[$k][$l]['borderbin'] = $this->_packCellBorder($this->cell[$k][$l]); + unset($this->cell[$k][$l]['border']); + unset($this->cell[$k][$l]['border_details']); + } + } + } + } + } + $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells'] = $this->cell; $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['wc'] = array_pad(array(),$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nc'],array('miw'=>0,'maw'=>0)); $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['hr'] = array_pad(array(),$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nr'],0); @@ -18924,6 +19260,12 @@ function CloseTag($tag) // Reset lower level table $this->base_table_properties = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['baseProperties']; + // mPDF 5.7.3 + $this->default_font = $this->base_table_properties['FONT-FAMILY']; + $this->SetFont($this->default_font,'',0,false); + $this->default_font_size = $this->ConvertSize($this->base_table_properties['FONT-SIZE'])*(_MPDFK); + $this->SetFontSize($this->default_font_size,false); + $this->cell = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells']; // mPDF 5.4.10 if (isset($this->cell['PARENTCELL'])) { @@ -19453,7 +19795,6 @@ function CloseTag($tag) $save_blklvl = $this->blklvl; $save_blk = $this->blk; $save_silp = $this->saveInlineProperties(); - $save_spanlvl = $this->spanlvl; $save_ilp = $this->InlineProperties; if ($this->blklvl>1) { // Close any open block tags @@ -19504,7 +19845,6 @@ function CloseTag($tag) unset($this->blk[$b+1]); $this->OpenTag($tc,$ac); } - $this->spanlvl = $save_spanlvl; $this->InlineProperties = $save_ilp; $this->restoreInlineProperties($save_silp); } @@ -19851,6 +20191,19 @@ arabic-indic | bengali | cambodian | devanagari | gujarati | gurmukhi | kannada $list_item_marker = $rnum . $this->list_number_suffix; $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(5, $cp),strlen($maxnum)).$this->list_number_suffix); break; + case 'khmer': + case 'cambodian': + $cp = 0x17E0; + $rnum = $this->dec2other($num, $cp); + $list_item_marker = $rnum . $this->list_number_suffix; + $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix); + break; + case 'lao': + $cp = 0x0ED0; + $rnum = $this->dec2other($num, $cp); + $list_item_marker = $rnum . $this->list_number_suffix; + $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(6, $cp),strlen($maxnum)).$this->list_number_suffix); + break; default: if ($this->listDir == 'rtl') { $list_item_marker = $this->list_number_suffix . $num; } else { $list_item_marker = $num . $this->list_number_suffix; } @@ -20093,13 +20446,13 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false) if(isset($vetor[15])) { // Word spacing $this->wSpacingCSS = $vetor[15]; if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') { - $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize); + $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize)/$this->shrin_k; // mPDF 5.7.3 } } if(isset($vetor[14])) { // Letter spacing $this->lSpacingCSS = $vetor[14]; if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') { - $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize); + $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize)/$this->shrin_k; // mPDF 5.7.3 } } if(isset($vetor[13])) { // Font Kerning @@ -20116,6 +20469,12 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false) { $this->textparam = $vetor[9] ; // mPDF 5.6.14 $this->SetTextOutline($this->textparam); // mPDF 5.6.07 + // mPDF 5.7.3 inline text-decoration parameters + if ($is_table && $this->shrin_k) { + if (isset($this->textparam['text-baseline'])) { $this->textparam['text-baseline'] /= $this->shrin_k; } + if (isset($this->textparam['decoration-baseline'])) { $this->textparam['decoration-baseline'] /= $this->shrin_k; } + if (isset($this->textparam['decoration-fontsize'])) { $this->textparam['decoration-fontsize'] /= $this->shrin_k; } + } } if(isset($vetor[8]) and $vetor[8] === true) // strike-through the text { @@ -20660,10 +21019,10 @@ function _setBorderLine($b, $k=1) { $this->SetLineWidth($b['w']/$k); $this->SetDColor($b['c']); if ($b['c'][0]==5) { // RGBa - $this->SetAlpha($b['c'][4], 'Normal', false, 'S')."\n"; + $this->SetAlpha(ord($b['c'][4])/100, 'Normal', false, 'S')."\n"; // mPDF 5.7.2 } else if ($b['c'][0]==6) { // CMYKa - $this->SetAlpha($b['c'][5], 'Normal', false, 'S')."\n"; + $this->SetAlpha(ord($b['c'][5])/100, 'Normal', false, 'S')."\n"; // mPDF 5.7.2 } } @@ -21978,6 +22337,10 @@ function ReadCharset($html) { function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST // tag= BODY if (!is_array($arrayaux)) return; //Removes PHP Warning + // mPDF 5.7.3 inline text-decoration parameters + $preceeding_fontkey = $this->FontFamily . $this->FontStyle; + $preceeding_fontsize = $this->FontSize; + // Set font size first so that e.g. MARGIN 0.83em works on font size for this element if (isset($arrayaux['FONT-SIZE'])) { $v = $arrayaux['FONT-SIZE']; @@ -22340,31 +22703,42 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST // case 'VERTICAL-ALIGN': //super and sub only dealt with here e.g. <SUB> and <SUP> switch (strtoupper($v)) { - case 'SUPER': + case 'SUPER': $this->SUP=true; $this->SUB=false; // mPDF 5.6.07 - break; - case 'SUB': + // mPDF 5.7.3 inline text-decoration parameters + if (isset($this->textparam['text-baseline'])) { $this->textparam['text-baseline'] += ($this->baselineSup)*$preceeding_fontsize; } + else { $this->textparam['text-baseline'] = ($this->baselineSup)*$preceeding_fontsize; } + break; + case 'SUB': $this->SUB=true; $this->SUP=false; // mPDF 5.6.07 - break; - case 'BASELINE': // mPDF 5.6.07 + // mPDF 5.7.3 inline text-decoration parameters + if (isset($this->textparam['text-baseline'])) { $this->textparam['text-baseline'] += ($this->baselineSub)*$preceeding_fontsize; } + else { $this->textparam['text-baseline'] = ($this->baselineSub)*$preceeding_fontsize; } + break; + case 'BASELINE': // mPDF 5.6.07 $this->SUB=false; $this->SUP=false; - break; - } - break; - - case 'TEXT-DECORATION': // none underline line-through (strikeout) //Does not support: overline, blink - if (stristr($v,'LINE-THROUGH')) { - $this->strike = true; - } - else if (stristr($v,'UNDERLINE')) { - $this->SetStyle('U',true); - } - else if (stristr($v,'NONE')) { - $this->SetStyle('U',false); - $this->strike = false; // mPDF 5.6.07 + // mPDF 5.7.3 inline text-decoration parameters + if (isset($this->textparam['text-baseline'])) { unset($this->textparam['text-baseline']); } + break; + // mPDF 5.7.3 inline text-decoration parameters + default: + $lh = $this->_computeLineheight($this->blk[$this->blklvl]['line_height']); + $sz = $this->ConvertSize($v,$lh,$this->FontSize,false); + $this->SUP=false; + $this->SUB=false; + if ($sz) { + if ($sz > 0) { + $this->SUP=true; + } + else { + $this->SUB=true; + } + if (isset($this->textparam['text-baseline'])) { $this->textparam['text-baseline'] += $sz; } + else { $this->textparam['text-baseline'] = $sz; } + } } break; @@ -22462,6 +22836,42 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST // }//end of foreach + + + // mPDF 5.7.3 inline text-decoration parameters + // Needs to be set at the end - after vertical-align = super/sub, so that textparam['text-baseline'] is set + if (isset($arrayaux['TEXT-DECORATION'])) { + $v = $arrayaux['TEXT-DECORATION']; // none underline line-through (strikeout) //Does not support: overline, blink + if (stristr($v,'LINE-THROUGH')) { + $this->strike = true; + // mPDF 5.7.3 inline text-decoration parameters + if (isset($this->textparam['text-baseline'])) { $this->textparam['decoration-baseline'] = $this->textparam['text-baseline']; } + else { $this->textparam['decoration-baseline'] = 0; } + $this->textparam['decoration-fontkey'] = $this->FontFamily . $this->FontStyle; + $this->textparam['decoration-fontsize'] = $this->FontSize; + $this->textparam['s-decoration']['color'] = strtoupper($this->TextColor); // change 0 0 0 rg to 0 0 0 RG + } + if (stristr($v,'UNDERLINE')) { + $this->SetStyle('U',true); + // mPDF 5.7.3 inline text-decoration parameters + if (isset($this->textparam['text-baseline'])) { $this->textparam['decoration-baseline'] = $this->textparam['text-baseline']; } + else { $this->textparam['decoration-baseline'] = 0; } + $this->textparam['decoration-fontkey'] = $this->FontFamily . $this->FontStyle; + $this->textparam['decoration-fontsize'] = $this->FontSize; + $this->textparam['u-decoration']['color'] = strtoupper($this->TextColor); // change 0 0 0 rg to 0 0 0 RG + } + if (stristr($v,'NONE')) { + $this->SetStyle('U',false); + $this->strike = false; + // mPDF 5.7.3 inline text-decoration parameters + if (isset($this->textparam['decoration-baseline'])) { unset($this->textparam['decoration-baseline']); } + if (isset($this->textparam['decoration-fontkey'])) { unset($this->textparam['decoration-fontkey']); } + if (isset($this->textparam['decoration-fontsize'])) { unset($this->textparam['decoration-fontsize']); } + if (isset($this->textparam['u-decoration'])) { unset($this->textparam['u-decoration']); } + if (isset($this->textparam['s-decoration'])) { unset($this->textparam['s-decoration']); } + } + } + } /*-- END HTML-CSS --*/ @@ -22525,7 +22935,7 @@ function DisableTags($str='') if ($str == '') //enable all tags { //Insert new supported tags in the long string below. - $this->enabledtags = "<span><s><strike><del><bdo><big><small><ins><cite><acronym><font><sup><sub><b><u><i><a><strong><em><code><samp><tt><kbd><var><q><table><thead><tfoot><tbody><tr><th><td><ol><ul><li><dl><dt><dd><form><input><select><textarea><option><div><p><h1><h2><h3><h4><h5><h6><pre><center><blockquote><address><hr><img><br><indexentry><indexinsert><bookmark><watermarktext><watermarkimage><tts><ttz><tta><column_break><columnbreak><newcolumn><newpage><page_break><pagebreak><formfeed><columns><toc><tocentry><tocpagebreak><pageheader><pagefooter><setpageheader><setpagefooter><sethtmlpageheader><sethtmlpagefooter><annotation><template><jpgraph><barcode><dottab><caption><textcircle><fieldset><legend><article><aside><figure><figcaption><footer><header><hgroup><nav><section><mark><details><summary><meter><progress><time>"; // mPDF 5.5.09 + $this->enabledtags = "<span><s><strike><del><bdo><big><small><ins><cite><acronym><font><sup><sub><b><u><i><a><strong><em><code><samp><tt><kbd><var><q><table><thead><tfoot><tbody><tr><th><td><ol><ul><li><dl><dt><dd><form><input><select><textarea><option><div><p><h1><h2><h3><h4><h5><h6><pre><center><blockquote><address><hr><img><br><indexentry><indexinsert><bookmark><watermarktext><watermarkimage><tts><ttz><tta><column_break><columnbreak><newcolumn><newpage><page_break><pagebreak><formfeed><columns><toc><tocentry><tocpagebreak><pageheader><pagefooter><setpageheader><setpagefooter><sethtmlpageheader><sethtmlpagefooter><annotation><template><jpgraph><barcode><dottab><caption><textcircle><fieldset><legend><article><aside><figure><figcaption><footer><header><hgroup><nav><section><mark><main><details><summary><meter><progress><time>"; // mPDF 5.7.3 } else { @@ -22713,13 +23123,13 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz if(isset($chunk[15])) { // Word spacing $this->wSpacingCSS = $chunk[15]; if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') { - $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize); + $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize)/$this->shrin_k; // mPDF 5.7.3 } } if(isset($chunk[14])) { // Letter spacing $this->lSpacingCSS = $chunk[14]; if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') { - $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize); + $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize)/$this->shrin_k; // mPDF 5.7.3 } } if(isset($chunk[13])) { // Font Kerning @@ -23083,13 +23493,13 @@ function TableCheckMinWidth($maxwidth, $forcewrap = 0, $textbuffer) { if(isset($chunk[15])) { // Word spacing $this->wSpacingCSS = $chunk[15]; if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') { - $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize); + $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize)/$this->shrin_k; // mPDF 5.7.3 } } if(isset($chunk[14])) { // Letter spacing $this->lSpacingCSS = $chunk[14]; if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') { - $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize); + $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize)/$this->shrin_k; // mPDF 5.7.3 } } if(isset($chunk[13])) { // Font Kerning @@ -23613,7 +24023,6 @@ function _tableColumnWidth(&$table,$firstpass=false){ $extrcw = $bl/2 + $br/2 + $c['padding']['L'] + $c['padding']['R']; } } - //$mw = $this->GetStringWidth('W') + $extrcw ; $mw = 0; // mPDF 5.6.13 Decimal point alignment @@ -23653,7 +24062,6 @@ function _tableColumnWidth(&$table,$firstpass=false){ if (isset($c['nestedmaw'])) { $c['nestedmaw'] += $extrcw; } } - // If minimum width has already been set by a nested table or inline object (image/form), use it if (isset($c['nestedmiw']) && $this->table[1][1]['overflow']!='visible') { $miw = $c['nestedmiw']; } else { $miw = $mw; } @@ -23695,7 +24103,7 @@ function _tableColumnWidth(&$table,$firstpass=false){ if ($miw<$c['w']) { $c['miw'] = $c['w']; } // Cell min width = that specified if ($miw>$c['w']) { $c['miw'] = $c['w'] = $miw; } // If width specified is less than minimum allowed (W) increase it if (!isset($wc['w'])) { $wc['w'] = 1; } // If the Col width is not specified = set it to 1 - + $c['maw'] = $c['w']; // mPDF 5.7.3 } else { $c['miw'] = $miw; } // If cell width not specified -> set Cell min width it to minimum allowed (W) @@ -23742,7 +24150,6 @@ function _tableColumnWidth(&$table,$firstpass=false){ }//rows }//columns - // COLUMN SPANS $wc = &$table['wc']; foreach ($listspan as $span) { @@ -23784,7 +24191,7 @@ function _tableColumnWidth(&$table,$firstpass=false){ } else { $wi = $c['miw'] - $wis; - foreach ($list as $k) { $wc[$k]['miw'] += ($wc[$k]['miw']/$wisa)*$wi; } + foreach ($list as $k) { if (!isset($wc[$k]['w']) || !$wc[$k]['w']) $wc[$k]['miw'] += ($wc[$k]['miw']/$wisa)*$wi; } // mPDF 5.7.2 } } if ($c['maw'] > $was) { @@ -23918,7 +24325,6 @@ function _tableColumnWidth(&$table,$firstpass=false){ if ((isset($table['maw']) && $checkmaxwidth > $table['maw']) || !isset($table['maw'])) { $table['maw'] = $checkmaxwidth; } $table['tl'] = $totallength ; - if (!$this->tableCJK) { if ($this->table_rotate) { $mxw = $this->tbrot_maxw; @@ -24013,8 +24419,18 @@ function _tableWidth(&$table){ } // if table width is set and is > allowed width if (isset($table['w']) && $table['w'] > $temppgwidth) { $table['w'] = $temppgwidth; } + // IF the table width is now set - Need to distribute columns widths - if (isset($table['w'])) { + // mPDF 5.7.3 + // If the table width is already set to the maximum width (e.g. nested table), then use maximum column widths exactly + if (isset($table['w']) && ($table['w'] == $tablewidth) && !$percentages_set) { + // This sets the columns all to maximum width + for ($i=0;$i<$numcols;$i++) { + $widthcols[$i] = $widthcols[$i]['maw']; + } + } + // Else If the table width is set distribute width using algorithm + else if (isset($table['w'])) { $wis = $wisa = 0; $list = array(); $notsetlist = array(); @@ -24049,7 +24465,7 @@ function _tableWidth(&$table){ for($k=0;$k<$numcols;$k++) { $spareratio = ($table['l'][$k] / $totaltextlength); // gives ratio to divide up free space // Don't allocate more than Maximum required width - save rest in surplus - if ($widthcols[$k]['miw'] + ($wi * $spareratio) > $widthcols[$k]['maw']) { + if ($widthcols[$k]['miw'] + ($wi * $spareratio) >= $widthcols[$k]['maw']) { // mPDF 5.7.3 $surplus += ($wi * $spareratio) - ($widthcols[$k]['maw']-$widthcols[$k]['miw']); $widthcols[$k]['miw'] = $widthcols[$k]['maw']; } @@ -24066,7 +24482,7 @@ function _tableWidth(&$table){ foreach ($list as $k) { $spareratio = ($table['l'][$k] / $totalatextlength); // gives ratio to divide up free space // Don't allocate more than Maximum required width - save rest in surplus - if ($widthcols[$k]['miw'] + ($wi * $spareratio) > $widthcols[$k]['maw']) { + if ($widthcols[$k]['miw'] + ($wi * $spareratio) >= $widthcols[$k]['maw']) { // mPDF 5.7.3 $surplus += ($wi * $spareratio) - ($widthcols[$k]['maw']-$widthcols[$k]['miw']); $widthcols[$k]['miw'] = $widthcols[$k]['maw']; } @@ -24127,7 +24543,6 @@ function _tableWidth(&$table){ } } } - } else { //table has no width defined $table['w'] = $tablewidth; @@ -25212,8 +25627,8 @@ function _fixTableBorders(&$table){ else { $cbord = &$cells[$i][$j]; } - - if (!$cbord['border'] && isset($table['border']) && $table['border'] && $this->table_border_attr_set) { + // mPDF 5.7.3 + if (!$cbord['border'] && $cbord['border']!==0 && isset($table['border']) && $table['border'] && $this->table_border_attr_set) { $cbord['border'] = $table['border']; $cbord['border_details'] = $table['border_details']; } @@ -25830,7 +26245,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0 } } - if ($level==1) { $this->_out('___TABLE___BACKGROUNDS'.date('jY')); } + if ($level==1) { $this->_out('___TABLE___BACKGROUNDS'.$this->uniqstr); } $tableheaderadj = 0; $tablefooteradj = 0; @@ -26093,12 +26508,12 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0 if ($this->tableBackgrounds) { $s = $this->PrintTableBackgrounds(); if ($this->bufferoutput) { - $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', '\\1'."\n".$s."\n", $this->headerbuffer); - $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', " ", $this->headerbuffer ); + $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->headerbuffer); + $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->headerbuffer ); } else { - $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); - $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', " ", $this->pages[$this->page]); + $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); + $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->pages[$this->page]); } $this->tableBackgrounds = array(); } @@ -26120,7 +26535,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0 $this->AddPage($this->CurOrientation); - $this->_out('___TABLE___BACKGROUNDS'.date('jY')); + $this->_out('___TABLE___BACKGROUNDS'.$this->uniqstr); if ($this->tableClipPath ) { $this->_out($this->tableClipPath); } @@ -26989,16 +27404,16 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0 if ($this->tableBackgrounds && $level == 1) { $s = $this->PrintTableBackgrounds(); if ($this->table_rotate && !$this->processingHeader && !$this->processingFooter) { - $this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', '\\1'."\n".$s."\n", $this->tablebuffer); - if ($level == 1) { $this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', " ", $this->tablebuffer); } + $this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->tablebuffer); + if ($level == 1) { $this->tablebuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->tablebuffer); } } else if ($this->bufferoutput) { - $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', '\\1'."\n".$s."\n", $this->headerbuffer); - if ($level == 1) { $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', " ", $this->headerbuffer ); } + $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->headerbuffer); + if ($level == 1) { $this->headerbuffer = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->headerbuffer ); } } else { - $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); - if ($level == 1) { $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.date('jY').')/', " ", $this->pages[$this->page]); } + $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', '\\1'."\n".$s."\n", $this->pages[$this->page]); + if ($level == 1) { $this->pages[$this->page] = preg_replace('/(___TABLE___BACKGROUNDS'.$this->uniqstr.')/', " ", $this->pages[$this->page]); } } $this->tableBackgrounds = array(); } @@ -27577,13 +27992,35 @@ function _putresources() { } /*-- BACKGROUNDS --*/ - if (isset($this->gradients) AND (count($this->gradients) > 0)) { + if ((isset($this->gradients) AND (count($this->gradients) > 0)) || ($this->enableImports && count($this->tpls))) { // mPDF 5.7.3 $this->_out('/Shading <<'); foreach ($this->gradients as $id => $grad) { $this->_out('/Sh'.$id.' '.$grad['id'].' 0 R'); } - $this->_out('>>'); + // mPDF 5.7.3 + // If a shading dictionary is in an object (tpl) imported from another PDF, it needs to be included + // in the document resources, as well as the object resources + // Otherwise get an error in some PDF viewers + if ($this->enableImports && count($this->tpls)) { + foreach($this->tpls as $tplidx => $tpl) { + if (isset($tpl['resources'])) { + $this->current_parser =& $tpl['parser']; + reset ($tpl['resources'][1]); + while (list($k, $v) = each($tpl['resources'][1])) { + if ($k == '/Shading') { + while (list($k2, $v2) = each($v[1])) { + $this->_out($k2 . " ",false); + $this->pdf_write_value($v2); + } + } + } + + } + } + } + + $this->_out('>>'); /* // ??? Not needed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $this->_out('/Pattern <<'); @@ -28125,14 +28562,9 @@ function TOCpagebreak($tocfont='', $tocfontsize='', $tocindent='', $TOCusePaging } function TOC_Entry($txt, $level=0, $toc_id=0) { - $txt = $this->purify_utf8_text($txt); - if ($this->text_input_as_HTML) { - $txt = $this->all_entities_to_utf8($txt); - } - if ($this->usingCoreFont) { $txt = mb_convert_encoding($txt,$this->mb_enc,'UTF-8'); } + // mPDF 5.7.2 if ($this->ColActive) { $ily = $this->y0; } else { $ily = $this->y; } // use top of columns - // mPDF 5.6.19 mPDF 5.6.25 mPDF 5.6.37 if (!class_exists('tocontents', false)) { include(_MPDF_PATH.'classes/tocontents.php'); } if (empty($this->tocontents)) { $this->tocontents = new tocontents($this); } $linkn = $this->AddLink(); @@ -28147,7 +28579,7 @@ function TOC_Entry($txt, $level=0, $toc_id=0) { /*-- RTL --*/ if ($this->biDirectional) { - $txt = preg_replace("/([".$this->pregRTLchars."]+)/ue", '$this->ArabJoin(stripslashes(\'\\1\'))', $txt ); + $txt = preg_replace_callback("/([".$this->pregRTLchars."]+)/u", array($this, 'arabJoinPregCallback'), $txt ); // mPDF 5.7+ } /*-- END RTL --*/ if (strtoupper($toc_id)=='ALL') { $toc_id = '_mpdf_all'; } @@ -28478,7 +28910,7 @@ function DeletePages($start_page, $end_page=-1) { // HTML Headers & Footers if (count($this->saveHTMLHeader)) { foreach($this->saveHTMLHeader AS $p=>$v) { - if($p>end_page) { $newarr[($p - $n_tod)] = $this->saveHTMLHeader[$p]; } + if($p>$end_page) { $newarr[($p - $n_tod)] = $this->saveHTMLHeader[$p]; } // mPDF 5.7.3 else if($p<$start_page) { $newarr[$p] = $this->saveHTMLHeader[$p]; } } ksort($newarr); @@ -28573,7 +29005,7 @@ function IndexEntry($txt, $xref='') { if ($this->keep_block_together) { if (isset($this->ktReference[$i]['t']) && $this->ktReference[$i]['t']==$txt){ $Present=1; - if (!in_array($this->page,$this->ktReference[$i]['p'])) { + if ($this->page != $this->ktReference[$i]['op']) { // mPDF 5.7.2 $this->ktReference[$i]['op'] = $this->page; } } @@ -28582,7 +29014,7 @@ function IndexEntry($txt, $xref='') { else if ($this->table_rotate) { if (isset($this->tbrot_Reference[$i]['t']) && $this->tbrot_Reference[$i]['t']==$txt){ $Present=1; - if (!in_array($this->page,$this->tbrot_Reference[$i]['p'])) { + if ($this->page != $this->tbrot_Reference[$i]['op']) { // mPDF 5.7.2 $this->tbrot_Reference[$i]['op'] = $this->page; } } @@ -28590,7 +29022,7 @@ function IndexEntry($txt, $xref='') { else if ($this->kwt) { if (isset($this->kwt_Reference[$i]['t']) && $this->kwt_Reference[$i]['t']==$txt){ $Present=1; - if (!in_array($this->page,$this->kwt_Reference[$i]['p'])) { + if ($this->page != $this->kwt_Reference[$i]['op']) { // mPDF 5.7.2 $this->kwt_Reference[$i]['op'] = $this->page; } } @@ -28600,7 +29032,7 @@ function IndexEntry($txt, $xref='') { else if ($this->ColActive) { if (isset($this->col_Reference[$i]['t']) && $this->col_Reference[$i]['t']==$txt){ $Present=1; - if (!in_array($this->page,$this->col_Reference[$i]['p'])) { + if ($this->page != $this->col_Reference[$i]['op']) { // mPDF 5.7.2 $this->col_Reference[$i]['op'] = $this->page; } } @@ -28736,7 +29168,7 @@ function CreateIndex($NbCol=1, $reffontsize='', $linespacing='', $offset=3, $use /*-- RTL --*/ // Change Arabic + Persian. to Presentation Forms if ($this->biDirectional) { - $this->Reference[$i]['t'] = preg_replace("/([".$this->pregRTLchars."]+)/ue", '$this->ArabJoin(stripslashes(\'\\1\'))', $this->Reference[$i]['t'] ); + $this->Reference[$i]['t'] = preg_replace_callback("/([".$this->pregRTLchars."]+)/u", array($this, 'arabJoinPregCallback'), $this->Reference[$i]['t'] ); // mPDF 5.7+ } /*-- END RTL --*/ @@ -29019,7 +29451,7 @@ function NewColumn() { function printcolumnbuffer() { // Columns ended (but page not ended) -> try to match all columns - unless disabled by using a custom column-break - if (!$this->ColActive && $this->ColumnAdjust && !$this->keepColumns) { + if (!$this->ColActive && $this->ColumnAdjust && !$this->keepColumns) { // mPDF 5.7.2 // Calculate adjustment to add to each column to calculate rel_y value $this->ColDetails[0]['add_y'] = 0; $last_col = 0; @@ -29123,12 +29555,14 @@ function printcolumnbuffer() { $yadj = ($s['rel_y'] - $s['y']) - ($last_col_bottom)+$this->y0; // callback function $t = $s['s']; - $t = preg_replace('/BT (\d+\.\d\d+) (\d+\.\d\d+) Td/e',"\$this->columnAdjustAdd('Td',_MPDFK,$xadj,$yadj,'\\1','\\2')",$t); - $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) ([\-]{0,1}\d+\.\d\d+) re/e',"\$this->columnAdjustAdd('re',_MPDFK,$xadj,$yadj,'\\1','\\2','\\3','\\4')",$t); - $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) l/e',"\$this->columnAdjustAdd('l',_MPDFK,$xadj,$yadj,'\\1','\\2')",$t); - $t = preg_replace('/q (\d+\.\d\d+) 0 0 (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) cm \/(I|FO)/e',"\$this->columnAdjustAdd('img',_MPDFK,$xadj,$yadj,'\\1','\\2','\\3','\\4','\\5')",$t); - $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) m/e',"\$this->columnAdjustAdd('draw',_MPDFK,$xadj,$yadj,'\\1','\\2')",$t); - $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) c/e',"\$this->columnAdjustAdd('bezier',_MPDFK,$xadj,$yadj,'\\1','\\2','\\3','\\4','\\5','\\6')",$t); + + // mPDF 5.7+ + $t = $this->columnAdjustPregReplace('Td', $xadj, $yadj, '/BT (\d+\.\d\d+) (\d+\.\d\d+) Td/', $t); + $t = $this->columnAdjustPregReplace('re', $xadj, $yadj, '/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) ([\-]{0,1}\d+\.\d\d+) re/', $t); + $t = $this->columnAdjustPregReplace('l', $xadj, $yadj, '/(\d+\.\d\d+) (\d+\.\d\d+) l/', $t); + $t = $this->columnAdjustPregReplace('img', $xadj, $yadj, '/q (\d+\.\d\d+) 0 0 (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) cm \/(I|FO)/', $t); + $t = $this->columnAdjustPregReplace('draw', $xadj, $yadj, '/(\d+\.\d\d+) (\d+\.\d\d+) m/', $t); + $t = $this->columnAdjustPregReplace('bezier',$xadj, $yadj, '/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) c/', $t); $this->columnbuffer[$key]['s'] = $t; $this->columnbuffer[$key]['newcol'] = $newcolumn; @@ -29483,6 +29917,16 @@ function printcolumnbuffer() { $this->breakpoints = array(); } +// mPDF 5.7+ +function columnAdjustPregReplace($type, $xadj, $yadj, $pattern, $subject) { + preg_match($pattern, $subject, $matches); + if (!isset($matches[3])) { $matches[3] = 0; } + if (!isset($matches[4])) { $matches[4] = 0; } + if (!isset($matches[5])) { $matches[5] = 0; } + if (!isset($matches[6])) { $matches[6] = 0; } + return str_replace($matches[0], $this->columnAdjustAdd($type, _MPDFK, $xadj, $yadj, $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]), $subject); +} + /*-- END COLUMNS --*/ @@ -30144,6 +30588,11 @@ function reverse_letters($str) { return $this->mb_strrev($str, $this->mb_enc); } +// mPDF 5.7+ +function reverse_letters_preg_callback($matches) { + return $this->reverse_letters($matches[1]); +} + function magic_reverse_dir(&$chunk, $join=true, $dir) { if ($this->usingCoreFont) { return 0; } if ($this->biDirectional) { @@ -30153,7 +30602,7 @@ function magic_reverse_dir(&$chunk, $join=true, $dir) { // Change Arabic + Persian. to Presentation Forms if ($join) { - $chunk = preg_replace("/([".$pregRTLchars."]+)/ue", '$this->ArabJoin(stripslashes(\'\\1\'))', $chunk ); + $chunk = preg_replace_callback("/([".$pregRTLchars."]+)/u", array($this, 'arabJoinPregCallback'), $chunk ); // mPDF 5.7+ } $contains_rtl = false; $all_rtl = true; @@ -30213,7 +30662,7 @@ function magic_reverse_dir(&$chunk, $join=true, $dir) { } else { // Reverse numerals only to RTL - $sbit = preg_replace("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/ue", '$this->reverse_letters(\'\\1\')', $sbit ); // mPDF 5.6.32 // mPDF 5.6.46 + $sbit = preg_replace_callback("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/u", array($this, 'reverse_letters_preg_callback'), $sbit ); // mPDF 5.7+ $sbits[$sbitkey] = $sbit; } } @@ -30225,7 +30674,7 @@ function magic_reverse_dir(&$chunk, $join=true, $dir) { } else { // Reverse numerals only to RTL - $bit = preg_replace("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/ue", '$this->reverse_letters(\'\\1\')', $bit ); // mPDF 5.6.32 // mPDF 5.6.46 + $bit = preg_replace_callback("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/u", array($this, 'reverse_letters_preg_callback'), $bit ); // mPDF 5.7+ $bits[$bitkey] = $bit; } } @@ -30236,7 +30685,7 @@ function magic_reverse_dir(&$chunk, $join=true, $dir) { $contains_rtl = true; // Un-Reverse numerals back to ltr - $chunk = preg_replace("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/ue", '$this->reverse_letters(\'\\1\')', $chunk ); // mPDF 5.6.13 // mPDF 5.6.32 // mPDF 5.6.46 + $chunk = preg_replace_callback("/([\x{0660}-\x{066C}0-9]+[\x{0660}-\x{066C}0-9\.,:\/]*[\x{0660}-\x{066C}0-9]+)/u", array($this, 'reverse_letters_preg_callback'), $chunk ); // mPDF 5.7+ if ($dir == 'rtl') { if ($endSpace) { $chunk = ' '.$chunk; } if ($initSpace) { $chunk .= ' '; } @@ -30656,8 +31105,6 @@ function purify_utf8($html,$lo=true) { // Only exception - leaves low ASCII entities e.g. < & etc. // Leaves in particular < to distinguish from tag marker if (!$this->is_utf8($html)) { - $e = new Exception(); - print $e->getTraceAsString(); echo "<p><b>HTML contains invalid UTF-8 character(s)</b></p>"; while (mb_convert_encoding(mb_convert_encoding($html, "UTF-32", "UTF-8"), "UTF-8", "UTF-32") != $html) { $a = iconv('UTF-8', 'UTF-8', $html); @@ -30689,11 +31136,7 @@ function purify_utf8($html,$lo=true) { function purify_utf8_text($txt) { // For TEXT // Make sure UTF-8 string of characters - if ($txt === null) $txt = ''; - if (!$this->is_utf8($txt)) { - $e = new Exception(); - print $e->getTraceAsString(); - $this->Error("Text contains invalid UTF-8 character(s)"); } + if (!$this->is_utf8($txt)) { $this->Error("Text contains invalid UTF-8 character(s)"); } $txt = preg_replace("/\r/", "", $txt ); @@ -31177,6 +31620,30 @@ function transformRotate($angle, $x='', $y='', $returnstring=false) { if ($returnstring) { return($this->_transform($tm, true)); } else { $this->_transform($tm); } } +// mPDF 5.7.3 TRANSFORMS +function transformSkew($angle_x, $angle_y, $x='', $y='', $returnstring=false) { + if ($x === '') { + $x = $this->x; + } + if ($y === '') { + $y = $this->y; + } + $angle_x = -$angle_x; + $angle_y = -$angle_y; + $x *= _MPDFK; + $y = ($this->h - $y) * _MPDFK; + //calculate elements of transformation matrix + $tm = array(); + $tm[0] = 1; + $tm[1] = tan(deg2rad($angle_y)); + $tm[2] = tan(deg2rad($angle_x)); + $tm[3] = 1; + $tm[4] = -$tm[2] * $y; + $tm[5] = -$tm[1] * $x; + //skew the coordinate system + if ($returnstring) { return($this->_transform($tm, true)); } + else { $this->_transform($tm); } +} function _transform($tm, $returnstring=false) { if ($returnstring) { return(sprintf('%.4F %.4F %.4F %.4F %.4F %.4F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5])); } else { $this->_out(sprintf('%.4F %.4F %.4F %.4F %.4F %.4F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5])); } @@ -31216,7 +31683,7 @@ function AutoFont($html) { /*-- CJK-FONTS --*/ if ($this->autoFontGroups & AUTOFONT_CJK) { - $e = preg_replace("/([".$this->pregCJKchars.$extra."]*[".$this->pregCJKchars."][".$this->pregCJKchars.$extra."]*)/ue", '$this->replaceCJK(stripslashes(\'\\1\'))', $e); + $e = preg_replace_callback("/([".$this->pregCJKchars .$extra."]*[".$this->pregCJKchars ."][".$this->pregCJKchars .$extra."]*)/u", array($this, 'replaceCJKPregCallback'), $e ); // mPDF 5.7+ } /*-- END CJK-FONTS --*/ @@ -31225,7 +31692,7 @@ function AutoFont($html) { // HEBREW $e = preg_replace("/([".$this->pregHEBchars .$extra."]*[".$this->pregHEBchars ."][".$this->pregHEBchars .$extra."]*)/u", "\xef\xbf\xb0span lang=\"he\"\xef\xbf\xb1\\1\xef\xbf\xb0/span\xef\xbf\xb1", $e); // All Arabic - $e = preg_replace("/([".$this->pregARABICchars .$extra."]*[".$this->pregARABICchars ."][".$this->pregARABICchars .$extra."]*)/ue", '$this->replaceArabic(stripslashes(\'\\1\'))', $e); + $e = preg_replace_callback("/([".$this->pregARABICchars .$extra."]*[".$this->pregARABICchars ."][".$this->pregARABICchars .$extra."]*)/u", array($this, 'replaceArabicPregCallback'), $e ); // mPDF 5.7+ } /*-- END RTL --*/ @@ -31302,6 +31769,11 @@ function replaceCJK($str) { } return $str; } + +// mPDF 5.7+ +function replaceCJKPregCallback($matches) { + return $this->replaceCJK(stripslashes($matches[1])); +} /*-- END CJK-FONTS --*/ /*-- RTL --*/ @@ -31341,6 +31813,11 @@ function replaceArabic($str) { return $str; } +// mPDF 5.7+ +function replaceArabicPregCallback($matches) { + return $this->replaceArabic(stripslashes($matches[1])); +} + // ARABIC =========================== // mPDF 5.4.08 function InitArabic() { @@ -31639,6 +32116,11 @@ function ArabJoin($str) { return $s; } +// mPDF 5.7+ +function arabJoinPregCallback($matches) { + return $this->ArabJoin(stripslashes($matches[1])); +} + // mPDF 5.4.08 function get_arab_glyphs($char, $type) { if ($type>0 && isset($this->arabGlyphs[$char])) { @@ -32049,6 +32531,22 @@ function ConvertSize($size=5,$maxsize=0,$fontsize=false,$usefontsize=true){ return $size; } +// mPDF 5.7.3 TRANSFORMS +function ConvertAngle($s, $makepositive=true) { + if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i',$s,$m)) { + $angle = $m[1] + 0; + if (strtolower($m[2])=='deg') { $angle = $angle; } + else if (strtolower($m[2])=='grad') { $angle *= (360/400); } + else if (strtolower($m[2])=='rad') { $angle = rad2deg($angle); } + while($angle >= 360) { $angle -= 360; } + while($angle <= -360) { $angle += 360; } + if ($makepositive) { // always returns an angle between 0 and 360deg + if ($angle < 0) { $angle += 360; } + } + } + else { $angle = $s + 0; } + return $angle; +} function lesser_entity_decode($html) { //supports the most used entity codes (only does ascii safe characters) @@ -32084,7 +32582,7 @@ function AdjustHTML($html, $tabSpaces=8) { preg_match_all("/(<svg.*?<\/svg>)/si", $html, $svgi); if (count($svgi[0])) { for($i=0;$i<count($svgi[0]);$i++) { - $file = _MPDF_TEMP_PATH.'_tempSVG'.RAND(1,10000).'_'.$i.'.svg'; + $file = _MPDF_TEMP_PATH.'_tempSVG'.uniqid(rand(1,100000),true).'_'.$i.'.svg'; //Save to local file file_put_contents($file, $svgi[0][$i]); $html = str_replace($svgi[0][$i], '<img src="'.$file.'" />', $html); // mPDF 5.5.18 @@ -32147,7 +32645,7 @@ function AdjustHTML($html, $tabSpaces=8) { $html = preg_replace('/[\t]/',' ',$html); //replace tabs by spaces // Converts < to < when not a tag - $html = preg_replace('/<([^!\/a-zA-Z])/i','<\\1',$html); + $html = preg_replace('/<([^!\/a-zA-Z_:])/i','<\\1',$html); // mPDF 5.7.3 $html = preg_replace("/[ ]+/",' ',$html); $html = preg_replace('/\/li>\s+<\/(u|o)l/i','/li></\\1l',$html); @@ -32160,12 +32658,14 @@ function AdjustHTML($html, $tabSpaces=8) { $iterator = 0; while($thereispre) //Recover <pre attributes>content</pre> { - $temp[2][$iterator] = preg_replace("/^([^\n\t]*?)\t/me", "stripslashes('\\1') . str_repeat(' ', ( $tabSpaces - (mb_strlen(stripslashes('\\1')) % $tabSpaces)) )",$temp[2][$iterator]); + $temp[2][$iterator] = preg_replace('/<([^!\/a-zA-Z_:])/','<\\1',$temp[2][$iterator]); // mPDF 5.7.2 // mPDF 5.7.3 + $temp[2][$iterator] = preg_replace_callback("/^([^\n\t]*?)\t/m", array($this, 'tabs2spaces_callback'), $temp[2][$iterator]); // mPDF 5.7+ $temp[2][$iterator] = preg_replace('/\t/',str_repeat(" ",$tabSpaces),$temp[2][$iterator]); $temp[2][$iterator] = preg_replace('/\n/',"<br />",$temp[2][$iterator]); $temp[2][$iterator] = str_replace('\\',"\\\\",$temp[2][$iterator]); - $html = preg_replace('#<pre(.*?)>(.*?)</pre>#si','<erp'.$temp[1][$iterator].'>'.$temp[2][$iterator].'</erp>',$html,1); + //$html = preg_replace('#<pre(.*?)>(.*?)</pre>#si','<erp'.$temp[1][$iterator].'>'.$temp[2][$iterator].'</erp>',$html,1); + $html = preg_replace('#<pre(.*?)>(.*?)</pre>#si','<erp'.$temp[1][$iterator].'>'.str_replace('$','\$',$temp[2][$iterator]).'</erp>',$html,1); // mPDF 5.7+ $thereispre--; $iterator++; } @@ -32193,6 +32693,14 @@ function AdjustHTML($html, $tabSpaces=8) { return $html; } +// mPDF 5.7+ +function tabs2spaces_callback($matches) { + return (stripslashes($matches[1]) . str_repeat(' ', $this->tabSpaces - (mb_strlen(stripslashes($matches[1])) % $this->tabSpaces))); +} +// mPDF 5.7+ +function date_callback($matches) { + return date($matches[1]); +} /*-- LISTS --*/ function dec2other($num, $cp) { diff --git a/include/mpdf/tmp/.keep b/include/mpdf/tmp/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/include/mpdf/ttfontdata/.keep b/include/mpdf/ttfontdata/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/include/staff/dynamic-form.inc.php b/include/staff/dynamic-form.inc.php index db879cc5f4690b226bc99370382be28b11fd62ec..4b1b852a09eedad808c779ba32e58c6d6b4c4bec 100644 --- a/include/staff/dynamic-form.inc.php +++ b/include/staff/dynamic-form.inc.php @@ -148,7 +148,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <?php } ?> </select> <?php if ($f->isConfigurable()) { ?> - <a class="action-button field-config" style="float:none;overflow:inherit" + <a class="action-button field-config" style="overflow:inherit" href="#ajax.php/form/field-config/<?php echo $f->get('id'); ?>" onclick="javascript: diff --git a/include/staff/dynamic-list.inc.php b/include/staff/dynamic-list.inc.php index f25f671135d4302bcbbda52a389e3fa904199d5b..f42abef7c27a9b035c5d4927147219bed01a5ad4 100644 --- a/include/staff/dynamic-list.inc.php +++ b/include/staff/dynamic-list.inc.php @@ -151,7 +151,7 @@ $info=Format::htmlchars(($errors && $_POST) ? array_merge($info,$_POST) : $info) </select> <?php if ($f->isConfigurable()) { ?> <a class="action-button field-config" - style="float:none;overflow:inherit" + style="overflow:inherit" href="#form/field-config/<?php echo $f->get('id'); ?>"><i class="icon-cog"></i> <?php echo __('Config'); ?></a> <?php } ?></td> @@ -254,7 +254,7 @@ $info=Format::htmlchars(($errors && $_POST) ? array_merge($info,$_POST) : $info) value="<?php echo $i->getValue(); ?>"/> <?php if ($list->hasProperties()) { ?> <a class="action-button field-config" - style="float:none;overflow:inherit" + style="overflow:inherit" href="#list/<?php echo $list->getId(); ?>/item/<?php echo $id ?>/properties" diff --git a/include/staff/helptopic.inc.php b/include/staff/helptopic.inc.php index 3674b6a10f2c4a063cfb050a501daeb91c269836..bd254cd2db7e1b7a1bc5d06ac42706cb5b6b3375 100644 --- a/include/staff/helptopic.inc.php +++ b/include/staff/helptopic.inc.php @@ -320,7 +320,7 @@ if ($info['form_id'] == Topic::FORM_USE_PARENT) echo 'selected="selected"'; ?>><?php echo $s->name; ?></option> <?php } ?> </select> - <button class="action-button" onclick="javascript: + <button class="action-button pull-right" onclick="javascript: $.dialog('ajax.php/sequence/manage', 205); return false; "><i class="icon-gear"></i> <?php echo __('Manage'); ?></button> diff --git a/include/staff/org-view.inc.php b/include/staff/org-view.inc.php index 304642b642d6fa0555d412b039181caf8941110d..c5cea44eb18989a13f3a3060f9c704183e383a64 100644 --- a/include/staff/org-view.inc.php +++ b/include/staff/org-view.inc.php @@ -9,11 +9,11 @@ if(!defined('OSTSCPINC') || !$thisstaff || !is_object($org)) die('Invalid path') title="Reload"><i class="icon-refresh"></i> <?php echo $org->getName(); ?></a></h2> </td> <td width="50%" class="right_align has_bottom_border"> - <span class="action-button" data-dropdown="#action-dropdown-more"> + <span class="action-button pull-right" data-dropdown="#action-dropdown-more"> + <i class="icon-caret-down pull-right"></i> <span ><i class="icon-cog"></i> <?php echo __('More'); ?></span> - <i class="icon-caret-down"></i> </span> - <a id="org-delete" class="action-button org-action" + <a id="org-delete" class="action-button pull-right org-action" href="#orgs/<?php echo $org->getId(); ?>/delete"><i class="icon-trash"></i> <?php echo __('Delete Organization'); ?></a> <div id="action-dropdown-more" class="action-dropdown anchor-right"> diff --git a/include/staff/settings-tickets.inc.php b/include/staff/settings-tickets.inc.php index eea65c8bb7186430cb3a17d0e4628240d0b8c9e2..2e23da95068b404e91ace8b02749690fb2b9a802 100644 --- a/include/staff/settings-tickets.inc.php +++ b/include/staff/settings-tickets.inc.php @@ -46,7 +46,7 @@ if(!($maxfileuploads=ini_get('max_file_uploads'))) ?>><?php echo $s->name; ?></option> <?php } ?> </select> - <button class="action-button" onclick="javascript: + <button class="action-button pull-right" onclick="javascript: $.dialog('ajax.php/sequence/manage', 205); return false; "><i class="icon-gear"></i> <?php echo __('Manage'); ?></button> @@ -220,7 +220,7 @@ if(!($maxfileuploads=ini_get('max_file_uploads'))) $tform = TicketForm::objects()->one()->getForm(); $f = $tform->getField('message'); ?> - <a class="action-button field-config" style="float:none;overflow:inherit" + <a class="action-button field-config" style="overflow:inherit" href="#ajax.php/form/field-config/<?php echo $f->get('id'); ?>" onclick="javascript: diff --git a/include/staff/team.inc.php b/include/staff/team.inc.php index 9923350b1429b15d11c1094c57099a045b489529..4b2feacbfd06c1898990ce90cfc9ce13f5b05321 100644 --- a/include/staff/team.inc.php +++ b/include/staff/team.inc.php @@ -105,7 +105,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </tr> <?php foreach($members as $k=>$staff){ - echo sprintf('<tr><td colspan=2><span style="width:350px;padding-left:5px; display:block; float:left;"> + echo sprintf('<tr><td colspan=2><span style="width:350px;padding-left:5px; display:block;" class="pull-left"> <b><a href="staff.php?id=%d">%s</a></span></b> <input type="checkbox" name="remove[]" value="%d"><i>'.__('Remove').'</i></td></tr>', $staff->getId(),$staff->getName(),$staff->getId()); diff --git a/include/staff/templates/content-manage.tmpl.php b/include/staff/templates/content-manage.tmpl.php index a570d19e47d3a28d88198606ad36c382b0cc327c..ddf9892ad4a5eef850ac4927571538f7580ec9c0 100644 --- a/include/staff/templates/content-manage.tmpl.php +++ b/include/staff/templates/content-manage.tmpl.php @@ -13,12 +13,12 @@ echo $content->getNotes(); ?></div> <hr/> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="<?php echo $user ? 'cancel' : 'close'; ?>" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Save Changes'); ?>"> </span> </p> diff --git a/include/staff/templates/dynamic-field-config.tmpl.php b/include/staff/templates/dynamic-field-config.tmpl.php index 5b2716e4e1e53d09034af80cdcfd7663b2668e21..51701b6ee1f66ce93c66fba5845a14abfd65d78b 100644 --- a/include/staff/templates/dynamic-field-config.tmpl.php +++ b/include/staff/templates/dynamic-field-config.tmpl.php @@ -51,11 +51,11 @@ </div> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" value="<?php echo __('Cancel'); ?>" class="close"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Save'); ?>"> </span> </p> diff --git a/include/staff/templates/dynamic-form.tmpl.php b/include/staff/templates/dynamic-form.tmpl.php index 611306d1ba831a32f54a1cca0a1d2bfe7b44b7dd..8ed99010089804b4a63f513b238c1ef50a56719c 100644 --- a/include/staff/templates/dynamic-form.tmpl.php +++ b/include/staff/templates/dynamic-form.tmpl.php @@ -64,7 +64,7 @@ if (isset($options['entry']) && $options['mode'] == 'edit') { ?> <?php } if (($a = $field->getAnswer()) && $a->isDeleted()) { - ?><a class="action-button danger overlay" title="Delete this data" + ?><a class="action-button float-right danger overlay" title="Delete this data" href="#delete-answer" onclick="javascript:if (confirm('<?php echo __('You sure?'); ?>')) $.ajax({ diff --git a/include/staff/templates/form-manage.tmpl.php b/include/staff/templates/form-manage.tmpl.php index abb649e78e6b7047f3575092500b1cac15d98d87..378fad751e0b7d52b019b17c7ffd9b2bd5030a4f 100644 --- a/include/staff/templates/form-manage.tmpl.php +++ b/include/staff/templates/form-manage.tmpl.php @@ -57,12 +57,12 @@ foreach ($forms as $e) { ?> </div> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="<?php echo $user ? 'cancel' : 'close' ?>" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Save Changes'); ?>"> </span> </p> diff --git a/include/staff/templates/list-item-properties.tmpl.php b/include/staff/templates/list-item-properties.tmpl.php index a8d158f98e5641ade0376c8090fec148fe8ff62f..dcfc34b92d5bb7f51497cd227a13a2f609a79bc6 100644 --- a/include/staff/templates/list-item-properties.tmpl.php +++ b/include/staff/templates/list-item-properties.tmpl.php @@ -50,11 +50,11 @@ </table> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" value="<?php echo __('Cancel'); ?>" class="close"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Save'); ?>"> </span> </p> diff --git a/include/staff/templates/org-delete.tmpl.php b/include/staff/templates/org-delete.tmpl.php index 76222df053c66bf666e3d5cf1758deb60218b3f2..16e06c83b556e6bb2a034ba46d38c5c4834e3ec7 100644 --- a/include/staff/templates/org-delete.tmpl.php +++ b/include/staff/templates/org-delete.tmpl.php @@ -50,12 +50,12 @@ if ($info['error']) { action="#orgs/<?php echo $org->getId(); ?>/delete"> <input type="hidden" name="id" value="<?php echo $org->getId(); ?>" /> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="close" value="<?php echo __('No, Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Yes, Delete'); ?>"> </span> </p> diff --git a/include/staff/templates/org-lookup.tmpl.php b/include/staff/templates/org-lookup.tmpl.php index 849eb126ba3684f05f906d0d8d8a884c901963a5..10a4ce28fbf75916ba718e52e45bd0c9f38ae25a 100644 --- a/include/staff/templates/org-lookup.tmpl.php +++ b/include/staff/templates/org-lookup.tmpl.php @@ -55,10 +55,10 @@ if ($info['error']) { <div class="clear"></div> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="button" name="cancel" class="close" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Continue'); ?>"> </span> </p> @@ -73,12 +73,12 @@ if ($info['error']) { </table> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> - <input type="button" name="cancel" class="<?php echo $org ? 'cancel' : 'close' ?>" + <input type="button" name="cancel" class="<?php echo $org ? 'cancel' : 'close' ?>" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Add Organization'); ?>"> </span> </p> diff --git a/include/staff/templates/org-profile.tmpl.php b/include/staff/templates/org-profile.tmpl.php index 800a0aad26ceb550e2f06276652a5b27c517e914..2b83f76b602a1fdbf32149957eb6118ed865efa1 100644 --- a/include/staff/templates/org-profile.tmpl.php +++ b/include/staff/templates/org-profile.tmpl.php @@ -144,12 +144,12 @@ if ($ticket && $ticket->getOwnerId() == $user->getId()) <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="<?php echo $account ? 'cancel' : 'close'; ?>" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Update Organization'); ?>"> </span> </p> diff --git a/include/staff/templates/org.tmpl.php b/include/staff/templates/org.tmpl.php index 222db9837f6a68ec786ba90d9985f7ca42443b94..06f82255c7736dc9db02d58f65ed5e51073f2b18 100644 --- a/include/staff/templates/org.tmpl.php +++ b/include/staff/templates/org.tmpl.php @@ -61,12 +61,12 @@ if ($ticket && $ticket->getOwnerId() == $user->getId()) </table> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="<?php echo $account ? 'cancel' : 'close'; ?>" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Update Organization'); ?>"> </span> </p> diff --git a/include/staff/templates/sequence-manage.tmpl.php b/include/staff/templates/sequence-manage.tmpl.php index 6f242eac61ab5e01d4bb449745eeca42c30a08b4..6827cd6267d5d5f0c8cbae54a0af44cf162c91be 100644 --- a/include/staff/templates/sequence-manage.tmpl.php +++ b/include/staff/templates/sequence-manage.tmpl.php @@ -19,7 +19,7 @@ foreach ($sequences as $e) { <input type="hidden" class="fdeleted" name="seq[<?php echo $e->get('id'); ?>][deleted]" value="0"/> <i class="icon-sort-by-order"></i> <div style="display:inline-block" class="name"> <?php echo $e->getName(); ?> </div> - <div style="display:inline-block;margin-right:60px" class="pull-right"> + <div class="manage-buttons pull-right"> <span class="faded">next</span> <span class="current"><?php echo $e->current(); ?></span> </div> @@ -45,7 +45,7 @@ foreach ($sequences as $e) { <div class="row-item hidden" id="template"> <i class="icon-sort-by-order"></i> <div style="display:inline-block" class="name"> <?php echo __('New Sequence'); ?> </div> - <div style="display:inline-block;margin-right:60px" class="pull-right"> + <div class="manage-buttons pull-right"> <span class="faded">next</span> <span class="next">1</span> </div> diff --git a/include/staff/templates/status-options.tmpl.php b/include/staff/templates/status-options.tmpl.php index 78372ed09195a50376f55cd34696db6c43af91a6..edfdf19564e0367a1ebaa97e3adc1e08d075cf04 100644 --- a/include/staff/templates/status-options.tmpl.php +++ b/include/staff/templates/status-options.tmpl.php @@ -15,13 +15,13 @@ $actions= array( ?> <span - class="action-button" + class="action-button pull-right" data-dropdown="#action-dropdown-statuses"> + <i class="icon-caret-down pull-right"></i> <a class="tickets-action" href="#statuses"><i class="icon-flag"></i> <?php echo __('Change Status'); ?></a> - <i class="icon-caret-down"></i> </span> <div id="action-dropdown-statuses" class="action-dropdown anchor-right"> diff --git a/include/staff/templates/ticket-status.tmpl.php b/include/staff/templates/ticket-status.tmpl.php index 23d54255b00ac9c2d5ecdba8ea530596c58eb7ca..c033e0caa8d541b2a9bbed596fb3e8ba2d8c7c80 100644 --- a/include/staff/templates/ticket-status.tmpl.php +++ b/include/staff/templates/ticket-status.tmpl.php @@ -93,12 +93,12 @@ $action = $info['action'] ?: ('#tickets/status/'. $state); </table> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="close" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo $verb ?: __('Submit'); ?>"> </span> diff --git a/include/staff/templates/tickets.tmpl.php b/include/staff/templates/tickets.tmpl.php index 64f1aa91c6c0cbbfa4da5379ec870256e9e85184..ea0aae0b7e3b28be02252f2d245100b4b73cbddc 100644 --- a/include/staff/templates/tickets.tmpl.php +++ b/include/staff/templates/tickets.tmpl.php @@ -56,7 +56,7 @@ if ($results) { } } ?> -<div style="width:700px; float:left;"> +<div style="width:700px;" class="pull-left"> <?php if ($results) { echo '<strong>'.sprintf(_N('Showing %d ticket', 'Showing %d tickets', @@ -66,7 +66,7 @@ if ($results) { } ?> </div> -<div style="float:right;text-align:right;padding-right:5px;"> +<div class="pull-right flush-right" style="padding-right:5px;"> <?php if ($user) { ?> <b><a class="Icon newTicket" href="tickets.php?a=open&uid=<?php echo $user->getId(); ?>"> diff --git a/include/staff/templates/user-account.tmpl.php b/include/staff/templates/user-account.tmpl.php index 95509afc6cc5317af65af3575f168cc2f5b86a3f..c56e44bda86865f6220c17311d7404fecac85512 100644 --- a/include/staff/templates/user-account.tmpl.php +++ b/include/staff/templates/user-account.tmpl.php @@ -154,11 +154,11 @@ if ($info['error']) { </div> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="close" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Save Changes'); ?>"> </span> diff --git a/include/staff/templates/user-delete.tmpl.php b/include/staff/templates/user-delete.tmpl.php index 876b5d14ee278b3505b7291ca2fa53710246c15d..b563643d284146896f33ce2df58532d6da5d4554 100644 --- a/include/staff/templates/user-delete.tmpl.php +++ b/include/staff/templates/user-delete.tmpl.php @@ -64,12 +64,12 @@ if ($info['error']) { } ?> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="close" value="<?php echo __('No, Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Yes, Delete User'); ?>"> </span> </p> diff --git a/include/staff/templates/user-import.tmpl.php b/include/staff/templates/user-import.tmpl.php index 25a261e39c1bf03dcd39dbdca6720a67442a6805..447f83ee2441b3764853e2f5e7098b800c6bc9db 100644 --- a/include/staff/templates/user-import.tmpl.php +++ b/include/staff/templates/user-import.tmpl.php @@ -74,12 +74,12 @@ if ($org_id) { ?> </div> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="close" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Import Users'); ?>"> </span> </p> diff --git a/include/staff/templates/user-lookup.tmpl.php b/include/staff/templates/user-lookup.tmpl.php index 980a032fc4050edd86e7d24e98d8448dfb1edcc7..fa18f885888041d997c5e75e192d5644e7fd35b2 100644 --- a/include/staff/templates/user-lookup.tmpl.php +++ b/include/staff/templates/user-lookup.tmpl.php @@ -54,11 +54,11 @@ if ($info['error']) { <div class="clear"></div> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="button" name="cancel" class="close" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Continue'); ?>"> </span> </p> @@ -73,11 +73,11 @@ if ($info['error']) { </table> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="<?php echo $user ? 'cancel' : 'close' ?>" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Add User'); ?>"> </span> </p> diff --git a/include/staff/templates/user-register.tmpl.php b/include/staff/templates/user-register.tmpl.php index 6f5662ca213361fd8e163b3e3be43134a46bb3d2..015f82edf9fa5a66fe9d0c744deeb8a8eb665896 100644 --- a/include/staff/templates/user-register.tmpl.php +++ b/include/staff/templates/user-register.tmpl.php @@ -165,11 +165,11 @@ echo sprintf(__( </table> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="close" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Create Account'); ?>"> </span> </p> diff --git a/include/staff/templates/user.tmpl.php b/include/staff/templates/user.tmpl.php index 655e92ecfeba38232b3d6ac4e8c5a90f37d435b3..af21b01286708196a9d3ebfce6b4b08849f9954f 100644 --- a/include/staff/templates/user.tmpl.php +++ b/include/staff/templates/user.tmpl.php @@ -129,12 +129,12 @@ if ($ticket && $ticket->getOwnerId() == $user->getId()) </table> <hr> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="reset" value="<?php echo __('Reset'); ?>"> <input type="button" name="cancel" class="<?php echo ($ticket && $user) ? 'cancel' : 'close' ?>" value="<?php echo __('Cancel'); ?>"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="submit" value="<?php echo __('Update User'); ?>"> </span> </p> diff --git a/include/staff/templates/users.tmpl.php b/include/staff/templates/users.tmpl.php index 11eb0952a47eaa4561fefb40e2aef178e9920347..40a2d4952e1c2043917b961b9601cf3a0f0d6c81 100644 --- a/include/staff/templates/users.tmpl.php +++ b/include/staff/templates/users.tmpl.php @@ -53,8 +53,8 @@ else $showing .= __("This organization doesn't have any users yet"); ?> -<div style="width:700px; float:left;"><b><?php echo $showing; ?></b></div> -<div style="float:right;text-align:right;padding-right:5px;"> +<div style="width:700px;" class="pull-left"><b><?php echo $showing; ?></b></div> +<div class="pull-right flush-right" style="padding-right:5px;"> <b><a href="#orgs/<?php echo $org->getId(); ?>/add-user" class="Icon newstaff add-user" ><?php echo __('Add User'); ?></a></b> | @@ -164,10 +164,10 @@ if ($res && $num) { //Show options.. <div><?php echo __('Please confirm to continue.'); ?></div> <hr style="margin-top:1em"/> <p class="full-width"> - <span class="buttons" style="float:left"> + <span class="buttons pull-left"> <input type="button" value="<?php echo __('No, Cancel'); ?>" class="close"> </span> - <span class="buttons" style="float:right"> + <span class="buttons pull-right"> <input type="button" value="<?php echo __('Yes, Do it!'); ?>" class="confirm"> </span> </p> diff --git a/include/staff/ticket-edit.inc.php b/include/staff/ticket-edit.inc.php index 406d6967196bc9d8fe2d72e4ff2e8528719ffb65..96d1abe6fc943457bf67cbfd3459582dd5b0da2c 100644 --- a/include/staff/ticket-edit.inc.php +++ b/include/staff/ticket-edit.inc.php @@ -36,7 +36,7 @@ if ($_POST) <span id="client-name"><?php echo Format::htmlchars($user->getName()); ?></span> <<span id="client-email"><?php echo $user->getEmail(); ?></span>> </a> - <a class="action-button" style="float:none;overflow:inherit" href="#" + <a class="action-button" style="overflow:inherit" href="#" onclick="javascript: $.userLookup('ajax.php/tickets/<?php echo $ticket->getId(); ?>/change-user', function(user) { diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index 5ca5cb5436b480e319d5c2b93a522ad036735249..3c8b8f2421ee1840c2ddae3e2574abb4d387c1b0 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -59,7 +59,7 @@ if ($_POST) <span id="user-name"><?php echo Format::htmlchars($user->getName()); ?></span> <<span id="user-email"><?php echo $user->getEmail(); ?></span>> </a> - <a class="action-button" style="float:none;overflow:inherit" href="#" + <a class="action-button" style="overflow:inherit" href="#" onclick="javascript: $.userLookup('ajax.php/users/select/'+$('input#uid').val(), function(user) { diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 5a0100bbcaf2f16ce5c9513d19905845f5c7c013..078af3a0a268bf45bed22653fcbecfdaef703ba2 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -57,14 +57,14 @@ if($ticket->isOverdue()) title="<?php echo __('Reload'); ?>"><i class="icon-refresh"></i> <?php echo sprintf(__('Ticket #%s'), $ticket->getNumber()); ?></a></h2> </td> - <td width="auto" class="right_align has_bottom_border"> + <td width="auto" class="flush-right has_bottom_border"> <?php if ($thisstaff->canBanEmails() || $thisstaff->canEditTickets() || ($dept && $dept->isManager($thisstaff))) { ?> - <span class="action-button" data-dropdown="#action-dropdown-more"> + <span class="action-button pull-right" data-dropdown="#action-dropdown-more"> + <i class="icon-caret-down pull-right"></i> <span ><i class="icon-cog"></i> <?php echo __('More');?></span> - <i class="icon-caret-down"></i> </span> <?php } @@ -72,20 +72,20 @@ if($ticket->isOverdue()) echo TicketStatus::status_options(); if ($thisstaff->canEditTickets()) { ?> - <a class="action-button" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=edit"><i class="icon-edit"></i> <?php + <a class="action-button pull-right" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=edit"><i class="icon-edit"></i> <?php echo __('Edit'); ?></a> <?php } if ($ticket->isOpen() && !$ticket->isAssigned() && $thisstaff->canAssignTickets()) {?> - <a id="ticket-claim" class="action-button confirm-action" href="#claim"><i class="icon-user"></i> <?php + <a id="ticket-claim" class="action-button pull-right confirm-action" href="#claim"><i class="icon-user"></i> <?php echo __('Claim'); ?></a> <?php }?> - <span class="action-button" data-dropdown="#action-dropdown-print"> + <span class="action-button pull-right" data-dropdown="#action-dropdown-print"> + <i class="icon-caret-down pull-right"></i> <a id="ticket-print" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=print"><i class="icon-print"></i> <?php echo __('Print'); ?></a> - <i class="icon-caret-down"></i> </span> <div id="action-dropdown-print" class="action-dropdown anchor-right"> <ul> @@ -389,11 +389,13 @@ $tcount+= $ticket->getNumNotes(); <tr> <th colspan="4" width="100%"> <div> + <span class="pull-left"> <span style="display:inline-block"><?php echo Format::db_datetime($entry['created']);?></span> - <span style="display:inline-block;padding-left:1em" class="faded title"><?php + <span style="display:inline-block;padding:0 1em" class="faded title"><?php echo Format::truncate($entry['title'], 100); ?></span> - <span style="float:right;white-space:no-wrap;display:inline-block"> + </span> + <span class="pull-right" style="white-space:no-wrap;display:inline-block"> <span style="vertical-align:middle;" class="textra"></span> <span style="vertical-align:middle;" class="tmeta faded title"><?php @@ -632,7 +634,7 @@ print $response_form->getField('attachments')->render(); </tr> </tbody> </table> - <p style="padding-left:165px;"> + <p style="padding:0 165px;"> <input class="btn_sm" type="submit" value="<?php echo __('Post Reply');?>"> <input class="btn_sm" type="reset" value="<?php echo __('Reset');?>"> </p> diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php index 3b716905e3a12150365c39da98d19458daa2e23c..bedb40e2fffd47676dc5669a8a7b9eb6b8ca5b00 100644 --- a/include/staff/tickets.inc.php +++ b/include/staff/tickets.inc.php @@ -334,7 +334,7 @@ if ($results) { <?php if ($thisstaff->canDeleteTickets()) { ?> - <a id="tickets-delete" class="action-button tickets-action" + <a id="tickets-delete" class="action-button pull-right tickets-action" href="#tickets/status/delete"><i class="icon-trash"></i> <?php echo __('Delete'); ?></a> <?php diff --git a/include/staff/user-view.inc.php b/include/staff/user-view.inc.php index 7a5bd384bf413ce7e8507a5ef04c8248c847fcfe..58f4348ee258fe3d26c1fefe8d196083cb6c2328 100644 --- a/include/staff/user-view.inc.php +++ b/include/staff/user-view.inc.php @@ -13,21 +13,21 @@ $org = $user->getOrganization(); title="Reload"><i class="icon-refresh"></i> <?php echo Format::htmlchars($user->getName()); ?></a></h2> </td> <td width="50%" class="right_align has_bottom_border"> - <span class="action-button" data-dropdown="#action-dropdown-more"> + <span class="action-button pull-right" data-dropdown="#action-dropdown-more"> + <i class="icon-caret-down pull-right"></i> <span ><i class="icon-cog"></i> <?php echo __('More'); ?></span> - <i class="icon-caret-down"></i> </span> - <a id="user-delete" class="action-button user-action" + <a id="user-delete" class="action-button pull-right user-action" href="#users/<?php echo $user->getId(); ?>/delete"><i class="icon-trash"></i> <?php echo __('Delete User'); ?></a> <?php if ($account) { ?> - <a id="user-manage" class="action-button user-action" + <a id="user-manage" class="action-button pull-right user-action" href="#users/<?php echo $user->getId(); ?>/manage"><i class="icon-edit"></i> <?php echo __('Manage Account'); ?></a> <?php } else { ?> - <a id="user-register" class="action-button user-action" + <a id="user-register" class="action-button pull-right user-action" href="#users/<?php echo $user->getId(); ?>/register"><i class="icon-edit"></i> <?php echo __('Register'); ?></a> <?php diff --git a/js/filedrop.field.js b/js/filedrop.field.js index 8b53508c1b5ea8f9ce969c8cddf766e50ff9d08b..d07a2a675455cf3c5af0f8046a82aa5822c4497b 100644 --- a/js/filedrop.field.js +++ b/js/filedrop.field.js @@ -153,7 +153,7 @@ filenode .append($('<div class="filetype"></div>').addClass()) .append($('<img class="preview" />')) - .append($('<div class="filename"></div>') + .append($('<span class="filename ltr"></div>') .append($('<span class="filesize"></span>').text( this.fileSize(parseInt(file.size)) )) @@ -186,7 +186,7 @@ .attr('href', 'file.php?h='+escape(file.download)) ); else - filenode.find('.filename').prepend(document.createTextNode(file.name)); + filenode.find('.filename').prepend($('<span>').text(file.name)); this.$element.parent().find('.files').append(filenode); this.uploads.push(filenode); return filenode; diff --git a/js/osticket.js b/js/osticket.js index 133c225c7d4e328c72dc4401d268affe7fa561de..f4aeebd1a1075541fadb34c70f4f49ce6fd70452 100644 --- a/js/osticket.js +++ b/js/osticket.js @@ -132,7 +132,7 @@ $(document).ready(function(){ if (!extra) return; if (!imgs.length) return; extra.append($('<a>') - .addClass("action-button show-images") + .addClass("action-button show-images pull-right") .css({'font-weight':'normal'}) .text(' ' + __('Show Images')) .click(function(ev) { @@ -194,7 +194,7 @@ showImagesInline = function(urls, thread_id) { } ).append($('<div class="caption">') .append('<span class="filename">'+info.filename+'</span>') - .append('<a href="'+info.download_url+'" class="action-button"><i class="icon-download-alt"></i> ' + __('Download') + '</a>') + .append('<a href="'+info.download_url+'" class="action-button pull-right"><i class="icon-download-alt"></i> ' + __('Download') + '</a>') ); e.data('wrapped', true); } diff --git a/js/redactor-fonts.js b/js/redactor-fonts.js index a052e57ec8a00c1389c5849ea8f501f4a4bda73a..021ca561d63b28bd5e38b8c4f1c4ef8bdc6bfe57 100644 --- a/js/redactor-fonts.js +++ b/js/redactor-fonts.js @@ -145,28 +145,43 @@ RedactorPlugins.textdirection = { var button = this.buttonAdd('textdirection', __('Change Text Direction'), false, dropdown); + + if (this.opts.direction == 'rtl') + this.setRtl(); }, setRtl: function() { - if (!this.opts.linebreaks) { - this.bufferSet(); - this.blockSetAttr('dir', 'rtl'); + var c = this.getCurrent(), s = this.getSelection(); + this.bufferSet(); + if (s.type == 'Range' && s.focusNode.nodeName != 'div') { + this.linebreakHack(s); } - else { - this.$editor.attr('dir', 'rtl'); + else if (!c) { + var repl = '<div dir="rtl">' + this.get() + '</div>'; + this.set(repl, false); } - this.$box.removeClass('ltr').addClass('rtl'); - + $(this.getCurrent()).attr('dir', 'rtl'); + this.sync(); }, setLtr: function() { - if (!this.opts.linebreaks) { - this.bufferSet(); - this.blockSetAttr('dir', 'ltr'); + var c = this.getCurrent(), s = this.getSelection(); + this.bufferSet(); + if (s.type == 'Range' && s.focusNode.nodeName != 'div') { + this.linebreakHack(s); } - else { - this.$editor.attr('dir', 'ltr'); + else if (!c) { + var repl = '<div dir="ltr">' + this.get() + '</div>'; + this.set(repl, false); } - this.$box.removeClass('rtl').addClass('ltr'); + $(this.getCurrent()).attr('dir', 'ltr'); + this.sync(); + }, + linebreakHack: function(sel) { + var range = sel.getRangeAt(0); + var wrapper = document.createElement('div'); + wrapper.appendChild(range.extractContents()); + range.insertNode(wrapper); + this.selectionElement(wrapper); } }; diff --git a/scp/css/bootstrap.css b/scp/css/bootstrap.css index 596bdd56453bc4187ae7e1368c80d7f9918fb652..7a02fb748814898548e67f60e34185991712de67 100644 --- a/scp/css/bootstrap.css +++ b/scp/css/bootstrap.css @@ -1268,7 +1268,7 @@ legend + .control-group { } .nav-tabs > li, .nav-pills > li { - float: left; + display: inline-block; } .nav-tabs > li > a, .nav-pills > li > a { diff --git a/scp/css/dropdown.css b/scp/css/dropdown.css index 961abd6fa0fb3b7945ef6bcd56594c1c947ddb8d..4fb664178aaa2ab61f663d6b9219ad00740bf64d 100644 --- a/scp/css/dropdown.css +++ b/scp/css/dropdown.css @@ -104,7 +104,6 @@ padding: 0 5px; text-decoration: none !important; line-height:18px; - float:right; margin-left:5px; } .action-button span, @@ -121,7 +120,6 @@ background-image: -ms-linear-gradient(top, #efefef 0%, #dddddd 100%); background-image: -o-linear-gradient(top, #efefef 0%, #dddddd 100%); background-image: linear-gradient(top, #efefef 0%, #dddddd 100%); - float: right; height: 18px; line-height: 18px; margin-right: 0; diff --git a/scp/css/scp.css b/scp/css/scp.css index 0dc2092a119c3d89d5e0625067459cd22fd75abe..2fe63818d17da1f6514482d6b93a69b27c96791b 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -144,8 +144,7 @@ div#header a { } #nav .active, #nav .inactive { - display:block; - float:left; + display:inline-block; min-width:95px; width: auto; padding-left: 10px; @@ -254,8 +253,7 @@ div#header a { } #sub_nav a { - display:block; - float:left; + display:inline-block; padding:0 10px 0 21px; background-position:0 50%; background-repeat:no-repeat; @@ -784,9 +782,8 @@ h2 .reload { } #threads li a { - display:block; + display:inline-block; width:auto; - float:left; height:30px; line-height:30px; border-top:1px solid #F4FAFF; @@ -896,7 +893,7 @@ ul.tabs { padding:4px 0 0 20px; margin:0; margin-bottom: 5px; - text-align:center; + text-align:left; height:29px; border-bottom:1px solid #aaa; background:#eef3f8; @@ -921,14 +918,14 @@ ul.tabs li a { height:18px; line-height:20px; color:#444; - display:block; - float:left; + display:inline-block; outline:none; position:relative; - top:0; + bottom:1px; background:#fbfbfb; border:1px solid #eee; border-bottom:none; + text-align: center; } #response_options .reply_tab.tell { @@ -945,6 +942,7 @@ ul.tabs li a.active { border:1px solid #aaa; border-top:2px solid #81a9d7; border-bottom:none; + bottom: 0; } #response_options > form { @@ -1763,6 +1761,10 @@ div.selected-signature .inner { background: #fc9f41; /* Old browsers */ color: rgba(255,255,255,0.8) !important; } +#sequences .manage-buttons { + display: inline-block; + margin-right: 60px; +} tr.disabled td, tr.disabled th { diff --git a/scp/js/jquery.dropdown.js b/scp/js/jquery.dropdown.js index c0604e75d2686c457c5ccb56c4c7be9122dbe970..b885042086efee07eeb228c60abefd86ec278c0b 100644 --- a/scp/js/jquery.dropdown.js +++ b/scp/js/jquery.dropdown.js @@ -36,7 +36,8 @@ if(jQuery) (function($) { var trigger = $(this), dropdown = $( $(this).attr('data-dropdown') ), - isOpen = trigger.hasClass('dropdown-open'); + isOpen = trigger.hasClass('dropdown-open'), + rtl = $('html').hasClass('rtl'); event.preventDefault(); event.stopPropagation(); @@ -45,6 +46,9 @@ if(jQuery) (function($) { if( isOpen || trigger.hasClass('dropdown-disabled') ) return; + if (rtl && dropdown.hasClass('anchor-right')) + dropdown.removeClass('anchor-right'); + dropdown.css({ left: dropdown.hasClass('anchor-right') ? trigger.offset().left - (dropdown.outerWidth() - trigger.outerWidth() - 4) : trigger.offset().left, diff --git a/scp/js/ticket.js b/scp/js/ticket.js index ca5f3957e25da6f1218aa102e27725f6c51b17e3..2c9398a5ac28bf56b2f8da4ba0c02f927d97fc49 100644 --- a/scp/js/ticket.js +++ b/scp/js/ticket.js @@ -306,7 +306,7 @@ $.showImagesInline = function(urls, thread_id) { } ).append($('<div class="caption">') .append('<span class="filename">'+info.filename+'</span>') - .append('<a href="'+info.download_url+'" class="action-button no-pjax"><i class="icon-download-alt"></i> '+__('Download')+'</a>') + .append('<a href="'+info.download_url+'" class="action-button pull-right no-pjax"><i class="icon-download-alt"></i> '+__('Download')+'</a>') ); e.data('wrapped', true); } @@ -419,7 +419,7 @@ var ticket_onload = function($) { if (!extra) return; if (!imgs.length) return; extra.append($('<a>') - .addClass("action-button show-images") + .addClass("action-button pull-right show-images") .css({'font-weight':'normal'}) .text(' ' + __('Show Images')) .click(function(ev) { diff --git a/scp/js/tips.js b/scp/js/tips.js index 4d623eb165224df19caf4fb06a51593d0f907540..93f4f14c75d49d1c151e27ffc787e1abb42f3078 100644 --- a/scp/js/tips.js +++ b/scp/js/tips.js @@ -10,8 +10,16 @@ jQuery(function() { var tip_shadow = $('<div>').addClass('tip_shadow'); var tip_content = $('<div>').addClass('tip_content').load(url, function() { tip_content.prepend('<a href="#" class="tip_close"><i class="icon-remove-circle"></i></a>').append(tip_arrow); - if ($(window).width() < tip_content.outerWidth() + the_tip.position().left) { - console.log(x_pos, tip_content.outerWidth(), elem.width()); + var width = $(window).width(), + rtl = $('html').hasClass('rtl'), + size = tip_content.outerWidth(), + left = the_tip.position().left, + left_room = left - size, + right_room = width - size - left, + flip = rtl + ? (left_room > 0 && left_room > right_room) + : (right_room < 0 && left_room > right_room); + if (flip) { the_tip.css({'left':x_pos-tip_content.outerWidth()-elem.width()-32+'px'}); tip_box.addClass('right'); tip_arrow.addClass('flip-x'); @@ -105,7 +113,16 @@ jQuery(function() { tip_timer = setTimeout(function() { $('.tip_box').remove(); $('body').append(the_tip.hide().fadeIn()); - if ($(window).width() < tip_content.outerWidth() + the_tip.position().left) { + var width = $(window).width(), + rtl = $('html').hasClass('rtl'), + size = tip_content.outerWidth(), + left = the_tip.position().left, + left_room = left - size, + right_room = width - size - left, + flip = rtl + ? (left_room > 0 && left_room > right_room) + : (right_room < 0 && left_room > right_room); + if (flip) { the_tip.css({'left':x_pos-tip_content.outerWidth()-40+'px'}); tip_box.addClass('right'); tip_arrow.addClass('flip-x'); diff --git a/setup/cli/modules/i18n.php b/setup/cli/modules/i18n.php index 269386dfd55097de993e3d6bbc0309e474d9cc67..57a8bd0abf91f0d5fc6d016c22c56928bfeb9199 100644 --- a/setup/cli/modules/i18n.php +++ b/setup/cli/modules/i18n.php @@ -41,6 +41,7 @@ class i18n_Compiler extends Module { static $crowdin_api_url = 'http://i18n.osticket.com/api/project/{project}/{command}'; function _http_get($url) { + $this->stdout->write(">>> Downloading $url\n"); #curl post $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); @@ -198,6 +199,25 @@ class i18n_Compiler extends Module { $this->stderr->write(str_replace('_','-',$lang) .": Unable to fetch jQuery UI Datepicker locale file\n"); + // True type fonts for PDF printing + $langs = (include I18N_DIR . 'langs.php'); + $info = $langs[$lang]; + if (isset($info['fonts'])) { + foreach ($info['fonts'] as $name => $types) { + foreach ($types as $code => $fullname) { + list($ttf, $url) = $fullname; + if (!$url) + continue; + list($code, $file) = $this->_http_get($url); + if ($code == 200) + $phar->addFromString('fonts/'.$ttf, $file); + else + $this->stderr->write( + "*** Unable to fetch $url\n"); + } + } + } + // Add in the messages.mo.php file if ($po_file) { $pipes = array();