<![CDATA[ Support/Comments for PHx - My Forums]]> https://forums.modx.com/thread/?thread=45302 <![CDATA[Re: Support/Comments for PHx]]> https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261670 Create new posts here.]]> rethrash Dec 06, 2008, 09:08 AM https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261670 <![CDATA[Re: Support/Comments for PHx]]> https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261669

http://modxcms.com/forums/index.php/board,328.0.html]]>
zaigham Dec 05, 2008, 02:10 PM https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261669
<![CDATA[Re: Support/Comments for PHx]]> https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261668

Thanks!

quick question... it seems like phx could be used to escalate user privlege... some sites have a lot of manager users and if you put in phx code you might be able to say this page has this type of security needed etc..

im sure there are other plugins the let you add shells.. so maybe its not a sizeble threat.]]>
antirem Dec 03, 2008, 01:56 PM https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261668
<![CDATA[Re: Support/Comments for PHx]]> https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261667
/mnt/target03/358650/www.arezombiesattacking.com/web/content/assets/]]>
Metaller Dec 03, 2008, 02:18 AM https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261667
<![CDATA[Re: Support/Comments for PHx]]> https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261666 I copied all of the contents of phx.plugin.txt in my new plugin called "PHx".. then i set the system event to "OnParseDocument"

(i am doing everything right)

This results in the modx error of..
« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »
 
PHP error debug
  Error: 	include_once(/assets/plugins/phx/phx.parser.class.inc.php) [function.include-once]: failed to open stream: No such file or directory	 
  Error type/ Nr.: 	Warning - 2	 
  File: 	/mnt/target03/358650/www.arezombiesattacking.com/web/content/manager/includes/document.parser.class.inc.php(745) : eval()'d code	 
  Line: 	10	 
 
Parser timing
  MySQL: 	0.0121 s	(3 Requests)
  PHP: 	0.1680 s	 
  Total: 	0.1801 s	 


The file IS there... i am not calling phx even yet.

What should i do?]]>
antirem Dec 03, 2008, 01:01 AM https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261666
<![CDATA[Re: Support/Comments for PHx]]> https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261665 Parsing arrays (or other complex variables)

Hi,
maybe I’m heading for a very hard way to solve a simple issue - please help me.

I’m using phx through Chunkie class in a snippet (not installing phx as a plugin).
Everithing seems ok. Very useful the new template-file feature!

My snippet needs to output simple or complex variables: strings or arrays (of strings and of arrays of...). I’ve got to use a template regardless type of variables (type and composition can’t be foreseen).
I modified method CreateVars of Chunkie class, because it seems not possible to pass an array to a modifier:
function CreateVars($value = '', $key = '', $path = '') {
$keypath = !empty($path) ? $path . "." . $key : $key;
	if (is_array($value)) {
	    		
	     // added
	     //		type		name		fields
	     $info_string =	'array'.',' .	$keypath.',' .	implode(',' , array_keys($value));
	    		 				
             foreach ($value as $subkey => $subval) {
	     $this->CreateVars($subval, $subkey, $keypath);
	}
			
	// added
	$this->CreateVars($info_string, '__info', $keypath);			
	}
	else {
		$this->phx->setPHxVariable($keypath, $value);
	}
}

By this, if I pass an array:
$aaaa = array( "field1" => 5, "field2" => array( "field21" => 2));

as phx variable ’aaaa’ I get the placeholders:
[+aaaa.__info+] = "array,aaaa,field1,field2" (added placeholder containing type, name, fields list)
[+aaaa.field1+] = "5" (no news)
[+aaaa.field2.__info+] = "array,aaaa.field2,field21" (added placeholder containing type, name, fields list)
[+aaaa.field2.field21+] = "2" (no news)

while I can’t get placeholders for aaaa and aaaa.field2 because they’re not simple variables.

In this way I can create a template like
[+phx:input=`[+aaaa+]`:elements=`[+aaaa.__info+]`+]

which calls method elements:
<?php

if ($options == '') return $output;		// $output is a simple variable!!

$var_info = explode(',',$options);
$var_type = $var_info[0];

switch ($var_type) { // will add object type?
	case 'array':
		$var_name = $var_info[1];
		$var_fields_array = array_slice($var_info, 2);
		break;
	default:
		break;
}

$string .= '<h5>' . $var_name . ' = ' . $var_type . '</h5><br/>
';
$string .= '<ul>
';

foreach ($var_fields_array as $fieldname) {
	$field_placeholder = '[+' . $var_name . '.' . $fieldname . '+]';
	$options_placeholder = '[+' . $var_name . '.' . $fieldname . '.__info' . '+]';
	$string .= '<li>' . $fieldname . ' = ' . '[+phx:input=`' . $field_placeholder . '`:elements=`' . $options_placeholder . '`+]' . '</li>
';
}
$string .= '</ul>
';

return $string;
?>

which calls itself each time an element is an array.

the output is
aaaa = array
- field1 = 5
- field2 = aaaa.field2 = array
- field21 = 2

This is the only way I found to explore complex variables: I only have to know the variable name - no need to know if it is simple, an array and which fieldnames.
Of course this is just a test.

Two questions:
1 - Is there a different simple way to pass arrays as variables and use them with phx placeholders when the template doesn’t know field names?
2 - Is there a way to use templates within a modifier code (avoiding html tags into the modifier).
(3 - any other suggestion is welcome..)

thanks in advance]]>
asamax01 Aug 24, 2008, 02:00 PM https://forums.modx.com/thread/45302/support-comments-for-phx?page=22#dis-post-261665
<![CDATA[Re: Support/Comments for PHx]]> https://forums.modx.com/thread/45302/support-comments-for-phx?page=21#dis-post-261664 TobyL Jun 30, 2008, 10:18 AM https://forums.modx.com/thread/45302/support-comments-for-phx?page=21#dis-post-261664 <![CDATA[Re: Support/Comments for PHx]]> https://forums.modx.com/thread/45302/support-comments-for-phx?page=21#dis-post-261663
The real pain is creating complex nested conditions that combined "and" and "or" logic. It gets very messy very quickly. For one thing, it’s hard for me to keep track of all of the conditions being processed when the conditions are spread around in so many places. I’m more likely to make errors, and it’s harder to debug because you can’t do it at a quick glance. All of the conditions get mixed in with complex content that also has conditions. It’s very messy.]]>
paulb Jun 29, 2008, 11:02 AM https://forums.modx.com/thread/45302/support-comments-for-phx?page=21#dis-post-261663
<![CDATA[Re: Support/Comments for PHx]]> https://forums.modx.com/thread/45302/support-comments-for-phx?page=21#dis-post-261662
[+tv1:isnot=``:then=`At least one of these is not empty.`:else=`
[+tv2:isnot=``:then=`At least one of these is not empty.`:else=`
[+tv3:isnot=``:then=`At least one of these is not empty.`+]
`+]
`+]


As you says, it is not as elegant as a single conditional statement but it works.]]>
Metaller Jun 29, 2008, 01:26 AM https://forums.modx.com/thread/45302/support-comments-for-phx?page=21#dis-post-261662
<![CDATA[Re: Multiple conditions in PHx]]> https://forums.modx.com/thread/45302/support-comments-for-phx?page=21#dis-post-261661 Quote from: Metaller at Jun 28, 2008, 06:00 PM

You can use multiple variables like that

[+tv1:isnot=``:then=`
[+tv2:isnot=``:then=`<p>Template Variable 1 and Template Variable 2 are not empty</p>`+]
`+]

That will work for some things -- though it is not as elegant as a single conditional statement -- but a common situation for me is the need to check to see if at least one value is not empty. In other words, I need an "or" condition, something like this:

if ( ($tv1 != '') || ($tv2 != '') || ($tv3 != '') ) echo 'At least one of these is not empty.';
]]>
paulb Jun 28, 2008, 01:17 PM https://forums.modx.com/thread/45302/support-comments-for-phx?page=21#dis-post-261661