function validate () { $attr = $this->attribs->getAttribs('html'); $file = $attr['file']; $msg = ""; if ($file == '' && $attr['url'] == '') return $showErrors ? errorHTML("No <i>file</i> attribute found in (:embed:) statement") : ''; if ($attr['file']=='' && $attr['url'] != '') $file = $attr['url']; $mo = MediaObjectFactory::createMediaObject($this->pagename, $file, $this->attribs); if ($mo == false || !$mo->exists()) { global $ScriptUrl; $msg = "Embedded file <i>$file</i> not found<br>"; $msg.= "<a href='$ScriptUrl?n={$this->pagename}/?action=upload&upname=$file'>upload now</a>"; } elseif ($mo->isRemote() && !$mo->urlSupported()) { $msg = "<i>url</i> attribute not supported for filetype ".strtoupper($mo->format()); } // test if print-file attribnute is given and if referenced file exists $attr = $this->attribs->getAttribs('fo', true); if (isset($attr['file'])) { $file = $attr['file']; $mo = MediaObjectFactory::createMediaObject($this->pagename, $file, $this->attribs); if ($mo == false || !$mo->exists()) { global $ScriptUrl; if ($msg != "") $msg .= "<hr/>"; $msg .= "Embedded print file <i>$file</i> not found<br>"; $msg .= "<a href='$ScriptUrl?n={$this->pagename}/?action=upload&upname=$file'>upload now</a>"; } } return $msg; }
function doTextLink ($pagename, $attrstr, $linktext='') { $attribs = new Attributes($attrstr); $attr = $attribs->getAttribs('html'); if (!isset($attr['file'])) return ''; if (!file_exists(getUploadPath($pagename, $attr['file']))) { global $ScriptUrl; $msg = "textlink file <i>$attr[file]</i> not found<br>"; $msg.= "<a href='$ScriptUrl?n=$pagename/?action=upload&upname=$attr[file]'>upload now</a>"; return Keep(errorHTML($msg)); } $url = FmtPageName("\$PageUrl?action=m2m-showfile&f=$attr[file]", $pagename); if ($linktext == '') return Keep("<a href='$url'>$attr[file]</a>"); return Keep("<a href='$url'>").$linktext.Keep("</a>"); }