[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] sitemgr/modules class.module_external_html.inc.php, 1
From: |
skwashd |
Subject: |
[Phpgroupware-cvs] sitemgr/modules class.module_external_html.inc.php, 1.1.4.1 class.module_contactus.inc.php, 1.1.2.1 |
Date: |
Sun, 13 Nov 2005 02:36:00 +0100 |
Update of sitemgr/modules
Added Files:
Branch: skwashd-16-compat
class.module_external_html.inc.php lines: +40 -47
class.module_contactus.inc.php lines: +107 -0
Log Message:
new modules for including external files and for a contact form
====================================================
Index: class.module_external_html.inc.php
<?php
/*******************************************************************************\
* phpGroupWare - sitemgr - external html module
*
* http://www.phpgroupware.org
*
* Written by Dave Hall skwashd at phpgroupware.org
*
* Copyright (C) 2004 Free Software Foundation Inc.
*
* --------------------------------------------
*
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by
the *
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\*******************************************************************************/
class module_external_html extends Module
{
function module_external_html()
{
$this->arguments = array(
'filename' => array(
'type' => 'textfield',
'label' => lang('The full path to the
html document (must start with a slash /)')
),
);
$this->title = lang('External HTML');
$this->description = lang('This module allows inclusion
of external static html files, the contents will be everything between the
>body<');
}
function get_content(&$arguments,$properties)
{
$page = '';
if ( is_file($arguments['filename']) &&
is_readable($arguments['filename']) )
{
$page =
file_get_contents($arguments['filename']);
}
if( $page )
{
if( strpos($page, '<html>') )
{
$page = preg_replace('/\r/', '', $page);
$page = preg_replace('/\n/', '', $page);
preg_match('/\<BODY[^>]*\>\s*(.*?)\s*\<\/BODY\>/i', $page, $match);
$page =
preg_replace('/\<\/?BODY[^>]*\>/i', '', $match[0]);
if ( !isset($GLOBALS['data_cleaner'])
|| !is_object($GLOVALS['data_cleaner']) )
{
$GLOBALS['data_cleaner'] =
createObject('phpgwapi.data_cleaner', '');
}
$page = clean_vars($page, false);
}
else
{
$page = '<pre>' . htmlentities($page) .
'</pre>';
}
return $page;
}
else
{
return lang('404 - Page not Found!');
}
}
}
?>
====================================================
Index: class.module_contactus.inc.php
<?php
/*******************************************************************************\
* phpGroupWare - sitemgr - contact form handler
*
* http://www.phpgroupware.org
*
* Written by Dave Hall skwashd at phpgroupware.org
*
* Copyright (C) 2005 Free Software Foundation Inc.
*
* --------------------------------------------
*
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by
the *
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\*******************************************************************************/
class module_contactus extends Module
{
function module_contactus()
{
$this->title = 'Contact Us Form';
$this->description = lang('Allow website users to
contact you via email');
$this->post = array
(
'name' => array ('type' =>
'textfield', 'label' => 'name'),
'email' => array ('type' =>
'textfield', 'label' => 'email address'),
'phone' => array ('type' =>
'textfield', 'label' => 'phone number'),
'subject' => array ('type' =>
'textfield', 'label' => 'subject'),
'comments' => array
(
'type' =>
'textarea',
'label' =>
'comments',
'params' =>
array('rows' => 15, 'cols' => 75)
),
'send' => array ('type' =>
'submit', 'value' => 'Send', 'label' => 'Send')
);
$this->arguments = array
(
'sendto' => array('type' =>
'textfield', 'label' => 'Send Message to'),
'subject_prefix'=> array('type' =>
'textfield', 'label' => 'Message Subject Prefix'),
'prefix_msg' => array
(
'type' =>
'richtext',
'label' =>
'Content to show above form',
'params' =>
array('rows' => 15, 'cols' => 75)
),
'sent_msg' => array
(
'type' =>
'richtext',
'label' =>
'Text to show after message sent',
'params' =>
array('rows' => 15, 'cols' => 75)
)
);
}
function get_content(&$arguments,$properties)
{
$content = "<div id=\"sitemgr_contactus\">\n";
if ( isset($arguments['send']) && $arguments['send'] )
{
$smtp = createObject('news_admin.mailer_smtp');
$smtp->AddAddress($arguments['sendto']);
$smtp->From = (!empty($arguments['email']) ?
$arguments['email'] : "address@hidden'SERVER_NAME']}");
$smtp->FromName = $arguments['name'];
$smtp->Subject =
"{$arguments['subject_prefix']} {$arguments['subject']}";
$body = lang('subject') .
":\t{$smtp->Subject}\n\n";
$body .= lang('name') .
":\t\t{$arguments['name']} <{$smtp->From}>\n";
$body .= lang('phone') .
":\t\t{$arguments['phone']}\n\n";
$body .= lang('comments') . ":\n";
$body .= $arguments['comments'];
$smtp->Body =& $body;
if ( $smtp->Send() )
{
$content .= $arguments['sent_msg'];
}
else
{
$content .= $smtp->ErrorInfo;
}
}
else
{
$content .= $arguments['prefix_msg'];
$content .="<div
id=\"sitemgr_contactus_form\">\n\t<form method=\"post\">\n";
foreach ( $this->post as $key => $vals )
{
$content .= "\t\t";
if ( $vals['type'] != 'submit' )
{
$content .= "<label
for=\"block_{$this->block->id}_{$key}\">" . lang($vals['label']) . ':</label> ';
}
if ( $vals['type'] == 'textarea' )
{
$content .= "<br />\n";
}
$content .=
$this->build_post_element($key) . "<br />\n";
}
$content .= "\t</form>\n</div>\n";
}
$content .= "</div>\n";
return $content;
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] sitemgr/modules class.module_external_html.inc.php, 1.1.4.1 class.module_contactus.inc.php, 1.1.2.1,
skwashd <=
- Prev by Date:
[Phpgroupware-cvs] news_admin/inc class.mailer_smtp.inc.php,1.2
- Next by Date:
[Phpgroupware-cvs] sitemgr/modules class.module_logout.inc.php, 1.1.2.1 class.module_login.inc.php, 1.1.2.1.4.1 class.module_external_html.inc.php, 1.1.4.2 class.module_contactus.inc.php, 1.1.2.2
- Previous by thread:
[Phpgroupware-cvs] news_admin/inc class.mailer_smtp.inc.php,1.2
- Next by thread:
[Phpgroupware-cvs] sitemgr/modules class.module_logout.inc.php, 1.1.2.1 class.module_login.inc.php, 1.1.2.1.4.1 class.module_external_html.inc.php, 1.1.4.2 class.module_contactus.inc.php, 1.1.2.2
- Index(es):