Tarjei Huse wrote:

> Jowza! (got tired of hi)
> 
> When this point was raised last time Emile thought of the idea of making a
> way to easily integreate custom code into the admin interface. It could be
> done by referencing a pageelement og snippet so that if it exists, the code
> will be included.
> How about creating a snippet/pageelement for the two situations:
> (beware: I'm not to confident with files in php due to heavy use of midgard)
> 1. when the file is in a variable (line 21 below)
> 2. after the attachment has been created (so that the parameters can be
> created, line 30 below)
> 
> Is the mgd_snippet_exists(snippet) function in existence now? If not, we
> could create two emptysnippets to be called. Then different users can put
> code into them to suit their needs without messing about in the main code of
> the admin interfaces.
> 
> If this cannot be done, then pleas post somewere in the interface (on som
> kind of docu page of something) where I should look to find the code
> handling these situations.
> 
> Tarjei
> 
> 
> 
> <?
> 2: $adminhost = mgd_get_host($midgard->host);
> 3:  $mgdroot = $adminhost->prefix;
> 4: if ($OK_x) {
> 5:  if ($type=="article" && $id) $object = mgd_get_article($id);
> 6: if ($type=="styleelement" && $id) $object = mgd_get_element($id);
> 7:
> 8:   print "add attache $addattachment $type, $id";
> 9:   if ($addattachment == "none") $addattachment = "";
> 10:   $formname = "addattachment";
> 11:   $sizename = $formname . "_size";
> 12:   $typename = $formname . "_type";
> 13:   $namename = $formname . "_name";
> 14:   if( $$formname && $object)  {
> 15:         $filename = basename( $$namename );
> 16:         $result = fopen( $$formname, "r" );
> 17:         $file = fread( $result, $$sizename );
> 18:         fclose( $result );
> 19:         if( $$typename == "" )  $$typename = "application/octet-stream";
> 20:        $att = $object->createattachment($filename,$filename,$$typename);
> 21:        $size = GetImageSize($addattachment);
> 22:        if(! $att) {
> 23:              echo "Failed to create attachment.<br>\n";
> 24:              echo "Reason: " . mgd_errstr();
> 25:        } else {
> 26:            $filehandle = mgd_open_attachment($att);
> 27:             fputs($filehandle, $file);
> 28:             fclose($filehandle);
> 29: //            echo "Attachment created. ID is $att.<br>\n";
> 30: $att = mgd_get_attachment($att);
> 31: $att->parameter('size', 'x', $size[0]);
> 32: $att->parameter('size', 'y', $size[1]);
> 33: $att->parameter('size', 'HW', $size[3]);
> 34: $att = $att->id;
> 35:        }
> 36:
> 37:   } else { echo "No file attached?"; }
> 38:  }
> 39:
> 40:  $ts = time();
> 41: ?>
> 42: <html>
> 43: <head>
> 44: <title>Untitled Document</title>
> 45: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> 46: </head>
> 47:
> 48: <body bgcolor="#FFFFCC">
> 49:
> 50: <? if ($att) { ?>
> 51:          <script language="javascript">
> 52:            parent.mainFrame.location = "http://<? echo $HTTP_HOST .
> $mgdroot ?>/dhtml/nodhtmlpickimage_browser.html?action=info&dhtml=<? echo
> $dhtml ?>&type=<? echo $type ?>&id=<? echo $id ?>&img=<? echo $att ?>";
> 53:          </script>
> 54:     <? } ?>
> 55: <? if ($id)  { ?>
> 56: <form enctype="multipart/form-data"
> action="&(mgdroot);/dhtml/nodhtmlpickimage_attach.html" METHOD=POST>
> 57: <input type="hidden" name="type" value="&(type);">
> 58: <input type="hidden" name="id" value="&(id);">
> 59: <input type="hidden" name="dhtml" value="&(dhtml);">
> 60:
> 61: <font size="2" face="Arial, Helvetica, sans-serif">Add File<b>
> </b></font>
> 62:
> 63: <input type="file" name="addattachment">
> 64:   <input type="image" border="0" name="OK"
> src="/fimages/images/add.gif">
> 65: </form>
> 66: <? } else {  ?>
> 67: <P> Sorry You can not attach a file.<BR>- You must submit the article
> first then edit again
> 68: <? } ?>
> 69: </body>
> 70: </html>
> 


-- 
Best Regards,
David Guerizec           Free Software Developer
Aurora R&D               [EMAIL PROTECTED]
Midgard core developer   http://www.midgard-project.org/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to