Jump to content

scottybwoy

Members
  • Posts

    532
  • Joined

  • Last visited

    Never

Posts posted by scottybwoy

  1. Hi REGEX Lords,

     

    I'd like to beautify my JSON files so it's a bit easier to read. json_encode and fwrite, just sticks it all on on line, so I'd like to add in some /n and /t to break it up a bit.

     

    So I thought once I've got my JSON encoded object I could use some preg_replace magic to do some stuff like changing

    { => {/n/t
    } => }/n
    : => " : " // But without the quotes, just wanted to space it out a bit
    , => ,/n // and would it be possible to have the cursor level to the line above it?
    

    Thanks for your help, this may be a good one to put up on some Regex libraries too, what do ya think ;)

  2. This function is part of my template class...  (Yeah, yeah, I know the arguments.. But this is for uploading to a flat file site).

     

    <?
    
    function ReplaceStatic($tcontent, $static_data) {
    
    foreach ($static_data as $k => $v) {
        	if (is_array($v)) {
        		$prefix = $k;
    
        		$rowbegin = "<!--%" . $prefix . "_ROWBEGIN%-->";
            		$row_b_len = strlen($rowbegin);
            		$startrow = strpos($tcontent, $rowbegin);
    
            		$rowend = "<!--%" . $prefix . "_ROWEND%-->";
            		$row_e_len = strlen($rowend);
            		$endrow = strpos($tcontent, $rowend) + $row_e_len;
            		$rowlen = $endrow - $startrow;
            		$row = substr($tcontent, $startrow, $rowlen);
            		$subrowlen = ($endrow - $row_e_len) - ($startrow + $row_b_len);
            		$row_content = substr($tcontent, $startrow + $row_b_len, $subrowlen);
            		$nrow_content = "$row_content\r\n";
            		$rowsyntax = "<!--%" . $prefix . "_ROW%-->";
            		foreach ($v as $nv) {
            			$rows .= str_replace($rowsyntax, $nv, $nrow_content);
            		}
    
            		$tcontent = str_replace($row, $rows, $tcontent);
            		unset($rows);
    
        	} else {
    	    	$placeMat = "<!--%$k%-->";
    	    	$tcontent = str_replace($placeMat, $v, $tcontent);
        	}
        }
    
        return $tcontent;
    }
    ?>
    

     

    Now the actual functionality works fine, however the returned $tcontent is repeated a number of times and when written to the file, comes out as so.  Can anyone see why?

     

    Thanks

  3. I'm trying to upgrade from v5.1.4 to v5.2 on a WIN2K ADV SERVER with IIS6.  What I did was replace the original folder and files with the new php directory, except for PEAR.bat and the PEAR Directory and then amended php.ini and restarted the Web Server.

     

    However running phpinfo(); still says its php 5.1.4

     

    What else would I need to do?

  4. A very basic method would be to just include a print type css for your html file.  That way when you choose to print the html web page, it looks exactly how you styled it via css.  You just use display: none; for the items on the page you don't want to print.

     

    Alternatively you can use very small pdf libs or classes (you can find a few on the web) that require very limited install procedures, if you don't want to download the pear library, which is generally more bulky but concise.

     

    Good luck

  5. For left middle and right, try adding display:inline; and float:left; to all of them.

     

    Note how that works and work around that.  You can then play around using that same style to the top and bottom one since the way you are making your grid.

     

    Good Luck

  6. yes is will. so in your second class you need to offset the styles in the previous class.

     

    But it seems maybe you are using this for a layout. Use divs instead (search google for tableless layouts)

     

    Only use table for tabular data / grids from now on.

     

    Good luck

  7. OK have it working now anyone else had this trouble here is a working version.  It's a mess I know, but if anyone has a better idea, please share.

     

    html

    <div class="menu">
    <ul>
    <li style='left:-8px; width:16px; margin:0px; padding:0px; z-index:150;'><img src="http://www.mri.co.uk/header/mri_head_c.png" style='left:-11.9%; width:16px;' alt='navigation image' /></li>
    <li class='ff ie6'>
    <a class="r" href="http://www.mri.co.uk/news/index.htm" title='News'>News<!--[if IE 7]><!--></a><!--<![endif]-->
    <!--[if lte IE 6]><table style='top:0px; z-index:203;'><tr><td><![endif]-->
    <ul style='top:0px;' id='red'>
    	<li style='width:100%; height:17px; z-index:203;'><img alt="" src='http://www.mri.co.uk/header/mri_head_r_up.png' style='width:16px; z-index:203;' class='ff ie6' /><img alt="" src='http://www.mri.co.uk/header/ru.gif' style='right:-2px; width:16px; z-index:203; margin:0px; padding:0px;' /></li>
    </ul>
    <!--[if lte IE 6]></td></tr></table></a><![endif]-->
    <img src='http://www.mri.co.uk/header/grey.gif' alt="" />
    </li>
    <li>
    <a class="y" href="http://www.mri.co.uk/products/index.htm" title='Products'>Products<!--[if IE 7]><!--></a><!--<![endif]-->
    <!--[if lte IE 6]><table style='top:0px; z-index:203;'><tr><td><![endif]-->
    <ul style='top:0px;' id='yellow'>
    <li style='width:100%; height:17px; z-index:203;'><img alt="" src='http://www.mri.co.uk/header/yd.gif' style='left:1px; width:16px; z-index:203; margin:0px; padding:0px;' /><img alt="" src='http://www.mri.co.uk/header/yu.gif' style='right:-2px; width:16px; z-index:203; margin:0px; padding:0px;' /></li>
    <li><a href="http://www.mri.co.uk/products/Controllers/index.htm" title="Storage Controller Cards">Controller Cards ><!--[if IE 7]><!--></a><!--<![endif]-->
    <!--[if lte IE 6]><table><tr><td><![endif]-->
    	<ul>
    		<li><a href="http://www.mri.co.uk/products/Controllers/sata.htm" title="RAID and Non-RAID SATA Controllers">SATA</a></li>
    		<li><a href="http://www.mri.co.uk/products/Controllers/scsi.htm" title="Ultra Wide SCSI Controllers">SCSI</a></li>
    		<li><a href="http://www.mri.co.uk/products/Controllers/ide.htm" title="RAID and Non-RAID IDE Controllers">IDE</a></li>
    	</ul>
    <!--[if lte IE 6]></td></tr></table></a><![endif]-->
    </li>
    <li><a href="http://www.mri.co.uk/products/InputOutput/index.htm" title="I/O Devices">I/O Devices ><!--[if IE 7]><!--></a><!--<![endif]-->
    <!--[if lte IE 6]><table><tr><td><![endif]-->
    	<ul>
    		<li><a href etc...
    

     

    css

    /* bitch hack */
    li.ff {
    margin-left: 6px;
    }
    
    img.ff {
    left: 0px;
    }
    

    the rest is the same as above.

  8. I have half solved this issue.

     

    What I have done is created an extra <li> that goes over the initial <li>.  This second <li> holds the images on either side, this gives the appearance I am looking for.  However it only half works in IE 6.  Can anyone tell me why that is and how I can get around it.

     

    Here is the html :

    <ul>
    <li>
    <img name="mri_head_r2_c2" src="http://www.mri.co.uk/header/mri_head_c.png" style='left:-11.9%; width:16px;' id="mri_head_r2_c2" alt='navigation image' />
    <a class="r" href="http://www.mri.co.uk/news/index.htm" title='News'>News</a>
    <!--[if lte IE 6]><table><tr><td><![endif]-->
    <ul style='top:0px;' id='red'>
    <li style='width:100%; height:17px;'><img alt="" src='http://www.mri.co.uk/header/mri_head_r_up.png' style='left:6px; width:16px; z-index:203; margin:0px; padding:0px;' /><img alt="" src='http://www.mri.co.uk/header/ru.gif' style='right:-2px; width:16px; z-index:203; margin:0px; padding:0px;' /></li>
    </ul>
    <!--[if lte IE 6]></td></tr></table></a><![endif]-->
    <img name="tab1" src='http://www.mri.co.uk/header/grey.gif' alt="" />
    </li>
    <li>
    <a class="y" href="http://www.mri.co.uk/products/index.htm" title='Products'>Products<!--[if IE 7]><!--></a><!--<![endif]-->
    <!--[if lte IE 6]><table><tr><td><![endif]-->
    <ul style='top:0px;' id='yellow'>
    <li style='width:100%; height:17px;'><img alt="" src='http://www.mri.co.uk/header/yd.gif' style='left:1px; width:16px; z-index:203; margin:0px; padding:0px;' /><img alt="" src='http://www.mri.co.uk/header/yu.gif' style='right:-2px; width:16px; z-index:203; margin:0px; padding:0px;' /></li>
    <li><a href="http://www.mri.co.uk/products/Controllers/index.htm" title="Storage Controller Cards">Controller Cards ><!--[if IE 7]><!--></a><!--<![endif]-->
    <!--[if lte IE 6]><table><tr><td><![endif]-->
    etc...
    

    As you can see the first one is a bit different from the second, however the rest are the same.

     

    And the css:

    .menu {
    position: relative;
    width: auto;
    height: auto;
    margin: 0px 140px 0px 192px;
    padding: 0px;
    font-family: arial, sans-serif;
    text-align: center;
    vertical-align: middle;
    font-size: 9pt;
    z-index: 100;
    }
    
    /* remove all the bullets, borders and padding from the default list styling */
    .menu ul {
    position: relative;
    padding: 0px;
    margin: 0px;
    list-style-type: none;
    }
    
    /* float the list to make it horizontal and a relative positon so that you can control the dropdown menu positon */
    .menu ul li {
    position: relative;
    float: left;
    width: 11.9%;
    margin-right: 15px;
    font-weight: bold;
    }
    
    /* style the links for the top level */
    .menu a, .menu a:visited {
    display: block;
    height: 17px;
    background-image: url(http://www.mri.co.uk/header/greyd.gif);
    text-align: center;
    color: #c00;
    font-size: 9pt;
    text-decoration: none;
    overflow: hidden;
    }
    
    /* hide the sub levels and give them a positon absolute so that they take up no room */
    .menu ul ul {
    visibility: hidden;
    position: absolute;
    top: 0px;
    left: -16px;
    width: 110px;
    }
    
    .menu ul ul li {
    display: block;
    clear: both;
    }
    

     

    Thanks for having a look

  9. OK let me narrow this down.

     

    I have a list + css type nav.

     

    When the mouse rolls over the anchor of the list I want it to change 3 images.  One to the left, one to the right and all in the middle.

     

    I have this working with Javascript, is there a way to do it purely in css?

     

    Please look at the horizontal nav on this page

    [link]http://www.mri.co.uk/company-info/terms-of-business2.htm[/link] for an example.

     

    Would it be done using layers?

     

  10. Lol, Thanks Roopurt18,

     

    That's great advise, I suppose I should have just gone on with that myself.  I do however would like to know if this is common place.

     

    I have two switches in my handling class.  One that deals with _GET data from various hrefs and generally just present the correct template.

     

    Then another that deals with buttons, and that usually opens up a script, which then displays the correct template after doing something.

     

    Would it be better to just use buttons, styled to look like anchors (except when u do actually want an anchor)?  And is the scenario I'm using at the mo common?

  11. I think your half way to getting on the right track.  I'm probably not the best person to answer your question either.  I haven't really coded in C++ so can't point out the differences.

     

    I can however pick out where I think you are going wrong.

     

    You don't need to use sessions, until you want something to be available throughout the script, like userdata, a cart perhaps, the users level of admission etc.

     

    You would only need to force users to a point of entry script, if you needed them to do anything there i.e log in.

     

    My current framework does pretty much what you said in your 2nd point.  Since everything pretty much relates to an index.php, thats a good way to start.  A benefit of that is passing users directly to securer areas of you directory, without having them specifically executing the file.  Also if you look at the URI for this thread you can see that the way you got here, was one being passed to the relevant index.php which was given a $_GET handle and id file so that it can be easily accessed and sought via google etc.

     

    Generally you must always control the $_GET data and it should be intrinsic to your framework.  All the other data that that is sent via $_POST and is user inputted, should go through some sort of validation and serialisation methods to stop your script from being broken or security breached.

     

    I think that should send you on your way a little.  But maybe someone else can elaborate more or give sum basic examples.  Good Luck and happy coding ;)

  12. Hmm, not sure if you understood what I mean.  I do that anyway.  But I suppose thats what I'm trying to do in the case laid out below...

     

    Basically, for passing $vars between methods in different classes I use globals.  This can become messy especially when trying to work out whats available to what.  Especially when stuff gets passed thought one method to get to another, which I don't think return can be useful here.

     

    Also I usually have it set up so that my form data is usually passed through a handler class that passes data onto child classes.  Which generally handles through switches.

     

    Is there a better way about going about that?

  13. Hi, I don't mean to hijack this thread, but my question's are somewhat similar to kratsg.

     

    I have been programming for about a year, and pretty much just jumped straight into OOP, I don't really understand why you wouldn't.

     

    I have been making myself a framework over the course of stuff I've done and notice I use globals allot and that it can become messy and sometimes difficult to see what belongs to what.

     

    Generally all my php files are classes and I use a function at the bottom to call a process function.

    I generally have a central class with all the main functions I use everywhere and I usually have a class sorts out what is displayed to the user.  Then all other classes are called by sorting class and do various things.

     

    What my question is, is what is the best way to be passing information around instead of having lot's of globals and particularly in reference to when a button in a template is pressed?

     

    I hope this makes sense, if not I can post some examples of my shoody programming skills to help explain.

     

    Thanks

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.