/** construct javascript alerts for messages
  *
  * This constructs a piece of HTML that yields 0 or more
  * calles to the javascript alert() function, once per message.
  * If no messages need to be displayed an empty string is
  * returned.
  *
  * @param array @messages a collection of message to display via alert()
  * @param string $m left margin for increased readability
  * @return string generated HTML-code with Javascript or empty string
  */
 function get_popups($messages, $m = '')
 {
     $s = '';
     if (!empty($messages)) {
         $s .= $m . "<script>\n" . $m . "<!--\n";
         foreach ($messages as $message) {
             $s .= $m . "  " . javascript_alert($message) . "\n";
         }
         $s .= $m . "-->\n" . $m . "</script>\n";
     }
     return $s;
 }
Exemplo n.º 2
0
/** construct the end of the simple HTML-page, closing the full size table
 *
 * @param string $alert_message (optional) message to show via a javascript alert()
 * @see login_page_open()
 * @return string the constructed HTML
 * @uses javascript_alert()
 */
function login_page_close($alert_message = '')
{
    $s = "        </td>\n" . "      </tr>\n" . "    </table>\n";
    if (!empty($alert_message)) {
        $alert_message = wordwrap($alert_message, MAXIMUM_LINE_LENGTH);
        $s .= "  <script>\n" . "  <!--\n" . "    " . javascript_alert($alert_message) . "\n" . "  -->\n" . "  </script>\n";
    }
    $s .= "  </body>\n" . "</html>\n";
    return $s;
}