Changeset - r30:de0b00cc9fec
[Not reviewed]
v0.8 default
0 3 0
Wolfgang Scherer (ws) - 13 years ago 2012-04-02 17:07:31
wolfgang.scherer@gmx.de
index.php: show/hide export mode (jQuery).
3 files changed with 47 insertions and 3 deletions:
0 comments (0 inline, 0 general)
index.php
Show inline comments
 
@@ -85,57 +85,90 @@ div.error {
 
    margin-bottom: 10px;
 
}
 
span.label {
 
    width: 100px;
 
    display: inline-block;
 
    vertical-align: top;
 
}
 
hr.sep {
 
    width: 550px;
 
    text-align: left;
 
    margin-left: 0;
 
}
 
#body, #copyright-notice {
 
    width: 550px;
 
    margin: 10px auto;
 
    position:relative;
 
}
 
#body {
 
    text-align: left;
 
}
 
#copyright-notice {
 
    text-align: center;
 
    font-size: 8pt;
 
}
 
h4._more, h4._less {
 
    cursor: pointer;
 
}
 
h4._more:after {
 
    content: "...";
 
    font-weight: bold;
 
    padding-left: 4px;
 
}
 
h4._less:before {
 
    content: "^";
 
    font-weight: bold;
 
    padding-right: 4px;
 
}
 
';
 

	
 
$headers = '<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>';
 

	
 
$script ='
 
jQuery(document).ready(function(){
 
    $("#expert-mode").click(function(ev) {
 
        ev.preventDefault();
 
        var jthis = $(this);
 
        var contents = jthis.next();
 
        if (contents.is(":visible")) {
 
            jthis.addClass("_more");
 
            jthis.removeClass("_less");
 
            contents.hide();
 
        } else {
 
            jthis.removeClass("_more");
 
            jthis.addClass("_less");
 
            contents.show();
 
        }
 
        return false;
 
    }).click();
 
});
 
';
 

	
 
echo substitute_elements(
 
    $HEAD, Array(
 
        'title' => trim($title),
 
        'css' => trim($css),
 
        'headers' => trim($headers),
 
        'script' => trim($script),
 
        ));
 
hl($title);
 

	
 
// --------------------------------------------------
 
// |||:sec:||| Error handling (User)
 
// --------------------------------------------------
 

	
 
if ($_debug > 2) {
 
    $user = '';                 // error #1
 
}
 
if ($_debug > 3) {
 
    $user = 'unknown';          // error #2
 
}
 

	
 
if (empty($user)) {
 
    error_msg(get_text('error_no_user'));
 
    echo $FOOT;
 
    exit(0);
 
}
 

	
 
if (!$is_admin && !in_array($user, $user_names)) {
 
    error_msg(sprintf('%s (%s)!', get_text('error_unknown_user'), $user));
 
    echo $FOOT;
 
@@ -432,69 +465,74 @@ if ( !$x_wsv_raw )
 
    // subject
 
    $form[] = sprintf('<span class="label">%s<sup>*</sup>:</span>', get_text('subject'));
 
    $form[] = (
 
        '<input type="text" name="subject" value="' . htmlspecialchars($vacation_subject, ENT_COMPAT, "UTF-8")
 
        .'" size="49" style="width: 440px;" /><br />');
 

	
 
    // message
 
    $form[] = sprintf('<span class="label">%s<sup>*</sup>:</span>', get_text('body'));
 
    $form[] = (
 
        '<textarea name="body" cols="56" rows="'.$text_rows.'"'
 
        .' style="vertical-align: top; width: 440px;">' . htmlspecialchars($vacation_body, ENT_NOQUOTES, "UTF-8") . '</textarea><br />');
 

	
 
    // actions
 
    $form[] = '<hr class="sep"/>';
 
    $form[] = '<span class="label">&nbsp;</span>';
 
    $form[] = sprintf('<input type="submit" name="save" value="%s" />', get_text('save'));
 
    //$form[] = ' ' . get_text('enable_encoding');
 
    $form[] = '<hr class="sep"/>';
 
}
 

	
 
if ($x_wsv_raw || $EXPERT_ENABLED)
 
{
 
    if ( $x_wsv_raw ) {
 
        $text_rows = 15;
 
        $id = null;
 
    } else {
 
        $text_rows = 5;
 
        $id = 'expert-mode';
 
    }
 
    $form[] = sshl(get_text('expert_mode'));
 
    $form[] = sshl(get_text('expert_mode'), $id);
 
#    $form[] = sshl('<a href="#">'.get_text('expert_mode').'</a>', 'expert-mode-head');
 
    $form[] = '<div>';
 
    // raw message
 
    $form[] = sprintf('<span class="label">%s<sup>*</sup>:</span>', get_text('message'));
 
    $form[] = (
 
        '<textarea name="message" cols="56" rows="'.$text_rows.'"'
 
        .' style="vertical-align: top; width: 440px;">' . htmlspecialchars($vacation_msg, ENT_NOQUOTES, "UTF-8") . '</textarea><br />');
 

	
 
    $form[] = '<span class="label">&nbsp;</span>';
 
    $form[] = (
 
        '<span style="display: inline-block; width: 440px; margin-top: 5px; font-size: 8pt;">'
 
        . get_text('explain_expert')
 
        .'</span><br />');
 

	
 
    $form[] = '<hr class="sep"/>';
 
    $form[] = '<span class="label">&nbsp;</span>';
 
    $form[] = sprintf('<input type="submit" name="raw" value="%s" />', get_text('save'));
 
    //$form[] = ' ' . get_text('disable_encoding');
 
    $form[] = '<hr class="sep"/>';
 
    $form[] = '</div>';
 

	
 
}
 

	
 
//$form[] = '<span class="label">&nbsp;</span>';
 
$form[] = (
 
    '<span style="display: inline-block; width: 550px;"><sup>*</sup>'
 
    . get_text('explain_subject')
 
    .'</span><br />');
 

	
 
// --------------------------------------------------
 
// |||:sec:||| Vacation History
 
// --------------------------------------------------
 

	
 
$vacation_list_cmd = sprintf(
 
    '%s -u %s %s %s -l', $SUDO_CMD, $user, $SUDO_OPT_H, $VACATION_CMD);
 
// echo ('<pre>'."\n");
 
// echo ($vacation_list_cmd);
 
// echo ('</pre>'."\n");
 
$vacation_ausgabe = popen ($vacation_list_cmd, 'r');
 
$vacation_list = stream_get_contents($vacation_ausgabe);
 
pclose($vacation_ausgabe);
 

	
 
if (!empty ($vacation_list)) {
 
    $form[] = shl(get_text('reply_history'));
lib/template.php
Show inline comments
 
@@ -61,48 +61,49 @@
 
    <style type="text/css"><!--
 
a, a:link, a:visited {
 
    text-decoration:none;
 
}
 
a:hover {
 
    background-color: #dddddd !important;
 
}
 
a:focus {
 
    background-color: #cccccc !important;
 
}
 
.light {
 
    color: #2e90ff;
 
}
 
.dark {
 
    color: #0e60ff;
 
}
 
.error {
 
    color: #dd0000;
 
}
 
.warning {
 
    color: #ff0e60;
 
}
 
@css@
 
      --></style>
 
@headers@
 
    <script type="text/javascript"><!--
 
@script@
 
      //--></script>
 
  </head>
 
  <body>
 
    <div id="body">
 
    <!-- |:here:| -->
 
';
 

	
 
$FOOT = '<!-- |:here:| -->
 
    </div>
 
    <div id="copyright-notice">
 
      Copyright (C) 2012, Wolfgang Scherer;
 
      Sponsored by <a href="http://www.wiedenmannseile.de">WIEDENMANN SEILE GMBH</a>
 
    </div>
 
  </body>
 
</html>
 
';
 

	
 
//
 
// :ide-menu: Emacs IDE Menu - Buffer @BUFFER@
 
// . M-x `eIDE-menu' ()(eIDE-menu "z")
 
// :ide: COMPILE: PHP _DEBUG_=2 _DEBUG_TEST_=2
 
// . (compile (concat "php " (file-name-nondirectory (buffer-file-name)) " _DEBUG_=2 _DEBUG_TEST_=2"))
lib/util.php
Show inline comments
 
@@ -213,51 +213,56 @@ if ( True && isset($_SERVER['HTTP_ACCEPT
 
function get_text($text)
 
{
 
    global $LC_MESSAGES_EN;
 
    global $LC_MESSAGES;
 
    if ( !array_key_exists($text, $LC_MESSAGES))
 
    {
 
        if ( array_key_exists($text, $LC_MESSAGES_EN) )
 
        {
 
            return $LC_MESSAGES_EN[$text];
 
        }
 
        return $text;
 
    }
 
    return $LC_MESSAGES[$text];
 
}
 

	
 
// --------------------------------------------------
 
// |||:sec:||| Überschrift/Fehlermeldung
 
// --------------------------------------------------
 

	
 
function shl($message)
 
{
 
    return sprintf('<h3>%s</h3>', $message);
 
}
 

	
 
function sshl($message)
 
function sshl($message, $id=null)
 
{
 
    return sprintf('<h4>%s</h4>', $message);
 
    if ( isset($id) ) {
 
        $id_fmt = sprintf(' id="%s"', $id);
 
    } else {
 
        $id_fmt = '';
 
    }
 
    return sprintf('<h4%s>%s</h4>', $id_fmt, $message);
 
}
 

	
 
function hl($message)
 
{
 
    echo shl($message)."\n";
 
}
 

	
 
function error_msg($message)
 
{
 
    echo sprintf('<div class="error"><strong>%s</strong></div>'."\n", $message);
 
}
 

	
 
// --------------------------------------------------
 
// |||:sec:||| vaccation(1) message
 
// --------------------------------------------------
 

	
 
// 2.2. Header Fields
 
//    Header fields are lines beginning with a field name, followed by a
 
//    colon (":"), followed by a field body, and terminated by CRLF.  A
 
//    field name MUST be composed of printable US-ASCII characters (i.e.,
 
//    characters that have values between 33 and 126, inclusive), except
 
//    colon.  A field body may be composed of printable US-ASCII characters
 
//    as well as the space (SP, ASCII value 32) and horizontal tab (HTAB,
 
//    ASCII value 9) characters (together known as the white space
0 comments (0 inline, 0 general)