<?php
global $xajax;
$xajax -> register( XAJAX_FUNCTION, 'deleteAnalysisPhrase' );
$xajax -> register( XAJAX_FUNCTION, 'setPrice' );
$xajax -> register( XAJAX_FUNCTION, 'deleteAnalysisSite' );

function deleteAnalysisSite( $id, $phrase_id, $category_id )
{  
  if ( \factory\Analysis::deleteAnalysisLink( $id ) )
    \S::alert( 'Wybrany link został usunięty.' );
  
  $objResponse = new xajaxResponse;
  $objResponse -> script( '$( "#site_' . $id . '" ).remove();' );
  return $objResponse;
}

function setPrice( $id, $price )
{
  \factory\Analysis::setPrice( $id, $price );
}

function deleteAnalysisPhrase( $id, $category_id )
{  
  if ( \factory\Analysis::deletePhrase( $id ) )
    \S::alert( 'Wybrana fraza została usunięta.' );
  
  $objResponse = new xajaxResponse();
  $objResponse -> script( 'document.location.href="./?rw=show_phrases&id=' . $category_id . '";' );
  return $objResponse;
}