PDA

View Full Version : Does Anyone Know How to Create Working Pages In Class and Public HTML Folders?


Hwona
07-16-2014, 09:14 PM
Hello, does anyone know how to add new pages and get them to work like the ones already in the script? I can't seem to create a class file that works with on in public html... it pops up as a blank page.

IntoRain
07-16-2014, 09:53 PM
1.3.3? This is the pattern for a page:


<?php

//substitute (PageName) with your page, for example if it's yoursite.com/quests you will name it QuestsController
class (PageName)Controller extends AppController{

public function __construct(){//check other files to check their constructor function, for permissions if you need
parent::__construct("member");
}
//this will be your /quests page's content
public function index(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$document->setTitle("title");//gotta have a title!

}

/*any other public function you add that has a title like in index(), will work as a page.
If you add a public function like:

public function reward(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$document->setTitle("title");//gotta have a title!
}

the page will be yoursite.com/quests/reward
*/

}
?>

This stays in the public_html folder pretty much. Create a file in class folder when you want to create a new object or something

Hwona
07-16-2014, 10:37 PM
Thanks, but I get a blank page when I try to edit the content of the myadopts file to this:
<?php

class AdoptGroupController extends AppController{

const PARAM = "aid";
const PARAM2 = "confirm";
private $view;
private $subController;
private $group;
private $image;

public function __construct(){
parent::__construct("member");
$mysidia = Registry::get("mysidia");
if($this->action != "index"){
$this->group = new AdoptableGroup($mysidia->input->get("gid"));
if($this->group->getGroupOwner() != $mysidia->user->username) throw new NoPermissionException("You do not have permission to manage the groups of other users.");
}
}


public function index(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$document->setTitle($mysidia->lang->title);

$adoptgroups = $mysidia->db->select("adoptgroups", array("gid"), "owner = '{$mysidia->user->username}'")->rowCount();
$pagination = new Pagination($adoptgroups, 20, "groups");
$pagination->setPage($mysidia->input->get("page"));
$stmt = $mysidia->db->select("adoptgroups", array("gid"), "owner = '{$mysidia->user->username}' ORDER BY gid LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
if($stmt->rowCount() == 0){
$document->addLangvar($mysidia->lang->empty);
return;
}

$groupTable = new TableBuilder("grouptable", 650);
$groupTable->setAlign(new Align("center", "middle"));
$groupTable->buildHeaders("Name", "Rename", "Delete");

while($gid = $stmt->fetchColumn()){
$group = new AdoptGroup($gid);
$name = new TCell($group->getGroupName));
$rename = new TCell(new Link("adoptgroup/rename/{$gid}", "Rename"));
$delete = new TCell(new Link("adoptgroup/delete/{$gid}", "Delete"));
$adoptTable->buildRow(array($name, $rename, $delete));
}
$document->add($groupTable);
$document->addLangvar($pagination->showPage());
}
?>
Here's the class file for it(database has been updated):
<?php

class AdoptGroup extends Model{

protected $gid;
protected $gname;
protected $gowner;


public function __construct($gid, $gowner = ""){
$mysidia = Registry::get("mysidia");
$whereClause = "gid ='{$gid}'";
if(!empty($gowner)) $whereClause .= " and gowner = '{$gowner}'";
$row = $mysidia->db->select("adoptgroups", array(), $whereClause)->fetchObject();
if(!is_object($row)) throw new AdoptGroupNotfoundException("This group does not exist or does not belong to the owner specified...");

parent::__construct($row->type);
foreach($row as $key => $val){
$this->$key = $val;
}
}

public function getGroupID(){
return $this->gid;
}

public function getGroupName(){

return $this->gname;}

public function getGroupOwner(){

return $this->gowner;
}

protected function save($field, $value){
$mysidia = Registry::get("mysidia");
$mysidia->db->update("adoptgroups", array($field => $value), "gid='{$this->gid}'");
}
}

?>
I'm trying to create a pet grouping system, but I don't know what I'm doing wrong...

IntoRain
07-16-2014, 11:15 PM
Blank page usually means syntax error. I can't test your code (my host is down :c ) so you will have to delete everything and slowly add lines until you find the one causing the blank page ^^'

edit:

$name = new TCell($group->getGroupName));

For example I see a missing ( here already

Infernette
07-17-2014, 01:21 PM
http://phpcodechecker.com/ this is usually good at catching syntax errors. :)

Hwona
07-17-2014, 01:49 PM
Thanks! :D
Edit: I changed the code up a bit, but now I'm getting this:
Fatal error: Call to a member function rowCount() on a non-object in /home/wallie12/public_html/classes/abstract/abstract_guicontainer.php on line 392