<?
include_once('clss_0.php') ;
class clss_36 extends clss_0
{

   function prepare_public_info(&$rec)
   {   //damp_array($rec) ;
       $name=$rec['url'] ;
       $name=trim(strip_tags($name))  ;   // удаляем начальные и конечные пробелы и HTML-теги
       $name=str_replace(array("\n"),array(''),$name) ; // удяляем переносты строк
       if (!$name) $name='# '.$rec['pkey'] ;
       $rec['__name']=$name ;
       $rec['_in_tree_name']=$name ;
       if (isset($rec['_child_cnt'])) $rec['_in_tree_child_cnt']=$this->prepare_child_cnt_to_tree($rec['_child_cnt']) ;
       if (isset($this->parent_to) and !_sizeof($this->parent_to)) $rec['_in_tree_child_cnt']=0 ;
   }

}

function sitemap_delete_check_reffer_from_rec($options=array())
{ global $obj_info ;
  $tkey=$_SESSION['pkey_by_table'][TM_SITEMAP] ;
  if (_sizeof($_POST['_check'][$tkey][36])) foreach($_POST['_check'][$tkey][36] as $id=>$value)
  { $seo_rec=execSQL_van('select * from '.TM_SITEMAP.' where pkey='.$id) ;
    if ($seo_rec['pkey'])
    { execSQL_update('update '.TM_SITEMAP.' set obj_reffer="" where pkey='.$seo_rec['pkey']) ;
      _event_reg('Удаление связи страницы с объектом',$obj_info['obj_name'].' != '.$seo_rec['url'],$obj_info['_reffer'],$seo_rec['_reffer']) ;
      echo 'Удалена связь для стараницы <strong>'.$seo_rec['url'].'</strong><br>' ;
    }
  }


  return('ok') ;
}

function sitemap_delete_id_reffer_from_rec($options=array())
{ global $obj_info ;
  $seo_rec=execSQL_van('select * from '.TM_SITEMAP.' where pkey='.$_POST['params']) ;
  if ($seo_rec['pkey'])
  { execSQL_update('update '.TM_SITEMAP.' set obj_reffer="" where pkey='.$seo_rec['pkey']) ;
    _event_reg('Удаление связи страницы с объектом',$obj_info['obj_name'].' != '.$seo_rec['url'],$obj_info['_reffer'],$seo_rec['_reffer']) ;
    echo 'Удалена связь для стараницы <strong>'.$seo_rec['url'].'</strong><br>' ;
  }
  return('ok') ;
}

function sitemap_copy_tags_to_main_page($options=array())
{ if (!$_POST['cur_sitemap_page_id']) return('ok') ;
  $seo_rec1=execSQL_van('select * from '.TM_SITEMAP.' where pkey='.$_POST['cur_sitemap_page_id']) ;
  $tkey=$_SESSION['pkey_by_table'][TM_SITEMAP] ;
  if (_sizeof($_POST['_check'][$tkey][36])) foreach($_POST['_check'][$tkey][36] as $id=>$value)
  { $seo_rec2=execSQL_van('select * from '.TM_SITEMAP.' where pkey='.$id) ;
    if ($seo_rec2['pkey'])
    {  unset($seo_rec2['pkey'],$seo_rec2['clss'],$seo_rec2['indx'],$seo_rec2['obj_name'],$seo_rec2['parent'],$seo_rec2['enabled'],$seo_rec2['c_data'],$seo_rec2['r_data'],$seo_rec2['parent_enabled'],$seo_rec2['url'],$seo_rec2['obj_reffer'],$seo_rec2['type'],$seo_rec2['status'],$seo_rec2['script'],$seo_rec2['class'],$seo_rec2['no_sitemap'],$seo_rec2['temp'],$seo_rec2['tkey'],$seo_rec2['_reffer'],$seo_rec2['_parent_reffer']) ;
       //damp_array($seo_rec2) ;
       update_rec_in_table(TM_SITEMAP,$seo_rec2,'pkey='.$seo_rec1['pkey']) ;
      echo '<strong>Теги скопированы</strong><br>' ;
    }
  }
  return('ok') ;
}

?>
