public function executePopupHelp() { $idXml = $this->hasRequestParameter('idXml') ? $this->getRequestParameter('idXml') : false; if ($idXml) { // Read doc $info['html'] = "<table border='0' cellpadding='0' cellspacing='0' id='whelp'><tr><th colspan=3><strong>Widget Help</strong></th></tr>"; $xp = XmlParser::readDocumentByUri($idXml); // Parse variables.. $module = strtok($idXml, "/"); $action = strtok("/"); $vars = afConfigUtils::getConfigVars($module, $action, $this->getRequest()); $ps = $xp->evaluate("/i:view/descendant::*[(local-name(.)='title' or local-name(.)='tooltip' or local-name(.)='help') and contains(.,'{') and contains(.,'}')]"); foreach ($ps as $node) { preg_match_all("/(\\{[^\\}]+\\})/", $node->nodeValue, $matches); foreach ($matches[1] as $tmp) { $match = true; $tmp = preg_replace("/[\\{\\}]+/", "", $tmp); if (array_key_exists($tmp, $vars)) { $node->nodeValue = str_replace("{" . $tmp . "}", $vars[$tmp], $node->nodeValue); } else { $info = array("success" => false, "message" => "The variable \"" . $tmp . "\" cannot be found among " . $idXml . " variables!"); $info = json_encode($info); return $this->renderText($info); } } } // View type $view = $xp->evaluate("//i:view")->item(0)->getAttribute("type"); // Title $title = $xp->evaluate("//i:title")->item(0)->nodeValue; $wh = $xp->evaluate("//i:description"); if ($wh->length) { $info['html'] .= "<tr><td colspan=2>" . $wh->item(0)->nodeValue . "</td></tr>"; } else { $info['html'] .= "<tr><td colspan=2>Not available..</td></tr>"; } if ($view == "edit" || $view == "show") { $fields = $xp->evaluate("//i:field[@type!='hidden']"); $info['html'] .= "<tr><th><strong>Field</strong></th><th><strong>Tip</strong></th></tr>"; $tmp = array(); $found = false; foreach ($fields as $t) { $tip = $xp->evaluate("./i:tooltip", $t); if ($tip->length == 1) { $h = $tip->item(0)->nodeValue; } else { $h = ""; } if (trim($h)) { $info['html'] .= "<tr><td>" . $t->getAttribute("label") . "</td><td>" . $h . "</td></tr>"; $found = true; } } if (!$found) { $info['html'] .= "<tr><td colspan=2>Not available..</td></tr>"; } } $info['html'] .= "</table>"; $info['winConfig']['title'] = $title . " Help"; $info['winConfig']['width'] = 500; $info['winConfig']['height'] = 300; } $info = json_encode($info); return $this->renderText($info); }
private function isUnAllowedWidget($uri) { $xp = XmlParser::readDocumentByUri($uri); $ret = $xp->evaluate("//i:view[@type='edit']|//i:view[@type='show']|//i:view[@type='wizard']")->length; if ($ret) { return false; } $module = substr($uri, 0, strrpos($uri, "/")); $method = "execute" . ucfirst(substr($uri, strrpos($uri, "/") + 1)); $class = $module . "Actions"; if (!class_exists($class) && !in_array($class, $this->classes)) { require_once $this->modules_dir . "/" . $module . "/actions/actions.class.php"; $this->classes[] = $class; } $obj = new $class($this->context, $module, $method); $ret = !method_exists($obj, $method); if ($ret) { afWidgetSelectorPeer::removeWidgetByUrl($uri); return false; } $permission = $obj->getCredential(); if (is_null($permission)) { return false; } if (is_array($permission)) { $permission = json_encode($permission); } return $permission; }