Skip to content

Commit

Permalink
Merge branch 'development' of git://github.com/cykod/Webiva into shar…
Browse files Browse the repository at this point in the history
…e-mod-seperate
  • Loading branch information
Tia committed Mar 5, 2010
2 parents 764b8a7 + 2d281de commit 560a9d3
Show file tree
Hide file tree
Showing 28 changed files with 388 additions and 73 deletions.
3 changes: 2 additions & 1 deletion app/controllers/cms_controller.rb
Expand Up @@ -273,7 +273,8 @@ def cms_page_info(title,section=nil,menu_js = nil) # :nodoc:
# The last page title does not need to exist in cms_admin_paths unless it
# is referenced somewhere else in the controller.
def self.cms_admin_paths(section,pages = {})
pages['Content'] ||= { :controller => '/content' }
pages['Content'] ||= { :controller => '/content' }
pages['Website'] ||= { :controller => '/structure' }
pages['Options'] ||= { :controller => '/options' }
pages['Modules'] ||= { :controller => '/options/modules' }
sing = class << self; self; end
Expand Down
30 changes: 12 additions & 18 deletions app/controllers/mail_manager_controller.rb
Expand Up @@ -8,8 +8,7 @@ class MailManagerController < CmsController # :nodoc: all

cms_admin_paths "e_marketing",
"E-marketing" => { :controller => '/emarketing' },
"Mail Templates" => { :controller => '/mail_manager', :action => 'templates' },
"Marketing Campaigns" => { :controller => 'campaigns', :action => 'index' }
"Mail Templates" => { :controller => '/mail_manager', :action => 'templates' }



Expand Down Expand Up @@ -85,43 +84,38 @@ def generate_text_body
end

def edit_template

if params[:path][1]
@campaign = MarketCampaign.find(params[:path][1])
if params[:return] && params[:return_id]
@handler_info = get_handler_info(:mail_template, :edit, params[:return])
logger.error("mail_template edit handler #{params[:return]}(#{params[:return_id]}) not found") unless @handler_info
end

template_id = params[:path][0]
@mail_template = MailTemplate.find_by_id(template_id) || MailTemplate.new(:body_type => 'html')

@design_templates = [['--No Design Template--','']] + SiteTemplate.find_select_options(:all,:order => 'name',:conditions => 'template_type = "mail"')

if @campaign
cms_page_path [ 'E-marketing', 'Marketing Campaigns' ], "Edit Mail Template"
if @handler_info && @handler_info[:class].respond_to?(:mail_template_cms_path)
cms_page_path *@handler_info[:class].mail_template_cms_path(self)
else
cms_page_path [ "E-marketing" ,"Mail Templates" ], "Edit Mail Template"
end

@mail_template = MailTemplate.find_by_id(template_id) || MailTemplate.new(:body_type => 'html', :template_type => @campaign ? 'campaign' : 'site')
@mail_template = MailTemplate.find_by_id(template_id) || MailTemplate.new(:body_type => 'html', :template_type => @handler_info && @handler_info[:template_type] ? @handler_info[:template_type] : 'site')

if request.post?
if save_template
DataCache.expire_content("Mailing")
if @campaign
@campaign.update_attribute(:mail_template_id,@mail_template.id)
redirect_to :controller => 'campaigns', :action => 'message', :path => [ @campaign.id ]
if @handler_info
if redirect_url = @handler_info[:class].mail_template_save(@mail_template, self)
redirect_to redirect_url
end
else
redirect_to :action => 'templates'
end
end
end

if @campaign
setup_campaign_steps
@campaign_step = 3
end


@generate_handlers = get_handler_info(:mail_manager,:generator)

end

def refresh_template
Expand Down
63 changes: 45 additions & 18 deletions app/controllers/structure_controller.rb
Expand Up @@ -4,12 +4,16 @@ class StructureController < CmsController # :nodoc: all

public

permit ['editor_structure','editor_structure_advanced'], :except => [ :index, :element_info ]
permit ['editor_structure','editor_structure_advanced'], :except => [ :index, :element_info, :wizards ]
permit ['editor_website','editor_structure','editor_structure_advanced'], :only => [:index, :element_info]


permit ['editor_structure_advanced'], :only => [:wizards]

helper :application


cms_admin_paths 'website'


def index
session[:structure_view_modifiers] = @display_modifiers= params[:modifiers] ||
Expand Down Expand Up @@ -45,10 +49,21 @@ def index
@active_modules = SiteModule.structure_modules
end

@wizard_list = get_handlers(:structure,:wizard) if myself.has_role?('editor_structure_advanced')

cms_page_info 'Website', 'website',myself.has_role?('editor_structure_advanced') ? 'CMSStructure.popup();' : nil
render :action => 'view', :layout => "manage"
end


def wizards
cms_page_path ['Website'], "Wizards"

@wizard_list = get_handler_info(:structure,:wizard) if myself.has_role?('editor_structure_advanced')
@wizard_list = @wizard_list.select { |info| myself.has_role?(info[:permit]) }

end


def move_node
node_id = params[:node_id]
Expand Down Expand Up @@ -278,35 +293,47 @@ def update_site_node_options
end

def create_revision
revision_id = params[:revision_create][:from_revision_id]
revision_id = params[:revision_create][:from_revision_id] if params[:revision_create]
language = params[:language]


@revision = PageRevision.find(revision_id)
@new_revision = @revision.clone
@new_revision.language = language
@new_revision.revision_type = 'real'
@new_revision.active= false
@new_revision.save

@revision.page_paragraphs.each do |para|
new_para = para.clone
new_para.page_revision_id=@new_revision.id
new_para.save
if revision_id
@revision = PageRevision.find(revision_id)
@new_revision = @revision.clone
@new_revision.language = language
@new_revision.revision_type = 'real'
@new_revision.active= false
@new_revision.save

@revision.page_paragraphs.each do |para|
new_para = para.clone
new_para.page_revision_id=@new_revision.id
new_para.save
end
else
if params[:framework_id]
@node = SiteNodeModifier.find(params[:framework_id])
else
@node = SiteNode.find(params[:node_id])
end

@new_revision = @node.page_revisions.create(:language => language,
:revision_type => 'real',
:active => false)

end


@languages = Configuration.languages

if @new_revision.revision_container.is_a?(SiteNode)
@node = @new_revision.revision_container
@revision_info = @node.language_revisions(@languages)
render :partial => 'revision_info', :locals => { :info => [ @new_revision.language, @new_revision ] }
render :partial => 'revision_info', :locals => { :info => [ @new_revision.language, @new_revision, @new_revision ] }
else
@mod = @new_revision.revision_container
@node = @mod.site_node
@revision_info = @mod.language_revisions(@languages)
render :partial => 'framework_revision_info', :locals => { :info => [ @new_revision.language, @new_revision ] }
render :partial => 'framework_revision_info', :locals => { :info => [ @new_revision.language, @new_revision, @new_revision ] }
end

expire_site
Expand Down
24 changes: 24 additions & 0 deletions app/helpers/cms_helper.rb
Expand Up @@ -757,5 +757,29 @@ def subpage_display(name,pages)
output += html.map { |elm| elm[1] }.join
output
end

class WizardSteps
def initialize(wizard_step,wizard_max_step)
@wizard_step = wizard_step
@wizard_max_step = wizard_max_step
end

def step(number,txt,url = {})

if number == @wizard_step
"<b class='large_ajax_link_selected'>#{number}. #{txt}</b>"
elsif number <= @wizard_max_step

"<a href='#{url}'>#{number}. #{txt}</a>"
else
"#{number}. #{txt}"
end
end

end

def wizard_steps(wizard_step,wizard_max_step)
yield WizardSteps.new(wizard_step,wizard_max_step)
end

end
8 changes: 6 additions & 2 deletions app/models/end_user.rb
Expand Up @@ -117,6 +117,10 @@ class EndUser < DomainModel
[ 'Import', 'import' ],
[ 'Referrel', 'referrel' ] ]

if CMS_EDITOR_LOGIN_SUPPORT
after_save :update_editor_login
end

def after_create #:nodoc:
if @tag_cache
self.tag(@tag_cache)
Expand All @@ -126,7 +130,6 @@ def after_create #:nodoc:
## Validation Fucntions



def before_validation #:nodoc:
self.email = self.email.downcase unless self.email.blank?
end
Expand Down Expand Up @@ -473,9 +476,10 @@ def before_save #:nodoc:
end

def update_editor_login #:nodoc:
if self.editor?
if self.registered? && self.activated? && self.editor?
editor_login= EditorLogin.find_by_domain_id_and_email(Configuration.domain_id,self.email) || EditorLogin.new
editor_login.update_attributes(:domain_id => Configuration.domain_id,
:login_hash => self.class.generate_hash,
:email => self.email,
:end_user_id => self.id,
:hashed_password => self.hashed_password)
Expand Down
6 changes: 5 additions & 1 deletion app/models/market_segment.rb
Expand Up @@ -13,7 +13,11 @@ class MarketSegment < DomainModel
[ 'Registered Members', 'members' ] ,
[ 'Content Model', 'content_model'] ]



named_scope :with_segment_type, lambda { |segment_type| segment_type == 'custom' || segment_type == 'content_model' ? {:conditions => 'segment_type = "custom" || segment_type = "content_model"'} : {:conditions => ['segment_type = ?', segment_type]} }
named_scope :for_campaign, lambda { |campaign| campaign.id ? {:conditions => ['market_campaign_id IS NULL OR market_campaign_id = ?', campaign.id]} : {:conditions => 'market_campaign_id IS NULL'} }
named_scope :order_by_name, :order => :name

def save_segment
self.market_campaign_id ? 'yes' : 'no'
end
Expand Down
18 changes: 18 additions & 0 deletions app/models/page_paragraph.rb
Expand Up @@ -169,6 +169,24 @@ def direct_set_page_connections(conns)
def display_module_identifier
self.display_module.gsub("/","_")
end

def add_paragraph_input!(input_name,other_para,conn_type,identifier)
self.connections ||= { }
self.connections[:inputs] ||= { }
self.connections[:inputs][input_name.to_sym] = [ other_para.identity_hash, conn_type.to_sym, identifier.to_sym]

other_para.connections ||= { }
other_para.connections[:outputs] ||= []
other_para.connections[:outputs] << [ identifier.to_sym, self.identity_hash, input_name.to_sym ]
other_para.save
self.save
end

def add_page_input(input_name,conn_type,identifier)
self.connections ||= { }
self.connections[:inputs] ||= { }
self.connections[:inputs][input_name.to_sym] = [ "0", conn_type.to_sym, identifier.to_sym]
end

def page_connection(name)
@page_connections ||= {}
Expand Down
13 changes: 13 additions & 0 deletions app/models/page_revision.rb
Expand Up @@ -241,6 +241,19 @@ def deactivate
self.revision,self.revision_container_type,self.revision_container_id, self.language])
end
end


# Programmatically add a paragraph to a revision
def add_paragraph(renderer_class,name,paragraph_options={ },options={ })

self.page_paragraphs.build(
:zone_idx => options[:zone] || 1,
:display_type => name,
:display_module => renderer_class,
:data => paragraph_options
)
end



end
10 changes: 5 additions & 5 deletions app/views/mail_manager/edit_template.rhtml
Expand Up @@ -102,14 +102,13 @@
};
</script>

<div class='admin_content'>
<% if @campaign %>
<%= render :partial => '/campaigns/campaign_steps' %>
<% end -%>
</div>
<%= render :partial => @handler_info[:partial] if @handler_info && @handler_info[:partial] %>

<div class='admin_content'>
<div style='position:relative;'>
<% cms_unstyled_form_for :mail_template, @mail_template, :html => { :id => 'mail_template_form', :class => 'admin_form', :onsubmit => 'TemplateEditor.triggerSave(); return true;' } do |f| -%>
<%= hidden_field_tag(:return, @handler_info[:identifier]) if @handler_info -%>
<%= hidden_field_tag(:return_id, params[:return_id]) if @handler_info -%>
<table width='100%'>
<tr>
<td width='200' valign='top' style='padding-right:20px;'>
Expand Down Expand Up @@ -213,4 +212,5 @@
<% end -%>

</div>
</div>

9 changes: 6 additions & 3 deletions app/views/structure/_framework_revision_info.rhtml
Expand Up @@ -16,8 +16,11 @@
<% remote_form_for :revision_create, info[1],
:update => "node_#{@node.id}_#{info[0]}",
:method => 'post',
:url => { :action => 'create_revision', :language => info[0] } do |f| -%>
<input type='submit' value='<%= "Create Framework".t %>' /> From
<%= f.select :from_revision_id, @revision_info.find_all { |inf| inf[1] }.collect { |inf| [ inf[0].upcase, inf[1].id ] } %>
:url => { :action => 'create_revision', :language => info[0],:node_id => @node.id, :framework_id => @mod.id } do |f| -%>
<input type='submit' value='<%= "Create Framework".t %>' />
<% if (available_revisions = @revision_info.find_all { |inf| inf[1] }.collect { |inf| [ inf[0].upcase, inf[1].id ] }).length > 0 -%>
From
<%= f.select :from_revision_id, available_revisions %>
<% end -%>
<% end -%>
<% end -%>
9 changes: 6 additions & 3 deletions app/views/structure/_revision_info.rhtml
Expand Up @@ -32,9 +32,12 @@
<% remote_form_for :revision_create, info[1],
:update => "node_#{@node.id}_#{info[0]}",
:method => 'post',
:url => { :action => 'create_revision', :language => info[0] } do |f| -%>
<input type='submit' value='<%= "Create Page".t %>' /> From
<%= f.select :from_revision_id, @revision_info.find_all { |inf| inf[1] }.collect { |inf| [ inf[0].upcase, inf[1].id ] } %>
:url => { :action => 'create_revision', :language => info[0],:node_id => @node.id } do |f| -%>
<input type='submit' value='<%= "Create Page".t %>' />
<% if (available_revisions = @revision_info.find_all { |inf| inf[1] }.collect { |inf| [ inf[0].upcase, inf[1].id ] }).length > 0 -%>
From
<%= f.select :from_revision_id, available_revisions %>
<% end -%>
<% end -%>
<% else %>
<%= "No Existing Revision".t %>
Expand Down
1 change: 1 addition & 0 deletions app/views/structure/view.rhtml
Expand Up @@ -38,6 +38,7 @@ if @show_archived == 'hide'
p.link 'Hide Archived', :icon => 'show.gif', :url => '?archived=hide'
end
%>
<%= p.link('Wizards',:icon => 'configure.gif',:action => 'wizards') if @wizard_list.length > 0 -%>
<% end -%>
<div class='admin_content'>

Expand Down
8 changes: 8 additions & 0 deletions app/views/structure/wizards.rhtml
@@ -0,0 +1,8 @@

<div class='admin_content'>

<% @wizard_list.each do |wizard| -%>
<h2><%= link_to wizard[:name], wizard[:url] -%></h2>
<%= simple_format(wizard[:description]) -%>
<% end -%>
</div>
2 changes: 2 additions & 0 deletions config/environment.rb
Expand Up @@ -32,6 +32,8 @@
CMS_DEFAULT_DOMAIN = defaults_config_file['domain']

CMS_SYSTEM_ADMIN_EMAIL = defaults_config_file['system_admin']

CMS_EDITOR_LOGIN_SUPPORT = defaults_config_file['editor_login'] || false

DEFAULT_DATETIME_FORMAT = defaults_config_file['default_datetime_format'] || "%m/%d/%Y %I:%M %p"
DEFAULT_DATE_FORMAT = defaults_config_file['default_date_format'] || "%m/%d/%Y"
Expand Down
4 changes: 2 additions & 2 deletions config/environments/development.rb
Expand Up @@ -22,5 +22,5 @@

config.action_mailer.delivery_method = :test

#require 'development_logger'
#config.logger = DevelopmentLogger.new(File.dirname(__FILE__) + "/../../log/#{RAILS_ENV}.log", "daily")
require 'development_logger'
config.logger = DevelopmentLogger.new(File.dirname(__FILE__) + "/../../log/#{RAILS_ENV}.log", 0, 0)

0 comments on commit 560a9d3

Please sign in to comment.