Example #1
0
/**
 * display recent changes
 *
 * @author Andreas Gohr <*****@*****.**>
 * @author Matthias Grimm <*****@*****.**>
 * @author Ben Coburn <*****@*****.**>
 * @author Kate Arzamastseva <*****@*****.**>
 */
function html_recent($first = 0, $show_changes = 'both')
{
    global $conf;
    global $lang;
    global $ID;
    /* we need to get one additionally log entry to be able to
     * decide if this is the last page or is there another one.
     * This is the cheapest solution to get this information.
     */
    $flags = 0;
    if ($show_changes == 'mediafiles' && $conf['mediarevisions']) {
        $flags = RECENTS_MEDIA_CHANGES;
    } elseif ($show_changes == 'pages') {
        $flags = 0;
    } elseif ($conf['mediarevisions']) {
        $show_changes = 'both';
        $flags = RECENTS_MEDIA_PAGES_MIXED;
    }
    $recents = getRecents($first, $conf['recent'] + 1, getNS($ID), $flags);
    if (count($recents) == 0 && $first != 0) {
        $first = 0;
        $recents = getRecents($first, $conf['recent'] + 1, getNS($ID), $flags);
    }
    $hasNext = false;
    if (count($recents) > $conf['recent']) {
        $hasNext = true;
        array_pop($recents);
        // remove extra log entry
    }
    print p_locale_xhtml('recent');
    if (getNS($ID) != '') {
        print '<div class="level1"><p>' . sprintf($lang['recent_global'], getNS($ID), wl('', 'do=recent')) . '</p></div>';
    }
    $form = new Doku_Form(array('id' => 'dw__recent', 'method' => 'GET'));
    $form->addHidden('sectok', null);
    $form->addHidden('do', 'recent');
    $form->addHidden('id', $ID);
    if ($conf['mediarevisions']) {
        $form->addElement(form_makeListboxField('show_changes', array('pages' => $lang['pages_changes'], 'mediafiles' => $lang['media_changes'], 'both' => $lang['both_changes']), $show_changes, $lang['changes_type'], '', '', array('class' => 'quickselect')));
        $form->addElement(form_makeButton('submit', 'recent', $lang['btn_apply']));
    }
    $form->addElement(form_makeOpenTag('ul'));
    foreach ($recents as $recent) {
        $date = dformat($recent['date']);
        if ($recent['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) {
            $form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
        } else {
            $form->addElement(form_makeOpenTag('li'));
        }
        $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
        if ($recent['media']) {
            $form->addElement(media_printicon($recent['id']));
        } else {
            $icon = DOKU_BASE . 'lib/images/fileicons/file.png';
            $form->addElement('<img src="' . $icon . '" alt="' . $filename . '" class="icon" />');
        }
        $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
        $form->addElement($date);
        $form->addElement(form_makeCloseTag('span'));
        if ($recent['media']) {
            $diff = count(getRevisions($recent['id'], 0, 1, 8192, true)) && @file_exists(mediaFN($recent['id']));
            if ($diff) {
                $href = media_managerURL(array('tab_details' => 'history', 'mediado' => 'diff', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
            }
        } else {
            $href = wl($recent['id'], "do=diff", false, '&');
        }
        if ($recent['media'] && !$diff) {
            $form->addElement('<img src="' . DOKU_BASE . 'lib/images/blank.gif" width="15" height="11" alt="" />');
        } else {
            $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => $href)));
            $form->addElement(form_makeTag('img', array('src' => DOKU_BASE . 'lib/images/diff.png', 'width' => 15, 'height' => 11, 'title' => $lang['diff'], 'alt' => $lang['diff'])));
            $form->addElement(form_makeCloseTag('a'));
        }
        if ($recent['media']) {
            $href = media_managerURL(array('tab_details' => 'history', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
        } else {
            $href = wl($recent['id'], "do=revisions", false, '&');
        }
        $form->addElement(form_makeOpenTag('a', array('class' => 'revisions_link', 'href' => $href)));
        $form->addElement(form_makeTag('img', array('src' => DOKU_BASE . 'lib/images/history.png', 'width' => 12, 'height' => 14, 'title' => $lang['btn_revs'], 'alt' => $lang['btn_revs'])));
        $form->addElement(form_makeCloseTag('a'));
        if ($recent['media']) {
            $href = media_managerURL(array('tab_details' => 'view', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
            $class = file_exists(mediaFN($recent['id'])) ? 'wikilink1' : ($class = 'wikilink2');
            $form->addElement(form_makeOpenTag('a', array('class' => $class, 'href' => $href)));
            $form->addElement($recent['id']);
            $form->addElement(form_makeCloseTag('a'));
        } else {
            $form->addElement(html_wikilink(':' . $recent['id'], useHeading('navigation') ? null : $recent['id']));
        }
        $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
        $form->addElement(' &ndash; ' . htmlspecialchars($recent['sum']));
        $form->addElement(form_makeCloseTag('span'));
        $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
        if ($recent['user']) {
            $form->addElement(editorinfo($recent['user']));
            if (auth_ismanager()) {
                $form->addElement(' (' . $recent['ip'] . ')');
            }
        } else {
            $form->addElement($recent['ip']);
        }
        $form->addElement(form_makeCloseTag('span'));
        $form->addElement(form_makeCloseTag('div'));
        $form->addElement(form_makeCloseTag('li'));
    }
    $form->addElement(form_makeCloseTag('ul'));
    $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav')));
    $last = $first + $conf['recent'];
    if ($first > 0) {
        $first -= $conf['recent'];
        if ($first < 0) {
            $first = 0;
        }
        $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev')));
        $form->addElement(form_makeTag('input', array('type' => 'submit', 'name' => 'first[' . $first . ']', 'value' => $lang['btn_newer'], 'accesskey' => 'n', 'title' => $lang['btn_newer'] . ' [N]', 'class' => 'button show')));
        $form->addElement(form_makeCloseTag('div'));
    }
    if ($hasNext) {
        $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next')));
        $form->addElement(form_makeTag('input', array('type' => 'submit', 'name' => 'first[' . $last . ']', 'value' => $lang['btn_older'], 'accesskey' => 'p', 'title' => $lang['btn_older'] . ' [P]', 'class' => 'button show')));
        $form->addElement(form_makeCloseTag('div'));
    }
    $form->addElement(form_makeCloseTag('div'));
    html_form('recent', $form);
}
 /**
  * Formats and prints one file in the list in the thumbnails view
  *
  * @see media_printfile_thumbs()
  */
 function _mod_media_printfile_thumbs($item, $auth, $jump = false, $display_namespace = false)
 {
     global $lang;
     global $conf;
     // Prepare filename
     $file = $this->_getOriginalFileName($item['id']);
     if ($file === false) {
         $file = utf8_decodeFN($item['file']);
     }
     // build fake media id
     $ns = getNS($item['id']);
     $fakeId = $ns === false ? $file : "{$ns}:{$file}";
     $fakeId_escaped = hsc($fakeId);
     // output
     echo '<li><dl title="' . $fakeId_escaped . '">' . NL;
     echo '<dt>';
     if ($item['isimg']) {
         media_printimgdetail($item, true);
     } else {
         echo '<a name="d_:' . $item['id'] . '" class="image" title="' . $fakeId_escaped . '" href="' . media_managerURL(array('image' => $fakeId, 'ns' => $ns, 'tab_details' => 'view')) . '">';
         echo media_printicon($fakeId_escaped);
         echo '</a>';
     }
     echo '</dt>' . NL;
     if (!$display_namespace) {
         $name = hsc($file);
     } else {
         $name = $fakeId_escaped;
     }
     echo '<dd class="name"><a href="' . media_managerURL(array('image' => $fakeId, 'ns' => $ns, 'tab_details' => 'view')) . '" name="h_:' . $item['id'] . '">' . $name . '</a></dd>' . NL;
     if ($item['isimg']) {
         $size = '';
         $size .= (int) $item['meta']->getField('File.Width');
         $size .= '&#215;';
         $size .= (int) $item['meta']->getField('File.Height');
         echo '<dd class="size">' . $size . '</dd>' . NL;
     } else {
         echo '<dd class="size">&#160;</dd>' . NL;
     }
     $date = dformat($item['mtime']);
     echo '<dd class="date">' . $date . '</dd>' . NL;
     $filesize = filesize_h($item['size']);
     echo '<dd class="filesize">' . $filesize . '</dd>' . NL;
     echo '</dl></li>' . NL;
 }
Example #3
0
/**
 * Formats and prints one file in the list in the thumbnails view
 *
 * @author Kate Arzamastseva <*****@*****.**>
 */
function media_printfile_thumbs($item, $auth, $jump = false, $display_namespace = false)
{
    // Prepare filename
    $file = utf8_decodeFN($item['file']);
    // output
    echo '<li><dl title="' . hsc($item['id']) . '">' . NL;
    echo '<dt>';
    if ($item['isimg']) {
        media_printimgdetail($item, true);
    } else {
        echo '<a id="d_:' . $item['id'] . '" class="image" title="' . $item['id'] . '" href="' . media_managerURL(array('image' => hsc($item['id']), 'ns' => getNS($item['id']), 'tab_details' => 'view')) . '">';
        echo media_printicon($item['id'], '32x32');
        echo '</a>';
    }
    echo '</dt>' . NL;
    if (!$display_namespace) {
        $name = hsc($file);
    } else {
        $name = hsc($item['id']);
    }
    echo '<dd class="name"><a href="' . media_managerURL(array('image' => hsc($item['id']), 'ns' => getNS($item['id']), 'tab_details' => 'view')) . '" id="h_:' . $item['id'] . '">' . $name . '</a></dd>' . NL;
    if ($item['isimg']) {
        $size = '';
        $size .= (int) $item['meta']->getField('File.Width');
        $size .= '&#215;';
        $size .= (int) $item['meta']->getField('File.Height');
        echo '<dd class="size">' . $size . '</dd>' . NL;
    } else {
        echo '<dd class="size">&#160;</dd>' . NL;
    }
    $date = dformat($item['mtime']);
    echo '<dd class="date">' . $date . '</dd>' . NL;
    $filesize = filesize_h($item['size']);
    echo '<dd class="filesize">' . $filesize . '</dd>' . NL;
    echo '</dl></li>' . NL;
}