[Phpmyadmin-devel] Regarding RFE #701

Isaac Bennetch bennetch at gmail.com
Mon May 25 15:01:01 CEST 2015


Hi,

Sorry for my delayed response; it's a holiday weekend here and I was
away from the internet all day yesterday.

On 5/23/15 6:29 AM, Deven Bansod wrote:
> Hi,
> 
> RFE #701 proposes that we should replace the 'Print View' and 'Print
> View (with Full Texts)' with a 'Print View' Option which should print
> out the CSS of the page only (i.e. whatever exactly is currently
> displayed on the page itself).
> 
> /I had something in mind about the implementation, but am not able to
> figure some details. Any help in this regard would be appreciated. /

My first thought when I saw the initial feature request years ago was to
make a print view stylesheet (such as [0])that hides the navigation
frame, menu bar, etc. At the time, that wasn't a viable option because
of the frameset, but with the move to a single page for display it might
be possible now. I did not test whether this would actually work for us,
but if it does the "Print" button can simply become a javascript
function to tell the browser to print rather than opening a whole new
plain-formatted page with different rendering. For me, this certainly
would be the preferred method if it works.

> *Details of implementation:*
> On clicking the 'Print View' link, it will call a click-handler JQuery
> function which will get the HTML for the table from the current page,
> traverse through the HTML.
> 
> Then, make a JSON of relevant information such as SQL Query, No. of
>  Rows, Column Heads and then arrays of values in each row *for SQL
> results* and information such as Table Name, Rows, Type, Collation,
> Size, Overhead, Comment for *db_structure.php and tbl_structure.php*.

This seems like quite an original idea, I like it so far.

> Now, send a POST Request to a PHP file and get the $response
> (PMA_Response) after making a output with good-looking table and other
> details and the 'Print' Button.
> 
> The main problem I am facing here is that, how should I output the
> $response ?
> 
> I thought of a very-unlike-PMA way:
> Open a new tab with JS and add HTML to it as 
> 
>     var w = window.open();
> 
>     $(w.document.body).html($html);

I don't see a problem with that.

> ​But here I guess there will be difficulty to use PMA_Response with its
> headers(and do I actually need to use PMA_Response or can I just print
> the $html_output recieved from PHP file).

For print view, avoiding PMA_Response might be okay, especially since I
don't see a way to do it with the code you've proposed above.

> or Can I somehow use 'target="print_view" ' and get the $response to be
> shown onto it ?

Hopefully someone else has some thought on this because if it's
possible, I don't know off hand.

> Also, please suggest any flaws/ possible problems that I may have missed
> or if you would suggest a different way.

I don't see any shortcomings or obstacles that you haven't already
addressed; the javascript code to add HTML makes sense and so
on...processing should be fast since we already have the data and are
just passing it around as JSON.

I'd love if some other developer has additional thoughts, but so far it
sounds pretty good to me.

> Thanks.

0 -
http://www.smashingmagazine.com/2011/11/24/how-to-set-up-a-print-style-sheet/




More information about the Developers mailing list