From: <rd...@us...> - 2008-06-13 16:43:46
|
Revision: 719 http://digir.svn.sourceforge.net/digir/?rev=719&view=rev Author: rdg Date: 2008-06-13 09:42:14 -0700 (Fri, 13 Jun 2008) Log Message: ----------- * Display mapping button for complex elements if they accept simple content. * Show indexing radio in all nodes (disabled for attributes). * Other adjustments in layout. Modified Paths: -------------- tapirbuilder/trunk/lib/TpToolSchemaTreeBrowser.php tapirbuilder/trunk/www/getstructure.php Modified: tapirbuilder/trunk/lib/TpToolSchemaTreeBrowser.php =================================================================== --- tapirbuilder/trunk/lib/TpToolSchemaTreeBrowser.php 2008-06-13 13:26:26 UTC (rev 718) +++ tapirbuilder/trunk/lib/TpToolSchemaTreeBrowser.php 2008-06-13 16:42:14 UTC (rev 719) @@ -1,4 +1,3 @@ - <?php /** @@ -206,21 +205,9 @@ // to store the whole tree view (it would be too demanding for the RAM allowed to PHP) function PrintHtmlTreeArray() { - - //if HTMLTreeArray is defined (it is an instance of "TpToolArraForTreeView") - //if(isset($this->HTMLTreeArray)===true) - //{ - // - // //store URL of the ResponseStructure in a hidden field which is on top of the treeview - // //This value is caught as an HTTP parameter by the class which produces the OutputModel - // //(see 'TpToolOutoutModel') - // print($this->createHiddenForSchemaLocation($this->mHTTPSchemaLoc, $this->mOutputStructureLocation)."\n"); - // $this->HTMLTreeArray->displayTreeView(); - // print("<br/>\n"); - // } print($this->createHiddenForSchemaLocation($this->mHTTPSchemaLoc, $this->mOutputStructureLocation)."\n"); - $this->callXSSchemaNavigator(); + $this->callXSSchemaNavigator(); } @@ -331,30 +318,41 @@ //function which creates a HTML radio button for the defintion of the indexing element //beware: all radio button are bound to the same HTTP variable //must share the same "name" attribute. - //input parameters are: id suffix of control, path of bound xml element (which is the value of the control) - function createIndexationButton($idHTMLButton, $nodePath) + //input parameters are: id suffix of control, path of bound xml element (which is the value of the control) and disabled + function createIndexationButton($idHTMLButton, $nodePath, $disabled) { - return "<input type=\"radio\" id=\"Option_".$idHTMLButton."\" name=\"".$this->nameIndexerControl."\" value=\"".$nodePath."\"/>"; + $disabled = ($disabled) ? ' disabled' : ''; + return "<input type=\"radio\" id=\"Option_".$idHTMLButton."\" name=\"".$this->nameIndexerControl."\" value=\"".$nodePath."\"$disabled/>"; } //function that returns the HTML that starts a new node in the treeview - //input parameters are: node name, node path, suffix to be used in the indexing element radio button, HTML for open/close buttons and HTML for concept select (?) - function getGeneralPrefix($nodeName, $nodePath, $ctrlCode, $button='', $select='') + //input parameters are: node path, suffix to be used in the indexing element radio button, HTML for open/close buttons and flag to indicate if the node has simple content + function getGeneralPrefix($nodePath, $ctrlCode, $openButton, $simpleContent, $isAttribute) { - // Attributes can never be indexing elements - $radioButton = ( strpos($nodePath, '@') === false ) ? $this->createIndexationButton($ctrlCode, $nodePath) : ''; + $radioButton = $this->createIndexationButton($ctrlCode, $nodePath, $isAttribute); - if (!$button) + $mappingButton = ''; + + $selectConceptHTML = ''; + + if ($simpleContent) { // Include mapping button to show/hide mapping - //print("<br/>".TABLE_MAPPING_HTML.'_'.$nodePath); - //$button = '<input type="button" id="'.BUTTON_MAPPING_HTML.'_'.$nodePath.'" value="?" style=\"font-family: mono\" onclick="switchObjectVisibility('."'".TABLE_MAPPING_HTML.'_'.$nodePath."'".');"/>'; - //$button = '<input type="button" id="'.BUTTON_MAPPING_HTML.'_'.$nodePath.'" value="?" style=\"font-family: mono\" onclick="alert(\'maman\');"/>'; - $button = "<input type=\"button\" id=\"".BUTTON_MAPPING_HTML."_".$nodePath."\" value=\"?\" style=\"font-family: mono\" onclick=\"switchObjectVisibility('".TABLE_MAPPING_HTML."_".$nodePath."');\"/>"; + $mappingButton = "<input type=\"button\" id=\"".BUTTON_MAPPING_HTML."_".$nodePath."\" value=\"?\" style=\"font-family: mono\" onclick=\"switchObjectVisibility('".TABLE_MAPPING_HTML."_".$nodePath."');\"/>"; + + // Combo for concept mapping + $selectConceptHTML = $this->createSelectConceptControlsSeveralMappings($nodePath, "SchemaAlias", "SchemaLabel"); } - return $button.' '.$radioButton.$nodePath." ".$select; - //return '<li>'.$button.' '.$radioButton.$nodePath." ".$select; + + if ($openButton) + { + return $openButton.' '.$radioButton.$nodePath." ".$mappingButton.$selectConceptHTML; + } + else + { + return $mappingButton.' '.$radioButton.$nodePath." ".$selectConceptHTML; + } } //function which creates an hidden HTML control @@ -966,11 +964,8 @@ return; } - ////// Added by Renato. TODO: move "temp" to constructor (?) and print Tree HTML + function callXSSchemaNavigator(){ - /* - function temp(){ - $navigator = new XsSchemaNavigator( $this->mTpParser ); $navigator->SetElementCallbacks( array($this,'StartElement'), array($this,'EndElement') ); @@ -978,99 +973,13 @@ $navigator->SetAttributeCallbacks( null, null, array($this,'AttributeData') ); $navigator->Navigate(); - } - function StartElement( $xsElementDecl, $path ) - { - $hasSubnodes = false; - $hasSimpleContent = true; - - $type = $xsElementDecl->GetType(); - - // Loop over all related types while they are complex - // to check if there are subnodes and to check the content type - while ( is_object( $type ) ) - { - if ( ! $type->IsComplexType() ) - { - break; - } - - if ( count( $type->GetDeclaredAttributeUses() ) ) - { - $hasSubnodes = true; - } - - $contentType = $type->GetContentType(); - - if ( is_object( $contentType ) and - strtolower( get_class( $contentType ) ) == 'xsmodelgroup' ) - { - if ( count( $contentType->GetParticles() ) ) - { - $hasSimpleContent = false; - $hasSubnodes = true; - break; - } - } - - $type = $type->GetBaseType(); - } - - $openButton = ( $hasSubnodes ) ? '[+]' : ''; - - $mappingButton = ( $hasSimpleContent ) ? '[?]' : ''; - - print( "<br/>$openButton $mappingButton $path\n" ); - - if ( $hasSubnodes ) - { - // TODO: Start list here (<ul>) - - $this->mNodes[] = $path; - } - - } // end of member function StartElement - - function EndElement( $xsElementDecl, $path ) - { - $lastIndex = count( $this->mNodes ) - 1; - - if ( $lastIndex >= 0 and $this->mNodes[$lastIndex] == $path ) - { - // TODO: End list here (</ul>) - - array_pop( $this->mNodes ); - } - - } // end of member function EndElement - - function AttributeData( $xsAttributeDecl, $path ) - { - // Attributes can always be mapped - $mappingButton = '[?]'; - - print( "<br/>$mappingButton $path\n" ); - - } // end of member function AttributeData -}*/ - - function callXSSchemaNavigator(){ - //print("<ul>"); - $navigator = new XsSchemaNavigator( $this->mTpParser ); - - $navigator->SetElementCallbacks( array($this,'StartElement'), array($this,'EndElement') ); - - $navigator->SetAttributeCallbacks( null, null, array($this,'AttributeData') ); - - $navigator->Navigate(); - //print("</ul>"); } function StartElement( $xsElementDecl, $path ) { - $hasSubnodes = false; + $hasSubnodes = false; $hasSimpleContent = true; $type = $xsElementDecl->GetType(); @@ -1105,68 +1014,45 @@ $type = $type->GetBaseType(); } - $openButton = ( $hasSubnodes ) ? '[+]' : ''; - - $mappingButton = ( $hasSimpleContent ) ? '[?]' : ''; - $newCtrlCode=$this->indexedForHTMLDiv; $this->indexedForHTMLDiv++; - - - print("<li>"); - print("<table style=\"border-style: solid; display:block \"><tr><td>"); + print("\n<li>"); - $tmpHTML="<br/>".$path; - if ( $hasSubnodes ) { - // TODO: Start list here (<ul>) - $idButton="CtrlBut_".(string)$newCtrlCode; $idList= "ListUL_".(string)$newCtrlCode; $HTMLButtonVisibilityText=$this->createButtonToSwitchVisibility($idButton , "ListUL_".$newCtrlCode); - $selectConceptHTML=''; - - print($this->getGeneralPrefix($path, $path, $newCtrlCode, $HTMLButtonVisibilityText, $selectConceptHTML)); - print("<div id=\"ListUL_".$newCtrlCode."\" style=\"display:NONE; position:RELATIVE\" ><ul>"); + print($this->getGeneralPrefix($path, $newCtrlCode, $HTMLButtonVisibilityText, $hasSimpleContent, false)); + print("\n<div id=\"ListUL_".$newCtrlCode."\" style=\"display:NONE; position:RELATIVE\" ><ul>"); $this->mNodes[] = $path; - } else { $HTMLButtonVisibilityText=''; - $selectConceptHTML=$this->createSelectConceptControlsSeveralMappings($path, "SchemaAlias", "SchemaLabel"); - print($this->getGeneralPrefix($path, $path, $newCtrlCode, $HTMLButtonVisibilityText, $selectConceptHTML)); + print($this->getGeneralPrefix($path, $newCtrlCode, $HTMLButtonVisibilityText, $hasSimpleContent, false)); } - } // end of member function StartElement function EndElement( $xsElementDecl, $path ) { $lastIndex = count( $this->mNodes ) - 1; + print("</li>"); if ( $lastIndex >= 0 and $this->mNodes[$lastIndex] == $path ) { - // TODO: End list here (</ul>) - - - print("</ul></div>"); + print("\n</ul></div>"); array_pop( $this->mNodes ); } - print("</td></tr></table>"); - print("</li>"); - } // end of member function EndElement - - function AttributeData( $xsAttributeDecl, $path ) { @@ -1174,13 +1060,10 @@ $newCtrlCode=$this->indexedForHTMLDiv; $this->indexedForHTMLDiv++; $HTMLButtonVisibilityText=''; - $selectConceptHTML=$this->createSelectConceptControlsSeveralMappings($path, "SchemaAlias", "SchemaLabel"); - print("<li>\n"); - print("<table style=\"border-style: solid; display:block \"><tr><td>"); - print($this->getGeneralPrefix($path, $path, $newCtrlCode, $HTMLButtonVisibilityText, $selectConceptHTML)); - print("</li>\n"); - print("</td></tr></table>"); + print("\n<li>"); + print($this->getGeneralPrefix($path, $newCtrlCode, $HTMLButtonVisibilityText, true, true)); + print("</li>"); } // end of member function AttributeData Modified: tapirbuilder/trunk/www/getstructure.php =================================================================== --- tapirbuilder/trunk/www/getstructure.php 2008-06-13 13:26:26 UTC (rev 718) +++ tapirbuilder/trunk/www/getstructure.php 2008-06-13 16:42:14 UTC (rev 719) @@ -69,6 +69,7 @@ print("<tr>\n"); print("<td>\n"); print($SchemaTreeObj->PrintHtmlTreeArray()); + print("<br/><br/>\n"); print("<span style=\"font-size: 9px\">\n"); print("[+] display subnodes.<br/>\n"); print("[-] hide subnodes.<br/>\n"); @@ -82,9 +83,6 @@ print("</div>"); print("<br/><input type=\"submit\" value=\"Display XML\" />\n"); print("<br/></form><br/>\n"); - - //print($SchemaTreeObj->temp()); - } catch ( Exception $e ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |