Skip to content

Commit

Permalink
updating all the files using wysiwyg to use a config array as the sec…
Browse files Browse the repository at this point in the history
…ond param
  • Loading branch information
dogmatic69 committed Feb 15, 2010
1 parent bd0ef01 commit 6dd4ce5
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 174 deletions.
12 changes: 8 additions & 4 deletions app_helper.php
Expand Up @@ -277,20 +277,24 @@ function paginationCounter($pagintion) {
return $out;
}

function wysiwyg($id = null, $toolbar = 'Basic') {
function wysiwyg($id = null, $config = array( 'toolbar' => 'Full')) {
if (!$id) {
$this->errors[] = 'No field specified for the wysiwyg editor';
return false;
}

if (!Configure::read('Wysiwyg.editor')) {
$this->errors[] = 'There is no editor configured';
return false;
}

$editor = (Configure::read('Wysiwyg.editor')) ? Configure::read('Wysiwyg.editor') : 'text';
$editor = 'text';

$_editor = Configure::read('Wysiwyg.editor');
if (!empty($_editor)) {
$editor = $_editor;
}

return $this->Wysiwyg->$editor($id, $toolbar);
return $this->Wysiwyg->{$editor}($id, $config);
}

function gravatar($email = null, $options = array()) {
Expand Down
37 changes: 2 additions & 35 deletions extensions/libs/views/helpers/wysiwyg.php
Expand Up @@ -25,11 +25,6 @@ class WysiwygHelper extends AppHelper
'Javascript'
);

function fck( $id = null, $toolbar = 'Basic' )
{
return $this->input( $id ).$this->fckStarter( $id, $toolbar );
}

function ckEditor($id = null, $config = array()){
$default = array(
'baseFloatZIndex' => '',
Expand Down Expand Up @@ -130,7 +125,7 @@ function ckEditor($id = null, $config = array()){
'templates_files' => '',
'templates_replaceContent' => '',
'theme' => '',
'toolbar' => 'Basic',
'toolbar' => 'Full',
'toolbar_Basic' => '',
'toolbar_Full' => '',
'toolbarCanCollapse' => '',
Expand All @@ -146,39 +141,11 @@ function ckEditor($id = null, $config = array()){
$did .= ucfirst($v);
}


$code = 'CKEDITOR.replace( \''.$did.'\', { toolbar : \''.$config['toolbar'].'\' } );';
return $this->input($id).$this->Javascript->codeBlock($code);
}

function fckStarter( $id = null, $toolbar = 'Basic' )
{
if ( !$id )
{
$this->errors[] = 'No id given for the text area';
return false;
}

$did = '';
foreach ( explode( '.', $id ) as $v )
{
$did .= ucfirst( $v );
}

$path = $this->webroot.'js/';

return <<<FCK_CODE
<script type="text/javascript">
fckLoader_$did = function () {
var bFCKeditor_$did = new FCKeditor('$did');
bFCKeditor_$did.BasePath = '$path';
bFCKeditor_$did.ToolbarSet = '$toolbar';
bFCKeditor_$did.ReplaceTextarea();
}
fckLoader_$did();
</script>
FCK_CODE;
}

function text( $id = null )
{
return $this->input( $id );
Expand Down
56 changes: 28 additions & 28 deletions infinitas/newsletter/views/newsletters/admin_add.ctp
@@ -1,29 +1,29 @@
<?php
/**
* Comment Template.
*
* @todo -c Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://infinitas-cms.org
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/

echo $this->Form->create( 'Newsletter' );
echo $this->Form->input( 'campaign_id' );
echo $this->Form->input( 'from', array( 'class' => 'title' ) );
echo $this->Form->input( 'reply_to', array( 'class' => 'title' ) );
echo $this->Form->input( 'subject', array( 'class' => 'title' ) );
echo $this->Letter->wysiwyg( 'Newsletter.html', 'EmailHtml' );
echo $this->Letter->wysiwyg( 'Newsletter.text', 'EmailText' );
echo $this->Form->end( 'Save Newsletter' );
<?php
/**
* Comment Template.
*
* @todo -c Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://infinitas-cms.org
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/

echo $this->Form->create( 'Newsletter' );
echo $this->Form->input( 'campaign_id' );
echo $this->Form->input( 'from', array( 'class' => 'title' ) );
echo $this->Form->input( 'reply_to', array( 'class' => 'title' ) );
echo $this->Form->input( 'subject', array( 'class' => 'title' ) );
echo $this->Letter->wysiwyg( 'Newsletter.html', array('toolbar' => 'EmailHtml') );
echo $this->Letter->wysiwyg( 'Newsletter.text', array('toolbar' => 'EmailText') );
echo $this->Form->end( 'Save Newsletter' );
?>
58 changes: 29 additions & 29 deletions infinitas/newsletter/views/newsletters/admin_edit.ctp
@@ -1,30 +1,30 @@
<?php
/**
* Comment Template.
*
* @todo -c Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://infinitas-cms.org
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/

echo $this->Form->create( 'Newsletter' );
echo $this->Form->input( 'id' );
echo $this->Form->input( 'campaign_id' );
echo $this->Form->input( 'from', array( 'class' => 'title' ) );
echo $this->Form->input( 'reply_to', array( 'class' => 'title' ) );
echo $this->Form->input( 'subject', array( 'class' => 'title' ) );
echo $this->Letter->wysiwyg( 'Newsletter.html', 'EmailHtml' );
echo $this->Letter->wysiwyg( 'Newsletter.text', 'EmailText' );
echo $this->Form->end( 'Save Newsletter' );
<?php
/**
* Comment Template.
*
* @todo -c Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://infinitas-cms.org
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/

echo $this->Form->create( 'Newsletter' );
echo $this->Form->input( 'id' );
echo $this->Form->input( 'campaign_id' );
echo $this->Form->input( 'from', array( 'class' => 'title' ) );
echo $this->Form->input( 'reply_to', array( 'class' => 'title' ) );
echo $this->Form->input( 'subject', array( 'class' => 'title' ) );
echo $this->Letter->wysiwyg( 'Newsletter.html', array('toolbar' => 'EmailHtml') );
echo $this->Letter->wysiwyg( 'Newsletter.text', array('toolbar' => 'EmailText') );
echo $this->Form->end( 'Save Newsletter' );
?>
156 changes: 78 additions & 78 deletions views/elements/global/comment_add.ctp
@@ -1,79 +1,79 @@
<?php
/**
* Comment Template.
*
* @todo -c Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://infinitas-cms.org
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/
?>
<div id="comment-box">
<?php
/**
* fields allowed in the comments
*/
$commentFields = explode(',',Configure::read('Comment.fields'));

$action = ( isset( $action ) ) ? $action : 'comment';
$modelName = ( isset( $modelName ) ) ? $modelName : Inflector::singularize( $this->name );

if ( isset( $urlParams ) )
{
echo $this->Form->create(
$modelName,
array(
'url' => array(
'plugin' => $this->params['plugin'],
'controller' => $this->params['controller'],
'action' => $action,
$urlParams
)
)
);
}

else
{
echo $this->Form->create(
$modelName,
array(
'url' => array(
'plugin' => $this->params['plugin'],
'controller' => $this->params['controller'],
'action' => $action
)
)
);
}
?>
<fieldset>
<legend><?php __( "Post a {$commentModel}" );?></legend>
<?php
echo $this->Form->input( "$modelName.id", array( 'value' => $fk ) );

foreach( $commentFields as $field )
{
if ( $field != 'comment' )
{
echo $this->Form->input( 'Comment.'.$field );
}
else
{
echo $this->Blog->wysiwyg( 'Comment.comment', 'Simple' );
}
}
?>
</fieldset>
<?php echo $this->Form->end('Submit'); ?>
<?php
/**
* Comment Template.
*
* @todo -c Implement .this needs to be sorted out.
*
* Copyright (c) 2009 Carl Sutton ( dogmatic69 )
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 )
* @link http://infinitas-cms.org
* @package sort
* @subpackage sort.comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.5a
*/
?>
<div id="comment-box">
<?php
/**
* fields allowed in the comments
*/
$commentFields = explode(',',Configure::read('Comment.fields'));

$action = ( isset( $action ) ) ? $action : 'comment';
$modelName = ( isset( $modelName ) ) ? $modelName : Inflector::singularize( $this->name );

if ( isset( $urlParams ) )
{
echo $this->Form->create(
$modelName,
array(
'url' => array(
'plugin' => $this->params['plugin'],
'controller' => $this->params['controller'],
'action' => $action,
$urlParams
)
)
);
}

else
{
echo $this->Form->create(
$modelName,
array(
'url' => array(
'plugin' => $this->params['plugin'],
'controller' => $this->params['controller'],
'action' => $action
)
)
);
}
?>
<fieldset>
<legend><?php __( "Post a {$commentModel}" );?></legend>
<?php
echo $this->Form->input( "$modelName.id", array( 'value' => $fk ) );

foreach( $commentFields as $field )
{
if ( $field != 'comment' )
{
echo $this->Form->input( 'Comment.'.$field );
}
else
{
echo $this->Blog->wysiwyg( 'Comment.comment', array('toolbar' => 'Basic') );
}
}
?>
</fieldset>
<?php echo $this->Form->end('Submit'); ?>
</div>

0 comments on commit 6dd4ce5

Please sign in to comment.