1
rebenta
Spaw - How to stop change urls and a soapbox implemention
  • 2005/9/20 19:24

  • rebenta

  • Just popping in

  • Posts: 30

  • Since: 2005/8/23


I´m having two problens with SPAW editor.
One problem is happening because the spaw editor is changing the links on pages every time who i edit one article.
It´s happening in all spaw implementions. How can i turn off the SPAW automatic manipulation of web links?
The second is when i post an article in admin area (of soapbox module). When i send new articles, XOOPS don´t confirm and screen stand white..how can i change code for show confirmation corretly?

The code of soapbox article.php when i´ve insert the code:
Quote:

<?php
/**
* $Id: article.php v 1.5 23 August 2004 hsalazar Exp $
* Module: Soapbox
* Version: v 1.5
* Release Date: 23 August 2004
* Author: hsalazar
* Licence: GNU
*/

// -- General Stuff -- //
include( "admin_header.php" );

//Insert start of SPAW
$module_handler = &xoops_gethandler('module');
$module = &$module_handler->getByDirname('spaw');

if (is_object($module) && $module->getVar('isactive'))
{
include_once XOOPS_ROOT_PATH . "/modules/spaw/spaw_control.class.php";
}
//insert finish

$op = '';

foreach ( $_POST as $k => $v )
{
${$k} = $v;
}

foreach ( $_GET as $k => $v )
{
${$k} = $v;
}

if ( isset( $_GET['op'] ) ) $op = $_GET['op'];
if ( isset( $_POST['op'] ) ) $op = $_POST['op'];


// -- Edit function -- //
function editarticle( $articleID = '' )
{
global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $modify, $xoopsModuleConfig, $xoopsModule, $XOOPS_URL;

include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';

/**
* Clear all variables before we start
*/
if(!isset($block)) { $block = 1; }

if(!isset($html)) { $html = 1; } else { $html = intval($html); }
if(!isset($smiley)) { $smiley = 1; } else { $smiley = intval($smiley); }
if(!isset($xcodes)) { $xcodes = 1; } else { $xcodes = intval($xcodes); }
if(!isset($breaks)) { $breaks = 1; } else { $breaks = intval($breaks); }

if(!isset($weight)) { $weight = 1; }
if(!isset($commentable)) { $commentable = 1; }
if(!isset($offline)) { $offline = 0; }
if(!isset($votes)) { $votes = 0; }
if(!isset($rating)) { $rating = 0.00; }

if(!isset($columnID)) { $columnID = 1; }

if(!isset($headline)) { $headline = ""; }
if(!isset($lead)) { $lead = ""; }
if(!isset($bodytext)) { $bodytext = ""; }
if(!isset($teaser)) { $teaser = ""; }
if(!isset($title)) { $title = ""; }
$artimage = "blank.png";

// If there is a parameter, and the id exists, retrieve data: we're editing an article
if ( $articleID )
{
$result = $xoopsDB -> query( "SELECT columnID, headline, lead, bodytext, teaser, weight, html, smiley, xcodes, breaks, block, artimage, votes, rating, commentable, offline, notifypub FROM " . $xoopsDB -> prefix( "sbarticles" ) . " WHERE articleID = '$articleID'" );
list( $columnID, $headline, $lead, $bodytext, $teaser, $weight, $html, $smiley, $xcodes, $breaks, $block, $artimage, $votes, $rating, $commentable, $offline, $notifypub ) = $xoopsDB -> fetchrow( $result );

if ( !$xoopsDB -> getRowsNum( $result ) )
{
redirect_header( "index.php", 1, _AM_SB_NOARTTOEDIT );
exit();
}
adminMenu(2, _AM_SB_ARTS._AM_SB_EDITING.$headline."'");

echo "<h3 style='color: #2F5376; '>" . _AM_SB_ADMINARTMNGMT . "</h5>";
$sform = new XoopsThemeForm( _AM_SB_MODART . ": $headline" , "op", xoops_getenv( 'PHP_SELF' ) );

}
else // there's no parameter, so we're adding an article
{
$result01 = $xoopsDB -> query( "SELECT COUNT(*) FROM " . $xoopsDB -> prefix( "sbcolumns" ) . " " );
list( $totalcolumns ) = $xoopsDB -> fetchRow( $result01 );
if ( $totalcolumns == 0 )
{
redirect_header( "index.php", 1, _AM_SB_NEEDONECOLUMN );
exit();
}
adminMenu(2, _AM_SB_ARTS._AM_SB_CREATINGART);

echo "<h3 style='color: #2F5376; '>" . _AM_SB_ADMINARTMNGMT . "</h5>";
$sform = new XoopsThemeForm( _AM_SB_NEWART, "op", xoops_getenv( 'PHP_SELF' ) );

}

$sform -> setExtra( 'enctype="multipart/form-data"' );

// COLUMN
/*
* Get information for pulldown menu using XoopsTree.
* First var is the database table
* Second var is the unique field ID for the categories
* Last one is not set as we do not have sub menus in WF-FAQ
*/
$mytree = new XoopsTree( $xoopsDB->prefix( "sbcolumns" ), "columnID" , "0" );

ob_start();
$sform -> addElement( new XoopsFormHidden( 'columnID', $columnID ) );
$mytree -> makeMySelBox( "name", "name", $columnID );
$sform -> addElement( new XoopsFormLabel( _AM_SB_COLNAME, ob_get_contents() ) );
ob_end_clean();

// HEADLINE, LEAD, BODYTEXT
// This part is common to edit/add
$sform -> addElement( new XoopsFormText( _AM_SB_ARTHEADLINE, 'headline', 50, 80, $headline ), true );
$sform -> addElement( new XoopsFormTextArea( _AM_SB_ARTLEAD, 'lead', $lead, 5, 60 ) );

// TEASER
$sform -> addElement( new XoopsFormTextArea( _AM_SB_ARTTEASER, 'teaser', $teaser, 5, 60 ) );
$autoteaser_radio = new XoopsFormRadioYN( _AM_SB_AUTOTEASER, 'autoteaser', 0, ' ' . _AM_SB_YES . '', ' ' . _AM_SB_NO . '' );
$sform -> addElement( $autoteaser_radio );
$sform -> addElement( new XoopsFormText( _AM_SB_AUTOTEASERAMOUNT, 'teaseramount', 4, 4, 100 ) );

// BODY - Implementado com spaw
ob_start();
$sw = new SPAW_Wysiwyg('bodytext', $bodytext, 'en', 'full', 'default', '99%', '600px');
$sw->show();
$sform->addElement(new XoopsFormLabel("Corpo do texto", ob_get_contents(), 1));
ob_end_clean();
//$sw = new SPAW_Wysiwyg( 'bodytext', _AM_SB_ARTBODY, 'en', 'full', 'default', '99%', '600px' );
//$sform -> addElement( $sw ); //( new XoopsFormDhtmlTextArea( _AM_SB_ARTBODY, 'bodytext', $bodytext, 15, 60 ) );

// IMAGE
// The article CAN have its own image :)
// First, if the article's image doesn't exist, set its value to the blank file
if (!file_exists(XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['sbuploaddir'] . "/" . $artimage) || !$artimage)
{
$artimage = "blank.png";
}
// Code to create the image selector
$graph_array = & XoopsLists :: getImgListAsArray( XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['sbuploaddir'] );
$artimage_select = new XoopsFormSelect( '', 'artimage', $artimage );
$artimage_select -> addOptionArray( $graph_array );
$artimage_select -> setExtra( "onchange='showImgSelected(\"image5\", \"artimage\", \"" . $xoopsModuleConfig['sbuploaddir'] . "\", \"\", \"" . XOOPS_URL . "\")'" );
$artimage_tray = new XoopsFormElementTray( _AM_SB_SELECT_IMG, '&nbsp;' );
$artimage_tray -> addElement( $artimage_select );
$artimage_tray -> addElement( new XoopsFormLabel( '', "<br /><br /><img src='" . XOOPS_URL . "/" . $xoopsModuleConfig['sbuploaddir'] . "/" . $artimage . "' name='image5' id='image5' alt='' />" ) );
$sform -> addElement( $artimage_tray );

// Code to call the file browser to select an image to upload
$sform -> addElement( new XoopsFormFile( _AM_SB_UPLOADIMAGE, 'cimage', $xoopsModuleConfig['maxfilesize'] ), false );

// COMMENTS
// Code to allow comments
$addcommentable_radio = new XoopsFormRadioYN( _AM_SB_ALLOWCOMMENTS, 'commentable', $commentable, ' ' . _AM_SB_YES . '', ' ' . _AM_SB_NO . '' );
$sform -> addElement( $addcommentable_radio );

// OFFLINE
// Code to take article offline, for maintenance purposes
$offline_radio = new XoopsFormRadioYN(_AM_SB_SWITCHOFFLINE, 'offline', $offline, ' '._AM_SB_YES.'', ' '._AM_SB_NO.'');
$sform -> addElement($offline_radio);

// ARTICLE IN BLOCK
// Code to put article in block
$block_radio = new XoopsFormRadioYN( _AM_SB_BLOCK, 'block', $block , ' ' . _AM_SB_YES . '', ' ' . _AM_SB_NO . '' );
$sform -> addElement( $block_radio );

// VARIOUS OPTIONS
// Code to accept HTML code
$html_radio = new XoopsFormRadioYN( _AM_SB_DOHTML, 'html', $html, ' ' . _AM_SB_YES . '', ' ' . _AM_SB_NO . '' );
$sform -> addElement( $html_radio );

// Code to accept smileys
$smiley_radio = new XoopsFormRadioYN( _AM_SB_DOSMILEY, 'smiley', $smiley, ' ' . _AM_SB_YES . '', ' ' . _AM_SB_NO . '' );
$sform -> addElement( $smiley_radio );

// Code to accept BBCodes
$xcodes_radio = new XoopsFormRadioYN( _AM_SB_DOXCODE, 'xcodes', $xcodes, ' ' . _AM_SB_YES . '', ' ' . _AM_SB_NO . '' );
$sform -> addElement( $xcodes_radio );

// Code to accept linebreaks
$breaks_radio = new XoopsFormRadioYN( _AM_SB_BREAKS, 'breaks', $breaks, ' ' . _AM_SB_YES . '', ' ' . _AM_SB_NO . '' );
$sform -> addElement( $breaks_radio );

$sform -> addElement( new XoopsFormHidden( 'articleID', $articleID ) );

$button_tray = new XoopsFormElementTray( '', '' );
$hidden = new XoopsFormHidden( 'op', 'addart' );
$button_tray -> addElement( $hidden );

if ( !$articleID ) // there's no articleID? Then it's a new article
{
$butt_create = new XoopsFormButton( '', '', _AM_SB_CREATE, 'submit' );
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addart\'"');
$button_tray->addElement( $butt_create );

$butt_clear = new XoopsFormButton( '', '', _AM_SB_CLEAR, 'reset' );
$button_tray->addElement( $butt_clear );

$butt_cancel = new XoopsFormButton( '', '', _AM_SB_CANCEL, 'button' );
$butt_cancel->setExtra('onclick="history.go(-1)"');
$button_tray->addElement( $butt_cancel );
}
else // else, we're editing an existing article
{
$butt_create = new XoopsFormButton( '', '', _AM_SB_MODIFY, 'submit' );
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addart\'"');
$button_tray->addElement( $butt_create );

$butt_cancel = new XoopsFormButton( '', '', _AM_SB_CANCEL, 'button' );
$butt_cancel->setExtra('onclick="history.go(-1)"');
$button_tray->addElement( $butt_cancel );
}

$sform -> addElement( $button_tray );
$sform -> display();
unset( $hidden );
}


/* -- Available operations -- */
switch ( $op )
{
case "mod":
xoops_cp_header();
$articleID = isset( $_POST['articleID'] ) ? intval( $_POST['articleID'] ) : intval( $_GET['articleID'] );
editarticle($articleID);
break;

case "addart":
// global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig ;

$articleID = (isset($_POST['articleID'])) ? intval($_POST['articleID']) : 0;
$columnID = (isset($_POST['columnID'])) ? intval($_POST['columnID']) : 0;
$block = (isset($_POST['block'])) ? intval($_POST['block']) : 1;
$offline = (isset($_POST['offline'])) ? intval($_POST['offline']) : 0;
$breaks = (isset($_POST['breaks'])) ? intval($_POST['breaks']) : 0;

$commentable = (isset($_POST['commentable'])) ? intval($_POST['commentable']) : 1;
$html = (isset($_POST['html'])) ? intval($_POST['html']) : 1;
$smiley = (isset($_POST['smiley'])) ? intval($_POST['smiley']) : 1;
$xcodes = (isset($_POST['xcodes'])) ? intval($_POST['xcodes']) : 1;

$weight = (isset($_POST['weight'])) ? intval($_POST['weight']) : 1;
$artimage = ($_POST['artimage'] != 'blank.png' ) ? $myts -> addSlashes($_POST['artimage']) : '';
$headline = $myts -> htmlSpecialChars($_POST['headline']);
$lead = $myts -> addSlashes($_POST['lead']);
$bodytext = $myts -> addSlashes($_POST['bodytext']);

$votes = (isset($_POST['votes'])) ? intval($_POST['votes']) : 0;
$rating = (isset($_POST['rating'])) ? intval($_POST['rating']) : 0.00;

if ( $_POST['autoteaser'] )
{
$charlength = $_POST['teaseramount'];
$teasertemp = $_POST['bodytext'];

if ( !XOOPS_USE_MULTIBYTES )
{
$teasertemp = strip_tags( $teasertemp, '' );
$teasertemp = $myts -> addSlashes( substr( $teasertemp, 0, ( $charlength -1 ) ) ) . "...";
}
$teaser = $teasertemp;
}
else
{
$teaser = $myts -> addSlashes( $_POST['teaser'] );
}

$date = time();

// ARTICLE IMAGE
// Define variables
$error = 0;
$word = null;
$uid = $xoopsUser -> uid();
$submit = 1;
$date = time();

if ( $HTTP_POST_FILES['cimage']['name'] != "" )
{
include_once XOOPS_ROOT_PATH . '/class/uploader.php';

if ( file_exists( XOOPS_ROOT_PATH . "/" . $xoopsModuleConfig['sbuploaddir'] . "/" . $HTTP_POST_FILES['cimage']['name'] ) )
{
redirect_header( "index.php", 1, _AM_SB_FILEEXISTS );
}
$allowed_mimetypes = array( 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/png' );

uploading($allowed_mimetypes, $HTTP_POST_FILES['cimage']['name'], "index.php", 0, $xoopsModuleConfig['sbuploaddir']);

$artimage = $HTTP_POST_FILES['cimage']['name'];
}
elseif ($_POST["artimage"] != "blank.png")
{
$artimage = $myts -> addSlashes( $_POST["artimage"] );
}
else
{
$artimage = '';
}

// Save to database
if ( !$articleID )
{
if ( $xoopsDB -> query( "INSERT INTO " . $xoopsDB -> prefix( "sbarticles" ) . " (articleID, columnID, headline, lead, bodytext, teaser, weight, html, smiley, xcodes, breaks, block, artimage, votes, rating, commentable, offline, datesub ) VALUES ('', '$columnID', '$headline', '$lead', '$bodytext', '$teaser', '$weight', '$html', '$smiley', '$xcodes', '$breaks', '$block', '$artimage', '$votes', '$rating', '$commentable', '$offline', '$date' )" ) )
{
$this -> db = & Database :: getInstance();
$newid = mysql_insert_id();
$result = $xoopsDB -> query( "SELECT columnID FROM " . $xoopsDB -> prefix( "sbarticles" ) . " WHERE articleID = '$newid'" );
list($columnID) = $xoopsDB -> fetchrow($result);

$result = $xoopsDB -> query( "SELECT name, total FROM " . $xoopsDB -> prefix( "sbcolumns" ) . " WHERE colid = '$columnID'" );
list( $name, $total ) = $xoopsDB -> fetchrow( $result );
$total++;

$tags = array();
$tags['ARTICLE_NAME'] = $headline;
$tags['ARTICLE_URL'] = XOOPS_URL . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/index.php?art&lid=' . $newid;
$tags['COLUMN_NAME'] = $name;
$tags['COLUMN_URL'] = XOOPS_URL . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/index.php?op=col&columnID=' . $columnID;
$notification_handler = & xoops_gethandler( 'notification' );
$notification_handler -> triggerEvent( 'global', 0, 'new_article', $tags );
$notification_handler -> triggerEvent( 'category', $columnID, 'new_article', $tags );

if ( $xoopsDB -> queryF( "UPDATE " . $xoopsDB -> prefix( "sbcolumns" ) . " SET total = '$total' WHERE columnID = '$columnID'" ) )

redirect_header( "index.php", 1, _AM_SB_ARTCREATEDOK );
}
else
{
redirect_header( "index.php", 1, _AM_SB_ARTNOTCREATED );
}
}
else // That is, $articleID exists, thus we're editing an article
{
if ( $xoopsDB -> query( "UPDATE " . $xoopsDB -> prefix( "sbarticles" ) . " SET columnID = '$columnID', headline = '$headline', lead = '$lead', bodytext = '$bodytext', teaser = '$teaser', weight = '$weight', html = '$html', smiley = '$smiley', xcodes = '$xcodes', breaks = '$breaks', block = '$block', artimage = '$artimage', votes = '$votes', rating = '$rating', commentable = '$commentable', offline = '$offline', datesub = '$date' WHERE articleID = '$articleID'" ) )
{
redirect_header( "index.php", 1, _AM_SB_ARTMODIFIED );
}
else
{
redirect_header( "index.php", 1, _AM_SB_ARTNOTUPDATED );
}
}
exit();
break;

case "del":
Global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB;

$confirm = ( isset( $confirm ) ) ? 1 : 0;

if ( $confirm )
{
$xoopsDB->query( "DELETE FROM " . $xoopsDB->prefix( "sbarticles" ) . " WHERE articleID = $articleID" );
xoops_comment_delete($xoopsModule->getVar('mid'), $articleID);
redirect_header( "index.php", 1, sprintf( _AM_SB_ARTISDELETED, $headline ) );
exit();
}
else
{
$articleID = ( isset( $_POST['articleID'] ) ) ? intval($_POST['articleID']) : intval($articleID);
$result = $xoopsDB -> query( "SELECT articleID, headline FROM " . $xoopsDB -> prefix( "sbarticles" ) . " WHERE articleID = $articleID" );
list( $articleID, $headline ) = $xoopsDB -> fetchrow( $result );
xoops_cp_header();
xoops_confirm( array( 'op' => 'del', 'articleID' => $articleID, 'confirm' => 1, 'headline' => $headline ), 'article.php', _AM_SB_DELETETHISARTICLE . "<br /><br>" . $headline, _AM_SB_DELETE );
xoops_cp_footer();
}
exit();
break;

case "default":
default:
xoops_cp_header();
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig, $xoopsModule;
$myts =& MyTextSanitizer::getInstance();
editarticle();
showArticles (0);
break;

}
xoops_cp_footer();

?>

Login

Who's Online

213 user(s) are online (127 user(s) are browsing Support Forums)


Members: 0


Guests: 213


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits