PDA

Zobacz pełną wersję : [Joomla 1.7] PDF na całej stronie (artykułu)



oneiro
07-12-2011, 23:59
Witam,

Chcę, aby w artykule umieścić PDF (a najlepiej, aby cały artykuł był PDF'em) - wiem, że istnieje kod HTML "embed", ale od v4 nie jest wpierany, a joomla 1.7 nie przyjmuje kodu (przy przełączaniu edytora w kod html).

Przykłady embed są poniżej, ale i tak nie działa to:
http://www.kurshtml.edu.pl/przyklady/html/osadzanie.html

Proszę o pomoc, pozdrawiam, Krzysiek

oneiro
12-12-2011, 17:43
To może chociaż ktoś podpowie, jak wyświetli PDF'a w artykule....

zwiastun
12-12-2011, 17:56
Dodaj załącznik. Wyświetlanie pdf-ów w artykułach jest trochę księżycowym pomysłem.
Kod jet filtrowany zgodnie z ustawieniami filtrowania tekstów w konfiguracji globalnej artykułów.

luqass
12-12-2011, 20:59
sprawdz sobie ten dodatek:
http://extensions.joomla.org/extensions/directory-a-documentation/print-a-pdf/14117

oneiro
12-12-2011, 21:08
Co do linka - teraz tak mam, powiem szczerze, to brzydko wygląda - w PDF'ie jest menu kawiarni.

Co do wspomnianego dodatku to nie wiedzieć czemu, nie działa poprawnie u mnie - po włączeniu dodatku artykuł nie ładuje się- jeszcze raz sprawdzę, co jest nie tak, bo z pamięci to mogę głupoty napisać....

EDIT: dostaję takie coś:

Warning: require_once() [function.require-once (http://www.cafemandragora.pl/j/index.php/menu/function.require-once)]: Unable to access /usr/home/domains/DOMENA/public_html/j/plugins/content/browser.php in /usr/home/domains/DOMENA/public_html/j/plugins/content/enbed_pdf/enbed_pdf.php on line 49

Warning: require_once(/usr/home/domains/DOMENA/public_html/j/plugins/content/browser.php) [function.require-once (http://www.cafemandragora.pl/j/index.php/menu/function.require-once)]: failed to open stream: No such file or directory in /usr/home/domains/DOMENA/public_html/j/plugins/content/enbed_pdf/enbed_pdf.php on line 49

Fatal error: require_once() [function.require (http://www.cafemandragora.pl/j/index.php/menu/function.require)]: Failed opening required '/usr/home/domains/DOMENA/public_html/j/plugins/content/browser.php' (include_path='.:/usr/local/php5/lib/php') in /usr/home/domains/DOMENA/public_html/j/plugins/content/enbed_pdf/enbed_pdf.php on line 49



Wersja joomla to: Joomla! 1.7.3 Stable [ Ember ] 14-Nov-2011 14:00 GMT
W sumie to więcej rzeczy nie działa niż tylko ta strona....

alex51
13-12-2011, 07:22
(...)w PDF'ie jest menu kawiarni.(...)
Jeśli jedynym zadaniem jest umieszczenie tego będącego w pdf'ie menu kawiarni, to podejrzewam, że rozsądniejszym wyjściem byłoby zrezygnowanie z formatu pdf na rzecz innych formatów, łatwiejszych do osadzania w treści artykułu. Są programy konwertujące pliki pdf do formatów graficznych - PDFill PDF Tools (http://www.pdfill.com/).

PeFik
13-12-2011, 08:35
Co to za kawiarnia, która menu ma w PDF, pachnie to obciachem. PDF umieszcza się tylko w wyjątkowych sytuacjach, a ta z pewnością do nich nie należy. :P

oneiro
13-12-2011, 20:25
Powiem tak - strona jest max obciachowa, nawet nie chcę podawać jej adresu (zresztą nie jestem programistą www - a stronę robię z dobrej woli - a sam sie czegoś nauczę :podstep:)

Jakby nie było, wg mnie dodatek wywala się w 49 linii bo nie znajduje pliki. Błędy plik poniżej, tylko jak to poprawić? Dodam, że znam ścieżkę brakującego pliku (jest katalog "wyżej")


<?php
/**
* @version $Id: Enbed pdf v1.8.5 2011-11-29 11:19Z $
* @package Joomla 1.5
* @copyright Copyright (C) 2005 - 2011 Maik Heinelt. All rights reserved.
* @author Maik Heinelt (www.heinelt.info)
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/


defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.plugin.plugin');



class plgContentenbed_pdf extends JPlugin
{
function plgContentenbed_pdf( &$subject, $params )
{
parent::__construct( $subject, $params );
}




function onAfterRender()
{

// [[[ 2010-12-13 Check for used PHP version, cause browser.php doesn't work with PHP4 !!!
$phpver = phpversion();

if ($phpver < 5)
{
echo "
<font color=\"red\"><b><br /><br /><center>Your server use PHP $phpver.<br />
It is necessary to use at least PHP 5 to run Enbed_pdf. Please contact your webhoster to upgrade!
<b></font></center>
<br /><br /><br />";
return 0;
}
/// ]]] 2010-12-13 Check for used PHP version, cause browser.php doesn't work with PHP4 !!!


require_once(JPATH_ROOT.DS.'plugins'.DS.'content'. DS.'browser.php');

$output = JResponse::getBody();
$pattern = "#{pdf}(.*?){/pdf}#s";
$found = preg_match_all($pattern, $output, $matches);

$Enbed_pdf_version = '1.8.5'; // Enbed_pdf Version
$com_start ='<!-- Enbed_pdf v'.$Enbed_pdf_version.' by http://www.heinelt.info Start -->';
$com_end ='<!-- Enbed_pdf v'.$Enbed_pdf_version.' by http://www.heinelt.info End -->';

$plugin = & JPluginHelper::getPlugin('content', 'enbed_pdf');

// [[[ Load plugin params info
$pluginParams = new JParameter($plugin->params);
$mode = $pluginParams->def('mode', 1);
$proxy = $pluginParams->def('proxy', 0);
$height = $pluginParams->def('dheight', 300);
$width = $pluginParams->def('dwidth', 400);
$alt_link = $pluginParams->def('alt_link', 0);
$link_comment = $pluginParams->def('link_comment', 'Can\'t see this Document?');
$placeholder = $pluginParams->def('placeholder');
$def_docupathswitch = $pluginParams->def('def_docupathswitch', 0);
$def_docupath = $pluginParams->def('def_docupath');

// !! Adobe Reader default settings !!
$ar_toolbar = $pluginParams->def('ar_toolbar', 1);
$ar_navpanes = $pluginParams->def('ar_navpanes', 1);
$ar_scrollbar = $pluginParams->def('ar_scrollbar', 1);
$ar_searchbar = $pluginParams->def('ar_searchbar', 0);
$sw_iframe = $pluginParams->def('iframe', 0);

// ]]] Load plugin params info


// [[[ Adobe Reader default settings (Toolbar, Navpanel, Scrollbar) 2010.11.10
$ar_param = null;
$o_tb = $ar_toolbar;
$o_np = $ar_navpanes;
$o_scb = $ar_scrollbar;
$o_sb = $ar_searchbar;
function arparams($var1, $var2, $var3, $var4)
{
$ar_search = null;
if ($var4 == 1)
{
$ar_search = '&search="foo"';
}
$ar_param = "#toolbar=$var1&navpanes=$var2&scrollbar=$var3$ar_search";

return $ar_param;
}
// ]]] Adobe Reader default settings (Toolbar, Navpanel, Scrollbar) 2010.11.10


// [[[ 2010-11-05 pdf link entry under each pdf file, in case it will not be displayed
function showpdfpath($alt_link, $link_comment, $placeholder, $enpdf)
{
if ($alt_link)
{
// [[[ 2010-11-12 Added placeholder for link to pdf
if (empty($placeholder))
{
$placeholder = $enpdf;
}
// [[[ 2010-11-12 Added placeholder for link to pdf
$alink = "<br/>$link_comment <a href=\"$enpdf\" target=\"_blank\">$placeholder</a><br/>";

return $alink;
}
}
// ]]] 2010-11-05 pdf link entry under each pdf file, in case it will not be displayed



// [[[ Browser identification (2010-11-08 Browser class changed, cause of similar class names in other Joomla extensions)
$isIE = 0;
$Enbedbrowser = new EnbedBrowser();

if ( $Enbedbrowser->getBrowser() == EnbedBrowser::BROWSER_IE )
{
$isIE = 1;
}
// ]]] Browser identification (2010-11-08 Browser class changed, cause of similar class names in other Joomla extensions)



// [[[ 2010-10-29 Use the proxy.php to avoid blocking the google page in IE8 >.

$googlepath = "http://docs.google.com/viewer";
if ( $proxy == 1 && $isIE == 1 )
{
$googlepath = JURI::base().DS.'plugins'.DS.'content'.DS.'proxy.p hp'; // 2011-11-29 FIX! Thanks to Antonino Migliore !!
}
// ]]] 2010-10-29 Use the proxy.php to avoid blocking the google page in IE8 >.


$mcount = 0;
$alink = null;

if ($found)
{

foreach ( $matches[0] as $value )
{

$enpdf = $value;

// 2011-01-21 Doc-path placeholder function added
if ( !$def_docupathswitch == 0 && isset($def_docupath) )
{
if (preg_match('*@@*', $enpdf))
{
$dmnname = $_SERVER['HTTP_HOST'];
if ( !preg_match('http://',$dmnname) )
{
$dmnname = 'http://'.$dmnname;
}

$def_docupath = trim($def_docupath, '/');
$enpdf = str_replace('*@@*', $dmnname.DS.$def_docupath, $enpdf);
}
}
// 2011-01-21 Doc-path placeholder function added


$find = '|';
if(strstr($enpdf, $find))
{
$arr = explode('|',$enpdf);
$enpdf = str_replace('{pdf}','', $arr[0]); // << replaced in version 1.8 !! Bug, if ftp:// path is used!



foreach ($arr as $phrase)
{
// Parse for PDF-height
if (strstr(strtolower($phrase), 'height:'))
{
$tpm1 = explode(':',$phrase);
$height = trim($tpm1[1], '"');
}

// Parse for PDF-width
if (strstr(strtolower($phrase), 'width:'))
{
$tpm1 = explode(':',$phrase);
$width = trim($tpm1[1], '"');
}

// Parse for adobe reader toolbar 2010-11-10
if (strstr(strtolower($phrase), 'toolbar:'))
{
$tpm1 = explode(':',$phrase);
$ar_toolbar = trim($tpm1[1], '"');
}

// Parse for adobe reader navpanel 2010-11-10
if (strstr(strtolower($phrase), 'nav:'))
{
$tpm1 = explode(':',$phrase);
$ar_navpanes = trim($tpm1[1], '"');
}

// Parse for adobe reader scrollbar 2010-11-10
if (strstr(strtolower($phrase), 'scroll:'))
{
$tpm1 = explode(':',$phrase);
$ar_scrollbar = trim($tpm1[1], '"');
}

// Parse for adobe reader searchpanel 2010-11-10
if (strstr(strtolower($phrase), 'search:'))
{
$tpm1 = explode(':',$phrase);
$ar_searchbar = trim($tpm1[1], '"');
}

// Parse for google reader page-Setting 2010-12-15 << THANKS TO Andreas Seifert (as[at]nsi[dot]de)
if (strstr(strtolower($phrase), 'page:'))
{
$ar_gpage = null;
$tpm1 = explode(':',$phrase);
$ar_gpage = trim($tpm1[1], '"');

if (!$ar_gpage < 1)
{
$ar_gpage = $ar_gpage - 1;
}
else
{
$ar_gpage = 0;
}

}
else
{
$ar_gpage = 0;
}

//exit($enpdf);
// [[[ Parse for the PDF-app
if (strstr(strtolower($phrase), 'app:'))
{
$tpm1 = explode(':',$phrase);
$tpm1[1] = rtrim($tpm1[1], "{/pdf}");
$app = trim(strtolower($tpm1[1]), '"');

$alink = showpdfpath($alt_link, $link_comment, $placeholder, $enpdf);

if ($app == "acrobat" || $app == "adobe")
{
// 2010-10-10 Fix for disabled acrobat plugin in IE
if ($isIE == 1)
{
if ($sw_iframe == 1) {
$replacement[$mcount] = "
$com_start
<iframe src=\"$enpdf$ar_param\" width=\"$width\" height=\"$height\">
[Your browser does <em>not</em> support <code>iframe</code>,
or has been configured not to display inline frames.
You can access <a href=\"$enpdf$ar_param\">the document</a>
via a link though.]</iframe>
$com_end
";
} else {

$replacement[$mcount] = "
$com_start
<object classid=\"clsid:CA8A9780-280D-11CF-A24D-444553540000\" width=\"$width\" height=\"$height\">
<param name=\"src\" value=\"$enpdf$ar_param\" />
<param name=\"wmode\" value=\"transparent\"> PDF plugin is deactivated! Please click the link</br>
<a href=\"$enpdf\" target=\"_blank\">$enpdf</a>
</object>".$alink."
$com_end
";
}
}
else
{
$replacement[$mcount] = $com_start.'


<embed width="'.$width.'" height="'.$height.'" wmode="transparent" href="'.$enpdf.'" src="'.$enpdf.$ar_param.'" hidden="false">'.$alink.'
'.$com_end;
}
}

if ($app == "google")
{
$enpdf = urlencode($enpdf); // 2011-01-21 Encoding problems with special characters
$replacement[$mcount] = $com_start.'


<iframe src="'.$googlepath.'?url='.$enpdf.'&embedded=true'.($ar_gpage != null ? '#:0.page.'.$ar_gpage : '' ).'" width="'.$width.'" height="'.$height.'" style="border: none;">
</iframe>'.$alink.'
'.$com_end;
}

// [[[ 2010-12-13 Let's show doc from an Google Docs account, too !!
if ($app == "gdoc")
{
$directlink = 'https://docs.google.com/document/pub?id='.$enpdf;
$alink = showpdfpath($alt_link, $link_comment, $placeholder, $directlink);
$replacement[$mcount] = $com_start.'


<iframe width="'.$width.'" height="'.$height.'" style="border: medium none;" src="https://docs.google.com/document/pub?id='.$enpdf.'&amp;embedded=true">
</iframe>'.$alink.'
'.$com_end;
}
// ]]] 2010-12-13 Let's show doc from an Google Docs account, too !!


// [[[ 2010-12-13 Added Zoho viewer to display documents embedded.
if ($app == "zoho")
{
$enpdf = urlencode($enpdf); // 2011-01-21 Encoding problems with special characters
$replacement[$mcount] = $com_start.'

<iframe src="http://viewer.zoho.com/docs/urlview.do?url='.$enpdf.'&embed=true" width="'.$width.'" height="'.$height.'" frameborder="0" displayfilename="false">
</iframe>'.$alink.'
'.$com_end;
}
//]]] 2010-12-13 Added Zoho viewer to display documents embedded.


// [[[ 2010-12-17 Added Flapdf viewer (http://www.looky-look.net) to display documents embedded.
if ($app == "flash")
{
$replacement[$mcount] = $com_start.'

<iframe src="http://looky-look.net/flapdf/?url='.$enpdf.'" width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" allowtransparency="true">
</iframe>'.$alink.'
'.$com_end;
}
//]]] 2010-12-17 Added Flapdf viewer (http://www.looky-look.net) to display documents embedded.


}
// ]]] Parse for the PDF-app
else
{
$ar_param = arparams($ar_toolbar, $ar_navpanes, $ar_scrollbar, $ar_searchbar); // Let's check for Acrobat Reader options !

if ($mode == 1) // If app:google
{
$genpdf = urlencode($enpdf); // 2011-01-21 Encoding problems with special characters
$replacement[$mcount] = $com_start.'

<iframe src="'.$googlepath.'?url='.$genpdf.'&embedded=true'.($ar_gpage != null ? '#:0.page.'.$ar_gpage : '' ).'" width="'.$width.'" height="'.$height.'" style="border: none;">
</iframe>'.$alink.'
'.$com_end;
}
else
{
// [[[ 2010-10-10 Fix for disabled acrobat plugin in IE
if ($isIE == 1)
{
if ($sw_iframe == 1) {
$replacement[$mcount] = "
$com_start
<iframe src=\"$enpdf$ar_param\" width=\"$width\" height=\"$height\">
[Your browser does <em>not</em> support <code>iframe</code>,
or has been configured not to display inline frames.
You can access <a href=\"$enpdf$ar_param\">the document</a>
via a link though.]</iframe>
$com_end
";
} else {

$replacement[$mcount] = "
$com_start
<object classid=\"clsid:CA8A9780-280D-11CF-A24D-444553540000\" width=\"$width\" height=\"$height\">
<param name=\"src\" value=\"$enpdf$ar_param\" />
<param name=\"wmode\" value=\"transparent\"> PDF plugin is deactivated! Please click the link</br>
<a href=\"$enpdf\" target=\"_blank\">$enpdf</a>
</object>".$alink."
$com_end
";
}
}
else
{
$replacement[$mcount] = $com_start.'


<embed width="'.$width.'" height="'.$height.'" wmode="transparent" href="'.$enpdf.'" src="'.$enpdf.$ar_param.'">'.$alink.'
'.$com_end;
}
// ]]] 2010-10-10 Fix for disabled acrobat plugin in IE
}
}
}
}
else // If there are no settings at the string in article, this code will be used.
{
$enpdf1 = ltrim($enpdf, "{pdf}");
$enpdf1 = rtrim($enpdf1, '/pdf}');
$enpdf = rtrim($enpdf1, '{');

$alink = showpdfpath($alt_link, $link_comment, $placeholder, $enpdf);


if ($mode == 1) // If app|google
{
$enpdf = urlencode($enpdf); // 2011-01-21 Encoding problems with special characters
$replacement[$mcount] = $com_start.'


<iframe src="'.$googlepath.'?url='.$enpdf.'&embedded=true" width="'.$width.'" height="'.$height.'" style="border: none;">
</iframe>'.$alink.'
'.$com_end;
}
else
{
$ar_param = arparams($ar_toolbar, $ar_navpanes, $ar_scrollbar, $ar_searchbar); // Let's check for Acrobat Reader options !

// 2010-10-10 Fix for disabled acrobat plugin in IE
if ($isIE == 1)
{
if ($sw_iframe == 1) {
$replacement[$mcount] = "
$com_start
<iframe src=\"$enpdf$ar_param\" width=\"$width\" height=\"$height\">
[Your browser does <em>not</em> support <code>iframe</code>,
or has been configured not to display inline frames.
You can access <a href=\"$enpdf$ar_param\">the document</a>
via a link though.]</iframe>
$com_end
";
} else {

$replacement[$mcount] = "
$com_start
<object classid=\"clsid:CA8A9780-280D-11CF-A24D-444553540000\" width=\"$width\" height=\"$height\">
<param name=\"src\" value=\"$enpdf$ar_param\" />
<param name=\"wmode\" value=\"transparent\"> PDF plugin is deactivated! Please click the link</br>
<a href=\"$enpdf\" target=\"_blank\">$enpdf</a>
</object>".$alink."
$com_end
";
}
}
else
{
$replacement[$mcount] = $com_start.'


<embed width="'.$width.'" height="'.$height.'" wmode="transparent" href="'.$enpdf.'" src="'.$enpdf.$ar_param.'" hidden="false">'.$alink.'
'.$com_end;
}
}
}

// Re-reset of Adobe Reader default settings (Toolbar, Navpanel, Scrollbar) 2010.11.10
$o_tb = $ar_toolbar = $o_tb;
$ar_navpanes = $o_np;
$ar_scrollbar = $o_scb;
$ar_searchbar = $o_sb;
// Re-reset of Adobe Reader default settings (Toolbar, Navpanel, Scrollbar) 2010.11.10

$mcount = $mcount + 1;
}



// [[[ Replace the original content with the added pdf content of article.
for($i = 0; $i < count($replacement); $i++)
{
$output = preg_replace($pattern, $replacement[$i], $output, 1);
}

JResponse::setBody($output);
// ]]] Replace the original content with the added pdf content of article.
}


return true;

}
}
?>

alex51
14-12-2011, 07:57
Dla przetestowania zainstalowałem polecany dodatek na dwóch stronach. Zarówno na działającej, rozbudowanej witrynie jak i na specjalnie postawionej czystej, testowej Joomla!1.7.3 dodatek działa bezproblemowo. Być może Twoje wcześniejsze stwierdzenie:

(...)W sumie to więcej rzeczy nie działa niż tylko ta strona.... będzie odpowiedzią na zaistniałe kłopoty.

Jac
14-12-2011, 10:34
Jeszcze dwie możliwości, o których chyba nie wspomnieliście:

1. PDF to Flash
2. Slide Share http://www.slideshare.net (http://www.slideshare.net/)
3. Scribd http://www.scribd.com (http://www.scribd.com/)

Każde z tych rozwiązań ma wady i zalety i nie zawsze będzie odpowiednie.
Dla przykładu z usługi Slide Share korzystam na stronach internetowych organizacji non profit, osadzając w ten sposób pliki PDF i prezentacje Power Point.
Ale na stronie firmowej już bym Slide Share raczej nie zastosował.