Example #1
0
 function image($attr = null)
 {
     global $c;
     if (is_numeric($attr["ID"])) {
         $pgnRef = createPGNRef2($attr["ID"], $this->variation);
         if (!is_object($pgnRef)) {
             return " ";
         }
         if (!$pgnRef->exists()) {
             $pgnRef = createPGNRef2($attr["ID"], $c["stdvariation"]);
         }
         $image = $pgnRef->draw("ALL");
         $manualattribs = array("WIDTH", "HEIGHT", "PATH", "ID", "VARIATION");
         $output = "<img src=\"" . $image["path"] . "\"";
         array_key_exists("WIDTH", $attr) ? $output .= " width=\"" . $attr["WIDTH"] . "\"" : ($output .= " width=\"" . $image["width"] . "\"");
         array_key_exists("HEIGHT", $attr) ? $output .= " height=\"" . $attr["HEIGHT"] . "\"" : ($output .= " height=\"" . $image["height"] . "\"");
         foreach ($attr as $key => $value) {
             if (!in_array(strtoupper($key), $manualattribs)) {
                 $output .= " {$key}=\"{$value}\"";
             }
         }
         $output .= ">";
         return $output;
     }
 }
 /**
  *  Parses the placeholders [xxx] and replaces them with code.
  *
  * @param string $text text to parse;
  */
 function parse($text)
 {
     global $cds, $db;
     if (is_object($cds)) {
         $live = $cds->level == 10;
     } else {
         $live = false;
     }
     if (preg_match_all('/\\[(.+?)\\]/is', $text, $matches)) {
         $tags = $matches[1];
         foreach ($tags as $tag) {
             $id = "";
             if ($live) {
                 $sql = 'SELECT c.CID FROM content c, state_translation t Where c.CID=t.OUT_ID AND t.LEVEL=10 AND t.EXPIRED=0 AND UPPER(c.ACCESSKEY)="' . strtoupper($tag) . '"';
             } else {
                 $sql = 'SELECT c.CID FROM content c, state_translation t Where c.CID<>t.OUT_ID AND UPPER(c.ACCESSKEY)="' . strtoupper($tag) . '"';
             }
             $query = new query($db, $sql);
             if ($query->getrow()) {
                 $id = $query->field('CID');
             }
             if ($id != "") {
                 $pgnRef = createPGNRef2($id);
                 if (!is_object($pgnRef)) {
                     return " ";
                 }
                 if (!$pgnRef->exists()) {
                     $pgnRef = createPGNRef2($id, $c["stdvariation"]);
                 }
                 $res = $pgnRef->draw();
                 $text = str_ireplace('[' . $tag . ']', $res, $text);
             }
         }
     }
     return $text;
 }
Example #3
0
	/**
	 * Return the drawn content of a library object
	 * @param integer Content-ID of the object
	 * @param integer Variation-ID to select
	 * @param mixed additional parameters (ALL or s.th. else)
	 */
	function getLibraryContent($cid, $variation, $param=null) {
		$ref = createPGNRef2($cid, $variation);
		if (is_object($ref)) return $ref->draw($param);			
	}