Index: trunk/admin/category/addcategory.php =================================================================== diff -u -r642 -r667 --- trunk/admin/category/addcategory.php (.../addcategory.php) (revision 642) +++ trunk/admin/category/addcategory.php (.../addcategory.php) (revision 667) @@ -1,385 +1,747 @@ -Get("Site_Path"); -$admin = $objConfig->Get("AdminDirectory"); -if(!strlen($admin)) - $admin = "admin"; -$localURL=$rootURL."kernel/"; -$adminURL = $rootURL.$admin; -$imagesURL = $adminURL."/images"; -//$pathtolocal = $pathtoroot."in-news/"; - -require_once ($pathtoroot.$admin."/include/elements.php"); -require_once ($pathtoroot."kernel/admin/include/navmenu.php"); -//require_once ($pathtolocal."admin/include/navmenu.php"); -require_once($pathtoroot.$admin."/toolbar.php"); - -unset($objEditItems); - -if($_REQUEST['item']) -{ - // smulate like normal edit button pressed - $tmp_cat =& $objCatList->GetItemByField('ResourceId', $_REQUEST['item']); - $_POST['catlist'][] = $tmp_cat->UniqueId(); -} - -$objEditItems = new clsCatList(); -$objEditItems->SourceTable = $objSession->GetEditTable("Category"); -$objCustomFields = new clsCustomFieldList(1); -$objCustomDataList = new clsCustomDataList(); -$objRelList = new clsRelationshipList(); -$objImages = new clsImageList(); - -//Multiedit init -if ($_GET["new"] == 1) -{ - $c = new clsCategory(NULL); - $c->Set("CreatedOn", time()); - $c->Set("EndOn", time()); - $c->Set("ParentId",$objCatList->CurrentCategoryID()); - $c->Set("NewItem",2); //auto - $c->Set("Status",2); //pending - $en = 0; - $action = "m_add_category"; - $objCatList->CreateEmptyEditTable("CategoryId"); - $objRelList->CreateEmptyEditTable("RelationshipId"); - $objCustomDataList->CreateEmptyEditTable("CustomDataId"); - $objImages->CreateEmptyEditTable("ResourceId"); - - $TitleVerb = prompt_language("la_Text_Adding"); -} -else -{ - if(isset($_POST["catlist"])) - { - $cats = $_POST["catlist"]; - $objCatList->CopyToEditTable("CategoryId",$cats); - $objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable); - /* make a copy of the relationship records */ - $ids = $objEditItems->GetResourceIDList(); - $objRelList->CopyToEditTable("SourceId", $ids); - $objCustomDataList->CopyToEditTable("ResourceId",$ids); - $objImages->CopyToEditTable("ResourceId", $ids); - $c = $objEditItems->GetItemByIndex(0); - $itemcount=$objEditItems->NumItems(); - $en = 0; - } - else - { - if($_GET["item"]) - { - /*shortcut to edit link */ - $objCatList->CopyToEditTable("ResourceId",$_GET["item"]); - $backurl = $_GET["return"]; - } - - //Multiedit init - $en = (int)$_GET["en"]; - $objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable); - - //$ids = $objEditItems->GetResourceIDList(); - //$objRelList->CopyToEditTable("SourceId", $ids); - //$objCustomDataList->CopyToEditTable("ResourceId",$ids); - //$objImages->CopyToEditTable("ResourceId", $ids); - - $itemcount=$objEditItems->NumItems(); - $c = $objEditItems->GetItemByIndex($en); - } - - if($itemcount>1) - { - if ($en+1 == $itemcount) - $en_next = -1; - else - $en_next = $en+1; - - if ($en == 0) - $en_prev = -1; - else - $en_prev = $en-1; - } - - $action = "m_edit_category"; - $TitleVerb = prompt_language("la_Text_Editing"); -} - -$envar = "env=" . BuildEnv() . "&en=$en"; -$section = 'in-portal:editcategory_general'; - -if (strlen($c->Get("Name"))) - $editing_category_title = "'".$c->Get("Name")."' "; -else - $editing_category_title = ""; - -$title = $TitleVerb." ".prompt_language("la_Text_Category")." $editing_category_title- ".prompt_language("la_tab_General"); - -//$saveURL = $admin."/browse.php"; -$saveURL = $admin."/category/category_maint.php"; -$cancelURL = $admin."/".$objSession->GetVariable('ReturnScript'); - -//Display header -$sec = $objSections->GetSection($section); - -$objCatToolBar = new clsToolBar(); -$objCatToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","edit_submit('category','CatEditStatus','$saveURL',1,'');","tool_select.gif"); -$objCatToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","edit_submit('category','CatEditStatus','$cancelURL',2,'');","tool_cancel.gif"); - -if ( isset($en_prev) || isset($en_next) ) -{ - $url = $RootUrl.$admin."/category/addcategory.php"; - $StatusField = "CatEditStatus"; - $form = "category"; - MultiEditButtons($objCatToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"),'','la_PrevCategory','la_NextCategory'); -} - -int_header($objCatToolBar,NULL,$title); -$c->Data=inp_htmlize($c->Data); -if ($objSession->GetVariable("HasChanges") == 1) { -?> - - - - -
- -
- - - - > - - - - Get("CategoryId") > 0 ) { ?> - > - - - - - - > - - - - - > - - - - - - - > - - - - - > - - - - - > - - - - - > - - - - - > - - - - - - - > - - - - - > - - - - -GetFieldUIList(TRUE); -if($CustomFieldUI->NumItems()>0) -{ - $objCustomDataList->SourceTable = $objSession->GetEditTable("CustomMetaData"); - if((int)$c->Get("ResourceId")>0) - { - $objCustomDataList->LoadResource($c->Get("ResourceId")); - } - $headings = $CustomFieldUI->GetHeadingList(); - //echo "
";print_r($objCustomFields); echo "
"; - for($i=0;$i<=count($headings);$i++) - { - $h = $headings[$i]; - if(strlen($h)) - { - int_subsection_title(prompt_language($h)); - $Items = $CustomFieldUI->GetHeadingItems($h); - foreach($Items as $f) - { - $n = substr($f->name,1); - - $cfield = $objCustomFields->GetItemByField("FieldName",$n,FALSE); - if(is_object($cfield)) - { - $cv = $objCustomDataList->GetDataItem($cfield->Get("CustomFieldId")); - if(is_object($cv)) - { - $f->default_value = $cv->Get("Value"); - } - } - print "\n"; - print " \n"; - print " "; - if(is_object($f->NextItem)) - { - $n = $f->NextItem; - print " "; - } - else - print " \n"; - print "\n"; - } - } - } -} -?> - "> - "> - - - - -
- -
- -
Get("CategoryId"); ?> 
- "> -
-
- - - -
- -
- Get("Status") == 1) echo "checked"; ?>> - Get("Status") == 2) echo "checked"; ?>> - Get("Status") == 0) echo "checked"; ?>> -  
- Get("NewItem") == 2) echo "checked"; ?>> - Get("NewItem") == 1) echo "checked"; ?>> - Get("NewItem") == 0) echo "checked"; ?>> - -  
- Get("EditorsPick") == 1) echo "checked"; ?>> -  
"> 
- "> - - - DBG: '.date('M d. Y H:i:s', $c->get('Modified') ); ?> -
- "> -  
- -  
".$f->GetPrompt()."".$f->ItemFormElement()."".$n->ItemFormElement()." 
- - - -
- -
- - - - +Get("Site_Path"); + +$admin = $objConfig->Get("AdminDirectory"); + +if(!strlen($admin)) + + $admin = "admin"; + +$localURL=$rootURL."kernel/"; + +$adminURL = $rootURL.$admin; + +$imagesURL = $adminURL."/images"; + +//$pathtolocal = $pathtoroot."in-news/"; + + + +require_once ($pathtoroot.$admin."/include/elements.php"); + +require_once ($pathtoroot."kernel/admin/include/navmenu.php"); + +//require_once ($pathtolocal."admin/include/navmenu.php"); + +require_once($pathtoroot.$admin."/toolbar.php"); + + + +unset($objEditItems); + + + +if($_REQUEST['item']) + +{ + + // smulate like normal edit button pressed + + $tmp_cat =& $objCatList->GetItemByField('ResourceId', $_REQUEST['item']); + + $_POST['catlist'][] = $tmp_cat->UniqueId(); + +} + + + +$objEditItems = new clsCatList(); + +$objEditItems->SourceTable = $objSession->GetEditTable("Category"); + +$objCustomFields = new clsCustomFieldList(1); + +$objCustomDataList = new clsCustomDataList(); + +$objRelList = new clsRelationshipList(); + +$objImages = new clsImageList(); + + + +//Multiedit init + +if ($_GET["new"] == 1) + +{ + + $c = new clsCategory(NULL); + + $c->Set("CreatedOn", time()); + + $c->Set("EndOn", time()); + + $c->Set("ParentId",$objCatList->CurrentCategoryID()); + + $c->Set("NewItem",2); //auto + + $c->Set("Status",2); //pending + + $en = 0; + + $action = "m_add_category"; + + $objCatList->CreateEmptyEditTable("CategoryId"); + + $objRelList->CreateEmptyEditTable("RelationshipId"); + + $objCustomDataList->CreateEmptyEditTable("CustomDataId"); + + $objImages->CreateEmptyEditTable("ResourceId"); + + + + $TitleVerb = prompt_language("la_Text_Adding"); + +} + +else + +{ + + if(isset($_POST["catlist"])) + + { + + $cats = $_POST["catlist"]; + + $objCatList->CopyToEditTable("CategoryId",$cats); + + $objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable); + + /* make a copy of the relationship records */ + + $ids = $objEditItems->GetResourceIDList(); + + $objRelList->CopyToEditTable("SourceId", $ids); + + $objCustomDataList->CopyToEditTable("ResourceId",$ids); + + $objImages->CopyToEditTable("ResourceId", $ids); + + $c = $objEditItems->GetItemByIndex(0); + + $itemcount=$objEditItems->NumItems(); + + $en = 0; + + } + + else + + { + + if($_GET["item"]) + + { + + /*shortcut to edit link */ + + $objCatList->CopyToEditTable("ResourceId",$_GET["item"]); + + $backurl = $_GET["return"]; + + } + + + + //Multiedit init + + $en = (int)$_GET["en"]; + + $objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable); + + + + //$ids = $objEditItems->GetResourceIDList(); + + //$objRelList->CopyToEditTable("SourceId", $ids); + + //$objCustomDataList->CopyToEditTable("ResourceId",$ids); + + //$objImages->CopyToEditTable("ResourceId", $ids); + + + + $itemcount=$objEditItems->NumItems(); + + $c = $objEditItems->GetItemByIndex($en); + + } + + + + if($itemcount>1) + + { + + if ($en+1 == $itemcount) + + $en_next = -1; + + else + + $en_next = $en+1; + + + + if ($en == 0) + + $en_prev = -1; + + else + + $en_prev = $en-1; + + } + + + + $action = "m_edit_category"; + + $TitleVerb = prompt_language("la_Text_Editing"); + +} + + + +$envar = "env=" . BuildEnv() . "&en=$en"; + +$section = 'in-portal:editcategory_general'; + + + +if (strlen($c->Get("Name"))) + + $editing_category_title = "'".$c->Get("Name")."' "; + +else + + $editing_category_title = ""; + + + +$title = $TitleVerb." ".prompt_language("la_Text_Category")." $editing_category_title- ".prompt_language("la_tab_General"); + + + +//$saveURL = $admin."/browse.php"; + +$saveURL = $admin."/category/category_maint.php"; + +$cancelURL = $admin."/".$objSession->GetVariable('ReturnScript'); + + + +//Display header + +$sec = $objSections->GetSection($section); + + + +$objCatToolBar = new clsToolBar(); + +$objCatToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","edit_submit('category','CatEditStatus','$saveURL',1,'');","tool_select.gif"); + +$objCatToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","edit_submit('category','CatEditStatus','$cancelURL',2,'');","tool_cancel.gif"); + + + +if ( isset($en_prev) || isset($en_next) ) + +{ + + $url = $RootUrl.$admin."/category/addcategory.php"; + + $StatusField = "CatEditStatus"; + + $form = "category"; + + MultiEditButtons($objCatToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"),'','la_PrevCategory','la_NextCategory'); + +} + + + +int_header($objCatToolBar,NULL,$title); + +$c->Data=inp_htmlize($c->Data); + +if ($objSession->GetVariable("HasChanges") == 1) { + +?> + + + + + + + + +
+ + + +
+ + + + + + > + + + + + + + + Get("CategoryId") > 0 ) { ?> + + > + + + + + + + + + + > + + + + + + + + + + > + + + + + + + + + + > + + + + + + + + + + > + + + + + + + + + + > + + + + + + + + + + > + + + + + + + + + + > + + + + + + + + + + > + + + + + + + + + + > + + + + + + + + +GetFieldUIList(TRUE); + +if($CustomFieldUI->NumItems()>0) + +{ + + $objCustomDataList->SourceTable = $objSession->GetEditTable("CustomMetaData"); + + if((int)$c->Get("ResourceId")>0) + + { + + $objCustomDataList->LoadResource($c->Get("ResourceId")); + + } + + $headings = $CustomFieldUI->GetHeadingList(); + + //echo "
";print_r($objCustomFields); echo "
"; + + for($i=0;$i<=count($headings);$i++) + + { + + $h = $headings[$i]; + + if(strlen($h)) + + { + + int_subsection_title(prompt_language($h)); + + $Items = $CustomFieldUI->GetHeadingItems($h); + + foreach($Items as $f) + + { + + $n = substr($f->name,1); + + + + $cfield = $objCustomFields->GetItemByField("FieldName",$n,FALSE); + + if(is_object($cfield)) + + { + + $cv = $objCustomDataList->GetDataItem($cfield->Get("CustomFieldId")); + + if(is_object($cv)) + + { + + $f->default_value = $cv->Get("Value"); + + } + + } + + print "\n"; + + print " \n"; + + print " "; + + if(is_object($f->NextItem)) + + { + + $n = $f->NextItem; + + print " "; + + } + + else + + print " \n"; + + print "\n"; + + } + + } + + } + +} + +?> + "> + + "> + + + + + + + + + +
+ + + +
+ + + +
Get("CategoryId"); ?> 
+ + "> + +
+ +
+ + + + + + + +
+ + + +
+ + Get("Status") == 1) echo "checked"; ?>> + + Get("Status") == 2) echo "checked"; ?>> + + Get("Status") == 0) echo "checked"; ?>> + +  
+ + Get("NewItem") == 2) echo "checked"; ?>> + + Get("NewItem") == 1) echo "checked"; ?>> + + Get("NewItem") == 0) echo "checked"; ?>> + + + +  
+ + Get("EditorsPick") == 1) echo "checked"; ?>> + +  
"> 
+ + "> + + + + + + DBG: '.date('M d. Y H:i:s', $c->get('Modified') ); ?> + +
+ + "> + +  
+ + + +  
".$f->GetPrompt()."".$f->ItemFormElement()."".$n->ItemFormElement()." 
+ + + + + + + +
+ + + +
+ \ No newline at end of file