Example #1
0
 /**
  * Get template/form proposals.
  */
 public static function getTemplateOrFormProposals($userContext, $match, $namespace)
 {
     // template context
     // parse template paramters
     $templateParameters = explode("|", $userContext);
     if (count($templateParameters) > 1) {
         // if it is a template parameter try the semantic namespaces
         $results = smwfGetAutoCompletionStore()->getPages($match, array(SMW_NS_PROPERTY, NS_CATEGORY, NS_MAIN));
         return AutoCompletionRequester::encapsulateAsXML($results);
     } else {
         // otherwise it is a template or form name
         $templates = smwfGetAutoCompletionStore()->getPages($match, array($namespace));
         $matches = array();
         if (defined('SF_NS_FORM')) {
             foreach ($templates as $t) {
                 switch ($namespace) {
                     case NS_TEMPLATE:
                         $matches[] = array($t, false, TemplateReader::formatTemplateParameters($t));
                         break;
                     case SF_NS_FORM:
                         $matches[] = array($t, false);
                         break;
                 }
             }
         } else {
             foreach ($templates as $t) {
                 $matches[] = array($t, false, TemplateReader::formatTemplateParameters($t));
             }
         }
         return AutoCompletionRequester::encapsulateAsXML($matches, $namespace != NS_TEMPLATE);
     }
 }