Location: PHPKode > projects > EmbryoCore > content/plugins/welcomemessage/config.php
<?php
/*==============================================================================================
/**
 * @package                 EmbryoCore
 * @author                  Steve Dunstan (hide@address.com)
 * @copyright               2010-2011 EmbryoCore
 * @licence                 GNU General Public License v3: http://www.gnu.org/licenses/
 * @link                    http://embryocore.com
 * @since                   File available since Release 1.0
 * @version                 SVN: $Id: config.php 3 2010-08-10 11:09:05Z stevedunstan $
/**
===============================================================================================*/

$config = new Embryo_Welcomemessage_Config;
$this->content .= $config->configStart();


class Embryo_Welcomemessage_Config
{

	public function configStart()
	{
		if(!_constant('user:admin')) {
			return false;
		}
		
		$options = _core('welcomemessage');
		if(!$options) {
			$options = new stdClass();
			$options->ga = 0;
			$options->ma = 0;
			$options->aa = 0;
			$options->gm = '';
			$options->mm = '';
			$options->am = '';
			Embryo_Core::write('welcomemessage', $options);
		}
		
		_registerLanguage(dirname(__FILE__).'/languages/');
		Embryo_Constants::write('jscript', 'welcomemessage:admin', true);
		Embryo_Constants::write('jscript', 'listitem', true);
		
		if(_constant('pmode') == 'save') {
			$this->saveMessages();
			exit;
		}
		
		if(_constant('pmode') == 'saveOptions') {
			$this->saveOptions();
			exit;
		}
		
		$text = "
<div id='pwrapper'>
<div id='aright'>

<div class='panel'>
<div class='list-typeimage'><img src='"._constant('path:plugins')."welcomemessage/icon.png' alt='logo' /></div> <h2>Welcome Message</h2>
version 1.0, by Steve Dunstan<br /><br /><br />
<strong>{lan Usage}:</strong> {lan After setting each message, add the template tag} &#123;WELCOMEMESSAGE} {lan to your theme template. As long as the message is active (see below), the message will appear according the the visitor type}.
</div>

<div class='panel'>
<h2>{lan Options}</h2>
<table>
<tr><td style='width: 5%;'>".Embryo_Form::build('checkbox', array('name' => 'ga', 'value' => 1), $options->ga)."</td><td style='width: 95%;'>{lan Guest} {lan Message} {lan Active}?<br /></td></tr>
<tr><td style='width: 5%;'>".Embryo_Form::build('checkbox', array('name' => 'ma', 'value' => 1), $options->ma)."</td><td style='width: 95%;'>{lan Member} {lan Message} {lan Active}?<br /></td></tr>
<tr><td style='width: 5%;'>".Embryo_Form::build('checkbox', array('name' => 'aa', 'value' => 1), $options->aa)."</td><td style='width: 95%;'>{lan Admin} {lan Message} {lan Active}?<br /></td></tr>
</table>


<p>".Embryo_Form::build('gbutton', array('id' => 'wmsave-options', 'class' => 'abutton1', 'value' => '{lan Save}'))."</p>

</div>

</div>
<div id='aleft'>
<div id='plugin-content'>
		
		
<form id='wmmessage-form'>	
<div id='dhitem-1' class='panel listitem'>
<div class='list-buttons' id='listbuttons-1'><a class='sbutton1' href='#' id='pex-1'>{lan Edit} {lan Message}</a></div>
<div class='list-title'>{lan Guest} {lan Message}</div><div id='pde-1' class='no-display'>
<br />".
Embryo_Form::build('textarea', array('name' => 'gm', 'style' => 'width: 65%', 'rows' => 6, 'value' => $options->gm))."
<p><a class='abutton1' href='#' id='cancel-1'>Cancel</a> <a class='abutton1' href='#' id='savewm'>{lan Save}</a></p></div>
</div>


<div id='dhitem-2' class='panel listitem'>
<div class='list-buttons' id='listbuttons-2'><a class='sbutton1' href='#' id='pex-2'>{lan Edit} {lan Message}</a></div>
<div class='list-title'>{lan Member} {lan Message}</div><div id='pde-2' class='no-display'>
<br />".
Embryo_Form::build('textarea', array('name' => 'mm', 'style' => 'width: 65%', 'rows' => 6, 'value' => $options->mm))."
<p><a class='abutton1' href='#' id='cancel-2'>Cancel</a> <a class='abutton1' href='#' id='savewm'>{lan Save}</a></p></div>
</div>


<div id='dhitem-3' class='panel listitem'>
<div class='list-buttons' id='listbuttons-3'><a class='sbutton1' href='#' id='pex-3'>{lan Edit} {lan Message}</a></div>
<div class='list-title'>{lan Admin} {lan Message}</div><div id='pde-3' class='no-display'>
<br />".
Embryo_Form::build('textarea', array('name' => 'am', 'style' => 'width: 65%', 'rows' => 6, 'value' => $options->am))."
<p><a class='abutton1' href='#' id='cancel-3'>Cancel</a> <a class='abutton1' href='#' id='savewm'>{lan Save}</a></p></div>
</div>

</form>
	
</div>
</div>
<div class='clear'></div>	
</div>";
		return $text;
		
		
	}
/*+-------------------------------------------------------------------------------------------------------------------+*/
	private function saveMessages()
	{
		$plugconf = _core('welcomemessage');
		foreach($_POST as $post_name => $post_value) {
			$plugconf->$post_name = $post_value;
		}
		Embryo_Core::write('welcomemessage', $plugconf);
		_render("{lan Messages} {lan Saved}");
	}
/*+-------------------------------------------------------------------------------------------------------------------+*/
	private function saveOptions()
	{
		$plugconf = _core('welcomemessage');
		foreach($_POST as $post_name => $post_value) {
			$plugconf->$post_name = $post_value;
		}
		Embryo_Core::write('welcomemessage', $plugconf);
		_render("{lan Options} {lan Saved}");
	}
/*+-------------------------------------------------------------------------------------------------------------------+*/
}
?>
Return current item: EmbryoCore