Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2007
    Messaggi
    489

    aiuto nel salvare una variabile

    ciao a tutti!

    ho trovato questo script su internet ma il codice é troppo complicato per me. cio che vorrei fare é la cosa seguente...

    nel codice guardate il pezzo finale dopo il blocco commentato.

    li viene generato un testo e scritto all interno dell immagine. cio che vorrei fare é salvare questo testo in una variabile. come si fa? grazie

    (questa parte di codice verrebbe eseguita piu volte, una per ogni dato salvato. il dato salvato é soltanto uno nel mio caso percio non mi importa se la variabile viene sovvrascritta)

    Codice PHP:

    <?

    class gantt {
        var 
    $img;

        
    /**
         * All the information to be sent to class
         * the keys of array will be allocated to class variables
         * See documentation of others variables to know what information 
         * sent to this array
         *
         * @var array
         */
        
    var $definitions = array();
        var 
    $img_width800;
        var 
    $img_height 300;
        var 
    $img_bg_color = array();
        var 
    $grid_color = array();
        var 
    $workday_color = array();
        var 
    $title_color = array();
        var 
    $title_string "";
        var 
    $planned = array();
        var 
    $planned_adjusted = array();
        var 
    $real = array();
        var 
    $limit = array();
        var 
    $dependency = array();
        var 
    $milestones = array();
        var 
    $groups = array();
        var 
    $progress = array();
        var 
    $y;
        var 
    $cell;
        var 
    $dependency_planned;
        
    /**
         * The ONLY function to be accessed. All information to the class have to be passed to array
         * $definitions. The class will use the informations to generate the gantt graphic
         *
         * @param array $definitions
         * @return gantt
         */
        
    function gantt($definitions) {
            
    $this->definitions $definitions;
            
    //allocate the variables of array definitions to class variables
            
    foreach ($definitions as $key=>$value) {
                
    $this->$key $value;
            }
            
    $this->definesize();

            
    //create the image
            
    $this->img imagecreatetruecolor($this->img_width,$this->img_height);
            
    //imagealphablending($this->img,true);

            
    $this->background();
            
    $this->title();
            
    $this->grid();
            
    $this->groups(); // draws groups and phases
            
    if (is_array($this->dependency_planned)) {
                
    $this->dependency($this->dependency_planned,'p');
            }
            if (
    is_array($this->dependency)) {
                
    $this->dependency($this->dependency);
            }
            if (
    $this->definitions['today']['data']) {
                
    $this->today();
            }

            if (
    $this->definitions['status_report']['data']) {
                
    $this->last_status_report();
            }

            
    $this->legend();

            
    $this->draw();
        }
        function 
    today(){
            
    $y$this->definitions['grid']['y']+40;
            
    $rows $this->rows();
            
    $y2 = ($rows*$this->definitions['row']['height'])+$y;
            
    $x = (($this->definitions['today']['data'] - $this->limit['start'])/(60*60*24))*$this->cell +$this->definitions['grid']['x'];
            
    //imageline($this->img,$x,$y,$x,$y2,IMG_COLOR_STYLED);
            
    $this->line_styled($x,$y,$x,$y2,$this->definitions['today']['color'],$this->definitions['today']['alpha'],$this->definitions['today']['pixels']);
        }
        function 
    last_status_report(){
            
    $y$this->definitions['grid']['y']+40;
            
    $rows $this->rows();


            
    $y2 = ($rows*$this->definitions['row']['height'])+$y;
            
    $x = (($this->definitions['status_report']['data'] - $this->limit['start'])/(60*60*24))*$this->cell +$this->definitions['grid']['x'];

            
    $this->line_styled($x,$y,$x,$y2,$this->definitions['status_report']['color'],$this->definitions['status_report']['alpha'],$this->definitions['status_report']['pixels']);
        }
        function 
    line_styled($x,$y,$x2,$y2,$color,$alpha,$pixels){
            
    $w  imagecolorallocatealpha($this->img255255255,100);
            
    //$red = imagecolorallocate($im, 255, 0, 0);
            
    $color $this->color_alocate($color,$alpha);
            for (
    $i=0;$i<$pixels;$i++){
                
    $style[] = $color;
            }
            for (
    $i=0;$i<$pixels;$i++){
                
    $style[] = $w;
            }

            
    imagesetstyle($this->img,$style);
            
    imageline($this->img,$x,$y,$x,$y2,IMG_COLOR_STYLED);
        }
        function 
    groups()    {
            
    $start_grid $this->definitions['grid']['x'];
            
    $this->$this->definitions['grid']['y'] + 40;

            foreach (
    $this->groups['group'] as $cod=>$phases) {

                if (
    $this->definitions["not_show_groups"] != true) {


                    
    $y = &$this->y;
                    
    $x = (($this->groups['group'][$cod]['start'] - $this->limit['start'])/(60*60*24))*$this->cell +$start_grid;

                    
    $x2 = (($this->groups['group'][$cod]['end']-$this->groups['group'][$cod]['start'])/(60*60*24))*$this->cell +$x;
                    
    //echo "$x : $x2";
                    
    $this->rectangule($x,$y,$x2,$y+6,$this->groups['color'],$this->groups['alpha']);
                    
    $y2 $y+7;
                    
    $this->polygon(array($x,$y2,$x+10$y2,$x,$y+15),3,$this->groups['color'],$this->groups['alpha']);
                    
    $this->polygon(array($x2-10,$y2,$x2$y2,$x2,$y+15),3,$this->groups['color'],$this->groups['alpha']);

                    
    $y2 $y +$this->definitions['row']['height']/2;


                    
    // title of group
                    
    $this->rectangule(0,$y,$start_grid-1,$y+$this->definitions['row']['height']/2,$this->groups['bg_color']);



    /////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////        


            
    $this->text($this->groups['group'][$cod]['name'],5,$y+$this->definitions['row']['height']/4-6,$this->definitions["group"]['text_color']);


    //VORREI SALVARE IL TESTO INERITO QUI SOPRA IN UNA VARIABILE CHIAMATA "$groupname"

    .
    .
    .
    .
    .



    ?>

    grazie

    ciao

    igor

  2. #2
    Mancano tre chiusure di graffe nell'ultima funzione.

    Non ho studiato il codice ma devi eseguire un return dell'output che vuoi venga visualizzato quando richiami la funzione.

  3. #3
    Utente di HTML.it
    Registrato dal
    Dec 2007
    Messaggi
    489
    ciao!

    il codice continua dopo i punti finali, non l ho postato tutto perche é molto lungo. il return non é un problema, mi riferivo piu a come salvare la variabile.. cioé basta se faccio una cosa cosi?

    $nomevariabile = $this->groups['group'][$cod]['name'];

    ci ho provato ma mi restituisce "array"..

    grazie

    ciao

    igor

  4. #4
    Evidentemente è un array

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.