FilesWikidotMeta Class

Description

This class extends the WikidotSite Class.

Syntax Examples

to do…

The Code

<?php
//////////////////files classes
//////////////////parent FilesWikidotMeta Class
class FilesWikidotMeta extends WikidotSite
{//////////////////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();
}
function __destruct()
{    echo "Subclass Destructor called....</br>";
    foreach ($this as $key => $value) {
        unset($this->$key);} 
}
//////////////////meta properties
private $page;
private $files;
private $size;
private $comment;
private $mime_type;
private $mime_description;
private $uploaded_by;
private $uploaded_at;
private $download_url;
//////////////////set functions
function setPage($pname){$this->page = $pname;}
//////////////////get functions
function getPage(){return $this->page;}
//////////////////api wrapper functions
function php_files_select($category, &$returnar)
{    echo "</br>Start New Files Select</br>\n";
    $request = new xmlrpcmsg("files.select");
    $request->addParam(new xmlrpcval(
            array("site" => new xmlrpcval($this->site, "string"),
                "page" => new xmlrpcval($category, "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_files_get_meta($files, &$returnar)
{    echo "</br>Start New Files Get Meta</br>\n";
    $request = new xmlrpcmsg("files.get_meta");
    $temparray = array();
    $temparray['site'] = new xmlrpcval($this->site, "string");
    $temparray['page'] = new xmlrpcval($this->page, "string");
    $filearray = array();
    foreach($files as $key=>$data){
        $filearray[$key] = new xmlrpcval($data, "string");}
     $temparray['files'] = new xmlrpcval($filearray, "array");
     $request->addParam(new xmlrpcval($temparray, "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_files_get_one($file, &$returnar)
{    echo "</br>Start New Files Get One</br>\n";
    $request = new xmlrpcmsg("files.get_one");
    $temparray = array();
    $temparray['site'] = new xmlrpcval($this->site, "string");
    $temparray['page'] = new xmlrpcval($this->page, "string");
     $temparray['file'] = new xmlrpcval($file, "string");
     $request->addParam(new xmlrpcval($temparray, "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_files_save_one($criteria, &$returnar)
{    echo "</br>Start New Files Save One</br>\n";
    $request = new xmlrpcmsg("files.save_one");
    $selectors = array();
    $selectors['site'] = new xmlrpcval($this->site, "string");
//////////parse critera
    foreach($criteria as $key=>$data){
        switch($key){
            case "file": $selectors['file'] = new xmlrpcval($data, "string" );
            echo $key.": ".$data."</br>";
                break;
            case "page": $selectors['page'] = new xmlrpcval($data, "string" );
            echo $key.": ".$data."</br>";
                break;    
            case "comment": $selectors['comment'] = new xmlrpcval($data, "string" );
            echo $key.": ".$data."</br>";
                break;
            case "save_mode": $selectors['save_mode'] = new xmlrpcval($data, "string" );
            echo $key.": ".$data."</br>";
                break;
            case "content": $selectors['content'] = new xmlrpcval($data, "string" );
            //echo $key.": ".$data."</br>";
                break;
            case "notify_watchers": 
                $selectors['notify_watchers'] = new xmlrpcval($data, "string" );
            echo $key.": ".$data."</br>";
                break;
            case "revision_comment":
                $selectors['revision_comment'] = new xmlrpcval($data, "string" );
            echo $key.": ".$data."</br>";
                break;}}  
    $request->addParam(new xmlrpcval($selectors, "struct"));
    if($selectors['content']) $result = $this->client->send($request, $this->timeout, "https");
    else {echo "no content"; return false;}
    $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 FilesWkidotMeta
?>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License