Comments (3)
What is inside of plugin with the id 17?
from pdfresource.
I haven't found the recursion reason.
by means of the friend have rewritten a plug-in
`<?php
$pdfresourceCorePath = $modx->getOption('pdfresource.core_path', null, $modx->getOption('core_path') . 'components/pdfresource/');
$pdfresource = $modx->getService('pdfresource', 'PDFResource', $pdfresourceCorePath . 'model/pdfresource/', $scriptProperties);
if (!function_exists('checkTvAssigned')) {
function checkTvAssigned(&$pdfresource, &$resource, $tvOptName, $tvDefVal) {
global $modx;
$tplVarTmplTbl = $modx->getTableName('modTemplateVarTemplate');
$tplVarTbl = $modx->getTableName('modTemplateVar');
$pdfTvName = $modx->quote($pdfresource->getOption($tvOptName, null, $tvDefVal));
$tplId = $resource->get('template');
$assocRes = $modx->query("SELECT `modTemplateVar`.`name`, `modTemplateVarTemplate`.`templateid`
FROM $tplVarTmplTbl AS `modTemplateVarTemplate`
LEFT JOIN $tplVarTbl `modTemplateVar`
ON `modTemplateVarTemplate`.`tmplvarid` = `modTemplateVar`.`id`
WHERE (`modTemplateVar`.`name` = $pdfTvName AND `modTemplateVarTemplate`.`templateid` = $tplId );");
$assigned = $assocRes->fetch(PDO::FETCH_ASSOC);
return !!$assigned;
}
}
$eventName = $modx->event->name;
switch ($eventName) {
case 'OnDocFormSave':
/** @var modResource $resource */
$assigned = checkTvAssigned($pdfresource, $resource, 'pdfTv', 'create_pdf');
if ($assigned) {
$modx->switchContext($resource->context_key);
$aliasPath = $resource->get('parent') ? preg_replace('#(\.[^./]*)$#', '/', $modx->makeUrl($resource->get('parent'))) : '';
$modx->switchContext('mgr');
$createPDF = intval($resource->getTVValue($pdfresource->getOption('pdfTv', null, 'create_pdf')));
$pdfDirPath = $pdfresource->getOption('pdfPath') . $aliasPath;
$pdfFilePath = $pdfDirPath . $resource->get('alias') . '.pdf';
if ($createPDF) {
if (!file_exists($pdfDirPath)){
mkdir(rtrim($pdfDirPath, '/'), 0755, true);
}
$modx->invokeEvent('OnHandleRequest', array()); // call ClientConfig if installed
$modx->resource = &$resource;
$pdfresource->createPDF($resource, $aliasPath);
} elseif (file_exists($pdfFilePath)){
@unlink($pdfFilePath);
}
}
break;
case 'OnWebPagePrerender':
// Generate the PDF on the fly once if it does not exist and live_pdf template variable is checked
// Check if the live_pdf template variable is assigned
$assigned = checkTvAssigned($pdfresource, $modx->resource, 'pdfTvLive', 'live_pdf');
if ($assigned) {
$livePDF = intval($modx->resource->getTVValue($pdfresource->getOption('pdfTvLive', null, 'live_pdf')));
if ($livePDF) {
header('Content-Type: application/pdf');
header('Content-Disposition:inline;filename=' . $modx->resource->get('alias') . '.pdf');
echo $pdfresource->createPDF($modx->resource, false);
exit;
}
}
// Generate the PDF once if it does not exist, create_pdf template variable is assigned and system setting generateOnPrerender is enabled
if ($pdfresource->getOption('generateOnPrerender')) {
$assigned = checkTvAssigned($pdfresource, $modx->resource, 'pdfTv', 'create_pdf');
if ($assigned) {
$aliasPath = $modx->resource->get('parent') ? preg_replace('#(\.[^./]*)$#', '/', $modx->makeUrl($modx->resource->get('parent'))) : '';
$createPDF = intval($modx->resource->getTVValue($pdfresource->getOption('pdfTv', null, 'create_pdf')));
$pdfDirPath = $pdfresource->getOption('pdfPath') . $aliasPath;
$pdfFilePath = $pdfDirPath . $modx->resource->get('alias') . '.pdf';
if ($createPDF /*&& (!file_exists($pdfFilePath) || $pdfresource->getOption('regenerateAll'))*/) {
if (!file_exists($pdfDirPath)){
mkdir(rtrim($pdfDirPath, '/'), 0755, true);
}
$pdfresource->createPDF($modx->resource, $aliasPath);
}
}
}
}
return;`
from pdfresource.
Could not reproduce this. Feel free to reopen the issue with more specific informations.
from pdfresource.
Related Issues (20)
- Fatal error with PHP 7.0.8 HOT 2
- Error opening pdf on the fly HOT 10
- Changing template HOT 5
- Using png image data HOT 9
- Do tv parameters work in pdfresource.SetHTMLFooter HOT 1
- Default font always 'dejavusanscondensed' HOT 3
- Package installation does not work HOT 4
- Could not create the pdf alias path HOT 1
- Fatal error: Allowed memory size HOT 17
- Failed to install on Modx 2.5.7 HOT 1
- Couldn't use Contexts HOT 2
- Memory loss HOT 1
- Using a snippet to populate the pdfOptions TV on the resource HOT 1
- Generate live PDF from snippet instead of html resource HOT 6
- pdf file for downloading is not formed HOT 2
- Can I pass the current date to the SetHTMLHeader? HOT 1
- Extra not saving resource as PDF HOT 1
- Failed to install on modx 2.7.1 HOT 3
- How to debug problems HOT 4
- Error in getParentPath HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfresource.