*/ /** * patTemplate-function for ediatable XML content * * User XML markup handler to transform to HTML. * Also users may edit content. After that, the new content will be stored * in database. * * @version 0.3.0 * @package Wombat * @subpackage patTemplate */ class patTemplate_Function_Wxml extends patTemplate_Function { /** * name of the function * @access private * @var string */ public $_name = 'Wxml'; /** * tell that this function has to be executed during runtime * @var string */ public $_type = PATTEMPLATE_FUNCTION_RUNTIME; /** * call the function * * @access public * @param array $params parameters of the function (= attributes of the tag) * @param string $content inside tag * @return string content to insert into the template */ public function call($params, $content) { // content must be XML like $content = trim($content); if (empty($content)) { return ''; } // prepare attributes $params = array_merge(array( 'class' => '', 'requiredgroup' => '', 'requirededitorgroup' => '', 'cs' => '' ), $params); // don't show content if user is not in requiredgroup if (!empty($params['requiredgroup'])) { WBClass::load('WBUser'); $user = WBUser::getCurrent(); if (!$user->isInGroup($params['requiredgroup'])) { return ''; } } // find url WBClass::load('WBString'); if (isset($params['path']) && !empty($params['path'])) { $url = WBString::replaceSuperPlaceholders('[[SELF]][[PATH]]', $params['path']); } else { $req = WBClass::create('WBRequest'); $url = WBString::replaceSuperPlaceholders('[[SELF]][[PATH]]', $req->path); } $wxml = WBClass::create('WBMarkup_Wxml'); if (empty($params['cs'])) { $cs = md5($content); } else { $cs = $params['cs']; } $wxml->load($cs, $content); $wxml->setEditorGroup($params['requirededitorgroup']); $wxml->setClassname($params['class']); $wxml->setUrl($url); return $wxml->getHtml(); } }