Jump to content

x1nick

Members
  • Posts

    74
  • Joined

  • Last visited

    Never

Everything posted by x1nick

  1. I have the following, which I thought wouldnt work but gave it a go. {foreach from=$this->toolbar_items key=id item=params} {$this->partial('toolbar/item.tpl', array('id' => id, 'params' => params))} {/foreach} Essentially this would output <?php foreach ($this->toolbar_items as $id => $params): ?> <?php echo $this->partial('toolbar/item.tpl', array('id' => $id, 'params' => $params)) ?> <?php endforeach ?> Is this even possible? I must do this a fair few times in all my projects so need to be able to do this! Cheers
  2. Ah thanks, perfect! I knew that was possible as well but it just didnt cross my mind!
  3. No idea what the correct naming is for this... In php you can do things like this $variable = 'my_class_name'; new $variable() or $variable = "class_{$class_name}" new $variable() I want to be able to do something similar in javascript, is this possible? This is my line of javascript which is clearly not going to work, but idx and file will change App.{idx}.{file} = new App.View.{file} Cheers
  4. Answred my own question http://php.net/manual/en/function.call-user-func-array.php Oops might help someone else anyway!
  5. I have a odd one here, two classes and one which calls another class. I want to pass all of the parameters from the array as seperate variables into the next function. Hope my example explains a little better class master { public function __call($name, $args) { second->$name($args); } } class second { public function example($param1, $param2) { } } master->example($param1, $param2); ( i know its not accurate php, but should get the idea of what im trying to do) I need to do something with the following line second->$name($args); Where param1 and param2 will be seperated out Is there a php function which you can tell it the class, method name and pass it an array of parameters? Thanks
  6. All seems to be working perfectly now Thanks
  7. wow, first look it looks perfect. I am assuming I can add more of (?:\ ([A-Za-z0-9]++)(?:\[([A-Za-z0-9 ]++)\]){0,1}){0,1} To increase the number of options within A 1 and A 2 for example. It would just simply re arrange the results of $matches? Thanks
  8. They could be in any order really So yes they are both the same Thanks Nick
  9. Regex isnt my strong point at all. I am writing a bit of a odd templating system where it replaces special HTML like syntax with PHP code Anyway the different types of syntax can include <fw:head> <fw:var name="test"> <fw:var name="test2" format="max"> <fw:var name="test2" format="max date[d M Y]"> Basically format could have one or two options seperated by a space, but options defined within [ ] can have spaces The name field would never have a space There are some others, but think if I can get the regex for these I can figure the rest out myself. Currently I do the following Seperate out all the <fw: possibilities in a string using preg_match_all('/<fw:(.*)>/Uis', $source, $matches); I then loop through the matches this produces looking for spaces using preg_match_all('/"(?:\\\\.|[^\\\\"])*"|\S+/', $matches[1][$i], $options); Im either looking to 1) run this all in one regex statment (would that even be possible) 2) work on the second regex to support eg="eg eg"
  10. I have a default plugin (function($) { $.lsc = function (json) { $.lsc.vars = json; if (json['toolbar']) $.lsc.toolbar (); } //Create essential functions $.extend ($.lsc, { init: function () { //some code }, }); }); This appears to work fine Now when my whole project is in debug mode, a seperate javascript file is loaded with the following (function($) { //Create essential functions $.extend ($.lsc, { toolbar: function () { alert(1); }, }); }); But I get the following error: $.lsc.toolbar is not a function How can I create a plugin and extend in a seperate file with additional functions when my project is in debug mode? I have never written a jQuery plugin before and struggling to get my head round it
  11. Sorry, my browser crashed so that may have caused it.
  12. This should be really simple but I can't get my head round it. Please see the PHP/HTML below. <?php $a = array( 'test' => "'data'" ); $json = json_encode($a); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Unknown Page</title> <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.5.min.js"></script> <script type="text/javascript"> var j = jQuery.parseJSON('<?php echo $json; ?>'); </script> </head> <body> </body> </html> You will notice that data is stored by " then ' I have tried how it is and also with add slashes $a = array( 'test' => addslashes("'data'") ); It either outputs without slashes (which is clearly wrong) var j = jQuery.parseJSON('{"test":"'data'"}'); Or which I cant work out why dosent work var j = jQuery.parseJSON('{"test":"\\'data\\'"}'); Now firebog throws the following error missing ) after argument list How should I be escaping this variable?
  13. I have mysql exported in the following sql format: - CREATE TABLE IF NOT EXISTS `pma_history` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(64) COLLATE utf8_bin NOT NULL DEFAULT '', `db` varchar(64) COLLATE utf8_bin NOT NULL DEFAULT '', `table` varchar(64) COLLATE utf8_bin NOT NULL DEFAULT '', `timevalue` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `sqlquery` text COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`), KEY `username` (`username`,`db`,`table`,`timevalue`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='SQL history for phpMyAdmin' AUTO_INCREMENT=3761 ; -- -- Dumping data for table `pma_history` -- INSERT INTO `pma_history` (`id`, `username`, `db`, `table`, `timevalue`, `sqlquery`) VALUES (2, 'root', 'information_schema', 'FILES', '2010-03-04 19:26:33', 'SELECT * FROM `FILES`') Just as an example anyway. What I need to be able to do, is import this using PHP. Does anyone know of a suitable class for doing this? I could make my own, but I cant quite work out the best way to seperate the queries out? Thanks
  14. I have a iframe which loads a php in the same directory as the html file. This PHP file can take any where from a few seconds to a miniute to execute. While executing it will output basic HTML using the php flush command so the latest data shows everytime the server executes a command. What I want to be able to do is force this iframe while loading to always scroll to the bottom or end of the page to show the latest output. is this possible?
  15. Im looking for a jQuery plugin which allows the user to resize an image using points around the image. My only example I can think of is the one here: http://tinymce.moxiecode.com/js/tinymce/jscripts/tiny_mce/plugins/imagemanager/pages/im/index.html Where when you edit an image, you have the option to resize it. Enter the new width, height and constrain proportions. Does a plugin like this exist?
  16. Basically I want to open up a png file with a transparent background which is 48x48 pixels And set the opacity of this to about 50% of the original. I have the following to do what I want but just returns an empty image On imagecolorallocatealpha i have tried setting the alpha value at different values between 0 and 127 with no success as 127 returns a black block imagecopy($menu,$image, #Positioning 0,0, 0,0, #Image size 48,48 ); #Create transparent block $new_img = imagecreatetruecolor(48, 48); imagealphablending($new_img, true); $transparent = imagecolorallocatealpha($new_img, 255, 255, 255, 0); imagefilledrectangle($new_img, 0, 0, 48, 48, $transparent); #Put block over original image imagecopy($menu,$new_img, #Positioning 0,0, 0,0, #Image size 48,48 ); The image below shows on top the original and on bottom what I am roughly trying to create Where am i going wrong?
  17. Also need a way of a user clicking the image, and creating a pin. Then store the X,Y cordinates of where the user clicked on the image Know this is possible, just not too sure the best way to go about doing it
  18. I want to do it with a custom image though, not google maps
  19. Basically need to be able to create something like below: I need to be able to specify and x and y cordinate of where to display the pin, then when a user clicks the pin I can carry out some javascript (ajax request and put contents in a div) Does anything like this exist?
  20. Ah thanks just tested in ie and chrome and issue doesn't exist! Now to work out how to get my logout function to work round this! As currently unable to destroy the session.
  21. Struggling to get my head round this, may be really simple and im just not seeing it because im tired, but why does the following code generate two files? <?php class x { var $val = ''; var $cfg = array(); public function __construct($somevalue) { $this->val = $somevalue; file_put_contents(rand(0,1000).'init','null'); } public function addcfg($name,$value) { $this->cfg[$name] = $value; } } //Create $somevalue = 'abc'; $x = new x($somevalue); //Add database config $x->addcfg('name','dbname'); $x->addcfg('user','dbuser'); $x->addcfg('pass','dbpass');
  22. Thanks $replace = 'return date(\'d-m-y\',$row_data[\'lastupdate\']);'; worked perfectly. $replace is set outside the class, the first suggested way would probably be best, but due to the way the whole system has been made, it wouldn't be easy to implment for the sake of this Thanks again
  23. So theres no simple way for me to replace {data} with some php code I thought about putting some eval code in a output buffer, but this seems a little excessive and guessing it would use quite a bit of system resources
  24. Basically I am making a class which displays a set of data. Now sometimes the data returned from the database will be a unix time stamp so this needs to be displayed in a correct form. For this I use str_replace $replace - below this will contain a way of converting the data Replace is defined by: $replace = 'date(\'d-m-y\',$row_data[\'lastupdate\'])'; $row.= str_replace('{data}',eval($replace),'<td>{data}</td>'); This just gives me Parse error: syntax error, unexpected $end in C:\xampp\htdocs\z\src\lib\lib.table.php(348) : eval()'d code on line 1 Is this possible at all?
  25. Been trying to follow this but struggling a little here to get the output I want server version: 5.1.41 Table structures -- -- Table structure for table `tpl_category` -- CREATE TABLE IF NOT EXISTS `tpl_category` ( `categoryid` int(10) NOT NULL AUTO_INCREMENT, `categoryname` varchar(20) COLLATE utf8_bin NOT NULL, `catfolder` varchar(20) COLLATE utf8_bin NOT NULL, `subcategory` tinyint(1) NOT NULL DEFAULT '0', `subcategoryid` int(10) NOT NULL DEFAULT '0', `moduleid` int(10) NOT NULL, `themeid` int(10) NOT NULL, PRIMARY KEY (`categoryid`), UNIQUE KEY `categoryname` (`categoryname`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=3 ; -- -- Dumping data for table `tpl_category` -- INSERT INTO `tpl_category` (`categoryid`, `categoryname`, `catfolder`, `subcategory`, `subcategoryid`, `moduleid`, `themeid`) VALUES (1, 'Admin', 'admin/', 0, 0, 0, 1), (2, 'Templates', 'tpl/', 1, 1, 2, 1); -- -------------------------------------------------------- -- -- Table structure for table `tpl_define` -- CREATE TABLE IF NOT EXISTS `tpl_define` ( `tplid` int(10) NOT NULL AUTO_INCREMENT, `tplname` varchar(25) COLLATE utf8_bin NOT NULL, `tpltag` varchar(25) COLLATE utf8_bin NOT NULL, `tplfile` varchar(30) COLLATE utf8_bin NOT NULL, `minify` tinyint(1) NOT NULL, `tpltype` int(10) NOT NULL, `lastupdate` int(10) NOT NULL, `categoryid` int(11) NOT NULL, PRIMARY KEY (`tplid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=5 ; -- -- Dumping data for table `tpl_define` -- INSERT INTO `tpl_define` (`tplid`, `tplname`, `tpltag`, `tplfile`, `minify`, `tpltype`, `lastupdate`, `categoryid`) VALUES (1, 'Admin Login', 'ADMIN_LOGIN', 'login.tpl', 1, 1, 1283964629, 1), (2, 'Admin HTML', 'ADMIN_INDEX', 'index.tpl', 1, 1, 1283967051, 1), (3, 'Admin Dashboard', 'ADMIN_DASH', 'dashboard.tpl', 1, 1, 1283964597, 1), (4, 'Templates Browse', 'ADMIN_TPL_BROWSE', 'tpl_browse.tpl', 1, 1, 1283990584, 2); My current query select *,`subfolder`.`catfolder` as `subfolder` from `tpl_define` join `tpl_category` on `tpl_define`.`categoryid` = `tpl_category`.`categoryid` left join `tpl_category` `subfolder` on `tpl_category`.`subcategoryid` = `subfolder`.`categoryid` Now this outputs the following Array ( [tplid] => 1 [tplname] => Admin Login [tpltag] => ADMIN_LOGIN [tplfile] => login.tpl [minify] => 1 [tpltype] => 1 [lastupdate] => 1283964629 [categoryid] => [categoryname] => [catfolder] => [subcategory] => [subcategoryid] => [moduleid] => [themeid] => [subfolder] => ) Array ( [tplid] => 2 [tplname] => Admin HTML [tpltag] => ADMIN_INDEX [tplfile] => index.tpl [minify] => 1 [tpltype] => 1 [lastupdate] => 1283967051 [categoryid] => [categoryname] => [catfolder] => [subcategory] => [subcategoryid] => [moduleid] => [themeid] => [subfolder] => ) Array ( [tplid] => 3 [tplname] => Admin Dashboard [tpltag] => ADMIN_DASH [tplfile] => dashboard.tpl [minify] => 1 [tpltype] => 1 [lastupdate] => 1283964597 [categoryid] => [categoryname] => [catfolder] => [subcategory] => [subcategoryid] => [moduleid] => [themeid] => [subfolder] => ) Array ( [tplid] => 4 [tplname] => Templates Browse [tpltag] => ADMIN_TPL_BROWSE [tplfile] => tpl_browse.tpl [minify] => 1 [tpltype] => 1 [lastupdate] => 1283990584 [categoryid] => 1 [categoryname] => Admin [catfolder] => admin/ [subcategory] => 0 [subcategoryid] => 0 [moduleid] => 0 [themeid] => 1 [subfolder] => admin/ ) What I want to do: Basically rows within tpl_define can either be within a root category or a sub category. So a result for tplid '1' no subfolder as this is under a root category Array ( [tplid] => 1 [tplname] => Admin Login [tpltag] => ADMIN_LOGIN [tplfile] => login.tpl [minify] => 1 [tpltype] => 1 [lastupdate] => 1283964629 [categoryid] => 1 [categoryname] => Admin [catfolder] => admin/ [subcategory] => 0 [subcategoryid] => [moduleid] => 1 [themeid] => 1 [subfolder] => ) Result tplid 4 which belongs in a sub category Array ( [tplid] => 4 [tplname] => Templates Browse [tpltag] => ADMIN_TPL_BROWSE [tplfile] => tpl_browse.tpl [minify] => 1 [tpltype] => 1 [lastupdate] => 1283990584 [categoryid] => 1 [categoryname] => Admin [catfolder] => admin/ [subcategory] => 0 [subcategoryid] => 0 [moduleid] => 0 [themeid] => 1 [subfolder] => tpl/ ) Note all I require is when its in a sub category is the folder (catfolder as subfolder)
×
×
  • 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.