Jump to content

need help on my function codes


pixeltrace

Recommended Posts

guys,

 

i need help, i an currently modifying a php page in joomla and i am getting this error

on the admin.brandname.html.php page

Warning: Missing argument 3 for HTML_BrandName::edit() in /var/www/html/memoryworld/administrator/components/com_brandname/admin.brandname.html.php on line 6

 

sorry i am not yet that good in reading php codes. hope you could help me with this

 

this is the code for my admin.brandname.html.php page

<?
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 

class HTML_BrandName{

function edit( $option, &$lists, &$row) {
?>

<form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm">
<table border="0" cellpadding="3" cellspacing="0">

<tr>
<td>Brand Name: </td>
<td><input type="text" size="50" maxsize="100" name="bname" value="<?php echo $row->bname; ?>" /></td>
</tr>

<tr>
<td>Ordering: </td>
<td><?php echo $lists['ordering']; ?></td>
</tr>

<tr>
<td>Published: </td>
<td><? echo mosHTML::yesnoSelectList( "published", "", $row->published ); ?></td>
</tr>

</table>
<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="" />
</form>
<? }

function listConfiguration($option, &$rows)
{
?>

<form action="index2.php" method="post" name="adminForm">

<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
<?
$row = $rows[0];
?>
<tr><td>Bold</td><td><? echo mosHTML::yesnoSelectList( "bold", "", $row->bold ); ?></td></tr>
<tr><td>Italic</td><td><? echo mosHTML::yesnoSelectList( "italic", "", $row->italic ); ?></td></tr>
<tr><td>Underline</td><td><? echo mosHTML::yesnoSelectList( "underline", "", $row->underline ); ?></td></tr>
<tr><td>Show Date</td><td><? echo mosHTML::yesnoSelectList( "showdate", "", $row->showdate ); ?></td></tr>
</table>

<input type="hidden" name="option" value="<?php echo $option; ?>" />

<input type="hidden" name="task" value="" />

<input type="hidden" name="configid" value=<? echo $row->configid ?> />

<input type="hidden" name="act" value="configure" />

</form> 

<?
}


function listMessages( $option, &$pageNav, &$rows) {
?>
<form action="index2.php" method="post" name="adminForm">
<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
<tr>
<th width="8" align="center" class="title">  </th>
<th width="21" align="center" class="title">#</th>
<th width="20" align="center"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>
<th width="28" align="center" class="title"> </th>
<th width="245" class="title">Brand Name</th>
<th width="217" align="center" class="title"> </th>
<th width="97" align="center">Published</th>
<th colspan="2">Reorder</th>
<th width="40" align="center">ID</th>
<th width="84"> </th>
</tr>

<?php
$k = 0;
for ($i=0, $n=count( $rows ); $i < $n; $i++) {
	$row = &$rows[$i];
	if ($row->ordering !=NULL) {
		$img = 'tick.png' ;
		//$task = _EC_EXCLUDE . _EC_TASK_ARTICLE;

	}
	else
	{	$img = 'publish_x.png';


		//$task =  _EC_INCLUDE . _EC_TASK_ARTICLE;;

	}

?>
<tr class="<?php echo "row$k"; ?>">
<td width="8" align="center">  </td>
<td width="21" align="center"><?=$i+$pageNav->limitstart+1;?></td>
<td width="20" align="center"><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" /></td>
<td width="28" align="center"> </td>
<td width="245"><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')"><?php echo $row->bname; ?></a></td>
<td width="217" align="center"> </td>
<td width="97" align="center"><?php
if ($row->published == "1") {
echo "<a href=\"javascript: void(0);\" onClick=\"return listItemTask('cb$i','unpublish')\"><img src=\"images/publish_g.png\" border=\"0\" /></a>";
} else {
echo "<a href=\"javascript: void(0);\" onClick=\"return listItemTask('cb$i','publish')\"><img src=\"images/publish_x.png\" border=\"0\" /></a>";
}
   ?></td>
<td width="78" align="center"><?php
	if ($i > 0) {
?>
      <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?>','orderup')"><img src="images/uparrow.png" border="0" /></a>
      <?php
	} // if
?></td>
<td width="76" align="center"><?php
	if ($i < count($rows)-1) {
?>
      <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?>','orderdown')"><img src="images/downarrow.png" border="0" /></a>
      <?php
	} // if
?></td>
<td width="40" align="center"><?php echo $row->id; ?></td>
<td width="84" align="center"> </td>
<?php $k = 1 - $k; ?>
</tr>
<?php } 

?>
</table>
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
</form> 


<? } 


}

?>

 

 

and this is the code for my admin.brandname.php page

<?php 
defined('_VALID_MOS') or die('Direct Access to this location is not allowed.');

// ensure user has access to this function
if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' )
	| $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'com_brandname' ))) {
mosRedirect( 'index2.php', _NOT_AUTH );
}

require_once( $mainframe->getPath( 'admin_html' ) );
require_once( $mainframe->getPath( 'class' ) );

$id = mosGetParam( $_REQUEST, 'cid', array(0) );
if (!is_array( $id )) {
$id = array(0);
}


switch($act)
{
case "configure":
switch($task) {
	case "save":
	saveConfiguration($option);
	break;

	default:
	listConfiguration($option);
	break;
}
break;

default:
switch ($task) {
	case "save" :
		save($option);
		break;

	case "edit" :
		edit( $option, $id );
		break;

	case "new" :
		$id = '';
		edit( $option, $id);
		break;

	case "delete" :
		del($option, $id);
		break;

	case "publish" :
		publishMessage($option, '1', $id);
		break;

	case "unpublish" :
		publishMessage($option, '0', $id);
		break;

case 'orderup':
	orderMessage( $option,$cid, -1 );
	break;

case 'orderdown':
	orderMessage( $option,$cid, 1 );
	break;

	case "listMessages" :
		default:
		listMessages($option);
		break;

}
break;
}


function saveConfiguration($option) {
global $database;
$row = new BrandNameConf($database);


// bind it to the table
if (!$row -> bind($_POST)) {
	echo "<script> alert('"
		.$row -> getError()
		."'); window.history.go(-1); </script>\n";
	exit();
}


// store it in the db
if (!$row -> store()) {
	echo "<script> alert('"
		.$row -> getError()
		."'); window.history.go(-1); </script>\n";
	exit();	
}

mosRedirect("index2.php?option=$option&act=configure", "Configuration Saved");
}


function listConfiguration($option)
{
global $database;

$database->setQuery("SELECT * FROM #__brandname_conf"  );
$rows = $database -> loadObjectList();
if ($database -> getErrorNum()) {
	echo $database -> stderr();
	return false;
}
HTML_BrandName::listConfiguration($option, $rows);
}



function publishMessage( $option, $publish=1 ,$cid )
{
global $database, $my;

if (!is_array( $cid ) || count( $cid ) < 1) {
	$action = $publish ? 'publish' : 'unpublish';
	echo "<script> alert('Select an item to $action'); window.history.go(-1);</script>\n";
	exit;
}

$cids = implode( ',', $cid );

$database->setQuery( "UPDATE #__brandname SET published='$publish'"
. "\nWHERE id IN ($cids)"
// AND (checked_out=0 OR (checked_out='$my->id')
);
if (!$database->query()) {
	echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
	exit();
}

mosRedirect( "index2.php?option=$option" );

}


function save($option) {
global $database;
$row = new BrandName($database);

// bind it to the table
if (!$row -> bind($_POST)) {
	echo "<script> alert('"
		.$row -> getError()
		."'); window.history.go(-1); </script>\n";
	exit();
}

// store it in the db
if (!$row -> store()) {
	echo "<script> alert('"
		.$row -> getError()
		."'); window.history.go(-1); </script>\n";
	exit();	
}
mosRedirect("index2.php?option=$option", "Saved");
}

function del($option, $cid) {
global $database;
if (!is_array($cid) || count($cid) < 1) {
	echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n";
	exit();
}

if (count($cid))
{
	$ids = implode(',', $cid);
	$database->setQuery("DELETE FROM #__brandname \nWHERE id IN ($ids)");
}
if (!$database->query()) {
	echo "<script> alert('"
		.$database -> getErrorMsg()
		."'); window.history.go(-1); </script>\n";
}
mosRedirect("index2.php?option=$option");

}

function edit($option, $id) {
global $database, $my, $mosConfig_absolute_path;

$row = new BrandName( $database );
// load the row from the db table
$row->load( (int)$id );

if($id){
	$row -> load($id[0]);
} else {
	// initialise new record
	$row->published = 1;
	$row->order 	= 0;
}

// build the html select list for ordering
$query = "SELECT ordering AS value"
. "\n FROM #__brandname"
. "\n WHERE id = " . (int) $row->id
. "\n ORDER BY ordering"
;
$lists['ordering'] 			= mosAdminMenus::SpecificOrdering( $row, $id, $query, 1 );

	HTML_BrandName::edit($option, $row);
}

function listMessages($option) {
global $database, $mainframe;

$limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', 10 );
$limitstart = $mainframe->getUserStateFromRequest( "viewban{$option}limitstart", 'limitstart', 0 );

// get the total number of records
$database->setQuery( "SELECT count(*) FROM #__brandname");
$total = $database->loadResult();
echo $database->getErrorMsg();

require_once("includes/pageNavigation.php");
$pageNav = new mosPageNav( $total, $limitstart, $limit );

$database->setQuery( "SELECT id, ordering, bname "
. "\nFROM #__brandname"
. "\nORDER BY ordering ASC"
. "\nLIMIT $limitstart, $limit"
);

$rows = $database->loadObjectList();

if(!$result = $database->query()) {
	echo $database->stderr();
	return false;
}
	HTML_BrandName::listMessages($option, $pageNav, $rows);
}
/**
* Moves the order of a record
* @param integer The increment to reorder by
*/
function orderMessage($option, $uid, $inc  ) {
global $database;

mylog($uid[0]);
$row = new BrandName( $database );
$row->load( $uid[0] );

mylog($row->ordering);
$row->move( $inc, "" );


mosRedirect( "index2.php?option=$option");
}


?>

 

 

hope you could help me with this.

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/48895-need-help-on-my-function-codes/
Share on other sites

edit()'s function requires a $row... a 3rd value... you either need to add $row="", or, put some value in there...

default:
switch ($task) {
	case "save" :
		save($option);
		break;

	case "edit" :
		edit( $option, $id );
		break;

	case "new" :
		$id = '';
		edit( $option, $id);
		break;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.