/**
 * Create a new Page Template
 * @param string Name
 * @param string Description
 * @param string Filename of the template
 * @param string Template
 * @param integer GUID of Cluster Template
 * @param integer Id of Type (1=singlepage, 2=multipage)
 * @param integer OPtional key to use.
 */
function createSitepageMaster($name, $description, $templatePath, $template, $clt, $type, $id = null)
{
    global $db, $c, $errors;
    if ($id == null) {
        $id = nextGUID();
    }
    $name = makeCopyName("sitepage_master", "NAME", parseSQL($name), "VERSION=0 AND DELETED=0");
    $description = parseSQL($description);
    $filename = substr($templatePath, 0, strcspn($templatePath, "."));
    $filesuffix = $templatePath = substr($templatePath, strcspn($templatePath, ".") + 1);
    $templatePath = makeUniqueFilename($c["devpath"], parseSQL($filename), $filesuffix);
    $fp = @fopen($c["devpath"] . $templatePath, "w+");
    if ($fp != "") {
        @fwrite($fp, $template);
        @fclose($fp);
    } else {
        $errors .= "--Could not write spm: " . $templatePath;
    }
    $sql = "INSERT INTO sitepage_master (SPM_ID, NAME, DESCRIPTION, TEMPLATE_PATH, CLT_ID, SPMTYPE_ID) VALUES ";
    $sql .= "({$id}, '{$name}', '{$description}', '{$templatePath}', {$clt}, {$type})";
    $query = new query($db, $sql);
    $query->free();
    $variations = createDBCArray("variations", "VARIATION_ID", "1");
    for ($i = 0; $i < count($variations); $i++) {
        $sql = "INSERT INTO sitepage_variations (SPM_ID, VARIATION_ID) VALUES ( {$id}, " . $variations[$i] . ")";
        $query = new query($db, $sql);
        $query->free();
    }
    return $id;
}
Example #2
0
 /**
  * Not yet ready for use !!!
  * Smooth out the image and create a fuzz by using gaussian algorithm and advanced filtering to preserve original colors when blurring
  * @param integer radius
  * @param double sigma
  */
 function __feather($radius, $sigma)
 {
     global $c;
     $fileparts = explode(".", basename(strval($this->tempfile)));
     $suffix = $fileparts[count($fileparts) - 1];
     $fade_init = $c["path"] . "cache/nximage/" . makeUniqueFilename($c["path"] . "cache/nximage/", basename(strval($this->tempfile), "." . $suffix), "png");
     $fp[1] = fopen($fade_init, "w");
     $fade_mask = $c["path"] . "cache/nximage/" . makeUniqueFilename($c["path"] . "cache/nximage/", basename(strval($fade_init), ".png"), "png");
     $fp[2] = fopen($fade_mask, "w");
     $fade_work_1a = $c["path"] . "cache/nximage/" . makeUniqueFilename($c["path"] . "cache/nximage/", basename(strval($fade_init), ".png"), "png");
     $fp[3] = fopen($fade_work_1a, "w");
     $fade_work_1b = $c["path"] . "cache/nximage/" . makeUniqueFilename($c["path"] . "cache/nximage/", basename(strval($fade_init), ".png"), "png");
     $fp[4] = fopen($fade_work_1b, "w");
     $fade_work_2 = $c["path"] . "cache/nximage/" . makeUniqueFilename($c["path"] . "cache/nximage/", basename(strval($fade_init), ".png"), "png");
     $fp[5] = fopen($fade_work_2, "w");
     $fadeout = $c["path"] . "cache/nximage/" . makeUniqueFilename($c["path"] . "cache/nximage/", basename(strval($fade_init), ".png"), "png");
     $fp[6] = fopen($fadeout, "w");
     foreach ($fp as $pointer) {
         fclose($pointer);
     }
     $this->_execute("convert   {$this->tempfile} {$fade_init}");
     # extract the mask of the this image
     $this->_execute("convert   {$fade_init} -channel matte -negate -separate {$fade_mask}");
     # spread image (border will become 50% transparent)
     $this->_execute("convert   {$fade_mask}  -gaussian " . $radius . "x" . $sigma . " +matte {$fade_work_1a}");
     # Use multiply to limit the spread to original boarders of image
     $this->_execute("composite   -compose Multiply {$fade_mask} {$fade_work_1a} {$fade_work_1b}");
     # Now repeat.  Spreading then masking the image mask, a number of times.
     $this->_execute("convert {$fade_work_1b} -gaussian " . $radius . "x" . $sigma . " +matte {$fade_work_2}");
     $this->_execute("composite   -compose Multiply {$fade_mask} {$fade_work_2} {$fade_work_2}");
     for ($i = 2; $i < $sigma - 1; $i++) {
         $this->_execute("convert   {$fade_work_2} -gaussian " . $radius . "x" . ($sigma - $i) . " +matte {$fade_work_2}");
         $this->_execute("composite   -compose Multiply {$fade_mask} {$fade_work_2} {$fade_work_2}");
     }
     # When satisfied,  re-add the faded mask into original image
     $this->_execute("composite   -compose CopyOpacity {$fade_work_2} {$fade_init} {$fadeout}");
     $this->_execute("convert   {$fadeout} {$this->tempfile}");
 }