Re-work notes printing for better theming capabilities
This commit is contained in:
parent
c2e8725352
commit
728aac3be7
7 changed files with 98 additions and 72 deletions
|
@ -46,11 +46,6 @@ class kolab_notes extends rcube_plugin
|
|||
|
||||
$this->rc = rcube::get_instance();
|
||||
|
||||
$this->register_task('notes');
|
||||
|
||||
// load plugin configuration
|
||||
$this->load_config();
|
||||
|
||||
// proceed initialization in startup hook
|
||||
$this->add_hook('startup', array($this, 'startup'));
|
||||
}
|
||||
|
@ -65,6 +60,11 @@ class kolab_notes extends rcube_plugin
|
|||
return;
|
||||
}
|
||||
|
||||
$this->register_task('notes');
|
||||
|
||||
// load plugin configuration
|
||||
$this->load_config();
|
||||
|
||||
// load localizations
|
||||
$this->add_texts('localization/', $args['task'] == 'notes' && (!$args['action'] || $args['action'] == 'dialog-ui'));
|
||||
$this->rc->load_language($_SESSION['language'], array('notes.notes' => $this->gettext('navtitle'))); // add label for task title
|
||||
|
@ -79,6 +79,7 @@ class kolab_notes extends rcube_plugin
|
|||
$this->register_action('action', array($this, 'note_action'));
|
||||
$this->register_action('list', array($this, 'list_action'));
|
||||
$this->register_action('dialog-ui', array($this, 'dialog_view'));
|
||||
$this->register_action('print', array($this, 'print_note'));
|
||||
|
||||
if (!$this->rc->output->ajax_call && in_array($args['action'], array('dialog-ui', 'list'))) {
|
||||
$this->load_ui();
|
||||
|
@ -518,7 +519,7 @@ class kolab_notes extends rcube_plugin
|
|||
|
||||
// encode for client use
|
||||
if (is_array($data)) {
|
||||
$this->_client_encode($data, true);
|
||||
$this->_client_encode($data);
|
||||
}
|
||||
|
||||
$this->rc->output->command('plugin.render_note', $data);
|
||||
|
@ -830,6 +831,52 @@ class kolab_notes extends rcube_plugin
|
|||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the template for printing with placeholders
|
||||
*/
|
||||
public function print_note()
|
||||
{
|
||||
$uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET);
|
||||
$list = rcube_utils::get_input_value('_list', rcube_utils::INPUT_GET);
|
||||
|
||||
$this->note = $this->get_note(array('uid' => $uid, 'list' => $list));
|
||||
|
||||
// encode for client use
|
||||
if (is_array($this->note)) {
|
||||
$this->_client_encode($this->note);
|
||||
}
|
||||
|
||||
$this->rc->output->set_pagetitle($this->note['title']);
|
||||
$this->rc->output->add_handlers(array(
|
||||
'noteheader' => array($this, 'print_note_header'),
|
||||
'notebody' => array($this, 'print_note_body'),
|
||||
));
|
||||
|
||||
$this->include_script('notes.js');
|
||||
|
||||
$this->rc->output->send('kolab_notes.print');
|
||||
}
|
||||
|
||||
public function print_note_header()
|
||||
{
|
||||
$tags = array_map(array('rcube', 'Q'), (array) $this->note['tags']);
|
||||
$tags = implode(' ', $tags);
|
||||
|
||||
return html::tag('h1', array('id' => 'notetitle'), rcube::Q($this->note['title']))
|
||||
. html::div(array('id' => 'notetags', 'class' => 'tagline'), $tags)
|
||||
. html::div('dates',
|
||||
html::label(null, rcube::Q($this->gettext('created')))
|
||||
. html::span(array('id' => 'notecreated'), rcube::Q($this->note['created']))
|
||||
. html::label(null, rcube::Q($this->gettext('changed')))
|
||||
. html::span(array('id' => 'notechanged'), rcube::Q($this->note['changed']))
|
||||
);
|
||||
}
|
||||
|
||||
public function print_note_body()
|
||||
{
|
||||
return isset($this->note['html']) ? $this->note['html'] : rcube::Q($this->note['description']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a list of revisions for the given object
|
||||
*
|
||||
|
@ -1431,4 +1478,3 @@ class kolab_notes extends rcube_plugin
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@ class kolab_notes_ui
|
|||
|
||||
$this->plugin->include_stylesheet($this->plugin->local_skin_path() . '/notes.css');
|
||||
|
||||
$this->plugin->register_action('print', array($this, 'print_template'));
|
||||
|
||||
$this->ready = true;
|
||||
}
|
||||
|
||||
|
@ -68,7 +66,6 @@ class kolab_notes_ui
|
|||
// load config options and user prefs relevant for the UI
|
||||
$settings = array(
|
||||
'sort_col' => $this->rc->config->get('kolab_notes_sort_col', 'changed'),
|
||||
'print_template' => $this->rc->url('print'),
|
||||
);
|
||||
|
||||
if ($list = rcube_utils::get_input_value('_list', rcube_utils::INPUT_GPC)) {
|
||||
|
@ -419,15 +416,4 @@ class kolab_notes_ui
|
|||
|
||||
return $acl['form']['sharing']['content'] ?: html::div('hint', $this->plugin->gettext('aclnorights'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the template for printing with placeholders
|
||||
*/
|
||||
public function print_template()
|
||||
{
|
||||
header('Content-Type: text/html; charset=' . RCUBE_CHARSET);
|
||||
$this->rc->output->reset(true);
|
||||
echo $this->rc->output->parse('kolab_notes.print', false, false);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -455,7 +455,6 @@ function rcube_kolab_notes_ui(settings)
|
|||
changed: rcmail.gettext('now', 'kolab_notes')
|
||||
}
|
||||
render_note(me.selected_note);
|
||||
rcmail.enable_command('print', true);
|
||||
}
|
||||
else {
|
||||
ui_loading = rcmail.set_busy(true, 'loading');
|
||||
|
@ -1135,28 +1134,11 @@ function rcube_kolab_notes_ui(settings)
|
|||
*/
|
||||
function print_note()
|
||||
{
|
||||
var printwin, data, list;
|
||||
if (me.selected_note && (printwin = rcmail.open_window(settings.print_template))) {
|
||||
list = me.notebooks[me.selected_note.list] || me.notebooks[me.selected_list] || {};
|
||||
data = get_save_data();
|
||||
var list = me.notebooks[me.selected_list],
|
||||
uid = me.selected_note ? me.selected_note.uid : 0;
|
||||
|
||||
// for read-only notes, get_save_data() won't return the content
|
||||
if (me.selected_note.readonly || !list.editable) {
|
||||
data.description = me.selected_note.html || me.selected_note.description;
|
||||
if (!me.selected_note.html || !data.description.match(/<(html|body)/)) {
|
||||
data.description = text2html(data.description);
|
||||
}
|
||||
}
|
||||
|
||||
$(printwin).on('load', function() {
|
||||
printwin.document.title = data.title;
|
||||
$('#notetitle', printwin.document).text(data.title);
|
||||
$('#notebody', printwin.document).html(data.description);
|
||||
$('#notetags', printwin.document).html('<span class="tag">' + data.tags.join('</span><span class="tag">') + '</span>');
|
||||
$('#notecreated', printwin.document).text(me.selected_note.created);
|
||||
$('#notechanged', printwin.document).text(me.selected_note.changed);
|
||||
printwin.print();
|
||||
});
|
||||
if (list && uid) {
|
||||
rcmail.open_window(rcmail.url('print', {_uid: uid, _list: list.id}), true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1691,6 +1673,11 @@ function kolab_notes_options_menu()
|
|||
/* Notes plugin UI initialization */
|
||||
var kolabnotes;
|
||||
window.rcmail && rcmail.addEventListener('init', function(evt) {
|
||||
if (rcmail.task == 'notes' && rcmail.env.action == 'print') {
|
||||
rcmail.print_dialog();
|
||||
return;
|
||||
}
|
||||
|
||||
kolabnotes = new rcube_kolab_notes_ui(rcmail.env.kolab_notes_settings);
|
||||
|
||||
if (rcmail.env.action == 'dialog-ui')
|
||||
|
|
|
@ -1,17 +1,8 @@
|
|||
<roundcube:include file="includes/layout.html" />
|
||||
|
||||
<div class="print-content" role="main">
|
||||
<div id="notedetailstitle">
|
||||
<h1 id="notetitle">#Title</h1>
|
||||
<div id="notetags" class="tagline">#Tags</div>
|
||||
<div class="dates">
|
||||
<label><roundcube:label name="kolab_notes.created" /></label>
|
||||
<span id="notecreated">#Created</span>
|
||||
<label><roundcube:label name="kolab_notes.changed" /></label>
|
||||
<span id="notechanged">#Changed</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="notebody">#Body</div>
|
||||
<div id="notedetailstitle"><roundcube:object name="noteheader" /></div>
|
||||
<div id="notebody"><roundcube:object name="notebody" /></div>
|
||||
</div>
|
||||
|
||||
<roundcube:include file="includes/footer.html" />
|
||||
|
|
|
@ -1,24 +1,15 @@
|
|||
<roundcube:object name="doctype" value="html5" />
|
||||
<html>
|
||||
<head>
|
||||
<title>Print</title>
|
||||
<link rel="stylesheet" type="text/css" href="/this/print.css" />
|
||||
<title><roundcube:object name="pagetitle" /></title>
|
||||
<link rel="stylesheet" type="text/css" href="/this/print.css" />
|
||||
</head>
|
||||
<body class="notesprint">
|
||||
|
||||
<div id="notedetailstitle">
|
||||
<h1 id="notetitle">#Title</h1>
|
||||
<div id="notetags" class="tagline">#Tags</div>
|
||||
<div class="dates">
|
||||
<label><roundcube:label name="kolab_notes.created" /></label>
|
||||
<span id="notecreated">#Created</span>
|
||||
<label><roundcube:label name="kolab_notes.changed" /></label>
|
||||
<span id="notechanged">#Changed</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="notebody">
|
||||
#Body
|
||||
</div>
|
||||
<div id="notedetailstitle">
|
||||
<roundcube:object name="noteheader" />
|
||||
</div>
|
||||
<div id="notebody">
|
||||
<roundcube:object name="notebody" />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -40,6 +40,27 @@
|
|||
}
|
||||
}
|
||||
|
||||
#notedetailstitle {
|
||||
.dates {
|
||||
color: @color-list-secondary;
|
||||
}
|
||||
}
|
||||
|
||||
#print-layout {
|
||||
#notetitle {
|
||||
font-size: 1.5rem;
|
||||
line-height: 2;
|
||||
}
|
||||
|
||||
#notetags {
|
||||
margin-bottom: .5rem;
|
||||
}
|
||||
|
||||
#notecreated {
|
||||
margin-right: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
#kolabnoteslist {
|
||||
tr {
|
||||
display: flex;
|
||||
|
|
|
@ -187,6 +187,10 @@
|
|||
right: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
li.droptarget > div {
|
||||
background-color: @color-list-droptarget-background;
|
||||
}
|
||||
}
|
||||
|
||||
html.touch .listing {
|
||||
|
|
Loading…
Add table
Reference in a new issue