Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Nedeľa, 29. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Usefull tip to help users choosing different media like img

phpMyEdit Configuration     Usefull tip to help users choosing different media like img
Odoslať novú tému   Odpovedať na tému    
 
zaipro     Založený: 17.03.2010   Príspevky: 4  
Príspevok Zaslal: 2010-03-19 22:41
Návrat hore  Odpovedať s citátom     

I created simple extension to provide users simple adding url images,video url and other stuff to your database.

Please assess this option :)

1) First add to your field definition tag 'media'
Kód:
$opts['fdd']['Src'] = array(
  'name'     => 'Src',
  'select'   => 'T',
  'maxlen'   => 255,
  'required' => true,
  'media'     => true
);


2) Extension is based on phpMyEdit-mce-cal.class.php, so now you must modify this class. Go to function calPopup_helper() and add in this function this line

Kód:
if (@$this->fdd[$k]['media']) {
         echo '<input type="button" value="..." name="..." onclick="javascript: mywind = window.open(\'nbs_media_choose.php\',\'mywindow\',\'width=640,height=480,resizable=yes,scrollbars=yes\'); mywind.focus(); mywind.inputToEdit=document.getElementById(\'PME_dhtml_fld_'.$this->fds[$k].'\')">';
      }


So now your function looks like this

Kód:
function calPopup_helper($k, $curval) /* {{{ */
   {
      //echo "ecpo".$this->cgi['prefix']['data'].$this->fds[$k];
      
      if (@$this->fdd[$k]['media']) {
         echo '<input type="button" value="..." name="..." onclick="javascript: mywind = window.open(\'nbs_media_choose.php\',\'mywindow\',\'width=640,height=480,resizable=yes,scrollbars=yes\'); mywind.focus(); mywind.inputToEdit=document.getElementById(\'PME_dhtml_fld_'.$this->fds[$k].'\')">';
      }
      
      if (@$this->fdd[$k]['calendar']) {
         
         $cal_ar['ifFormat']    = '%Y-%m-%d %H:%M';
         $cal_ar['showsTime']   = true;
         $cal_ar['singleClick'] = false;
         if (isset($curval)) {
            if (substr($curval, 0, 4) != '0000')
               $cal_ar['date'] = $curval;
         }
         if (isset($this->fdd[$k]['strftimemask'])) {
            $cal_ar['ifFormat'] = $this->fdd[$k]['strftimemask'];
         }
         if (is_array($this->fdd[$k]['calendar'])) {
            foreach($this->fdd[$k]['calendar'] as $ck => $cv) {
               $cal_ar[$ck] = $cv;
            }
         }
         $cal_ar['button'] = $this->dhtml['prefix'].'calbutton_'.$this->fds[$k];
         $this->calendars[$this->fds[$k]] = $cal_ar;

         $label = @$this->fdd[$k]['calendar']['label'];
         strlen($label) || $label = '...';

         $do_button = true;
         if (isset($this->fdd[$k]['calendar']['button'])) {
            $do_button = $this->fdd[$k]['calendar']['button'];
         };

            if ($do_button) {
               echo '<button id="',$cal_ar['button'],'">',$label,'</button>';
            } else {
            echo '<span style="cursor: pointer" id="',$cal_ar['button'],'">',$label,'</span>';
         }
      }
   } /* }}} */


3) Create your own nbs_media_choose.php file.
You can create your own nbs_media_choose.php file to provide users adding other stuff, to choose the best colour, to fill quiz and return answers :)

My nbs_media_choose.php file looks like...
In this script user can do some actions (choose images) and return results to your field.

Kód:
<html>
<head>
<body bgcolor="#bgcolor">
<P OnClick='JavaScript: inputToEdit.value=""; window.close();'><strong>&nbsp; &nbsp; CANCEL &nbsp; &nbsp;<strong></P>
<?php
$path = "../media/";

$dir_handle2 = @opendir($path) or die("Unable to open $path");

$i=0;
echo "<TABLE border=0  cellpadding='1' cellspacing='1'  id='tab_1'>";
while ($director = readdir($dir_handle2))
{
if(filetype($path.$director)=="dir"  && $director!=".." && $director!="_cache") {
$dir_handle = @opendir($path.$director) or die("Unable to open $path");
$directory = $director."/";
if($directory=="./")$directory="";

echo "<tr style='background-color:#c7c7c7; padding:0px;'><th class='form' colspan='6'><h4>Katalog: ".$director."<h4></th></tr>";
echo "<TR>";

while ($file = readdir($dir_handle))
{
  if(strncmp($file,"thumb_",6) !=0  && $file!="." && $file!=".." && filetype($path.$director."/".$file)!="dir" && strtolower($file)!="thumbs.db"){

     echo "<td onmouseover=\"this.style.backgroundColor='#ddd'; document.body.style.cursor = 'pointer'; \" onmouseout=\"this.style.backgroundColor=''; document.body.style.cursor = 'normal';\" valign=\"top\" width='150'>";
        $i++;
        echo "<P style='border: 1px #ccc solid; font-size:8px;'>".$file."</P>";
        if((pathinfo($file, PATHINFO_EXTENSION)=="jpg" || pathinfo($file, PATHINFO_EXTENSION)=="jpeg" || pathinfo($file, PATHINFO_EXTENSION)=="gif" || pathinfo($file, PATHINFO_EXTENSION)=="png")  ) {
          
         echo "<P OnClick='JavaScript: inputToEdit.value=\"".$directory.$file."\"; window.close();'><IMG   src='".$path.$directory.$file."' WIDTH='50' HEIGHT='50' border=0></P>";   
         echo "</td>";
     }else {
      
           echo "<p>";
           if(pathinfo($file, PATHINFO_EXTENSION)=="pdf" ) echo '<IMG SRC="img/pdf_ico.jpg" WIDTH="62" HEIGHT="60" BORDER="0" ALT="">';
           if(pathinfo($file, PATHINFO_EXTENSION)=="doc" ) echo '<IMG SRC="img/word_ico.jpg" WIDTH="62" HEIGHT="60" BORDER="0" ALT="">';
           if(pathinfo($file, PATHINFO_EXTENSION)=="xls" ) echo '<IMG SRC="img/xls_ico.jpg" WIDTH="62" HEIGHT="60" BORDER="0" ALT="">';
           if(pathinfo($file, PATHINFO_EXTENSION)=="rar" || pathinfo($file, PATHINFO_EXTENSION)=="zip" ) echo '<IMG SRC="img/archiwe_ico.jpg" WIDTH="62" HEIGHT="60" BORDER="0" ALT="">';
           if(pathinfo($file, PATHINFO_EXTENSION)=="avi" || pathinfo($file, PATHINFO_EXTENSION)=="mp3" || pathinfo($file, PATHINFO_EXTENSION)=="mp4"  || pathinfo($file, PATHINFO_EXTENSION)=="mpg" || pathinfo($file, PATHINFO_EXTENSION)=="mpeg" || pathinfo($file, PATHINFO_EXTENSION)=="swf"  || pathinfo($file, PATHINFO_EXTENSION)=="flv"  )
              echo "<P OnClick='JavaScript: inputToEdit.value=\"".$directory.$file."\"; window.close();'><IMG SRC='img/media_ico.jpg' WIDTH='62' HEIGHT='60' BORDER='0' ALT=''></P>";
           echo "</p>";
      
        echo "</td>";
     }
  }

 
 
if($i%6==0)echo "</TR><TR>";
}
echo "</TR>";
}
}

echo "</TABLE>";
closedir($dir_handle);
?>

</TD>
</TR>
</TABLE>
</body>
</html>


 
roybrown     Založený: 07.03.2010   Príspevky: 7  
Príspevok Zaslal: 2010-03-22 01:12
Návrat hore  Odpovedať s citátom     

I've made the changes you suggested, and it works well except for one issue. The window appears, displays files in the target directory, and shows icons for non-image filetypes (word, html, etc.) It will not display the jpeg files except by name.

Any ideas?

roy

 
zaipro     Založený: 17.03.2010   Príspevky: 4  
Príspevok Zaslal: 2010-03-22 10:06
Návrat hore  Odpovedať s citátom     

Print results of this line:

Kód:
echo "<P OnClick='JavaScript: inputToEdit.value=\"".$directory.$file."\"; window.close();'><IMG src='".$path.$directory.$file."' WIDTH='50' HEIGHT='50' border=0></P>";   


You can change it to

Kód:
echo "<P OnClick='JavaScript: inputToEdit.value=\"".$directory.$file."\"; window.close();'><IMG src='".$path.$directory.$file."' WIDTH='50' HEIGHT='50' border=0></P>";   echo "src='".$path.$directory.$file."'";


Give me results of
Citácia:
echo "src='".$path.$directory.$file."'";
function.

Give me structure of your files:
1) where nbs_media_choose.php
2) where is your forlder with images and media

 
roybrown     Založený: 07.03.2010   Príspevky: 7  
Príspevok Zaslal: 2010-03-22 13:53
Návrat hore  Odpovedať s citátom     

results of echo:
src='c:/users/public/public projects/recipes-doc/in the book/Adobo Chicken with Ginger.jpg'

directory structure for code is:

c:/users/public/public projects/images
phpMyEdit.class.php
ae_gallery.php (product of phpmyeditsetup.php)

extensions (dir)
nbs_media_choose.php
phpMyEdit-mce-cal.class.php
images (dir)
phpmyedit icons
word, html, etc. icons
jscalendar (dir)
lang (dir)
tiny-mce (dir)

target word files and jpeg files (.jpg) are in directory as stated above.

I have IIS as my webserver, am on windows vista, and have my work directory as the physical directory for the localhost/images site.

If I invoke localhost/images/ae_gallery.php and select 'add' the button appears and I see the target directory with icons for the word documents, but not the images for the jpg files, just empty picture icon. Same if I invoke localhost/images/extensions/nbs_media_choose.php directly.

I use a tool called dev-php2 to develop code. When I run ae_gallery.php which calls nbs_media_choose I get same result.

When I call nbs_media_choose directly from dev-php2, it works! I see the jpg images. The echo of the path is the same.

roy

 
zaipro     Založený: 17.03.2010   Príspevky: 4  
Príspevok Zaslal: 2010-03-22 14:53
Návrat hore  Odpovedať s citátom     

Could you try to change the variable $path to be relative to the nbs_media_choose.php document?

Not
Citácia:
c:/users/public/public projects/images
but
Citácia:
./images/
.

Is this helped?

 
roybrown     Založený: 07.03.2010   Príspevky: 7  
Príspevok Zaslal: 2010-03-22 15:56
Návrat hore  Odpovedať s citátom     

same behavior! I would be happy to send a zip file of the code and data if you have the time, but it wouldn't be friendly to post it all here!

roy

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov