Re: [PHP] Highlighting image map on load
I'm not sure if you can use CSS alone to highlight, but if you can, just give the area a class as you output it with PHP That's the problem, area itself isn't visible, so giving a CSS class won't highlight it. -- View this message in context: http://old.nabble.com/Highlighting-image-map-on-load-tp26777088p26807008.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Highlighting image map on load
I have image map with dynamic circle areas whose coordinates stored in database. I'd like to colorize these areas so that it's obvious to see them. Most solutions I found on the net highlights the area on mouse hover, while my needs is to do it once when the window is loaded. Any idea? -- View this message in context: http://old.nabble.com/Highlighting-image-map-on-load-tp26777088p26777088.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multilingual website, texts in external JavaScript problem
I don't see why you can't use inline script in XHTML 1.0 Strict Because I don't know about CDATA, thanks. -- View this message in context: http://old.nabble.com/Multilingual-website%2C-texts-in-external-JavaScript-problem-tp26261666p26278740.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Multilingual website, texts in external JavaScript problem
I need to create a multilingual website and my framework already gives me that facility. However, I also use JavaScript quite extensively and since XHTML 1.0 Strict doesn't allow inline script, I must use external .js file. The problem is in these scripts, there are strings that needs to be translated as well. How can I make PHP parse these scripts as well? Or are there alternative approaches? -- View this message in context: http://old.nabble.com/Multilingual-website%2C-texts-in-external-JavaScript-problem-tp26261666p26261666.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calling extension function from another
extension A has function a, extension B has function b. How can I make b calls a? -- View this message in context: http://www.nabble.com/Calling-extension-function-from-another-tp25185839p25200892.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Calling extension function from another
Is it possible to call a function that resides in an extension from another extension? -- View this message in context: http://www.nabble.com/Calling-extension-function-from-another-tp25185839p25185839.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] anchor inside form
If I have an anchor inside form, how can I send form using the anchor without displaying target url? I've tried the code below but IE says that this.form is null or empty and Firefox does nothing. form action=somewhere.php method=get # Pick me /form -- View this message in context: http://www.nabble.com/anchor-inside-form-tp25129981p25129981.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] anchor inside form
Why not just use another submit button? Because it's actually an entry in a tree-like menu. I need to send parameters via get method, and code above is one way I can think of. -- View this message in context: http://www.nabble.com/anchor-inside-form-tp25129981p25131146.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] HTML text extraction
Usually, a website gives preview of its articles by extracting some of the first characters. This is easy if the article is a pure text, but what if it's a HTML text? For instance, if I have the full text: p bla bla bla ul liitem 1/li liitem 2/li liitem 3/li /ul /p and I take the first 40 characters, it would result in: p bla bla bla ul liitem As you can see, the tags are incomplete and it might break other texts below it (I mean, other than this preview). I need a way to solve this problem. -- View this message in context: http://www.nabble.com/HTML-text-extraction-tp25020687p25020687.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Radio buttons problem
Unless, of course, what you have is name[], email[], sex[0] name[], email[], sex[1] name[], email[], sex[2] Yep, that's exactly what I have. If it's important to you that the indexes match across name[], email[] and sex[], then you must supply them explicitly for every field in the group I guess there's no other way than this, so OK I'll do it. Thanks. -- View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24912487.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Radio buttons problem
Why do you? There's no reason you *have* to have consecutive indexes -- just iterate over the resulting array with foreach, and there's no problem. There is, the entries are grouped by its index. So, I group name[0], email[0], and sex[0] as one. The problem if I don't maintain the index for radio buttons, the index could go wrong. In the previous example I gave, if entry2 is deleted (and I don't maintain the index) then entry3 will contain name[1], email[1], and sex[2] which isn't desirable. -- View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24897287.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Radio buttons problem
you will have to manually maintain the number in the bracket. but you can try using a template engine like smarty, and use a for loop to take care of the numbers in the brackets Well.. the entries are inserted / deleted dynamically using JavaScript (to avoid unnecessary refresh). Why can't it be a multidimensional array? something like sex[][], first bracket denotes for which entry this field is, second is for which choice is chosen. -- View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24859548.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Radio buttons problem
This should work: input type='radio' name='sex[1]' value='1' input type='radio' name='sex[1]' value='2' input type='radio' name='sex[2]' value='1' input type='radio' name='sex[2]' value='2' Yes, that works. But should I manually maintain the number in the bracket? Is there anyway so that it can be automatically maintained? Because my app allows to delete entries arbitrarily. For instance, consider this layout (+ is insert button, - is delete): entry1 +/- entry2 +/- entry3 +/- entry1 has sex[0] field, entry2 has sex[1] and so on. If entry2 is deleted, then I have to change all sex fields in entries below entry2 which is a waste of time. -- View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24858699.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Radio buttons problem
I'm creating a form with variable number of entries (user controlled) where each entry consists of some input fields. For most input types, appending [] to their names is enough to allow me processing each entry. So, for instance, if there are 3 entries with field name[] and email[], they can be accessed as: name = Array( 0 = 'name1', 1 = 'name2', 2 = 'name3' ) email = Array( 0 = 'email1', 1 = 'email2', 2 = 'email3' ) However, this isn't the case for radio buttons. Let's see a common usage: sex determinition. Using sex[] will make the one in an entry to behave dependently to another. This is due to the radio button behavior to group choices based on name. How can I make a radio button in one entry to behave independently from the one in another so that it can be accessed as name and email above? -- View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24786766.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if elseif elseif elseif....
Daniel Brown-7 wrote: On Wed, Mar 4, 2009 at 20:10, Al n...@ridersite.org wrote: $obligatoryFieldNotPresent=null; foreach($_POST, as $value) { if(!empty($value)continue; Parse error. ;-P There should be no comma there. See http://id2.php.net/manual/en/control-structures.foreach.php this . -- View this message in context: http://www.nabble.com/if-elseif-elseif-elseif-tp22341403p22346913.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] optimizing space for array of booleans
but you're trying to pass stuff to it: public function tostring() { $str = $this-binstr($this-bits[0]); for ($i=1;$i8;$i++) $str .= , . $this-binstr($this-bits[$i]); return $str; } Slap (on my face)! My stupidity... I come from a strongly typed language background and dynamically typed language often makes me less careful. Thanks, good job =). -- View this message in context: http://www.nabble.com/optimizing-space-for-array-of-booleans-tp22159131p22198832.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] optimizing space for array of booleans
Just tried serializing array of 256 booleans and printing the length, it really shocked me: 2458. This project will be used by about 500 students, so in the worst case (all students enroll all courses) it will eat 500 * 2458 (assuming one character eats one byte) = 1229000 Bytes ~= 1.2 MB. Not a big deal, eh? -- View this message in context: http://www.nabble.com/optimizing-space-for-array-of-booleans-tp22159131p22177808.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] optimizing space for array of booleans
Generally relationships like the one you describe are stored in three separate and related tables: Students, Courses, and Enrollment. The latter is a n:m association between the first two. The advantage this approach has with regard to storage is that it is a sparse matrix. I've done that and I'm playing around with the last one, this is where the problem arise. It's a table with two columns, user id the 'set' that stores the enroll information. Since SQL doesn't have 'nice set data type' (MySQL has it but it's restricted to 64 entries, and it's difficult to use), I need to cover the problem from PHP side. Most students will only enroll in a handful of courses. With this approach, you only store a row in the Enrollment table if a student is enrolled in a course. Otherwise, you don't need to store anything. Do you mean that, for example, if student A enrolls course x,y,z the table would be: user_id | course ---+--- A|x A|y A|z Students often forget (or are lazy) to unenroll after they've finished studying. Wouldn't the database be bloated? And what would be the primary key? And no, 1.2MB is not that big of a deal. A single floppy high-density drive could hold that much data 18 years ago! Yeah, but now I'm also considering the speed. So, I decided to build a class that implements bitset operations and I'm gonna store the contents in database as string. Here's the code: class bitset { private $bits; private function index($bit) { return $bit / 32; } private function offset($bit) { return $bit % 32; } private function binstr() { $temp_bits = $this-bits; $str = ; for ($i=0;$i32;$i++) { $str = strval($temp_bits 1) . $str; $temp_bits = 1; } return $str; } public function __construct() { $this-bits = array(0,0,0,0,0,0,0,0); } public function tostring() { $str = $this-binstr($this-bits[0]); for ($i=1;$i8;$i++) $str .= , . $this-binstr($this-bits[$i]); return $str; } public function set($bit) { $index = $this-index($bit); $offset = $this-offset($bit); $this-bits[$index] |= 1 $offset; } public function clear($bit) { $index = $this-index($bit); $offset = $this-offset($bit); $this-bits[$index] = ~(1 $offset); } public function test($bit) { $index = $this-index($bit); $offset = $this-offset($bit); return $this-bits[$index] (1 $offset); } } little problem: tostring() method always returns 00..001,00..001,.. regardless $bits contents. binstr() has been tested and works fine, what might be wrong? -- View this message in context: http://www.nabble.com/optimizing-space-for-array-of-booleans-tp22159131p22196477.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] optimizing space for array of booleans
Good points, I'll try it. Without testing it (it's late here), your binstr() function doesn't accept parameters, so it would always return the same result each time it's called, regardless of what you pass into it. In case you want to check it tomorrow or later: private function binstr() { $temp_bits = $this-bits; $str = ; for ($i=0;$i32;$i++) { $str = strval($temp_bits 1) . $str; $temp_bits = 1; } return $str; } it doesn't accept parameters, but instead use private field $bits assigned to $temp_bits (PHP manual states that it will be copied instead of referenced, and it's exactly what I need). -- View this message in context: http://www.nabble.com/optimizing-space-for-array-of-booleans-tp22159131p22196899.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] optimizing space for array of booleans
Some languages allows to bit-pack structures to save spaces. Since PHP doesn't have native set data type and operations, will array of booleans be optimized as such? If not, how can I achieve the same result? I need to save about 200 boolean values and I guess it's a good idea to use bitsets. Requirements: - Easy to use (set, unset, test), so C way to use bitwise operations is simply rejected. I need something like Pascal's set. - Small space (bit level if possible) -- View this message in context: http://www.nabble.com/optimizing-space-for-array-of-booleans-tp22159131p22159131.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] optimizing space for array of booleans
you should not worry about optimizing boolean values unless you would store them in database. I DO need to store them in a database, that's why I'm asking. I won't care if I only use PHP, since it won't keep my data in memory for a long time. anyways, use bitwise operators I think I've stated that I don't want to use bitwise operations. It's OK for small sets, but not for a set with about 200 elements. Anyway, I found bitset library in PECL, but I found no documentation at all. -- View this message in context: http://www.nabble.com/optimizing-space-for-array-of-booleans-tp22159131p22174206.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Class constant inconsistency
I've read the docs about class constants and found some inconsistency (at least according to my knowledge), namely in the following statement: The value must be a constant expression, not (for example) a variable, a class member, result of a mathematical operation or a function call. Questions: Can't result of a mathematical operation be a constant expression? What is the answer of 1 + (2 - 3) * 4 / 5? Does it depend on a value that can't be determined immediately (i.e. variable)? In the name of maintainability, we do need mathematical operation as constant expression (based on true story). For example, see the following code: // constants used to add log entry // authentication related const action_login = 1; const action_logout = action_login + 1; // sco related const action_create_sco = action_logout + 1; const action_search_sco = action_create_sco + 1; const action_list_sco = action_create_sco + 2; const action_edit_sco = action_create_sco + 3; const action_delete_sco = action_create_sco + 4; // eLesson related const action_create_lesson = action_delete_sco+ 1; const action_search_lesson = action_create_lesson + 1; const action_list_lesson= action_create_lesson + 2; const action_edit_lesson= action_create_lesson + 3; const action_delete_lesson = action_create_lesson + 4; const action_export_lesson = action_create_lesson + 5; const action_import_lesson = action_create_lesson + 6; // eCourse related const action_create_course = action_import_lesson + 1; const action_search_course = action_create_course + 2; const action_list_course= action_create_course + 3; const action_edit_course= action_create_course + 4; const action_delete_course = action_create_course + 5; const action_export_course = action_create_course + 6; const action_import_course = action_create_course + 7; const action_play_course= action_create_course + 8; // profile related const action_edit_profile = action_play_course + 1; const action_edit_password = action_edit_profile + 1; Does any of them results in a non-constant expression? Well, I can easily subtitute each value by hand. But what if I forget to add one (enough to get you frustrated) that should be inserted as the second entry? I need to adjust the other 23 (there are 24 of them) by hand! Using above code, I only need to adjust action_logout to action_login + 2 and everyone's happy. In case anybody has a solution without altering the implementation, please tell me. I'm not a PHP master so I might be coding it in the wrong way. Please don't suggest define() since it has global scope (i.e. no encapsulation). P.S.: I think this should work also for other constant expression (e.g. string), like: Hello . World -- View this message in context: http://www.nabble.com/Class-constant-inconsistency-tp21906832p21906832.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Visibility of class constant
Got it, thanks. I see that PHP is unlike many other OO language, it's a little stricter in scoping. -- View this message in context: http://www.nabble.com/Visibility-of-class-constant-tp21803985p21823751.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Visibility of class constant
I got a weird behaviour of class constant. Suppose I have Index_Controller and Another_Controller classes, both extending Controller class. I define some constants (let's assume I only have one, call it MY_CONST) in Controller class to be used by its descendants. In Index_Controller, I can freely use MY_CONST without parent:: needed. However, this isn't the case with Another_Controller. Without parent:: I got notice Use of undefined constant MY_CONST - assumed 'MY_CONST'. How could this happen and what's the correct behaviour? It's actually nicer to have it without parent::, assuming that constants have protected visibility specifier (which isn't possible AFAIK :-( ). -- View this message in context: http://www.nabble.com/Visibility-of-class-constant-tp21803985p21803985.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Please explain: index.php/index/index
I don't understand it. index.php should be a file and indeed it's a file, so what does /index/index after it mean? There's no index directory under directory where index.php resides. -- View this message in context: http://www.nabble.com/Please-explain%3A-index.php-index-index-tp21578728p21578728.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Please explain: index.php/index/index
Carlos Medina-2 wrote: this is a Front Controller situation (Pattern) Could you explain more on that? I've never seen anything like this in any tutorial I've found on the net. I'm using kohana framework. So, if I have index.php/index/index where does it actually go? -- View this message in context: http://www.nabble.com/Please-explain%3A-index.php-index-index-tp21578728p21579231.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Please explain: index.php/index/index
Is this web server specific? I can't get it to run under Microsoft IIS, but it works flawlessly in Apache. -- View this message in context: http://www.nabble.com/Please-explain%3A-index.php-index-index-tp21578728p21579384.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Please explain: index.php/index/index
Boyd, Todd M. wrote: IIRF - Ionics ISAPI Rewrite Filter [1] is totally free... and it supports the use of Regular Expressions [2] in your rewrite rules. If you're going to use any sort of MVC-based URLs in IIS, this library is a must-have. Thanks for the link, I'll try it tonight. -- View this message in context: http://www.nabble.com/Please-explain%3A-index.php-index-index-tp21578728p21598988.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php