Author Topic: Mohon Bantuannya Boss..  (Read 3797 times)

0 Members and 1 Guest are viewing this topic.

Offline ceplo

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Mohon Bantuannya Boss..
« on: December 29, 2009, 01:36:02 AM »
Aloo boss..
ganggu nie..
Aq membuat snippet modx untuk menampilkan cildren dalam bentuk circle tree (berbetuk melingkar).
Tapi kok hasilnya g bisa bagus ya..
mungkin boss bisa bantu..

ni potongan snippet nya

<?php
/**
 * ****************************************
 *
 * Snippet Name: CircleTree
 *
 * Short Desc: Show Family Tree in Circle Tree
 * Created By: sae_puol
 *
 * Version: 1.0
 * Modified: Desember 15, 2009
 *
 * Changelog:
 *   --
 *
 * ****************************************
 *
 * Description:
 *   Display Family Tree in Circle Tree
 *   Only meant to be used once per page.
 *
 * ****************************************
 */
 
echo '<form action="" method="post">';
echo '<table><tr>';
echo '<td><select name="deep">';
echo '<option value="1" >Generasi I</option>';
echo '<option value="2">Generasi II</option>';
echo '<option value="3" >Generasi III</option>';
echo '<option value="4" >Generasi IV</option>';
echo '<option value="5" >Generasi V</option>';
echo '<option value="6" >Generasi VI</option>';
echo '<option value="7" >Generasi VII</option>';
echo '</select></td>';
echo '<td><input name="submit" type="submit" value="Go!" /></td>';
echo '</tr>';
echo '</table>';
echo '</form>';
 
$zero      = (isset($_REQUEST['pid'])      ? $_REQUEST['pid'] : "14");
$deep      = (isset($_REQUEST['deep'])      ? $_REQUEST['deep'] : "3");

$rr = 200;
$pl = $rr+(($deep-1)*130);
$radius = $pl/2;
   
   function rotasix($xa, $ya, $q, $xp=0, $yp=0){
      return $xx = $xp+(($xa-$xp)*cos($q) - ($ya-$yp)*sin($q));
   }
   
   function rotasiy($xa, $ya, $q, $xp=0, $yp=0){
      return $yy = $yp+(($xa-$xp)*sin($q) + ($ya-$yp)*cos($q));
   }
   
   // $parent is the parent of the children we want to see
   // $level is increased when we go deeper into the tree,
   //        used to display a nice indented tree
   function display_children($parent, $level, $deep, $nn, $img, $corx, $cory, $r, $q=0) {
      // retrieve all children of $parent
   global $modx;   
   $tabel = $modx->getFullTableName('site_content');
   $result = $modx->db->select("id,pagetitle", $tabel, "parent=$parent");
    $num_c = $modx->db->getRecordCount( $result );   
      if($level<=$deep){
         // display each child
         $no=1;
         while ($row = $modx->db->getRow($result)) {
            // indent and display the title of this child
           $sdtx = 0;
           $sdty = 0;
           $sudut=0;
           $arc=0;            
            /*$child[$level][$no]['nama'] = $row['NAMA'];
            $child[$level][$no]['num'] = getNumChildren($row['ID']);*/
            $cid = $row['id'];
            if($level===1){
               $sudut =($no)*(270/($nn));
            }elseif($level===2){
                  $arc= 135/($nn+1);
               
               $sudut=(-30)+($arc/2)+0.25;
               for($jn=0;$jn<$no;$jn++){
                  $sudut += $arc;
               }
                  //$sudut = $sudut*(-1);      
            }else{
//$arc= sin(90/($nn)+(sin60));
$arc=0; $sudut = 0;
$arc = (45)/($nn);
if($nn==1) {$sudut=0;}else{
$sudut=(45)+($arc/2);
}
   for($jn=0;$jn<$no;$jn++){
$sudut += $arc;
}
                          }                                      
            $tvPhoto = $modx->getTemplateVarOutput(array("photo"),$docid=$cid,$published=1);
         //$sudut = $sudut*(-1);   
            $sdtx = $corx+($r*cos($q));
            $sdty = $cory+($r*sin($q));
                           
            $x1 = rotasix($sdtx, $sdty, $sudut, $corx, $cory);
            $y1 = rotasiy($sdtx, $sdty, $sudut, $corx, $cory);            
            
          
            //echo str_repeat('&nbsp;&nbsp;&nbsp;',$level).$no.". ".$row['NAMA']." ($num_c) $corx<br /> ";                     
               
                     
            $lenstr = strlen($row['pagetitle'])*2;
            
            imageline  ( $img  , $corx  , $cory  , $x1  , $y1  , 0xFF0000  );
            
            if($level>1){
             
               if($photo==""){$photo='assets/images/photo/No_photo.jpg';}
                     list($width, $height) = getimagesize($photo);            
                  $source1 = imagecreatefromjpeg($photo);
                  imagecopyresized($img, $source1, $corx-15, $cory-15, 0, 0, 30, 30, $width, $height);
                           
            }
            
          
            if($tvPhoto['photo']==""){   $tvPhoto['photo']='assets/images/photo/No_photo.jpg';}         
               list($width, $height) = getimagesize($tvPhoto['photo']);
               $source = imagecreatefromjpeg($tvPhoto['photo']);                           
               imagecopyresized($img, $source, $x1-15, $y1-15, 0, 0, 30, 30, $width, $height);
             
            
                            imagestring($img, 3, $x1, $y1+15, $level." - ".$no, 0x00FF00);
          
            
            $no++;
            // call this function again to display this
            // child's children
                           if($num_c>0){            
                 display_children($row['id'], $level+1, $deep, $num_c,$img,  $x1, $y1, 80, $sudut);
            }
         }
      }
    
   }

   
// select resources 
$tbl = $modx->getFullTableName('site_content');
$rs = $modx->db->select("pagetitle", $tbl, "id = $zero");
$rs2 = $modx->db->select("pagetitle", $tbl, "parent = $zero");
$im = imagecreatefromjpeg('assets/images/linkar_generasi/Generasi-'.$deep.'.jpg');
  while ($rw = $modx->db->getRow($rs)) {
   $parentName = $rw['pagetitle'];   
  }

   $tvPhoto = $modx->getTemplateVarOutput(array("photo"),$docid=$zero,$published=1);
   $tvPhoto2 = $modx->getTemplateVarOutput(array("photo_pasangan"),$docid=$zero,$published=1);    
   
   if($tvPhoto['photo']==""){ $tvPhoto['photo'] = 'assets/images/photo/No_photo.jpg';}
   if($tvPhoto2['photo_pasangan']==""){$tvPhoto2['photo_pasangan'] = 'assets/images/photo/No_photo.jpg';}
   
   $num_c = $modx->db->getRecordCount( $rs2 );

   
   echo '<MAP NAME="tree">';     
   

       $r =125;
   
   display_children($zero,1,$deep-1,$num_c,$im,$radius,$radius,$r);

$imsource = imagecreatefromjpeg($tvPhoto['photo']);
list($width, $height) = getimagesize($tvPhoto['photo']);
imagecopyresized($im, $imsource, $radius+5,$radius-25, 0, 0, 50, 50, $width, $height);

$imgsource = imagecreatefromjpeg($tvPhoto2['photo_pasangan']);
list($imwidth, $imheight) = getimagesize($tvPhoto2['photo_pasangan']);
imagecopyresized($im, $imgsource, $radius-55,$radius-25, 0, 0, 50, 50, $imwidth, $imheight);

   imagepng($im, 'assets/images/tree/'.$zero.'.png');
   imagedestroy($im);
   
   echo '</MAP>';
   
   echo '<div id="image"><img src="assets/images/tree/'.$zero.'.png" usemap="#tree" width="'.$pl.'" height="'.$pl.'" /></div>';
?>

Mungkin ada kesalahan di rumus menghitung sudut nya..
Mohon bantuannya ya boss..

Untuk contoh hasilnya bisa di lihat http://www.prawirodarmo.org/index.php?id=15

Offline goldsky

  • tweets @_goldsky
  • Administrator
  • Sr. Member
  • *****
  • Posts: 345
  • Karma: +1/-0
  • Less is more
    • Virtudraft Intermedia Telematika
Re: Mohon Bantuannya Boss..
« Reply #1 on: December 30, 2009, 07:28:07 AM »
Aloo boss..
ganggu nie..
Aq membuat snippet modx untuk menampilkan cildren dalam bentuk circle tree (berbetuk melingkar).
Tapi kok hasilnya g bisa bagus ya..
mungkin boss bisa bantu..

Untuk contoh hasilnya bisa di lihat http://www.prawirodarmo.org/index.php?id=15
Pantesan gak mau pake http://www.phpgedview.net/ , bentuknya melingker begini.
hehe... nantinya bukan jadi repot kalo mau tambah/kurang isi?

Apanya yang kurang bagus, Mas Ceplo?
Bukannya udah jalan, tuh?
Draft desainnya seperti apa?
Rico
Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!

Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets | IE 6 must die !

Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

PING ME ON TWITTER @_goldsky

Offline ceplo

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Re: Mohon Bantuannya Boss..
« Reply #2 on: January 11, 2010, 10:37:20 PM »
Client minta melingkar..gmn lagi..
itu kurangnya di generasi IV ke atas..tampilan jadi agak kurang bagus..

Offline goldsky

  • tweets @_goldsky
  • Administrator
  • Sr. Member
  • *****
  • Posts: 345
  • Karma: +1/-0
  • Less is more
    • Virtudraft Intermedia Telematika
Re: Mohon Bantuannya Boss..
« Reply #3 on: January 12, 2010, 04:30:09 AM »
Anda butuh lingkaran yang lebih besar lagi.

BTW,
Saya masih lebih menyarankan Anda untuk menggunakan http://www.phpgedview.net/ ,
karena dia sudah ada Circle Diagram.
Coba saja udak-udak lagi, atau contoh aja source code nya.
« Last Edit: January 12, 2010, 04:37:19 AM by goldsky »
Rico
Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!

Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets | IE 6 must die !

Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

PING ME ON TWITTER @_goldsky

Offline ceplo

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Re: Mohon Bantuannya Boss..
« Reply #4 on: January 19, 2010, 09:54:20 PM »
Saya rasa bukan masalah lingkarannya.
Karena arah perputarannya salah.
Ya aq wes bilang ke boss q buat pake gedview di padu dngan joomla.
tapi dy g mw..

Offline Adhiarta

  • Duta
  • Newbie
  • ****
  • Posts: 24
  • Karma: +0/-0
Re: Mohon Bantuannya Boss..
« Reply #5 on: January 19, 2010, 10:43:40 PM »
BTW menarik snippetnya memang akan menjadi kendala kalau sampai mempunya kedalaman yang banyak, mungkin bisa mengintegrasikan aplikasi seperti ini yg sudah ada

Offline ceplo

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Re: Mohon Bantuannya Boss..
« Reply #6 on: January 27, 2010, 10:05:35 PM »
Ya, aq tau.
Kalo kedalamannya tidak di batasi, maka tampilannya akan ruwet..

 

term