Don't know why, but I've been reworking the defaultadmin and have lost count of the revisions.
The content of your file should be this. If it still doesn't work, tell me and I'll upload the new release sooner than I planned.
Code: Select all
<?php
$reorderbtn = '';
if(!$infos["is_shared"]){
$reorderbtn = '." ".$this->CreateLink($id, "reorder", $returnid, $admintheme->DisplayImage("icons/system/reorder.gif", "","","","systemicon")." ".$this->Lang("reorder"))';
}
$modulename = $infos['nameofmodule'];
$defaultadmin = '<?php
if (!isset($gCms)) exit;
$admintheme = $gCms->variables["admintheme"];
$active_tab = isset($params["active_tab"])?$params["active_tab"]:"'.$levels[0][0].'";
echo \'
<__script__ type="text/javascript">
function ctlmm_search(what,inwhat){
var destination = document.getElementById(inwhat);
if(!destination) return;
var therows = destination.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
for(i=0;i<therows.length;i++){
var newstyle = "none";
var thecolumns = therows[i].getElementsByTagName("td");
for(j=0;j<thecolumns.length;j++){
if(thecolumns[j].className != "ctlmm_nosearch"){
var tmpa = thecolumns[j].getElementsByTagName("a")[0];
if(tmpa && tmpa.innerHTML.toLowerCase().indexOf(what.toLowerCase()) >= 0) newstyle = "table-row";
if(!tmpa && thecolumns[j].innerHTML.toLowerCase().indexOf(what.toLowerCase()) >= 0) newstyle = "table-row";
}
}
therows[i].style.display = newstyle;
}
}
</__script>\';
echo $this->StartTabHeaders();';
foreach($levels as $level){
$defaultadmin .= '
if( $this->CheckPermission("'.$modulename.'_advanced") || $this->CheckPermission("'.$modulename.'_manage_'.$level[0].'") ) {
echo $this->SetTabHeader("'.strtolower($level[0]).'", $this->Lang("'.$level[0].'_plural"), "'.$level[0].'" == $active_tab ? true : false);
}';
}
if(count($listfields) > 0){
$defaultadmin .= '
if( $this->CheckPermission("'.$modulename.'_advanced") ) {
echo $this->SetTabHeader("fieldoptions", $this->Lang("fieldoptions"), "fieldoptions" == $active_tab ? true : false);
}';
}
$defaultadmin .= '
if( $this->CheckPermission("'.$modulename.'_advanced") || $this->CheckPermission("Modify Templates") ) {
echo $this->SetTabHeader("templates", $this->Lang("templates"), "templates" == $active_tab ? true : false);
}
if( $this->CheckPermission("'.$modulename.'_advanced") ) {
echo $this->SetTabHeader("queries", $this->Lang("queries"), "queries" == $active_tab ? true : false);
}
echo $this->EndTabHeaders();
echo $this->StartTabContent();
';
#####################################
## CONTENT
$i = 0;
while($i < count($levels)){
$level = $levels[$i];
$defaultadmin .= '
if( $this->CheckPermission("'.$modulename.'_manage_'.$level[0].'") ) {
echo $this->StartTab("'.strtolower($level[0]).'");
';
if($i != 0) $defaultadmin .= '
if($this->countsomething("'.$levels[$i - 1][0].'") > 0){
';
$defaultadmin .= '
$whereclause = array();
echo \'<div style="float: right; text-align: right;">\';
';
$tmpbr = "";
if($i != 0 && $levels[$i -1][2] == 0){
$tmpbr = "<br/>";
$defaultadmin .= '
if(!isset($params["'.$level[0].'_showonly"])){
$filteroptions = $this->get_options("'.$levels[$i-1][0].'");
echo $this->CreateFormStart($id, "defaultadmin", $returnid);
echo "<p>".$this->Lang("filterby_'.$levels[$i-1][0].'")." : ";
echo $this->CreateInputDropdown($id, "'.$level[0].'_showonly", $filteroptions, -1);
echo $this->CreateInputHidden($id, "active_tab", "'.$level[0].'");
echo " ".$this->CreateInputSubmit($id, "submit", lang("submit"))."</p>";
echo $this->CreateFormEnd();
}else{
echo "<p>".$this->CreateLink($id, "defaultadmin", $returnid, $this->Lang("showall"), array("active_tab" => "'.$level[0].'"))."</p>";
$whereclause = array("parent_id"=>$params["'.$level[0].'_showonly"]);
}';
}
$tmpjs = "' onkeyup=\"ctlmm_search(this.value,\\'".$level[0]."_table\\');\"'";
$defaultadmin .= '
echo "<p>".$this->Lang("searchthistable")." ".$this->CreateInputText($id, "searchtable_'.$level[0].'", "", 10, 64, '.$tmpjs.')."</p>";
echo "</div>";
';
$defaultadmin .= '
echo "'.$tmpbr.'<p>".$this->CreateLink($id, "edit'.$level[1].'", $returnid, $admintheme->DisplayImage("icons/system/newobject.gif", "","","","systemicon")." ".$this->Lang("add_'.$level[0].'"))'.$reorderbtn.'."</p>'.$tmpbr.'";
$itemlist = $this->get_level_'.$level[0].'(isset($whereclause)?$whereclause:array(),true, $id, $returnid);
$this->smarty->assign("tableid", "'.$level[0].'_table");
$this->smarty->assign("itemlist", $itemlist);
$adminshow = array(';
foreach($level[5] as $field){
$nosearch = false;
$fieldname = $level[0].'_'.$field;
if($field == 'editlink' || $field == 'name'){
$fieldname = 'name';
$field = 'editlink';
}elseif($field == 'alias'){
$fieldname = 'alias';
$field = 'alias';
}elseif($field == 'movelinks'){
$nosearch = true;
$fieldname = 'reorder';
}elseif($field == 'parent'){
$fieldname = $levels[$i -1][0];
$field = 'parent_name';
}elseif($field == 'active'){
$nosearch = true;
$fieldname = 'active';
$field = 'toggleactive';
}elseif($field == 'isdefault'){
$nosearch = true;
$fieldname = 'isdefault';
$field = 'toggledefault';
}elseif($field == 'nbchildren'){
$fieldname = $field = 'nbchildren';
}else{
// we find out what kind of field this is:
$realfield = false;
foreach($level[4] as $tmpfield){
if($tmpfield[0] == $field) $realfield = $tmpfield;
}
if($realfield[1] == 6 || $realfield[1] == 7){
// if it's a list field, display only with single values
if(isset($realfield[5]['multiple']) && $realfield[5]['multiple'] == 1){
$field = false;
}else{
$field = $field.'_namevalue';
}
}elseif($realfield[1] == 12){
$field .= '_admindisplay';
}
}
if($field && ($field != 'parent_name' || $levels[$i-1][2] == 0)){
$defaultadmin .= '
array($this->Lang("'.$fieldname.'"),"'.$field.'",'.($nosearch?'true':'false').'),';
}
}
$defaultadmin .= '
array($this->Lang("Actions"),"deletelink",true)
);
$this->smarty->assign("adminshow", $adminshow);
echo $this->ProcessTemplate("adminpanel.tpl");
echo "<p>".$this->CreateLink($id, "edit'.$level[1].'", $returnid, $admintheme->DisplayImage("icons/system/newobject.gif", "","","","systemicon")." ".$this->Lang("add_'.$level[0].'"))."</p>";
';
if($i != 0) $defaultadmin .= '
}else{
echo "<p>".$this->Lang("error_noparent")."</p>";
}
';
$defaultadmin .= '
echo $this->EndTab();
}';
$i++;
}
if(count($listfields) > 0){
$defaultadmin .= '
if( $this->CheckPermission("Modify Templates") || $this->CheckPermission("'.$modulename.'_advanced") ) {
echo $this->StartTab("fieldoptions");
';
foreach($listfields as $field){
$defaultadmin .= '
echo "<fieldset style=\"width: 600px;\"><legend><b>('.$field[0].') '.$field[1].' :</b></legend><ul>";
$options = $this->get_fieldoptions("'.$field[0].'_'.$field[1].'",true);
echo \'<table cellspacing="0" cellpadding="0" class="pagetable">\';
$rowclass = 1;
foreach($options as $option){
$newparams = array("field"=>"'.$field[0].'_'.$field[1].'", "optionid"=>$option->id, "currentorder"=>$option->item_order);
echo "
<tr class=\"row".$rowclass."\"><td>".$option->name."</td><td width=\"120\">";
echo $this->CreateLink($id, "rename_optionvalue", $returnid, $admintheme->DisplayImage("icons/system/edit.gif", lang("edit"),"","","systemicon"), array_merge($newparams, array("optionname"=>$option->name)))." ";
echo $this->CreateLink($id, "delete_optionvalue", $returnid, $admintheme->DisplayImage("icons/system/delete.gif",lang("delete"),"","","systemicon"), $newparams, $this->Lang("prompt_deleteoption"));
echo $this->CreateLink($id, "move_optionvalue", $returnid, $admintheme->DisplayImage("icons/system/arrow-u.gif",lang("up"),"","","systemicon"), array_merge($newparams, array("move"=>"up")));
echo $this->CreateLink($id, "move_optionvalue", $returnid, $admintheme->DisplayImage("icons/system/arrow-d.gif",lang("down"),"","","systemicon"), array_merge($newparams, array("move"=>"down")));
echo "</td></tr>";
$rowclass = $rowclass == 1?2:1;
}
echo "</table>";
echo "<p>".$this->CreateFormStart($id, "add_optionvalue");
echo "<p>".$this->Lang("addoption").": ".$this->CreateInputText($id, "optionname", "", 20, 64);
echo $this->CreateInputHidden($id, "field", "'.$field[0].'_'.$field[1].'");
echo " ".$this->CreateInputSubmit($id, "submit", lang("submit"))."</p>";
echo $this->CreateFormEnd();
echo "</p></fieldset><br/><br/>";';
}
$defaultadmin .= '
echo $this->EndTab();
}
';
}
$defaultadmin .= '
if( $this->CheckPermission("'.$modulename.'_advanced") || $this->CheckPermission("Modify Templates") ) {
echo $this->StartTab("templates");
echo "<h2>".$this->Lang("defaulttemplates")."</h2>";
echo $this->CreateFormStart($id, "changedeftemplates", $returnid);
$templatelist = $this->ListTemplates($this->GetName());
$deftpls = $this->getDefaultTemplates();
$tploptions = array();
$itemlist = array();
foreach($templatelist as $onetpl){
$tploptions[$onetpl] = $onetpl;
$tpl = new stdClass();
$tpl->editlink = $this->CreateLink( $id, "editTemplate", $returnid, $onetpl, array("tplname"=>$onetpl) );
$tpl->deletelink = in_array($onetpl, $deftpls)?"":$this->CreateLink( $id, "deletetpl", $returnid, $admintheme->DisplayImage("icons/system/delete.gif", $this->Lang("delete"), "", "", "systemicon"), array("tplname"=>$onetpl) );
array_push($itemlist, $tpl);
}
';
foreach($levels as $level){
$defaultadmin .= '
echo " <div class=\"pageoverflow\">
<p class=\"pagetext\">".$this->Lang("deftemplatefor")." \"'.$level[0].'\":</p>
<p class=\"pageinput\">".$this->CreateInputDropdown($id,"listtemplate_'.$level[0].'",$tploptions,-1,$this->GetPreference("listtemplate_'.$level[0].'"))."</p>
</div>
";';
}
$defaultadmin .= '
echo " <div class=\"pageoverflow\">
<p class=\"pagetext\">".$this->Lang("defdetailtemplate").":</p>
<p class=\"pageinput\">".$this->CreateInputDropdown($id,"finaltemplate",$tploptions,-1,$this->GetPreference("finaltemplate"))."</p>
</div>
";
$tploptions[$this->Lang("uselevellisttpl")] = "**";
echo " <div class=\"pageoverflow\">
<p class=\"pagetext\">".$this->Lang("defsearchresultstemplate").":</p>
<p class=\"pageinput\">".$this->CreateInputDropdown($id,"searchresultstemplate",$tploptions,-1,$this->GetPreference("searchresultstemplate",0))."</p>
</div>
<p>".$this->CreateInputSubmit($id, "submit", lang("submit"))."</p>";
echo $this->CreateFormEnd();
echo "<br/><br/><hr/><h2>".$this->Lang("templates")."</h2>";
$this->smarty->assign("itemlist", $itemlist);
$adminshow = array( array($this->Lang("template"), "editlink"), array($this->Lang("Actions"), "deletelink") );
$this->smarty->assign("adminshow", $adminshow);
$this->smarty->assign("tableid", false);
echo $this->ProcessTemplate("adminpanel.tpl");
echo "<p>".$this->CreateLink($id, "editTemplate", $returnid, $admintheme->DisplayImage("icons/system/newobject.gif", "","","","systemicon")." ".$this->Lang("addtemplate"))."</p>";
echo $this->EndTab();
}
if( $this->CheckPermission("'.$modulename.'_advanced") ) {
echo $this->StartTab("queries");
echo "<p>".$this->CreateLink($id, "adminquery", $returnid, $admintheme->DisplayImage("icons/system/newobject.gif", "","","","systemicon")." ".$this->Lang("createquery"))."</p>";
$itemlist = $this->get_queries($where=array(), true, $id, $returnid);
$this->smarty->assign("itemlist", $itemlist);
$adminshow = array( array("id","id"),
array($this->Lang("name"), "name"),
array($this->Lang("Actions"), "actions")
);
$this->smarty->assign("adminshow", $adminshow);
$this->smarty->assign("tableid", false);
echo $this->ProcessTemplate("adminpanel.tpl");
echo "<p>".$this->CreateLink($id, "adminquery", $returnid, $admintheme->DisplayImage("icons/system/newobject.gif", "","","","systemicon")." ".$this->Lang("createquery"))."</p>";
echo $this->EndTab();
}
echo $this->EndTabContent();
?'.'>';
?>