یکی مشکل این کامپوننت رو بهم بگه
دوستان اسن کامپوننت رو اگه می شه یک نگاه بندازین ببینین مشکلش کجاست.
کامپوننت hello_world هستش. تو قسمت ادمین مشکل داره. اگه با IE وارد بخش مدیریتش بشی پیغام خطا می ده و صفحه رو لود نمی کنه. با ff هم تست کردم میاره ولی منوهای بالا رو نمیاره و نمی تونم چیزی اضافه کنم.
فایل admin.hello_world.html.php
کد:
<?php
//hello_world Component//
/**
* Content code
* @package hello_world
* @Copyright (C) 2004 Doyle Lewis
* @ All rights reserved
* @ hello_world is Free Software
* @ Released under GNU/GPL License : [مهمان/کاربر گرامی برای دیدن لینک ها ابتدا باید عضو سایت شوید و لاگین کنید برای ثبت نام اینجا کلیک کنید]
* @version 1.0
**/
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
require_once( $mainframe->getPath( 'toolbar_html' ) );
if($task) {
switch($task) {
case 'new':
case 'edit':
$act = "edit";
break;
}
}
if ($act) {
switch ( $act ) {
case 'edit':
menuHello_world::EDIT_MENU();
break;
case 'text':
menuHello_world::TEXT_MENU();
break;
}
}
?>
فایل admin.hello_world.php
کد:
<?php
//hello_world Component//
/**
* Content code
* @package hello_world
* @Copyright (C) 2004 Doyle Lewis
* @ All rights reserved
* @ hello_world is Free Software
* @ Released under GNU/GPL License : [مهمان/کاربر گرامی برای دیدن لینک ها ابتدا باید عضو سایت شوید و لاگین کنید برای ثبت نام اینجا کلیک کنید]
* @version 1.0
**/
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
require_once($mosConfig_absolute_path."/administrator/components/com_hello_world/class.hello_world.php");
require_once( $mainframe->getPath( 'admin_html' ) );
switch ($act) {
default:
$task = "showText";
break;
}
switch ($task) {
case "save":
save( $option );
break;
case "delete":
delete( $option, $id );
break;
case "new":
$id = '';
edit( $option, $id );
break;
case "edit":
save( $option, $id[0] );
break;
case "showText":
showText( $option );
break;
}
function save( $option ) {
global $database;
$row = new mosHello_world( $database );
if (!$row->bind( $_POST )) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>n";
exit();
}
if (!$row->store()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>n";
exit();
}
mosRedirect( "index2.php?option=$option", "Saved" );
}
function edit( $option, $uid ) {
global $database;
$row = new mosHello_world( $database );
$row->load( $uid );
HTML_hello_world::edit( $option, $row );
}
function delete( $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 )) {
$cids = implode( ',', $cid );
$database->setQuery( "DELETE FROM mos_hello_world WHERE id IN ($cids)" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>n";
}
}
mosRedirect( "index2.php?option=$option" );
}
function showText($option) {
global $database;
# Do the main database query
$database->setQuery( "SELECT * FROM mos_hello_world ORDER BY id" );
$rows = $database->loadObjectList();
if ($database->getErrorNum()) {
echo $database->stderr();
return false;
}
HTML_hello_world::showText( $option, $rows );
}
?>
فایل class.hello_world.php
کد:
<?php
defined('_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
class mosHello_world extends mosDBTable {
// INT(11) AUTO_INCREMENT
var $id=null;
// TEXT
var $text=null;
// TINYINT(1)
var $published=null;
function mosHello_world( &$db ) {
$this->mosDBTable( 'mos_hello_world', 'id', $db );
}
}
?>
فایل hello_world.php
کد:
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.');
global $database;
$query = "SELECT * FROM mos_hello_world";
$database->setQuery( $query );
$rows = $database->loadObjectList();
echo("<table width='100%' border='0'>");
for($i=0; $i < count( $rows ); $i++) {
$row = $rows[$i];
echo('<tr><td>');
echo $row->text;
echo('</tr></td>');
}
echo('</table>');
?>
فایل hello_world.xml
کد:
<?xml version="1.0" ?>
<mosinstall type="component">
<name>hello_world</name>
<creationDate>04/15/2004</creationDate>
<author>Doyle Lewis</author>
<copyright>This component in released under the GNU/GPL License</copyright>
<authorEmail> [مهمان/کاربر گرامی برای دیدن لینک ها ابتدا باید عضو سایت شوید و لاگین کنید برای ثبت نام اینجا کلیک کنید] </authorEmail>
<authorUrl>[مهمان/کاربر گرامی برای دیدن لینک ها ابتدا باید عضو سایت شوید و لاگین کنید برای ثبت نام اینجا کلیک کنید]
<version>1.0</version>
<files>
<filename>hello_world.php</filename>
</files>
<install>
<queries>
<query>DROP TABLE IF EXISTS `mos_hello_world`;</query>
<query>CREATE TABLE `mos_hello_world` (
`id` INT NOT NULL AUTO_INCREMENT,
`text` TEXT NOT NULL,
`published` TINYINT(1) NOT NULL,
PRIMARY KEY (`id`)
)
</query>
</queries>
</install>
<uninstall>
<queries>
<query>DROP TABLE IF EXISTS `mos_hello_world`;</query>
</queries>
</uninstall>
<installfile>
<filename>install.hello_world.php</filename>
</installfile>
<uninstallfile>
<filename>uninstall.hello_world.php</filename>
</uninstallfile>
<administration>
<menu>Hello World</menu>
<submenu>
<menu act="all">Show Text</menu>
</submenu>
<files>
<filename>admin.hello_world.php</filename>
<filename>admin.hello_world.html.php</filename>
<filename>class.hello_world.php</filename>
<filename>toolbar.hello_world.php</filename>
<filename>toolbar.hello_world.html.php</filename>
</files>
</administration>
</mosinstall>
فایل install.hello_world.php
کد:
<?php
function com_install() {
echo "Thank you for using this component. Please contact me at [مهمان/کاربر گرامی برای دیدن لینک ها ابتدا باید عضو سایت شوید و لاگین کنید برای ثبت نام اینجا کلیک کنید] with any questions";
}
?>
فایل toolbar.hello_world.html.php
کد:
<?php
//hello_world Component//
/**
* Content code
* @package hello_world
* @Copyright (C) 2004 Doyle Lewis
* @ All rights reserved
* @ hello_world is Free Software
* @ Released under GNU/GPL License : [مهمان/کاربر گرامی برای دیدن لینک ها ابتدا باید عضو سایت شوید و لاگین کنید برای ثبت نام اینجا کلیک کنید]
* @version 1.0
**/
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
class menuHello_world {
function TEXT_MENU() {
mosMenuBar::startTable();
mosMenuBar::publish('publish');
mosMenuBar::unpublish('unpublish');
mosMenuBar::divider();
mosMenuBar::addNew('new');
mosMenuBar::editList('edit', 'Edit');
mosMenuBar::deleteList( ' ', 'delete', 'Remove' );
mosMenuBar::endTable();
}
function EDIT_MENU() {
mosMenuBar::startTable();
mosMenuBar::back();
mosMenuBar::save('save');
mosMenuBar::spacer();
mosMenuBar::endTable();
}
}
?>
فایل toolbar.hello_world.php
کد:
<?php
//hello_world Component//
/**
* Content code
* @package hello_world
* @Copyright (C) 2004 Doyle Lewis
* @ All rights reserved
* @ hello_world is Free Software
* @ Released under GNU/GPL License : [مهمان/کاربر گرامی برای دیدن لینک ها ابتدا باید عضو سایت شوید و لاگین کنید برای ثبت نام اینجا کلیک کنید]
* @version 1.0
**/
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
require_once( $mainframe->getPath( 'toolbar_html' ) );
if($task) {
switch($task) {
case 'new':
case 'edit':
$act = "edit";
break;
}
}
if ($act) {
switch ( $act ) {
case 'edit':
menuHello_world::EDIT_MENU();
break;
case 'text':
menuHello_world::TEXT_MENU();
break;
}
}
?>
پاسخ : یکی مشکل این کامپوننت رو بهم بگه
شما خود کامپوننت رو بزارید تا بررسی بشه
پاسخ : یکی مشکل این کامپوننت رو بهم بگه
بسیار خوب
[مهمان/کاربر گرامی برای دیدن لینک ها ابتدا باید عضو سایت شوید و لاگین کنید برای ثبت نام اینجا کلیک کنید]
پاسخ : یکی مشکل این کامپوننت رو بهم بگه
سلام
تو فايل :toolbar.hello_world.php
اين كد رو جايگزين كنيد:
کد:
if ($act) {
switch ( $act ) {
case 'edit':
menuHello_world::EDIT_MENU();
break;
case 'text':
menuHello_world::TEXT_MENU();
break;
default:
menuHello_world::TEXT_MENU();
break;
}
}
موفق باشيد
يا علي