Beispiel #1
0
 /**
  * Construct the result definition from the contents of the ubar.xml file.
  *
  * @param class $xmlObj - XML representation of an result definition.
  *
  * @see ActionDef::getResult()
  * @see Result::getGlobalResult()
  */
 public function __construct($xmlObj)
 {
     $this->type = isset($xmlObj['type']) ? (string) $xmlObj['type'] : GlobalConstants::DEFAULT_TYPE;
     $this->name = isset($xmlObj['name']) ? (string) $xmlObj['name'] : GlobalConstants::DEFAULT_NAME;
     $this->target = (string) $xmlObj;
     if ($this->type == GlobalConstants::PAGE_TYPE && $this->target != '') {
         $this->viewLocation = FileUtils::dotToPath($this->target);
     }
     if (isset($xmlObj['template'])) {
         $this->templateName = (string) $xmlObj['template'];
     }
 }
Beispiel #2
0
 /**
  * Construct the action definition from the contents of the ubar.xml file.
  *
  * @param class $xmlDef - XML representation of an template definition.
  *
  * @see ActionMapper::getTemplate()
  */
 public function __construct($xmlDef)
 {
     if (!is_null($xmlDef->attributes()->path)) {
         $pathString = (string) $xmlDef->attributes()->path;
         $this->path = FileUtils::dotToPath($pathString);
     }
     foreach ($xmlDef->param as $param) {
         $attribs = $param->attributes();
         $name = (string) $attribs->name;
         $value = (string) $attribs->value;
         $this->addParam($name, $value);
     }
 }
Beispiel #3
0
 /**
  * Constructor for all definitions: actions, default action, global
  * results, templates, etc.
  *
  * @param string Path to ubar.xml file.
  *
  * @todo Make parsing failures be more graceful and provide more meaninful feedback.
  */
 public function __construct($file)
 {
     // convert xml of action definitions to an xml object
     libxml_clear_errors();
     $actionDefsXML = simplexml_load_file($file, "SimpleXMLElement", LIBXML_DTDVALID);
     if (libxml_get_last_error()) {
         throw new Exception('Error validating / loading XML');
     }
     // get the name of the default action
     $this->defaultActionName = (string) $actionDefsXML->defaultAction['name'];
     // get the name of the default action
     if (!is_null($actionDefsXML->dummyAction['path'])) {
         $this->dummyActionPath = FileUtils::dotToPath((string) $actionDefsXML->dummyAction['path']);
     }
     // assign actions as a local variable
     $this->actions = $actionDefsXML->actions->action;
     // assign results as a local variable
     $this->globalResults = $actionDefsXML->globalResults->result;
     // assign permission groups as a local variable
     $this->permissionGroups = $actionDefsXML->permissionGroups;
     // assign permission groups as a local variable
     $this->templates = $actionDefsXML->templates->template;
 }
Beispiel #4
0
 /**
  * Construct the action definition from the contents of the ubar.xml file.
  *
  * NOTE: If no path is defined for the action, a dummy action that always
  * returns GlobalConstants::SUCCESS will be used.
  *
  * @param class $actionXML - XML representation of an action definition.
  *
  * @see ActionMapper::getAction()
  */
 public function __construct($actionXML)
 {
     $path = (string) $actionXML['path'];
     // use dummy action if no action defined
     if ($path != '') {
         $this->actionLocation = FileUtils::dotToPath($path);
         $this->actionClassName = FileUtils::classFromFile($this->actionLocation);
     } else {
         $this->actionClassName = GlobalConstants::DUMMY_ACTION;
     }
     if (!is_null($actionXML['template'])) {
         $this->templateName = (string) $actionXML['template'];
     }
     if (!is_null($actionXML['view'])) {
         $this->viewLocation = FileUtils::dotToPath((string) $actionXML['view']);
     }
     $this->results = $actionXML->results->result;
     $this->permissionGroup = $actionXML->permissionGroup;
     $this->permissions = $actionXML->permissions;
     $this->name = (string) $actionXML['name'];
     // add params
     foreach ($actionXML->param as $param) {
         $attribs = $param->attributes();
         $name = (string) $attribs->name;
         $value = (string) $attribs->value;
         $this->addParam($name, $value);
     }
     // display values
     $this->title = (string) $actionXML['title'];
     $this->titleKey = (string) $actionXML['titleKey'];
     // TODO: page mostly makes sense as action name, consider decoupling however
     $this->page = (string) $actionXML['name'];
     $this->section = (string) $actionXML['section'];
     $this->subSection = (string) $actionXML['subSection'];
 }
Beispiel #5
0
 function testDotToPath()
 {
     $this->assertEquals("this/is/a/path/to/a/file.php", FileUtils::dotToPath("this.is.a.path.to.a.file"));
 }