summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormetzlerd2013-05-31 18:03:22 (GMT)
committer metzlerd2013-05-31 18:03:22 (GMT)
commit6a6fe1cdae86db03f5f4ee2ad23b21b9f76476b3 (patch)
tree653af76b5090d8f36b6f6e4dbf7e028187842e99
parent63eea5239faef2a7f25d63622c5e0b67b4884773 (diff)
First attempt at link validations.
-rwxr-xr-xFrxDrupalApplication.inc8
-rwxr-xr-xFrxReport.inc48
-rwxr-xr-xFrxReportGenerator.inc4
3 files changed, 46 insertions, 14 deletions
diff --git a/FrxDrupalApplication.inc b/FrxDrupalApplication.inc
index 41b893c..e76725a 100755
--- a/FrxDrupalApplication.inc
+++ b/FrxDrupalApplication.inc
@@ -29,14 +29,6 @@ class FrxDrupalApplication {
}
- /**
- * Convert a relative link to appropriately rendered html
- * return html A properly formatted anchor tag
- */
- public function link($title, $path, $options=array()) {
- return l($title, $path, $options);
- }
-
public function url($path, $options = array()) {
return url($path, $options);
}
diff --git a/FrxReport.inc b/FrxReport.inc
index 9768c9e..d4b5d57 100755
--- a/FrxReport.inc
+++ b/FrxReport.inc
@@ -30,6 +30,7 @@ class FrxReport {
public $missing_parms = FALSE;
private $dom;
private $format;
+ private $link_mode = 'remove';
public function __construct($xhtml, $data=array()) {
@@ -174,6 +175,13 @@ class FrxReport {
$frx = $node->attributes(FRX_NS);
$elements = $dom_node->childNodes->length;
+
+ // Check for invalid link processing.
+ if (@(string)$frx['invalid_link']) {
+ $old_link_mode = $this->link_mode;
+ $this->link_mode = (string)$frx['invalid_link'];
+ }
+
// Test to see if we have any nodes that contain data url
if ($node->xpath('*//@frx:*') || $frx) {
$attrs = $node->attributes();
@@ -280,6 +288,11 @@ class FrxReport {
$o .= $this->teng->replace($text);
}
+ // Restore link processing.
+ if (@(string)$frx['invalid_link']) {
+ $this->link_mode = $old_link_mode;
+ }
+
return $o;
}
@@ -313,6 +326,35 @@ class FrxReport {
Frx::Data()->pop();
return $o ;
}
+
+
+ /**
+ * Convert a relative link to appropriately rendered html
+ * return html A properly formatted anchor tag
+ */
+ public function link($title, $path, $options=array()) {
+ // check if we have
+ $l = '';
+ if (strpos($path, ':')===FALSE) {
+ $valid = drupal_valid_path($path,FALSE);
+ switch ($this->link_mode) {
+ case 'remove':
+ $l = '';
+ break;
+ case 'no-link':
+ $l = $valid ? l($title, $path, $options) : $title;
+ break;
+ case 'disable':
+ dpm($options);
+ default:
+ $l = l($title, $path, $options);
+ }
+ }
+ else {
+ }
+
+ }
+
/*
* Formatter used by the syntax engine to alter data that gets extracted.
* This invokes the field translation
@@ -390,8 +432,10 @@ class FrxReport {
$data = array_merge($parms, $data);
}
if (trim($url)) $value = FrxReportGenerator::instance()->link(
- htmlspecialchars_decode($value), $url,
- array('fragment' => $fragment, 'query' => $data, 'attributes' => $attributes, 'absolute' => TRUE));
+ htmlspecialchars_decode($value),
+ $url,
+ array('fragment' => $fragment, 'query' => $data, 'attributes' => $attributes, 'absolute' => TRUE)
+ );
}
return $value;
}
diff --git a/FrxReportGenerator.inc b/FrxReportGenerator.inc
index b203d39..58852cb 100755
--- a/FrxReportGenerator.inc
+++ b/FrxReportGenerator.inc
@@ -271,10 +271,6 @@ class FrxReportGenerator {
return $this->app->configuration('report_repos');
}
- public function link($title, $path, $options=array()) {
- return $this->app->link($title, $path, $options);
- }
-
public function url($path, $options = array()) {
return $this->app->url($path, $options);
}