Skip to content

Commit

Permalink
Fixes printer-friendly/export-pdf links in ajax paged views [#1018 st…
Browse files Browse the repository at this point in the history
…ate:resolved]
  • Loading branch information
dleffler committed May 28, 2013
1 parent 2f3b4ad commit c77f63d
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 20 deletions.
19 changes: 14 additions & 5 deletions framework/core/subsystems/expRouter.php
Expand Up @@ -540,34 +540,41 @@ public function buildUrlByPageId($id=null) {
return $url;
}

public function printerFriendlyLink($link_text="Printer Friendly", $class=null, $width=800, $height=600, $view='') {
public function printerFriendlyLink($link_text="Printer Friendly", $class=null, $width=800, $height=600, $view='', $title_text = "Printer Friendly") {
$url = '';
if (PRINTER_FRIENDLY != 1 && EXPORT_AS_PDF != 1) {
$class = !empty($class) ? $class : 'printer-friendly-link';
$url = '<a class="'.$class.'" href="javascript:void(0)" onclick="window.open(\'';
if (!empty($_REQUEST['view']) && !empty($view) && $_REQUEST['view'] != $view) {
$_REQUEST['view'] = $view;
}
if ($this->url_style == 'sef') {
$url .= $this->convertToOldSchoolUrl();
$url .= empty($view) ? '' : '&view='.$view;
if (empty($_REQUEST['view']) && !empty($view)) $url .= '&view='.$view;
if ($this->url_type=='base') $url .= '/index.php?section='.SITE_DEFAULT_SECTION;
} else {
$url .= $this->current_url;
}

$url .= '&printerfriendly=1\' , \'mywindow\',\'menubar=1,resizable=1,scrollbars=1,width='.$width.',height='.$height.'\');"';
$url .= ' title="'.$title_text.'"';
$url .= '> '.$link_text.'</a>';
$url = str_replace('&ajax_action=1','',$url);
}

return $url;
}

public function exportAsPDFLink($link_text="Export as PDF", $class=null, $width=800, $height=600, $view='', $orientation=false, $limit='') {
public function exportAsPDFLink($link_text="Export as PDF", $class=null, $width=800, $height=600, $view='', $orientation=false, $limit='', $title_text="Export as PDF") {
$url = '';
if (EXPORT_AS_PDF != 1 && PRINTER_FRIENDLY != 1) {
$class = !empty($class) ? $class : 'export-pdf-link';
$url = '<a class="'.$class.'" href="javascript:void(0)" onclick="window.open(\'';
if (!empty($_REQUEST['view']) && !empty($view) && $_REQUEST['view'] != $view) {
$_REQUEST['view'] = $view;
}
if ($this->url_style == 'sef') {
$url .= $this->convertToOldSchoolUrl();
$url .= empty($view) ? '' : '&view='.$view;
if (empty($_REQUEST['view']) && !empty($view)) $url .= '&view='.$view;
if ($this->url_type=='base') $url .= '/index.php?section='.SITE_DEFAULT_SECTION;
} else {
$url .= $this->current_url;
Expand All @@ -579,7 +586,9 @@ public function exportAsPDFLink($link_text="Export as PDF", $class=null, $width=
$limit = '&limit='.$limit;
}
$url .= '&exportaspdf=1'.$orientation.$limit.'&\' , \'mywindow\',\'menubar=1,resizable=1,scrollbars=1,width='.$width.',height='.$height.'\');"';
$url .= ' title="'.$title_text.'"';
$url .= '> '.$link_text.'</a>';
$url = str_replace('&ajax_action=1','',$url);
}

return $url;
Expand Down
2 changes: 1 addition & 1 deletion framework/modules/blog/views/blog/blogitem.tpl
Expand Up @@ -46,7 +46,7 @@
</p>
{/if}
<h1>{$record->title}</h1>
{printer_friendly_link}{export_pdf_link prepend='&#160;&#160;|&#160;&#160;'}
{printer_friendly_link view='show'}{export_pdf_link view='show' prepend='&#160;&#160;|&#160;&#160;'}
{subscribe_link prepend='<br/>'}
{$myloc=serialize($__loc)}
<div class="post-info">
Expand Down
2 changes: 1 addition & 1 deletion framework/modules/events/views/event/day.tpl
Expand Up @@ -18,7 +18,7 @@
<a class="nav module-actions" href="{link action=showall view=showall_Day time=$prev_timestamp3}" rel="{$prev_timestamp3}" title="{$prev_timestamp3|format_date:"%A, %B %e, %Y"}">{$prev_timestamp3|format_date:"%a"}</a>&#160;&#160;&laquo;&#160;
<a class="nav module-actions" href="{link action=showall view=showall_Day time=$prev_timestamp2}" rel="{$prev_timestamp2}" title="{$prev_timestamp2|format_date:"%A, %B %e, %Y"}">{$prev_timestamp2|format_date:"%a"}</a>&#160;&#160;&laquo;&#160;
<a class="nav module-actions" href="{link action=showall view=showall_Day time=$prev_timestamp}" rel="{$prev_timestamp}" title="{$prev_timestamp|format_date:"%A, %B %e, %Y"}">{$prev_timestamp|format_date:"%a"}</a>&#160;&#160;&laquo;&#160;&#160;&#160;&#160;&#160;
<strong>{$time|format_date:"%A, %B %e, %Y"}</strong>&#160;&#160;&#160;&#160;&#160;&#160;&raquo;&#160;&#160;
<strong>{$time|format_date:"%A, %B %e, %Y"}&#160;&#160;{printer_friendly_link view='showall_Day' text=''|gettext}{export_pdf_link view='showall_Day' text=''|gettext}&#160;&#160;&#160;&#160;&raquo;&#160;&#160;
<a class="nav module-actions" href="{link action=showall view=showall_Day time=$next_timestamp}" rel="{$next_timestamp}" title="{$next_timestamp|format_date:"%A, %B %e, %Y"}">{$next_timestamp|format_date:"%a"}</a>&#160;&#160;&raquo;&#160;
<a class="nav module-actions" href="{link action=showall view=showall_Day time=$next_timestamp2}" rel="{$next_timestamp2}" title="{$next_timestamp2|format_date:"%A, %B %e, %Y"}">{$next_timestamp2|format_date:"%a"}</a>&#160;&#160;&raquo;&#160;
<a class="nav module-actions" href="{link action=showall view=showall_Day time=$next_timestamp3}" rel="{$next_timestamp3}" title="{$next_timestamp3|format_date:"%A, %B %e, %Y"}">{$next_timestamp3|format_date:"%a"}</a>
Expand Down
2 changes: 1 addition & 1 deletion framework/modules/events/views/event/month.tpl
Expand Up @@ -20,7 +20,7 @@
<a class="nav module-actions" href="{link action=showall time=$prevmonth3}" rel="{$prevmonth3}" title="{$prevmonth3|format_date:"%B %Y"}">{$prevmonth3|format_date:"%b"}</a>&#160;&#160;&laquo;&#160;
<a class="nav module-actions" href="{link action=showall time=$prevmonth2}" rel="{$prevmonth2}" title="{$prevmonth2|format_date:"%B %Y"}">{$prevmonth2|format_date:"%b"}</a>&#160;&#160;&laquo;&#160;
<a class="nav module-actions" href="{link action=showall time=$prevmonth}" rel="{$prevmonth}" title="{$prevmonth|format_date:"%B %Y"}">{$prevmonth|format_date:"%b"}</a>&#160;&#160;&laquo;&#160;&#160;&#160;&#160;&#160;
<strong>{$time|format_date:"%B %Y"}</strong>&#160;&#160;&#160;&#160;&#160;&#160;&raquo;&#160;&#160;
<strong>{$time|format_date:"%B %Y"}</strong>&#160;&#160;{printer_friendly_link view='showall' text=''|gettext}{export_pdf_link view='showall' text=''|gettext}&#160;&#160;&#160;&#160;&raquo;&#160;&#160;
<a class="nav module-actions" href="{link action=showall time=$nextmonth}" rel="{$nextmonth}" title="{$nextmonth|format_date:"%B %Y"}">{$nextmonth|format_date:"%b"}</a>&#160;&#160;&raquo;&#160;
<a class="nav module-actions" href="{link action=showall time=$nextmonth2}" rel="{$nextmonth2}" title="{$nextmonth2|format_date:"%B %Y"}">{$nextmonth2|format_date:"%b"}</a>&#160;&#160;&raquo;&#160;
<a class="nav module-actions" href="{link action=showall time=$nextmonth3}" rel="{$nextmonth3}" title="{$nextmonth3|format_date:"%B %Y"}">{$nextmonth3|format_date:"%b"}</a>&#160;&#160;&raquo;
Expand Down
2 changes: 1 addition & 1 deletion framework/modules/events/views/event/monthlist.tpl
Expand Up @@ -19,7 +19,7 @@
<a class="nav module-actions" href="{link action=showall view='showall_Monthly List' time=$prev_timestamp3}" rel="{$prev_timestamp3}" title="{$prev_timestamp3|format_date:"%B %Y"}">{$prev_timestamp3|format_date:"%b"}</a>&#160;&#160;&laquo;&#160;
<a class="nav module-actions" href="{link action=showall view='showall_Monthly List' time=$prev_timestamp2}" rel="{$prev_timestamp2}" title="{$prev_timestamp2|format_date:"%B %Y"}">{$prev_timestamp2|format_date:"%b"}</a>&#160;&#160;&laquo;&#160;
<a class="nav module-actions" href="{link action=showall view='showall_Monthly List' time=$prev_timestamp}" rel="{$prev_timestamp}" title="{$prev_timestamp|format_date:"%B %Y"}">{$prev_timestamp|format_date:"%b"}</a>&#160;&#160;&laquo;&#160;&#160;&#160;&#160;&#160;
<strong>{$time|format_date:"%B %Y"}</strong>&#160;&#160;&#160;&#160;&#160;&#160;&raquo;&#160;&#160;
<strong>{$time|format_date:"%B %Y"}</strong>&#160;&#160;{printer_friendly_link view='showall_Monthly+List' text=''|gettext}{export_pdf_link view='showall_Monthly+List' text=''|gettext}&#160;&#160;&#160;&#160;&raquo;&#160;&#160;
<a class="nav module-actions" href="{link action=showall view='showall_Monthly List' time=$next_timestamp}" rel="{$next_timestamp}" title="{$next_timestamp|format_date:"%B %Y"}">{$next_timestamp|format_date:"%b"}</a>&#160;&#160;&raquo;&#160;
<a class="nav module-actions" href="{link action=showall view='showall_Monthly List' time=$next_timestamp2}" rel="{$next_timestamp2}" title="{$next_timestamp2|format_date:"%B %Y"}">{$next_timestamp2|format_date:"%b"}</a>&#160;&#160;&raquo;&#160;
<a class="nav module-actions" href="{link action=showall view='showall_Monthly List' time=$next_timestamp3}" rel="{$next_timestamp3}" title="{$next_timestamp3|format_date:"%B %Y"}">{$next_timestamp3|format_date:"%b"}</a>&#160;&#160;&raquo;
Expand Down
4 changes: 2 additions & 2 deletions framework/modules/events/views/event/showall.tpl
Expand Up @@ -43,8 +43,8 @@
{/if}
{/if}
{/permissions}
{printer_friendly_link text='Printer-friendly'|gettext prepend='&#160;&#160;|&#160;&#160;'}
{export_pdf_link prepend='&#160;&#160;|&#160;&#160;'}
{*{printer_friendly_link text='Printer-friendly'|gettext prepend='&#160;&#160;|&#160;&#160;'}*}
{*{export_pdf_link prepend='&#160;&#160;|&#160;&#160;'}*}
{br}
</div>
<h1>
Expand Down
4 changes: 2 additions & 2 deletions framework/modules/events/views/event/showall_Day.tpl
Expand Up @@ -42,8 +42,8 @@
{/if}
{/if}
{/permissions}
{printer_friendly_link text='Printer-friendly'|gettext prepend='&#160;&#160;|&#160;&#160;'}
{export_pdf_link prepend='&#160;&#160;|&#160;&#160;'}
{*{printer_friendly_link text='Printer-friendly'|gettext prepend='&#160;&#160;|&#160;&#160;'}*}
{*{export_pdf_link prepend='&#160;&#160;|&#160;&#160;'}*}
</div>
<h1>
{ical_link}
Expand Down
4 changes: 2 additions & 2 deletions framework/modules/events/views/event/showall_Monthly List.tpl
Expand Up @@ -43,8 +43,8 @@
{/if}
{/if}
{/permissions}
{printer_friendly_link text='Printer-friendly'|gettext prepend='&#160;&#160;|&#160;&#160;'}
{export_pdf_link prepend='&#160;&#160;|&#160;&#160;'}
{*{printer_friendly_link text='Printer-friendly'|gettext prepend='&#160;&#160;|&#160;&#160;'}*}
{*{export_pdf_link prepend='&#160;&#160;|&#160;&#160;'}*}
{br}
</div>
<h1>
Expand Down
4 changes: 2 additions & 2 deletions framework/modules/events/views/event/showall_Week.tpl
Expand Up @@ -40,8 +40,8 @@
{/if}
{/if}
{/permissions}
{printer_friendly_link text='Printer-friendly'|gettext prepend='&#160;&#160;|&#160;&#160;'}
{export_pdf_link prepend='&#160;&#160;|&#160;&#160;'}
{*{printer_friendly_link text='Printer-friendly'|gettext prepend='&#160;&#160;|&#160;&#160;'}*}
{*{export_pdf_link prepend='&#160;&#160;|&#160;&#160;'}*}
</div>
<h1>
{ical_link}
Expand Down
2 changes: 1 addition & 1 deletion framework/modules/events/views/event/week.tpl
Expand Up @@ -17,7 +17,7 @@
<p class="caption">
<a class="nav module-actions" href="{link action=showall view=showall_Week time=$prev_timestamp2}" rel="{$prev_timestamp2}" title="{'Week of'|gettext} {$prev_timestamp2|format_date:"%B %e, %Y"}">{$prev_timestamp2|format_date:"%b %e"}</a>&#160;&#160;&laquo;&#160;
<a class="nav module-actions" href="{link action=showall view=showall_Week time=$prev_timestamp}" rel="{$prev_timestamp}" title="{'Week of'|gettext} {$prev_timestamp|format_date:"%B %e, %Y"}">{$prev_timestamp|format_date:"%b %e"}</a>&#160;&#160;&laquo;&#160;&#160;&#160;&#160;&#160;
<strong>{'Week of'|gettext} {$time|format_date:"%B %e, %Y"}</strong>&#160;&#160;&#160;&#160;&#160;&#160;&raquo;&#160;&#160;
<strong>{'Week of'|gettext} {$time|format_date:"%B %e, %Y"}</strong>&#160;&#160;{printer_friendly_link view='showall_Week' text=''|gettext}{export_pdf_link view='showall_Week' text=''|gettext}&#160;&#160;&#160;&#160;&raquo;&#160;&#160;
<a class="nav module-actions" href="{link action=showall view=showall_Week time=$next_timestamp}" rel="{$next_timestamp}" title="{'Week of'|gettext} {$next_timestamp|format_date:"%B %e, %Y"}">{$next_timestamp|format_date:"%b %e"}</a>&#160;&#160;&raquo;&#160;
<a class="nav module-actions" href="{link action=showall view=showall_Week time=$next_timestamp2}" rel="{$next_timestamp2}" title="{'Week of'|gettext} {$next_timestamp2|format_date:"%B %e, %Y"}">{$next_timestamp2|format_date:"%b %e"}</a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion framework/modules/news/views/news/newsitem.tpl
Expand Up @@ -46,7 +46,7 @@
</p>
{/if}
<h1>{$record->title}</h1>
{printer_friendly_link}{export_pdf_link prepend='&#160;&#160;|&#160;&#160;'}
{printer_friendly_link view='show'}{export_pdf_link view='show' prepend='&#160;&#160;|&#160;&#160;'}
{subscribe_link prepend='<br />'}
{$myloc=serialize($__loc)}
{if !$config.datetag}
Expand Down
2 changes: 1 addition & 1 deletion framework/plugins/bootstrap/function.export_pdf_link.php
Expand Up @@ -61,7 +61,7 @@ function smarty_function_export_pdf_link($params,&$smarty) {
$text = '<i class="icon-book '.$icon_size.'"></i> ' . (isset($params['text']) ? $params['text'] : gt('Export as PDF'));

// spit out the link
echo $prepend.$router->exportAsPDFLink($text, $class, 800, 600, $view, $orientation, $limit).'<br>';
echo $prepend.$router->exportAsPDFLink($text, $class, 800, 600, $view, $orientation, $limit);
}
}

Expand Down

0 comments on commit c77f63d

Please sign in to comment.