WikidotPage Class

Description

This class extends the WikidotMeta Class.

Syntax Examples

to do…

The Code

<?php
//////////////////Extended Classes to WikidotMeta
class WikidotPage extends WikidotMeta
{//////////////////constructor destructor
function __construct($spSite, $spClient)
{    echo "Subclass Constructor called....</br>";
    WikidotSite::__construct($spSite, $spClient);
    $this->site = WikidotSite::getSite();
    $this->client = WikidotSite::getClient();
    $this->timeout = WikidotSite::getTimeout();
    $this->debug = WikidotSite::getDebug();
    $this->metapages = WikidotMeta::getMetapages();
    $this->fullname = WikidotMeta::getFullname();
    $this->created_at = WikidotMeta::getCreatedAt();
    $this->created_by = WikidotMeta::getCreatedBy();
    $this->updated_at = WikidotMeta::getUpdatedAt();
    $this->updated_by = WikidotMeta::getUpdatedBy();
    $this->title = WikidotMeta::getTitle();
    $this->parent_fullname = WikidotMeta::getParentFullname();
    $this->tags  = WikidotMeta::getTags();
    $this->rating = WikidotMeta::getRating();
    $this->revisions = WikidotMeta::getRevisions();
    $this->metacomments = WikidotMeta::getMetacomments();
    $this->files = WikidotMeta::getFiles();
    $this->metachildren = WikidotMeta::getMetachildren();
}
function __destruct()
{    echo "Subclass Destructor called....</br>";
    foreach ($this as $key => $value) {
        unset($this->$key);} 
}
//////////////////page properties
private $page;
private $parent_title;
private $children;
private $content = "Empty Page";
private $html;
private $comments;
private $commented_at;
private $commented_by;
private $save_mode = "create_or_update";
private $rename_as;
private $revision_comment;
private $notify_watchers = "false";
//////////////////set functions
function setPage($pname){$this->page = $pname;}
function setParentTitle($pPTitle){$this->parent_title = $pPTitle;}
function setChildren($pChild){$this->children = $pChild;}
function setContent($pContent){$this->content = $pContent;}
function setHTML($pHTML){$this->html = $pHTML;}
function setComments($pCom){$this->comments = $pCom;}
function setCommentedAt($pCmAt){$this->commented_at = $pCmAt;}
function setCommentedBy($pCmBy){$this->commented_by = $pCmBy;}
function setSaveMode($pMode){$this->save_mode = $pMode;}
function setRenameAs($pRen){$this->rename_as = $pRen;}
function setRevisionComment($pRCom){$this->revision_comment = $pRCom;}
function setNotifyWatchers($pNotify){$this->notify_watchers = $pNotify;}
//////////////////get functions
function getPage(){return $this->page;}
function getParentTitle(){return $this->parent_title;}
function getChildren(){return $this->children;}
function getContent(){return $this->content;}
function getHTML(){return $this->html;}
function getComments(){return $this->comments;}
function getCommentedAt(){return $this->commented_at;}
function getCommentedBy(){return $this->commented_by;}
function getSaveMode(){return $this->save_mode;}
function getRenameAs(){return $this->rename_as;}
function getRevisionComment(){return $this->revision_comment;}
function getNotifyWatchers(){return $this->notify_watchers;}
//////////////////api wrapper functions
function php_pages_select($criteria, &$returnar)
{    echo "</br>Start New Pages Select</br>\n";
    $request = new xmlrpcmsg("pages.select");
    $selectors = array();
    $selectors['site'] = new xmlrpcval($this->site, "string");
//////////parse critera
    foreach($criteria as $key=>$data){
        switch($key){
            case "pagetype":  
            $selectors['pagetype'] = new xmlrpcval($data, "string" ); break;
            case "categories":
                $sCat = array();
                foreach($data as $dkey=>$cat){
                    $sCat[$dkey] = new xmlrpcval($cat);}
                $selectors['categories'] = new xmlrpcval($sCat, "array");
                break;
            case "tags_any":    
                $sYtag = array();
                foreach($data as $dkey=>$tag){
                    $sYtag[$dkey] = new xmlrpcval($tag);}
                $selectors['tags_any'] = new xmlrpcval($sYtag, "array");
                break;
            case "tags_all":    
                $sAtag = array();
                foreach($data as $dkey=>$tag){
                    $sAtag[$dkey] = new xmlrpcval($tag);}
                $selectors['tags_all'] = new xmlrpcval($sAtag, "array");
                break;
            case "tags_none":    
                $sNtag = array();
                foreach($data as $dkey=>$tag){
                    $sNtag[$dkey] = new xmlrpcval($tag);}
                $selectors['tags_none'] = new xmlrpcval($sNtag, "array");
                break;
            case "parent": 
                $selectors['parent'] = new xmlrpcval($data, "string" ); break; 
            case "created_at": 
                $selectors['created_at'] = new xmlrpcval($data, "string" ); break;
            case "created_by": 
                $selectors['created_by'] = new xmlrpcval($data, "string" ); break;
            case "rating": 
                $selectors['rating'] = new xmlrpcval($data, "string" ); break;
            case "order":  
                $selectors['order'] = new xmlrpcval($data, "string" ); break;
            case "link_to": 
                $selectors['link_to'] = new xmlrpcval($data, "string" ); break;
            case "offset": 
                $selectors['offset'] = new xmlrpcval($data, "string" ); break;
            case "range": 
                $selectors['range'] = new xmlrpcval($data, "string" ); break;
            case "datafield":  
                $selectors[$data[0]] = new xmlrpcval($data[1], "string" );
                break;}}
    $request->addParam(new xmlrpcval($selectors, "struct"));
    $result = $this->client->send($request, $this->timeout, "https");
    $resultvalue = $result->value();
    if(!$result->faultCode()) { // SUCCESS!
        $returnar = $resultvalue;
        return true; }
    else {echo "<font color=\"red\"> <H1>Fault</H1><BR>\n"." Code: ".$result->faultCode()."\n<BR>".
        " Reason: ".$result->faultString()."'\n<BR></font>";
        return false;}
}
function php_pages_get_one(&$returnar)
{    echo "</br>Start New Pages Get One</br>\n";
    $request = new xmlrpcmsg("pages.get_one");
    $request->addParam(new xmlrpcval(
            array("site" => new xmlrpcval($this->site, "string"),
                "page" => new xmlrpcval($this->page, "string")),"struct"));
    $result = $this->client->send($request, $this->timeout, "https");
    $resultvalue = $result->value();
    if(!$result->faultCode()) { // SUCCESS!
        $returnar = $resultvalue;
        return true; }
    else {echo "<font color=\"red\"> <H1>Fault</H1><BR>\n"." Code: ".$result->faultCode()."\n<BR>".
        " Reason: ".$result->faultString()."'\n<BR></font>";
        return false;}
}
function php_pages_save_one($svmode)
{    echo "</br>Start New Pages Save One</br>\n";
    $request = new xmlrpcmsg("pages.save_one");
    $temparray = array();
    $temparray['site'] = new xmlrpcval($this->site, "string");
    $temparray['page'] = new xmlrpcval($this->page, "string");
    $temparray['title'] = new xmlrpcval($this->title, "string");
    $temparray['content'] = new xmlrpcval($this->content, "string");
    $temparray['tags'] = $this->getTags();
    $temparray['save_mode'] = new xmlrpcval($svmode, "string");
    $temparray['rename_as'] = new xmlrpcval($this->rename_as, "string");
    $temparray['revision_comment'] = new xmlrpcval($this->revision_comment, "string");
    if(WikidotMeta::getParentFullname()){
        $parent = WikidotMeta::getParentFullname();
        $temparray['parent_fullname'] = new xmlrpcval($parent, "string");}
    $request->addParam(new xmlrpcval($temparray, "struct"));
    $result = $this->client->send($request, $this->timeout, "https");
    $resultvalue = $result->value();
    if(!$result->faultCode()) { // SUCCESS!
        return true; }
    else {echo "<font color=\"red\"> <H1>Fault</H1><BR>\n"." Code: ".$result->faultCode()."\n<BR>".
        " Reason: ".$result->faultString()."'\n<BR></font>";
        return false;}
}
}//end class WikidotPage
?>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License