Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2019-02-25 23:18:10

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,129
Website

Re: geo_vote

lythande wrote #316181:

doesn’t work it with: $out[]= '<div class="'.$option_title_class-$1.'" … >

I’m not familiar with the plugin or its code but you want to alter - slightly to be .'-'. between the two variables if you want the classes to be linked via a hyphen:

if (${'option_title_'.$i} != '') { 
    …
    // hard coded css for alpha release
    $out[] = '<div class="' . $option_title_class . '-' . $1 . '" style="width: ' . $total_votes_percent[$i] . '%; height: 16px;"></div>';

The second thing with the title sounds like the title is being escaped twice in the code somewhere. Without finding the code, I can’t say for sure.

A way of getting around the problem in the meantime is to use curly quotes in your text, e.g. “title” or „titel“. As escaping will only affect the straight quote and straight apostrophe (along with a few other key letters and punctuation symbols), those will be unaffected.


TXP Builders – finely-crafted code, design and txp

Offline

#38 2019-02-27 09:04:00

lythande
Member
Registered: 2009-09-08
Posts: 197
Website

Re: geo_vote

Thanx you lot, Jacob!
I will try out it today evening.

After the last survey I have see another problem. The bars for “yes/no/maybe” are not really correct in the length.
e.g. a question has results:
yes: 62,5%
no: 25%
maybe: 12,5%

But the bars are not correct in the length. Normally the bar for 12,5 should be very short, but is same length how the bar for 62,5% (full wide length from page in the browser). The bar for 25% is the shortest.
Why? I think, the code cant work with the comma-separated %-length?
You can see the survey-results here

Offline

#39 2019-02-27 09:57:50

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,129
Website

Re: geo_vote

lythande wrote #316772:

The bars for “yes/no/maybe” are not really correct in the length … I think, the code cant work with the comma-separated %-length?

It’s because you have a German , instead of a decimal point in the value for width. You need it to output width:22.22%; and then it works.


TXP Builders – finely-crafted code, design and txp

Offline

#40 2019-03-02 00:32:33

lythande
Member
Registered: 2009-09-08
Posts: 197
Website

Re: geo_vote

Okay, I understand this now, thx. But the , its from the plugin-code.
How I can changing the , to . in the code?

function geo_vote_show_results($rs, $message){
$total_votes_percent = array_fill(1, 10, 0);		
				if ($total_votes > 0){
					for ($i = 1; $i <= 10; $i++) {
						$total_votes_percent[$i] = round((${'option_'.$i}/$total_votes)*100, 2);
						}
				}
...
for ($i = 1; $i <= 10; $i++){  
				if (${'option_title_'.$i} != '')	{
		 			$out[] =  '<span class="'.$option_title_class.'">'.doSpecial(${"option_title_".$i}).' ('.$total_votes_percent[$i].'%, '.${"option_".$i}.' '.geo_vote_gTxt('votes').')</span><br />';
		 			//hard coded css for alpha release 
		 			$out[] =  '<div style="background:'.$vote_bar_colour.';width:'.$total_votes_percent[$i].'%;height:16px;"></div>';
				}

Last edited by lythande (2019-03-02 00:45:37)

Offline

#41 2019-03-02 09:13:53

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,129
Website

Re: geo_vote

Ah, so it’s the language setting that is changing that. Try this small addition to the penultimate line:

function geo_vote_show_results($rs, $message){
$total_votes_percent = array_fill(1, 10, 0);		
				if ($total_votes > 0){
					for ($i = 1; $i <= 10; $i++) {
						$total_votes_percent[$i] = round((${'option_'.$i}/$total_votes)*100, 2);
						}
				}
...
for ($i = 1; $i <= 10; $i++){  
				if (${'option_title_'.$i} != '')	{
		 			$out[] =  '<span class="'.$option_title_class.'">'.doSpecial(${"option_title_".$i}).' ('.$total_votes_percent[$i].'%, '.${"option_".$i}.' '.geo_vote_gTxt('votes').')</span><br />';
		 			//hard coded css for alpha release 
		 			$out[] =  '<div style="background:' . $vote_bar_colour . ';width:' . number_format($total_votes_percent[$i], 2, '.', ',') . '%;height:16px;"></div>';
				}

The change is replacing $total_votes_percent[$i] with this number_format($total_votes_percent[$i], 2, '.', ',') which should reformat the number in the required decimal form to 2 decimal place. If that doesn’t produce the desired effect, then you can also replace it with str_replace($total_votes_percent[$i], ',', '.') to simply replace commas with dots.


TXP Builders – finely-crafted code, design and txp

Offline

#42 2019-03-04 15:18:23

lythande
Member
Registered: 2009-09-08
Posts: 197
Website

Re: geo_vote

jakob wrote #316728:

I’m not familiar with the plugin or its code but you want to alter - slightly to be .'-'. between the two variables if you want the classes to be linked via a hyphen:

if (${'option_title_'.$i} != '') {...

The second thing with the title sounds like the title is being escaped twice in the code somewhere. Without finding the code, I can’t say for sure.

Hi Jakob, much thanks! I have tried this ...'-'.$1.' . Unfortunately I getting an error:
Parse error: syntax error, unexpected '1.' (T_DNUMBER), expecting variable (T_VARIABLE) or '{' or '$' in /.../textpattern/lib/txplib_misc.php(1782) : eval()'d code on line 707

Last edited by lythande (2019-03-04 15:24:32)

Offline

#43 2019-03-04 16:53:33

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,129
Website

Re: geo_vote

Hi Lythande, may I take a look on your site? I used to have a login for your site but I don’t know if it’s still active. You know my mail address ;-)


TXP Builders – finely-crafted code, design and txp

Offline

#44 2021-02-28 11:14:39

sambooth74
Member
From: Sheffield, England
Registered: 2020-11-24
Posts: 12
Website

Re: geo_vote

I’ve not been able to get this plugin working on Textpattern 4.8.4.

I followed Bloke’s advice and replaced the mysql_ function calls, but when I access the installation page, the HTTP response never completes, and the tables don’t get created.

Does anybody know how I can get some more debug output from this plugin? Many thanks.

Last edited by sambooth74 (2021-02-28 11:15:19)

Offline

#45 2021-02-28 23:12:06

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,129
Website

Re: geo_vote

sambooth74 wrote #329074:

I’ve not been able to get this plugin working on Textpattern 4.8.4.

I had a look for you and it ended up being a bit of a rabbit hole … there are quite a few reasons why it wasn’t installing the tables: it used a word for a table column that is now an official “reserved word” along with deprecated MySQL syntax and it uses a date system that has since been changed in Textpattern. Not so surprising given that the plugin is 10 years old.

Here’s an interim test version that will install the tables on installing the plugin (no need to visit the plugin’s panel first). It also removes them again on deleting the plugin which the original didn’t. I tested adding a new vote, editing an existing vote and deleting a vote on the admin side. I haven’t, however, tested the public-side tags. Unzip the linked file, then drag the .php file to your “Upload plugin” button. You can then install and activate the plugin. You set up the “vote polls” via the Extensions › Vote panel (note: that doesn’t show if you happen to be on the install plugins panel).

Can you test that out and report back whether the public tag works as desired?

If it does, then I could do some more neatening up on the admin end: the edit panel and list of votes could be brought in line with current Textpattern methods, for example. But if the public tags don’t work properly, that may not be worth pursuing further.


TXP Builders – finely-crafted code, design and txp

Offline

#46 2021-03-01 13:56:22

sambooth74
Member
From: Sheffield, England
Registered: 2020-11-24
Posts: 12
Website

Re: geo_vote

jakob wrote #329079:

Can you test that out and report back whether the public tag works as desired?

If it does, then I could do some more neatening up on the admin end: the edit panel and list of votes could be brought in line with current Textpattern methods, for example. But if the public tags don’t work properly, that may not be worth pursuing further.

Hi Jakob, thanks for taking a look at this. I can’t test the public tag because I can’t set up a new poll. I receive the following errors (replaced sensitive details with xxx)

User_Error "Table 'xxxxx_txtp744.txpar_geo_vote_meta' doesn't exist"
in /home/xxxxx/public_html/textpattern/lib/txplib_db.php at line 448.
adminErrorHandler()
textpattern/lib/txplib_db.php:448 trigger_error()
textpattern/lib/txplib_db.php:1186 safe_query()
textpattern/lib/txplib_db.php:1034 startRows()
textpattern/plugins/geo_vote/geo_vote.php:381 safe_rows_start()
textpattern/plugins/geo_vote/geo_vote.php:177 geo_vote_meta_list()
textpattern/plugins/geo_vote/geo_vote.php:140 geo_vote_config()
textpattern/lib/txplib_misc.php:1535 geo_vote()
textpattern/index.php:231 callback_event()

This may be a good opportunity for me to learn how plugins work, and create my own, inspired by this one. Ideally it would support multiple answers (using checkboxes rather than radio buttons). It will be a nice challenge. Thanks for your help.

Offline

#47 2021-03-01 15:51:18

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,129
Website

Re: geo_vote

sambooth74 wrote #329082:

Hi Jakob, thanks for taking a look at this. I can’t test the public tag because I can’t set up a new poll. I receive the following errors (replaced sensitive details with xxx)

User_Error "Table 'xxxxx_txtp744.txpar_geo_vote_meta' doesn't exist"...

I know that was the case with the previous plugin, but is that still the case with the one I sent yesterday? That should install the tables when you install the plugin and if it can’t, it should throw an error during installation.

EDIT: I’ve updated the test version in the previous post to v0.1.6, which I have working in a simple trial with 4.8.5 and the latest PHP.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB