Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13

Thread: Image syntax

  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Smile Image syntax

    Code:
    $this->Image('ticketimages/imat_la_insert.jpg',295,45,5,157.5);
    I am trying to understand the code above. Specifically the numbers listed. I thought they were padding instructions top, right,bottom, left but now I'm not sure. This snippet comes from osCommerce. Can anybody straighten me out on this?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    This is a custom class. Providing us a call without the class definition will not allow us to determine what each argument represents.

  • Users who have thanked Fou-Lu for this post:

    patrickMcD (08-10-2011)

  • #3
    New Coder
    Join Date
    Mar 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    class

    Code:
    $this->images=array();
    Like an array?

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    No, inside of the class that is making that call will be a function called Image that will have arguments in the definition. It will look like this:
    PHP Code:
    class SomethingSomething
    {
        public function 
    Image($name$top$right$bottom$left// these args are what you're looking for
        
    {
            
    //etc.
        
    }


  • Users who have thanked Inigoesdr for this post:

    patrickMcD (08-10-2011)

  • #5
    New Coder
    Join Date
    Mar 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Like this?

    Code:
    function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by patrickMcD View Post
    Code:
    function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
    That would be the signature yes.
    Still a little useless. Given PHP's datatype weakness we don't even know what datatypes these are, though from the call I can determine that it would be function Image(string, unknown, unknown, int, int [though I see double in the call], string, string).
    These still do not help. $x and $y typically represent starting coordinates, and $w and $h typically represent width and height. Providing us the class body so we can see what it does would tell us what these represent.
    Professional programmers will generally doc comment any of their methods to indicate what each variable's represent.

  • #7
    New Coder
    Join Date
    Mar 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you for that information. I have created a variable called "usethisimage" to use in the function described above. I tried to concatenate the folder location with the image name (randomly selected from a local folder) like this:

    Code:
    $usethisimage = ".$img_folder.$adimage";
     
    	$this->Image('$usethisimage',15,235,180,20,'jpg','http://www.imats.net');
    Its not working, will the call of the class "image" work with the variable listed this way?

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by patrickMcD View Post
    Thank you for that information. I have created a variable called "usethisimage" to use in the function described above. I tried to concatenate the folder location with the image name (randomly selected from a local folder) like this:

    Code:
    $usethisimage = ".$img_folder.$adimage";
     
    	$this->Image('$usethisimage',15,235,180,20,'jpg','http://www.imats.net');
    Its not working, will the call of the class "image" work with the variable listed this way?
    I can guarantee it will not as the first parameter is a literal string $usethisimage, and not whatever the $usethisimage represents. The variable is also wrong, there will be a starting period and one between the two. That should just be $img_folder . $adimage;.
    Until you post the definition of the class, we cannot tell you what these represent or if you are using them properly with this image method.

    Edit:
    BTW, this class cannot / should not be called Image. If it is, you are trying to invoke a constructor through the context of an object which should not be done. That would require the call of new in order to construct a new object, not a call against the context of $this.

  • #9
    New Coder
    Join Date
    Mar 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Code:
    class FPDF
    {
    var $page;               //current page number
    var $n;                  //current object number
    var $offsets;            //array of object offsets
    var $buffer;             //buffer holding in-memory PDF
    var $pages;              //array containing pages
    var $state;              //current document state
    var $compress;           //compression flag
    var $k;                  //scale factor (number of points in user unit)
    var $DefOrientation;     //default orientation
    var $CurOrientation;     //current orientation
    var $PageFormats;        //available page formats
    var $DefPageFormat;      //default page format
    var $CurPageFormat;      //current page format
    var $PageSizes;          //array storing non-default page sizes
    var $wPt,$hPt;           //dimensions of current page in points
    var $w,$h;               //dimensions of current page in user unit
    var $lMargin;            //left margin
    var $tMargin;            //top margin
    var $rMargin;            //right margin
    var $bMargin;            //page break margin
    var $cMargin;            //cell margin
    var $x,$y;               //current position in user unit
    var $lasth;              //height of last printed cell
    var $LineWidth;          //line width in user unit
    var $CoreFonts;          //array of standard font names
    var $fonts;              //array of used fonts
    var $FontFiles;          //array of font files
    var $diffs;              //array of encoding differences
    var $FontFamily;         //current font family
    var $FontStyle;          //current font style
    var $underline;          //underlining flag
    var $CurrentFont;        //current font info
    var $FontSizePt;         //current font size in points
    var $FontSize;           //current font size in user unit
    var $DrawColor;          //commands for drawing color
    var $FillColor;          //commands for filling color
    var $TextColor;          //commands for text color
    var $ColorFlag;          //indicates whether fill and text colors are different
    var $ws;                 //word spacing
    var $images;             //array of used images
    var $PageLinks;          //array of links in pages
    var $links;              //array of internal links
    var $AutoPageBreak;      //automatic page breaking
    var $PageBreakTrigger;   //threshold used to trigger page breaks
    var $InHeader;           //flag set when processing header
    var $InFooter;           //flag set when processing footer
    var $ZoomMode;           //zoom display mode
    var $LayoutMode;         //layout display mode
    var $title;              //title
    var $subject;            //subject
    var $author;             //author
    var $keywords;           //keywords
    var $creator;            //creator
    var $AliasNbPages;       //alias for total number of pages
    var $PDFVersion;         //PDF version number

  • #10
    New Coder
    Join Date
    Mar 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Is that the class definition you were asking about?

  • #11
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    It may be. Is this: $this->Image('$usethisimage',15,235,180,20,'jpg','http://www.imats.net'); being called within a method inside that class somewhere? $this is reserved in PHP, so we know its being used within a class, but we don't know what class it is.

  • #12
    New Coder
    Join Date
    Mar 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    class PDF extends FPDF

  • #13
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by patrickMcD View Post
    class PDF extends FPDF
    This still doesn't help. Both of these are custom classes which we do not have the definitions for.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •