1   <?php
  2   ##############################################################
  3   ##In-portal                                                             ##
  4   ##############################################################
  5   ##                   In-portal                                          ##
  6   ##             Intechnic Corporation                                    ##
  7   ##          All Rights Reserved, 1998-2002                      ##
  8   ##                                                                      ##
  9   ## No portion of this code may be copied, reproduced or         ##
  10   ##    otherwise redistributed without proper written            ##
  11   ##   consent of Intechnic Corporation.  Violation will      ##
  12   ##    result in revocation of the license and support           ##
  13   ##  privileges along maximum prosecution allowed by law.        ##
  14   ##############################################################
  15  
  16   function k4getmicrotime()
  17   {
  18       list($usec, $sec) = explode(" ", microtime());
  19       return ((float)$usec + (float)$sec);
  20   }
  21  
  22   $start = k4getmicrotime();
  23  
  24   // new startup: begin
  25   define('REL_PATH', 'admin');
  26   $relation_level = count( explode('/', REL_PATH) );
  27   define('FULL_PATH', realpath(dirname(__FILE__) . str_repeat('/..', $relation_level) ) );
  28   require_once FULL_PATH.'/kernel/startup.php';
  29   // new startup: end
  30  
  31   if($application->GetVar('Action') == 'm_paste') define('REDIRECT_REQUIRED',1); // this script can issue redirect header
  32  
  33   define('REQUIRE_LAYER_HEADER', 1);
  34   $b_topmargin = "0";
  35   //$b_header_addon = "<DIV style='position:relative; z-Index: 1; background-color: #ffffff; padding-top:1px;'><div style='position:absolute; width:100%;top:0px;' align='right'><img src='images/logo_bg.gif'></div><img src='images/spacer.gif' width=1 height=15><br><div style='z-Index:1; position:relative'>";
  36  
  37   require_login();
  38  
  39   $indexURL = $rootURL."index.php";
  40   $homeURL = "javascript:AdminCatNav('".$_SERVER["PHP_SELF"]."?env=".BuildEnv()."');";
  41  
  42   $m_var_list_update["cat"] = 0;
  43   unset($m_var_list_update["cat"]);
  44  
  45   $envar = "env=" . BuildEnv();
  46  
  47   if($objCatList->CurrentCategoryID()>0)
  48   {
  49     $c = $objCatList->CurrentCat();
  50     $upURL = "javascript:AdminCatNav('".$c->Admin_Parent_Link()."');";
  51   }
  52   else
  53     $upURL = $_SERVER["PHP_SELF"]."?".$envar;
  54  
  55   //admin only util
  56  
  57   $pathtolocal = $pathtoroot."kernel/";
  58   require_once ($pathtoroot.$admin."/include/elements.php");
  59   //require_once ($pathtoroot."kernel/admin/include/navmenu.php");
  60   require_once ($pathtolocal."admin/include/navmenu.php");
  61   require_once($pathtoroot.$admin."/browse/toolbar.php");
  62  
  63   $m = GetModuleArray();
  64   foreach($m as $key=>$value)
  65   {
  66       $path = $pathtoroot.$value."admin/include/parser.php";
  67       if(file_exists($path))
  68       {
  69         //echo "<!-- $path -->";
  70         @include_once($path);
  71       }
  72   }
  73  
  74  
  75   $application->InitParser();
  76  
  77   $cat_templates = $objModules->ExecuteFunction('GetModuleInfo', 'catalog_template');
  78   foreach ($cat_templates as $a_mod => $a_template) {
  79           if (!$a_template) continue;
  80           
  81           $module_prefix = $application->findModule('Name', $a_mod, 'Var');
  82           $view_perm = $application->getUnitOption($module_prefix, 'PermItemPrefix').'.VIEW';
  83           if ($application->CheckPermission($view_perm, 0)) {
  84                   $a_var = $a_mod.'_TAB_HTML';
  85                   $$a_var = $application->ParseBlock(Array('name'=>$a_template), 0, true);
  86           }
  87   }
  88  
  89   //$application->SetVar('t', 'in-commerce/products/products_catalog');
  90  
  91  
  92   if( !defined('IS_INSTALL') ) define('IS_INSTALL', 0);
  93   if( !IS_INSTALL ) require_login();
  94  
  95   //Set Section
  96   $section = 'in-portal:browse';
  97  
  98   //Set Environment Variable
  99  
  100   //echo $objCatList->ItemsOnClipboard()." Categories on the clipboard<br>\n";
  101   //echo $objTopicList->ItemsOnClipboard()." Topics on the clipboard<br>\n";
  102   //echo $objLinkList->ItemsOnClipboard()." Links on the clipboard<br>\n";
  103   //echo $objArticleList->ItemsOnClipboard()." Articles on the clipboard<br>\n";
  104  
  105   // save last category visited
  106   $objSession->SetVariable('prev_category', $objSession->GetVariable('last_category') );
  107   $objSession->SetVariable('last_category', $objCatList->CurrentCategoryID() );
  108  
  109   /* // for testing
  110   $last_cat = $objSession->GetVariable('last_category');
  111   $prev_cat = $objSession->GetVariable('prev_category');
  112   echo "Last CAT: [$last_cat]<br>";
  113   echo "Prev CAT: [$prev_cat]<br>";
  114   */
  115   $SearchType = $objSession->GetVariable("SearchType");
  116   if(!strlen($SearchType))
  117     $SearchType = "all";
  118   $SearchLabel = "la_SearchLabel";
  119   if( GetVar('SearchWord') !== false ) $objSession->SetVariable('admin_seach_words', GetVar('SearchWord') );
  120   $SearchWord = $objSession->GetVariable('admin_seach_words');
  121  
  122   // where should all edit popups submit changes
  123   $objSession->SetVariable("ReturnScript", basename($_SERVER['PHP_SELF']) );
  124   $charset = GetRegionalOption('Charset');
  125  
  126   $base_href = $application->ProcessParsedTag('m', 'Base_Ref', Array());
  127           
  128   /* page header */
  129   print <<<END
  130   <html>
  131   <head>
  132     <title>In-portal</title>
  133     $base_href
  134     <meta http-equiv="content-type" content="text/html;charset=$charset">
  135     <meta http-equiv="Pragma" content="no-cache">
  136     <script language="JavaScript">
  137       imagesPath='$imagesURL'+'/';
  138     </script>
  139  
  140   END;
  141  
  142     require_once($pathtoroot.$admin."/include/mainscript.php");
  143  
  144   print <<<END
  145   <script type="text/javascript">
  146           if (window.opener != null) {
  147           theMainScript.CloseAndRefreshParent();
  148           }       
  149   </script>
  150   END;
  151  
  152   print <<<END
  153     <script src="$browseURL/toolbar.js"></script>
  154     <script src="$browseURL/checkboxes_new.js"></script>
  155     <script language="JavaScript1.2" src="$browseURL/fw_menu.js"></script>
  156     <script language="javascript" src="incs/script.js"></script>
  157     <link rel="stylesheet" type="text/css" href="$browseURL/checkboxes.css">
  158     <link rel="stylesheet" type="text/css" href="$cssURL/style.css">
  159     <link rel="stylesheet" type="text/css" href="$browseURL/toolbar.css">
  160   END;
  161   load_module_styles();
  162   if( !isset($list) ) $list = '';
  163   if(($SearchType=="categories" || $SearchType="all") && strlen($list))
  164   {
  165     int_SectionHeader(NULL,NULL,NULL,admin_language("la_Title_SearchResults"));
  166   }
  167   else
  168     int_SectionHeader();
  169  
  170   $filter = false; // always initialize variables before use
  171  
  172   if($objSession->GetVariable("SearchWord") != '') {
  173           $filter = true;
  174   }
  175   else {
  176           $bit_combo = $objModules->ExecuteFunction('GetModuleInfo', 'all_bitmask');
  177           $bit_combo = $objModules->MergeReturn($bit_combo);
  178           foreach($bit_combo['VarName'] as $mod_name => $VarName)
  179           {
  180                   //echo "VarName: [$VarName] = [".$objConfig->Get($VarName)."], ALL = [".$bit_combo['Bits'][$mod_name]."]<br>";
  181                   if( $objConfig->Get($VarName) )
  182                           if( $objConfig->Get($VarName) != $bit_combo['Bits'][$mod_name] )
  183                           {
  184                                   $filter = true;
  185                                   break;  
  186                           }
  187           }
  188   }
  189   ?>
  190   </div>
  191   <!-- alex mark -->
  192   <table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
  193           <tbody>
  194                   <tr>
  195                           <td>
  196                                   <div name="toolBar" id="mainToolBar">
  197                                           <tb:button action="upcat" title="<?php echo admin_language("la_ToolTip_Up"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  198                                           <tb:button action="homecat" title="<?php echo admin_language("la_ToolTip_Home"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  199                                           <tb:separator ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  200                                           <tb:button action="new_cat" title="<?php echo admin_language("la_ToolTip_New_Category"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  201                                           <tb:button action="editcat" title="<?php echo admin_language("la_ToolTip_Edit_Current_Category"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  202  
  203                                           <?php
  204                                               foreach($NewButtons as $btn)
  205                                               {
  206                                                   print '<tb:button action="'.$btn['Action'].'" title="'.$btn['Alt'].'" ImagePath="'.$btn['ImagePath'].'" ';
  207                                                   if (getArrayValue($btn, 'Tab')) print 'tab="'.$btn['Tab'].'"';
  208                                                   print ">\n";
  209                                               }
  210                                           ?>
  211                                           
  212                                           <tb:button action="edit" title="<?php echo admin_language("la_ToolTip_Edit"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  213                                           <tb:button action="delete" title="<?php echo admin_language("la_ToolTip_Delete"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  214                                           <tb:separator ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  215                                           <tb:button action="approve" title="<?php echo admin_language("la_ToolTip_Approve"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  216                                           <tb:button action="decline" title="<?php echo admin_language("la_ToolTip_Decline"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  217                                           <tb:separator ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  218                                           
  219                                           <tb:button action="export" title="<?php echo admin_language("la_ToolTip_Export"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  220                                           <tb:separator ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  221  
  222                                           <tb:button action="rebuild_cache" title="<?php echo admin_language("la_ToolTip_RebuildCategoryCache"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  223                                   <tb:separator ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  224            
  225                                           <tb:button action="cut" title="<?php echo admin_language("la_ToolTip_Cut"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  226                                           <tb:button action="copy" title="<?php echo admin_language("la_ToolTip_Copy"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  227                                           <tb:button action="paste" title="<?php echo admin_language("la_ToolTip_Paste"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  228                                           <tb:separator ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  229                                           <tb:button action="move_up" title="<?php echo admin_language("la_ToolTip_Move_Up"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  230                                           <tb:button action="move_down" title="<?php echo admin_language("la_ToolTip_Move_Down"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  231                                           <tb:separator ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  232                                           <tb:button action="print" title="<?php echo admin_language("la_ToolTip_Print"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  233                                           <tb:button action="view" title="<?php echo admin_language("la_ToolTip_View"); ?>" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  234                                   </div>
  235                           </td>
  236                   </tr>
  237           </tbody>
  238   </table>
  239  
  240   <table cellspacing="0" cellpadding="0" width="100%" bgcolor="#e0e0da" border="0" class="tableborder_full_a">
  241      <tbody>
  242       <tr>
  243        <td><img height="15" src="<?php echo $imagesURL; ?>/arrow.gif" width="15" align="middle" border="0">
  244             <span class="navbar"><?php $attribs["admin"]=1; print m_navbar($attribs); ?></span>
  245          </td>
  246         <td align="right">
  247             <FORM METHOD="POST" ACTION="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>" NAME="admin_search" ID="admin_search"><INPUT ID="SearchScope" NAME="SearchScope" type="hidden" VALUE="<?php echo $objSession->GetVariable("SearchScope"); ?>"><INPUT ID="SearchType" NAME="SearchType" TYPE="hidden" VALUE="<?php echo $objSession->GetVariable("SearchType"); ?>"><INPUT ID="NewSearch" NAME="NewSearch" TYPE="hidden" VALUE="0"><INPUT TYPE="HIDDEN" NAME="Action" value="m_Exec_Search">
  248             <table cellspacing="0" cellpadding="0"><tr>
  249             <td><?php echo admin_language($SearchLabel); ?>&nbsp;</td>
  250                                           <td><input ID="SearchWord" type="text" value="<?php echo inp_htmlize($SearchWord,1); ?>" name="SearchWord" size="10" style="border-width: 1; border-style: solid; border-color: 999999"></td>
  251             <td><img id="imgSearch" action="search_b" src="<?php echo $imagesURL."/toolbar/";?>/icon16_search.gif" title="<?php echo admin_language("la_ToolTip_Search"); ?>" align="absMiddle" onclick="this.action = this.getAttribute('action'); actionHandler(this);" src="<?php echo $imagesURL."/toolbar/";?>/arrow16.gif" onmouseover="this.src='<?php echo $imagesURL."/toolbar/";?>/icon16_search_f2.gif'" onmouseout="this.src='<?php echo $imagesURL."/toolbar/";?>/icon16_search.gif'" style="cursor:hand" width="22" width="22"><!--<img action="search_a" title="<?php echo admin_language("la_ToolTip_Search"); ?>" align="absMiddle" onclick="this.action = this.getAttribute('action'); actionHandler(this);" src="<?php echo $imagesURL."/toolbar/";?>/arrow16.gif" onmouseover="this.src='<?php echo $imagesURL."/toolbar/";?>/arrow16_f2.gif'" onmouseout="this.src='<?php echo $imagesURL."/toolbar/";?>/arrow16.gif'" style="cursor:hand">-->
  252             <img action="search_c" src="<?php echo $imagesURL."/toolbar/";?>/icon16_search_reset.gif" title="<?php echo admin_language("la_ToolTip_Search"); ?>" align="absMiddle" onclick="document.all.SearchWord.value = ''; this.action = this.getAttribute('action'); actionHandler(this);" onmouseover="this.src='<?php echo $imagesURL."/toolbar/";?>/icon16_search_reset_f2.gif'" onmouseout="this.src='<?php echo $imagesURL."/toolbar/";?>/icon16_search_reset.gif'" style="cursor:hand" width="22" width="22">&nbsp;
  253             </td>
  254             </tr></table>
  255             </FORM>
  256             <!--tb:button action="search_b" title="<?php echo admin_language("la_ToolTip_Search"); ?>" align="right" ImagePath="<?php echo $imagesURL."/toolbar/";?>">
  257             <tb:button action="search_a" title="<?php echo admin_language("la_ToolTip_Search"); ?>" align="right" ImagePath="<?php echo $imagesURL."/toolbar/";?>"-->
  258         </td>
  259       </tr>
  260     </tbody>
  261   </table>
  262   <?php if ($filter) { ?>
  263   <table width="100%" border="0" cellspacing="0" cellpadding="0" class="toolbar">
  264     <tr>
  265       <td valign="top">
  266         <?php int_hint_red(admin_language("la_Warning_Filter")); ?>
  267       </td>
  268     </tr>
  269   </table>
  270   <?php } ?>
  271   <br> 
  272    <!-- CATEGORY DIVIDER -->
  273   <?php
  274         
  275           $OrderBy = $objCatList->QueryOrderByClause(TRUE,TRUE,TRUE);  
  276       $objCatList->Clear();
  277       $IsSearch = FALSE;
  278           if($SearchType == 'categories' || $SearchType == 'all')
  279       {
  280                   $list = $objSession->GetVariable("SearchWord");
  281           $SearchQuery = $objCatList->AdminSearchWhereClause($list);
  282           if(strlen($SearchQuery))
  283           {
  284                   $SearchQuery = " (".$SearchQuery.") ";
  285               if( strlen($CatScopeClause) ) {             
  286                   $SearchQuery .= " AND ParentId = ".$objCatList->CurrentCategoryID();//" AND ".$CatScopeClause;
  287               }
  288                   $objCatList->LoadCategories($SearchQuery.$CategoryFilter,$OrderBy);
  289                   $IsSearch = TRUE;
  290           }
  291           else
  292                   $objCatList->LoadCategories("ParentId=".$objCatList->CurrentCategoryID()." ".$CategoryFilter,$OrderBy);
  293           }
  294       else
  295            $objCatList->LoadCategories("ParentId=".$objCatList->CurrentCategoryID()." ".$CategoryFilter, $OrderBy);
  296           
  297          $TotalItemCount += $objCatList->QueryItemCount;
  298         
  299   ?>
  300   <?php
  301     $e = $Errors->GetAdminUserErrors();
  302     if(count($e)>0)
  303     {     
  304       echo "<table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" border=\"0\">";
  305       for($ex = 0; $ex<count($e);$ex++)
  306       {
  307         echo "<tr><td width=\100%\" class=\"error\">".prompt_language($e[$ex])."</td></tr>";
  308       }
  309       echo "</TABLE><br>";
  310     }
  311   ?>
  312   <table cellspacing="0" cellpadding="0" width="100%" border="0">
  313      <tbody>
  314      <tr>
  315         <td width="138" height="20" nowrap="nowrap" class="active_tab" onclick="toggleCategoriesB(this)" id="cats_tab">
  316             <table cellspacing="0" cellpadding="0" width="100%" border="0">
  317                   <tr>
  318                           <td id="l_cat" background="<?php echo $imagesURL; ?>/itemtabs/tab_active_l.gif" class="left_tab">
  319                                   <img src="<?php echo $imagesURL; ?>/itemtabs/divider_up.gif" width="20" height="20" border="0" align="absmiddle">
  320                           </td>
  321                           <td id="m_cat" nowrap background="<?php echo $imagesURL; ?>/itemtabs/tab_active.gif" class="tab_class">
  322                           <?php echo admin_language("la_ItemTab_Categories"); ?>:&nbsp;
  323                   </td>
  324                   <td id="m1_cat" align="right" valign="top" background="<?php echo $imagesURL; ?>/itemtabs/tab_active.gif" class="tab_class">
  325                           <span class="cats_stats">(<?php echo $objCatList->QueryItemCount; ?>)</span>&nbsp;
  326                   </td>
  327                   <td id="r_cat" background="<?php echo $imagesURL; ?>/itemtabs/tab_active_r.gif" class="right_tab">
  328                           <img src="<?php echo $imagesURL; ?>/spacer.gif" width="21" height="20">
  329                   </td>
  330                   </tr>
  331             </table>
  332         </td>
  333         <td>&nbsp;</td>
  334      </tr>
  335     </tbody>
  336   </table>
  337   <div class="divider" style="" id="categoriesDevider"><img width="1" height="1" src="<?php echo $imagesURL; ?>/spacer.gif"></div>
  338   </DIV>
  339   </div>
  340   <DIV style="background-color: #ffffff; position: relative; padding-top: 1px; top: -1px; z-Index:0" id="firstContainer">
  341     <DIV style="background-color: #ffffff; position: relative; padding-top: 1px; top: -1px; z-Index:2" id="secondContainer">
  342       <!-- CATEGORY OUTPUT START -->
  343       <div id="categories" tabtitle="Categories">
  344         <form id="categories_form" name="categories_form" action="" method="post">
  345           <input type="hidden" name="Action">
  346           <?php
  347             if($IsSearch)
  348             {    
  349                           $template = "cat_search_element.tpl";
  350             }
  351             else {
  352                           $template = "cat_element.tpl";
  353             }
  354            print adListSubCats($objCatList->CurrentCategoryID(),$template);
  355           ?>
  356         </form>
  357       </div>
  358       <BR>
  359       <!-- CATEGORY OUTPUT END -->
  360       <?php
  361           print $ItemTabs->TabRow();
  362           if(count($ItemTabs->Tabs))
  363           {       
  364       ?>
  365       <div class="divider" id="tabsDevider"><img width=1 height=1 src="images/spacer.gif"></div>
  366         <?php
  367           }
  368         ?>
  369     </DIV>
  370     <?php
  371           unset($m);
  372           
  373           //echo $application->ParseBlock(Array('name'=>'kernel_form_start'), 0, true);
  374           
  375       $m = GetModuleArray("admin");
  376       foreach($m as $key=>$value)
  377       {
  378           $path = $pathtoroot.$value."admin/browse.php";
  379           if(file_exists($path))
  380           {
  381               //echo "\n<!-- $path -->\n";
  382               include_once($path);
  383           }
  384       }
  385      
  386       //echo $application->ParseBlock(Array('name'=>'kernel_form_end'), 0, true);
  387      
  388      
  389       $admin = $objConfig->Get("AdminDirectory");
  390           if(!strlen($admin)) $admin = "admin";
  391     ?>
  392     <form method="post" action="<?php echo $rootURL.$admin; ?>/browse.php?env=<?php echo BuildEnv(); ?>" name="viewmenu">
  393       <input type="hidden" name="fieldname" value="">
  394       <input type="hidden" name="varvalue" value="">
  395       <input type="hidden" name="varvalue2" value="">
  396       <input type="hidden" name="Action" value="">
  397     </form>
  398   </DIV>
  399   <!-- END CODE-->
  400   <script language="JavaScript">
  401      InitPage();
  402     
  403     
  404      cats_on = theMainScript.GetCookie('cats_tab_on');
  405      if (cats_on == 0) {
  406            toggleCategoriesB(document.getElementById('cats_tab'), true);
  407      }
  408     
  409      tabs_on = theMainScript.GetCookie('tabs_on');
  410      if (tabs_on == '1' || tabs_on == null) {
  411              if(default_tab.length == 0 || default_tab == 'categories' )
  412              {
  413                           cookie_start = theMainScript.GetCookie('active_tab');
  414                           if (cookie_start != null) start_tab = cookie_start;
  415                if(start_tab!=null) {
  416                   //alert('ok');
  417                  toggleTabB(start_tab, true);
  418                }
  419              }
  420              else
  421              {
  422                           //alert('ok');
  423                  toggleTabB(default_tab,true);
  424              }
  425            }
  426     
  427           d = document.getElementById('SearchWord');
  428           if(d)
  429           {
  430                   d.onkeyup = function(event) {
  431                           if(window.event.keyCode==13)
  432                           {
  433                                   var el = document.getElementById('imgSearch');
  434                                   el.onclick();
  435                           }
  436                   }
  437           }  
  438   </script>
  439  
  440   <?php
  441           $objSession->SetVariable("HasChanges", 0);
  442           int_footer();
  443   ?>