class Admin::HeadlinesController

OpenIrekia v4.0.0

Copyright 2009-2013 eFaber, S.L. Copyright 2009-2013 Ejie, S.A. Copyrigth 2009-2013 Dirección de Gobierno Abierto y Comunicación en Internet;

Gobernu Irekirako eta Interneteko Komunikaziorako Zuzendaritza; Lehendakaritza.
Gobierno Vasco – Eusko Jaurlaritza

Licencia con arreglo a la EUPL, Versión 1.1 o –en cuanto sean aprobadas por la Comisión Europea– versiones posteriores de la EUPL (la Licencia); Solo podrá usarse esta obra si se respeta la Licencia. Puede obtenerse una copia de la Licencia en: ec.europa.eu/idabc/eupl Salvo cuando lo exija la legislación aplicable o se acuerde por escrito, el programa distribuido con arreglo a la Licencia se distribuye TAL CUAL, SIN GARANTÍAS NI CONDICIONES DE NINGÚN TIPO, ni expresas ni implícitas. Véase la Licencia en el idioma concreto que rige los permisos y limitaciones que establece la Licencia

http://open.irekia.net, openirekia@efaber.net

Public Instance Methods

auto_complete_for_headline_tag_list_without_areas() click to toggle source

Auto complete para los tags

# File app/controllers/admin/headlines_controller.rb, line 133
def auto_complete_for_headline_tag_list_without_areas
  auto_complete_for_tag_list(params[:headline][:tag_list_without_areas])
  if @tags.length > 0
    render :inline => "<%= content_tag(:ul, @tags.map {|t| content_tag(:li, t.nombre)}) %>"
  else
    render :nothing => true
  end    
end
delete_from_entzumena() click to toggle source

API to delete item from entzumena.irekia.euskadi.net

# File app/controllers/admin/headlines_controller.rb, line 106
def delete_from_entzumena
  headline = Headline.find(:first, :conditions => {:source_item_type => params[:source_item_type], :source_item_id => params[:source_item_id]})
  if headline.destroy
    render :json => true, :status => 200
  else
    render :json => false, :status => :error
  end    
end
destroy() click to toggle source
# File app/controllers/admin/headlines_controller.rb, line 115
def destroy
  @headline = Headline.find(params[:id])
  if @headline.destroy
    respond_to do |format|
      format.html {
        flash[:notice] = 'La referencia se ha eliminado correctamente'
        redirect_to admin_headlines_path
      }
      format.js { 
        render :update do |page|
          page.visual_effect :fade, "headline_#{@headline.id}"
        end
      }
    end  
  end  
end
index() click to toggle source
# File app/controllers/admin/headlines_controller.rb, line 28
def index                                                 
  @title = t('headlines.title')                    
  @sort_order = params[:sort] ||  "published_at"
  
  case @sort_order
  when "published_at"
    order = "published_at DESC, score DESC, title"
  when "title"
    order = "lower(tildes(title)), published_at DESC, score DESC"
  when "media"
    order = "lower(tildes(media_name)), published_at DESC, score DESC"
  end                                              
  
  conditions = []
  cond_values = {}
  
  if params[:q].present?
    conditions << "lower(tildes(title)) like :q"
    cond_values[:q] = "%" + params[:q].tildes.downcase + "%"
  end

  @headlines = Headline.paginate :page => params[:page], :per_page => 20,
    :order => order,
    :conditions => [conditions.join(' AND '), cond_values]
end
update() click to toggle source
# File app/controllers/admin/headlines_controller.rb, line 54
def update       
  @headline = Headline.find(params[:id])
  if params[:build_params].present? && params[:build_params].eql?('true')
    params[:headline]={}
    params[:headline].merge!(:area_id => params[:area_id]) if params[:area_id].present?
    params[:headline].merge!(:locale => params[:hl_locale]) if params[:hl_locale].present?      
    params[:headline].merge!(:tag_list => params[:tag_list]) if params[:tag_list].present?
  end  
  if @headline.update_attributes(params[:headline])         
    render :update do |page|
      page.replace "headline_#{@headline.id}", :partial => "headline", :locals => {:headline => @headline}
      page["headline_#{@headline.id}"].className = @headline.draft ? 'pendiente' : 'aprobado'      
      page << "$$('.area_name').each(function(element) {  
        element.observe('change', function(){    
          updateArea(element);
        });             
      });
      "
      page << "$$('.locale').each(function(element) {         
        element.observe('change', function(){    
          updateLocale(element);
        });
      });
      "
      page << "$$('div.tags input[type=submit]').each(function(element) {         
        element.observe('click', function(){    
          updateTags(element);
        });
      });"
    end
  else
    render :update do |page|
      page.visual_effect :highlight, "headline_#{@headline.id}"
    end
  end
end
update_area() click to toggle source
# File app/controllers/admin/headlines_controller.rb, line 91
def update_area                             
  @headline = Headline.find(params[:id].to_i)     
  if @headline.update_attributes({:area_id => params[:area_id].to_i})
    render :update do |page|
      page.replace "headline_#{@headline.id}", :partial => "headline", :locals => {:headline => @headline}
      page["headline_#{@headline.id}"].className = @headline.draft ? 'pendiente' : 'aprobado'
    end                                                            
  else
    render :update do |page|
      page.visual_effect :highlight, "headline_#{@headline.id}"
    end
  end
end