Пример #1
0
 /**
  * Constructs HTML representation of a single key-value pair.
  * @return string: HTML.
  */
 static function objectRow($key, $val)
 {
     $th = Xml::elementClean('th', array(), $key);
     if (is_array($val)) {
         $td = Xml::tags('td', array(), self::objectTable($val));
     } else {
         if (is_string($val)) {
             $val = '"' . $val . '"';
         } else {
             $val = FormatJson::encode($val);
         }
         $td = Xml::elementClean('td', array('class' => 'value'), $val);
     }
     return Xml::tags('tr', array(), $th . $td);
 }
Пример #2
0
 /**
  * @param File $file
  * @param bool $dumpContents
  * @return string
  */
 function writeUpload($file, $dumpContents = false)
 {
     if ($file->isOld()) {
         $archiveName = "      " . Xml::element('archivename', null, $file->getArchiveName()) . "\n";
     } else {
         $archiveName = '';
     }
     if ($dumpContents) {
         $be = $file->getRepo()->getBackend();
         # Dump file as base64
         # Uses only XML-safe characters, so does not need escaping
         # @todo Too bad this loads the contents into memory (script might swap)
         $contents = '      <contents encoding="base64">' . chunk_split(base64_encode($be->getFileContents(array('src' => $file->getPath())))) . "      </contents>\n";
     } else {
         $contents = '';
     }
     if ($file->isDeleted(File::DELETED_COMMENT)) {
         $comment = Xml::element('comment', array('deleted' => 'deleted'));
     } else {
         $comment = Xml::elementClean('comment', null, $file->getDescription());
     }
     return "    <upload>\n" . $this->writeTimestamp($file->getTimestamp()) . $this->writeContributor($file->getUser('id'), $file->getUser('text')) . "      " . $comment . "\n" . "      " . Xml::element('filename', null, $file->getName()) . "\n" . $archiveName . "      " . Xml::element('src', null, $file->getCanonicalURL()) . "\n" . "      " . Xml::element('size', null, $file->getSize()) . "\n" . "      " . Xml::element('sha1base36', null, $file->getSha1()) . "\n" . "      " . Xml::element('rel', null, $file->getRel()) . "\n" . $contents . "    </upload>\n";
 }
Пример #3
0
 function writeUpload($file)
 {
     return "    <upload>\n" . $this->writeTimestamp($file->getTimestamp()) . $this->writeContributor($file->getUser('id'), $file->getUser('text')) . "      " . Xml::elementClean('comment', null, $file->getDescription()) . "\n" . "      " . Xml::element('filename', null, $file->getName()) . "\n" . "      " . Xml::element('src', null, $file->getFullUrl()) . "\n" . "      " . Xml::element('size', null, $file->getSize()) . "\n" . "    </upload>\n";
 }
function wfElementClean($element, $attribs = array(), $contents = '')
{
    return Xml::elementClean($element, $attribs, $contents);
}
Пример #5
0
function wfElementClean($element, $attribs = array(), $contents = '')
{
    wfDeprecated(__FUNCTION__);
    return Xml::elementClean($element, $attribs, $contents);
}
Пример #6
0
 /**
  * @param $file File
  * @param $dumpContents bool
  * @return string
  */
 function writeUpload($file, $dumpContents = false)
 {
     if ($file->isOld()) {
         $archiveName = "      " . Xml::element('archivename', null, $file->getArchiveName()) . "\n";
     } else {
         $archiveName = '';
     }
     if ($dumpContents) {
         # Dump file as base64
         # Uses only XML-safe characters, so does not need escaping
         $contents = '      <contents encoding="base64">' . chunk_split(base64_encode(file_get_contents($file->getPath()))) . "      </contents>\n";
     } else {
         $contents = '';
     }
     return "    <upload>\n" . $this->writeTimestamp($file->getTimestamp()) . $this->writeContributor($file->getUser('id'), $file->getUser('text')) . "      " . Xml::elementClean('comment', null, $file->getDescription()) . "\n" . "      " . Xml::element('filename', null, $file->getName()) . "\n" . $archiveName . "      " . Xml::element('src', null, $file->getCanonicalUrl()) . "\n" . "      " . Xml::element('size', null, $file->getSize()) . "\n" . "      " . Xml::element('sha1base36', null, $file->getSha1()) . "\n" . "      " . Xml::element('rel', null, $file->getRel()) . "\n" . $contents . "    </upload>\n";
 }
Пример #7
0
 function writeRedirects($row)
 {
     $out = '';
     if (isset($this->_redirects[$row->up_page])) {
         foreach ($this->_redirects[$row->up_page] as $row) {
             $title = Title::makeTitle($row->page_namespace, $row->page_title);
             $out .= "    <redirect>\n";
             $out .= '    ' . Xml::elementClean('title', array(), $title->getPrefixedText()) . "\n";
             if (isset($row->num_page_ref)) {
                 $out .= '    ' . Xml::element('references', array(), strval($row->num_page_ref)) . "\n";
             }
             $out .= "    </redirect>\n";
         }
     }
     return $out;
 }