Permalink
Browse files

changed the object generator to include class list of Parent and chil…

…d objects.
  • Loading branch information...
Rafeethu committed Apr 24, 2012
1 parent 9ba38d3 commit 39f9d7c31491aa19ddb70665aaf5e69dff30386b
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
106 index.php

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -19,6 +19,7 @@
$objectName = GetVariable('object');
$attributeList=Array();
$typeList=Array();
+ $classList=Array();
$z=0;
for ($i=1; $i<100; $i++)
{
@@ -43,6 +44,13 @@
//attribute may have been removed. proceed to next row
$z++;
}
+
+ if (GetVariable(('type_'.$i)) == "BELONGSTO" || GetVariable(('type_'.$i)) == "HASMANY"){
+ $classList[] = GetVariable(('tclass_'.$i));
+ }
+ else{
+ $classList[] = '';
+ }
}
$_SESSION['objectName'] = $objectName;
@@ -74,7 +82,7 @@
$client = new SoapClient('services/pog.wsdl', array('cache_wsdl' => 0));
try
{
- $object = base64_decode($client->GenerateObject($objectName, $attributeList, $typeList, $language, $wrapper, $pdoDriver));
+ $object = base64_decode($client->GenerateObject($objectName, $attributeList, $typeList, $language, $wrapper, $pdoDriver, $classList));
$_SESSION['objectString'] = $object;
$_SESSION['attributeList'] = serialize($attributeList);
$_SESSION['typeList'] = serialize($typeList);
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,15 +1,31 @@
<?xml version="1.0" ?>
<Links>
<Link>
- <URL>http://www.2mhost.com/php5-hosting.html</URL>
- <Text>PHP 5 web hosting</Text>
+ <LinkID>OI87827</LinkID>
+ <URL>http://www.forumla.de/archive/index.php/f-30.html</URL>
+ <Text>PS3 Community - Forumla.de</Text>
<BeforeText> </BeforeText>
<AfterText> </AfterText>
</Link>
<Link>
+ <LinkID>OI319561</LinkID>
<URL>http://www.superwarehouse.com/Sony_Laptops/b/250/c/14</URL>
<Text>Sony Laptops</Text>
<BeforeText> </BeforeText>
<AfterText> </AfterText>
</Link>
+ <Link>
+ <LinkID>OI469063</LinkID>
+ <URL>http://www.canadianwebhosting.com/domain_hosting.asp</URL>
+ <Text>domain hosting</Text>
+ <BeforeText> </BeforeText>
+ <AfterText> </AfterText>
+ </Link>
+ <Link>
+ <LinkID>OI576934</LinkID>
+ <URL>http://www.facebook.com/FisherInvestmentsMarketMinder</URL>
+ <Text>Market Minder on Facebook</Text>
+ <BeforeText> </BeforeText>
+ <AfterText> </AfterText>
+ </Link>
</Links>
@@ -9,20 +9,24 @@ class Object
var $separator = "\n\t";
var $pdoDriver = "";
var $language = 'php5.1';
+ var $classList;
+
// -------------------------------------------------------------
- function Object($objectName, $attributeList = '', $typeList ='', $pdoDriver = '', $language = 'php5.1')
+ function Object($objectName, $attributeList = '', $typeList ='', $pdoDriver = '', $language = 'php5.1', $classList)
{
$this->objectName = $objectName;
$this->attributeList = $attributeList;
$this->typeList = $typeList;
$this->pdoDriver = $pdoDriver;
$this->language = $language;
+ $this->classList = $classList;
}
// -------------------------------------------------------------
function BeginObject()
{
+ $impArray = array();
$misc = new Misc(array());
$this->string = "<?php\n";
$this->string .= $this->CreatePreface();
@@ -33,6 +37,13 @@ function BeginObject()
{
$this->string .= "\ninclude_once('class.".strtolower($misc->MappingName($this->objectName, $this->attributeList[$key])).".php');";
}
+ if ($type == "BELONGSTO" || $type == "HASMANY")
+ {
+ if(in_array(strtolower($this->classList[$key]), $impArray) == false)
+ $this->string .= "\ninclude_once('class.".strtolower($this->classList[$key]).".php');";
+
+ array_push($impArray, strtolower($this->classList[$key])) ;
+ }
}
$this->string .= "\nclass ".$this->objectName." extends POG_Base\n{\n\t";
$this->string.="public \$".strtolower($this->objectName)."Id = '';\n\n\t";
@@ -67,7 +78,7 @@ function BeginObject()
}
// create attribute => type array map
// needed for setup
- $this->string .= "private \$pog_attribute_type = array(\n\t\t";
+ $this->string .= "public \$pog_attribute_type = array(\n\t\t";
$this->string .= "\"".strtolower($this->objectName)."Id\" => array('db_attributes' => array(\"NUMERIC\", \"INT\")),\n\t\t";
$x = 0;
foreach ($this->attributeList as $attribute)
@@ -76,7 +87,7 @@ function BeginObject()
$x++;
}
$this->string .= ");\n\t";
- $this->string .= "private \$pog_query;";
+ $this->string .= "public \$pog_query;";
}
// -------------------------------------------------------------
@@ -741,12 +752,12 @@ function CreateAddChildFunction($child)
}
// -------------------------------------------------------------
- function CreateGetChildrenFunction($child)
+ function CreateGetChildrenFunction($child, $class)
{
$this->string .= "\n\t$this->separator\n\t";
$this->string .= $this->CreateComments("Gets a list of $child objects associated to this one", array("multidimensional array {(\"field\", \"comparator\", \"value\"), (\"field\", \"comparator\", \"value\"), ...}","string \$sortBy","boolean \$ascending","int limit"),"array of $child objects");
$this->string .= "\tfunction Get".ucfirst(strtolower($child))."List(\$fcv_array = array(), \$sortBy='', \$ascending=true, \$limit='')\n\t{";
- $this->string .= "\n\t\t\$".strtolower($child)." = new ".$child."();";
+ $this->string .= "\n\t\t\$".strtolower($child)." = new ".$class."();";
$this->string .= "\n\t\t\$fcv_array[] = array(\"".strtolower($this->objectName)."Id\", \"=\", \$this->".strtolower($this->objectName)."Id);";
$this->string .= "\n\t\t\$dbObjects = \$".strtolower($child)."->GetList(\$fcv_array, \$sortBy, \$ascending, \$limit);";
$this->string .= "\n\t\treturn \$dbObjects;";
@@ -781,12 +792,12 @@ function CreateSetParentFunction($parent)
}
// -------------------------------------------------------------
- function CreateGetParentFunction($parent)
+ function CreateGetParentFunction($parent, $class)
{
$this->string .= "\n\t$this->separator\n\t";
$this->string .= $this->CreateComments("Associates the $parent object to this one",'',"boolean");
$this->string .= "\tfunction Get".ucfirst(strtolower($parent))."()\n\t{";
- $this->string .= "\n\t\t\$".strtolower($parent)." = new ".$parent."();";
+ $this->string .= "\n\t\t\$".strtolower($parent)." = new ".$class."();";
$this->string .= "\n\t\treturn $".strtolower($parent)."->Get(\$this->".strtolower($parent)."Id);";
$this->string .= "\n\t}";
}
@@ -934,4 +945,4 @@ function CreateSetAssociationsFunction($sibling)
}
}
-?>
+?>
View
@@ -1,11 +1,11 @@
body {margin:0 auto;padding:0;color:#828282;background:#fff;font:bold 10px Verdana}
-.greybox {background:url('./images/tile.jpg') repeat-y;padding:10px 0 10px 45px;width:360px;font-size:9px;float:left;position:relative;z-index:100}
+.greybox {background:url('./images/tile.jpg') repeat-y;padding:10px 0 10px 45px;width:560px;font-size:9px;float:left;position:relative;z-index:100}
.greybox2 {background:url('./images/tile2.jpg') repeat-y;padding:5px 0 10px 60px;width:360px;font-size:9px;float:left;position:relative;z-index:100}
.header {width:425px;height:147px;float:left;background:url('./images/header.gif') top left no-repeat;position:relative}
-.objectname {float:left;position:relative;padding:45px 0 0 155px;background:url('./images/body.jpg') top left no-repeat;width:258px;height:79px;z-index:100}
+.objectname {float:left;position:relative;padding:45px 0 0 155px;background:url('./images/body.jpg') top left no-repeat;width:560px;height:79px;z-index:100}
.header2 {width:425px;height:147px;float:left;background:url('./images/header2.jpg') top left no-repeat;position:relative}
.result {float:left;position:relative;padding:90px 0 0;background:url('./images/body2.jpg') top left no-repeat;width:413px;height:151px;z-index:100}
-.generate {padding-left:235px;padding-top:10px;width:190px;height:56px;background:url('./images/customize.jpg') top left no-repeat;position:relative;float:left}
+.generate {padding-left:235px;padding-top:10px;width:560px;height:56px;background:url('./images/customize.jpg') top left no-repeat;position:relative;float:left}
.customize {padding-left:150px;padding-top:38px;width:258px;height:63px;background:url('./images/customize2.jpg') top left no-repeat;position:relative;z-index:99;float:left}
.generate2 {padding-left:280px;padding-top:10px;width:145px;height:10px;background:url('./images/end2.jpg') top left no-repeat;float:left;position:relative}
.restart {width:370px;height:100px;padding-top:30px;background-color:#333;background:url('./images/restart.gif') top left no-repeat;position:relative;float:left}
@@ -26,7 +26,7 @@ h1, h1 a{text-decoration:none;color:#828282;z-index:300;font:normal 10px Verdana
a {text-decoration:none;color:#837E3C;z-index:300;}
.left {width:170px;float:left;font-size:9px;line-height:14px;font-weight:normal;color:#848484;margin:93px auto 0 0;height:100%;position:absolute;z-index:300}
.left2 {width:170px;float:left;font-size:9px;line-height:14px;font-weight:normal;color:#848484;margin:122px auto 0 0;height:100%;position:absolute;z-index:300}
-.right {width:170px;float:left;margin:93px auto 0 600px;position:absolute;z-index:300;font-weight:normal;font-size:9px}
+.right {width:170px;float:left;/*margin:93px auto 0 600px;*/right: 120px; top: 93px; position:absolute;z-index:300;font-weight:normal;font-size:9px}
.right2 {width:170px;float:left;margin:122px auto 0 540px;position:absolute;z-index:300;font-weight:normal;font-size:9px}
.middle {position:absolute;float:left;padding-left:175px;width:500px}
textarea {width:267px;height:379px;color:#333;font-weight:bold;font-size:9px}
View
57 pog.js
@@ -1,42 +1,3 @@
-
-function AddField(){trs=document.getElementsByTagName("div")
-for(var w=0;w<trs.length;w++){if(trs[w].style.display=="none"){trs[w].style.display="block"
-var control=document.getElementById("field"+trs[w].id)
-try{control.focus()}
-catch(e){}
-break}}}
-function ResetFields(){trs=document.getElementsByTagName("input")
-for(var w=0;w<trs.length;w++){trs[w].value=""}}
-function ConvertDDLToTextfield(id){var thisId=id
-trs=document.getElementsByTagName("select")
-for(var w=0;w<trs.length;w++){if(trs[w].id==thisId){if(trs[w].value=="OTHER"){trs[w].style.display="none"
-trs2=document.getElementsByTagName("input")
-for(var v=0;v<trs2.length;v++){if(trs2[v].id=="t"+thisId){trs2[v].style.display="inline"
-trs2[v].focus()
-break}}}
-break}}}
-function FocusOnFirstField(){trs2=document.getElementById("FirstField")
-trs2.focus()}
-function IsPDO(){trs2=document.getElementById("wrapper")
-if(trs2.value.toUpperCase()=="PDO"){link=document.getElementById("disappear")
-link.style.display="none"
-trs2=document.getElementById("PDOdriver")
-trs2.value="mysql"
-trs2.style.display="inline"}
-else{select=document.getElementById("PDOdriver")
-select.style.display="none"
-link=document.getElementById("disappear")
-link.style.display="inline"}}
-function CascadePhpVersion(){trs2=document.getElementById("FirstField")
-select=document.getElementById("wrapper")
-select.length=0
-if(trs2.value=="php5.1"){optionsArray=new Array("PDO","POG")}
-else{optionsArray=new Array("POG")}
-for(var i=0;i<optionsArray.length;i++){NewOpt=new Option
-NewOpt.value=optionsArray[i].toLowerCase()
-NewOpt.text=optionsArray[i]
-select.options[i]=NewOpt}
-IsPDO()}
function GenerateSQLTypesForDriver(driver){for(var j=1;j<100;j++){ddlist=document.getElementById("type_"+j)
ddlist.length=0
switch(driver){case"mysql":optionsArray=new Array("VARCHAR(255)","TINYINT","TEXT","DATE","SMALLINT","MEDIUMINT","INT","BIGINT","FLOAT","DOUBLE","DECIMAL","DATETIME","TIMESTAMP","TIME","YEAR","CHAR(255)","TINYBLOB","TINYTEXT","BLOB","MEDIUMBLOB","MEDIUMTEXT","LONGBLOB","LONGTEXT","BINARY","OTHER","{ CHILD }","{ PARENT }","{ SIBLING }")
@@ -96,24 +57,6 @@ type2[0].style.display="inline"
cf2[0].value=""
cf2[0].style.display="none"}
attribute2[0].focus()}
-function WarnMinInput()
-{var inputCount=0;trs=document.getElementsByTagName("input");var allVals=new Array();var allCount=0;for(var w=0;w<trs.length;w++)
-{if(trs[w].value!=""&&trs[w].type!="hidden"&&trs[w].name!="object")
-{inputCount++;if(allVals,trs[w].value != '' && InArray(allVals,trs[w].value))
-{alert("Warning:\nYou have more than 1 attribute with the same value. Attributes must be unique.");return;}
-else if(trs[w].value == document.getElementById('objName').value)
-{alert("An object cannot relate to itself recursively. Make sure attribute names are different from the object name.");return;}
-else
-{allVals.push(trs[w].value);allCount++;}}}
-if(inputCount>0)
-{var typeCount=0;trs=document.getElementsByTagName("select");for(var w=0;w<trs.length;w++)
-{if(trs[w].value=="HASMANY"||trs[w].value=="BELONGSTO"||trs[w].value=="JOIN")
-{typeCount++;}}
-if(typeCount>=inputCount)
-{alert("Warning:\nYou need to have at least 1 non-parent/child attribute. Else POG will generate an invalid PHP object");}}
-else
-{alert("Warning:\nWithout any object attributes, POG may generate an invalid PHP object. You need to have at least 1 non-parent/child attribute");}
-return false;}
function InArray(array,val)
{var found=false;for(var i=0;i<array.length;i++)
{if(array[i]==val)
Oops, something went wrong.

0 comments on commit 39f9d7c

Please sign in to comment.