Exemplo n.º 1
0
 function Generate($template)
 {
     // Substitute the text inside the <part>/</part> tags
     $template = RtfStripTags($template);
     $parts = FieldExplode($template, "<part>", "</part>");
     $partslist = "";
     for ($i = 1; $i < count($parts); $i += 2) {
         $part = $parts[$i];
         $source = strtolower(RtfStrip($this->RtfField($part, "source")));
         if ($source == '') {
             $field = strtolower(RtfStrip($part));
             $parts[$i] = $this->PrepareHtml("<part>{$field}</part>");
             $this->debugtext .= "field={$field}<br/>\n";
         } else {
             if (array_key_exists($source, $this->fielddata)) {
                 $partslist = "{$part}<default></default>{$partslist}";
                 $parts[$i] = $this->RtfSubst($partslist, $source);
                 if (!RtfIsValid('{' . $parts[$i] . '}')) {
                     die("RTF invalid source={$source} rtf={$parts[$i]}");
                 }
             } else {
                 $parts[$i] = "{\\b !!{$source}!!}";
                 $this->debugtext .= "Invalid field {$source}<br/>\n";
             }
         }
     }
     $parts = FieldExplode(FieldImplode($parts), "INCLUDEPICTURE ", "\\\\d");
     for ($i = 1; $i < count($parts); $i += 2) {
         $parts[$i] = "INCLUDEPICTURE " . $parts[$i];
     }
     SetField($this->con, 'debug', addslashes($this->debugtext), 'Debug');
     return FieldImplode($parts);
 }
Exemplo n.º 2
0
$text = ValueFromSql($con, "SELECT concat(`introtext`,`fulltext`) 'text'\n\t\t\t\t\t\t\t\tFROM jos_content \n\t\t\t\t\t\t\t\tWHERE id={$id}");
$rtfpagewidth = ValueFromSql($con, "SELECT value \n\t\t\t\t\t\t\t\tFROM ctcweb9_newsletter.fields\n\t\t\t\t\t\t\t\tWHERE name='rtfpagewidth'");
$rtfincolour = ValueFromSql($con, "SELECT value \n\t\t\t\t\t\t\t\tFROM ctcweb9_newsletter.fields\n\t\t\t\t\t\t\t\tWHERE name='rtfincolour'") == '1';
$size = floatval($size) * floatval($rtfpagewidth);
if ($size < 10) {
    $error = "size is too small ({$size})";
    $size = 200;
} else {
    if ($caption > 0 && $size < $caption) {
        $error = "size is smaller than caption ({$size}/{$caption})";
        $size = 200;
    } else {
        if ($text == "") {
            $captiontext = "Invalid content id ({$id})";
        } else {
            $images = FieldExplode($text, "{mostripimage ", "}");
            $image = $images[$index * 2 - 1];
            if ($image == "") {
                $error = "Photo number {$index} does not exist for this story({$id}), " . "the last one is number " . (count($images) - 1) / 2 . ".";
            }
        }
    }
}
if ($error == "") {
    $image .= strpos($image, ",") === false ? "," : "";
    $pos = strpos($image, ",");
    $source = trim(substr($image, 0, $pos));
    $captiontext = trim(str_replace('"', '', substr($image, $pos + 1)));
    $orig = @imagecreatefromjpeg("../images/stories/{$source}");
    if (!$orig) {
        $error = "Cannot find {$source} for story({$id}) index({$index})";