-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharchive.php
198 lines (156 loc) · 7.78 KB
/
archive.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
global $can_modify, $campaign_id, $is_campaign_page;
$this_category = get_category($cat);
$this_category_name = $this_category->name;
$name_exploded = explode('cat', $this_category_name);
if (count($name_exploded) > 1) {
$campaign_id = $name_exploded[1];
}
$classes = '';
if (isset($campaign_id)) {
$campaign_post = get_post($campaign_id);
$campaign = atcf_get_campaign($campaign_post);
$edit_version = $campaign->edit_version();
$classes = 'version-' . $edit_version;
$is_campaign_page = TRUE;
$tag_list = wp_get_post_terms($campaign_id, 'download_tag');
foreach ($tag_list as $tag) {
if ($classes != '') { $classes .= ' '; }
$classes .= 'theme-' . $tag->slug;
$client_context = $tag->slug;
}
}
$page_edit_news = get_page_by_path('editer-une-actu');
if (isset($_POST['action']) && $_POST['action'] == 'ypcf-campaign-add-news') {
WDGFormProjects::form_validate_news_add($campaign_id);
//Afficher le nouvel article
header('Location: '.$_SERVER['REQUEST_URI']);
}
//Supprime un article (le place dans la corbeille de WP)
if (isset($_GET['delete_post_id'])){
//Test pour vérifier que le post de blog appartient à la campagne
$posts_blog = get_posts( array(
'category' => $campaign->get_news_category_id()
));
$delete_post_id = ($_GET['delete_post_id']);
$post_belong_campaign = false;
foreach ($posts_blog as $post_blog) {
if ($post_blog->ID == $delete_post_id){
$post_belong_campaign = true;
$title = $post_blog->post_title;
}
}
if ($post_belong_campaign && $campaign->current_user_can_edit()){
wp_trash_post($delete_post_id);
//Rafraichit la liste des posts
header('Location: '.$_SERVER['REQUEST_URI']);
}
}
?>
<?php get_header(); ?>
<div id="content" <?php echo 'class="'.$classes.'"'; ?>>
<div class="padder">
<div class="page" id="blog-archives" role="main">
<?php locate_template( array("projects/single/banner.php"), true ); ?>
<div id="post_bottom_content" class="center margin-height">
<?php if ($can_modify): ?>
<h2><a class="expandator" data-target="add-news" id="add-news-opener"><?php _e('Publier une actualité', 'yproject'); ?> <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/plus.png" alt="signe plus"/></a></h2>
<form action="" method="post" enctype="multipart/form-data" id="extendable-add-news" class="expandable
<?php if(isset($_GET['new-topic']) || (isset($_POST['action']) && $_POST['action'] == 'ypcf-campaign-preview-news')){echo 'default-expanded';}?>">
<?php if (isset($_POST['action']) && $_POST['action'] == 'ypcf-campaign-preview-news') { ?>
<div class="preview">
<h3>Prévisualisation de l'actu</h3>
<div class="preview-frame">
<div class="post-content">
<?php echo '<h3 class="posttitle">'.$_POST['posttitle'].'</h3>';
echo '<p class="date">'.mysql2date( get_option( 'date_format' ), date_format(new DateTime(), 'Y-m-d H:i:s')).'</p>';
echo '<div class="entry">'.nl2br($_POST['postcontent']).'</div>';?>
</div>
</div>
</div>
<?php } ?>
<label class="title-news" for="posttitle"><?php _e( 'Titre', 'ypcf' ); ?></label> <br/>
<input type="text" name="posttitle" style="width: 250px;" value="<?php if (isset($_POST['posttitle'])){echo $_POST['posttitle'];}?>"><br/><br/>
<label class="title-news" for="postcontent"><?php _e( 'Contenu', 'ypcf' ); ?></label> <br/>
<label>Attention à ne pas mettre une image de plus de <span class="advice-news">600 px</span> de largeur afin de ne pas déformer la mise en page du mail envoyé à vos évaluateurs et investisseurs.</label> <br/> <br/>
<?php
global $post_ID, $post;
$post_ID = $post = 0;
if (isset($_POST['postcontent'])){
$previous_content = $_POST['postcontent'];
} else {
$previous_content = '';
}
wp_editor( $previous_content, 'postcontent',
array(
'media_buttons' => true,
'quicktags' => false,
'tinymce' => array(
'plugins' => 'wordpress, paste, wplink, textcolor',
'paste_remove_styles' => true
)
)
);
?> <br/><br/>
<label><input type="checkbox" name="send_mail" <?php if (isset($_POST['send_mail'])){echo 'checked';}?>/>
Envoyer par mail cette actualité aux utilisateurs qui suivent le projet. <em>Les utilisateurs qui se sont désabonnés de vos actualités ne les recevront pas.</em></label> <br/><br/>
<?php _e('Relayez cette actualité sur vos réseaux sociaux et prévenez WE DO GOOD pour une communication décuplée !', 'yproject'); ?><br /><br />
<button type="submit" name="action" value="ypcf-campaign-preview-news" class="button"><?php _e('Prévisualisation', 'yproject'); ?></button>
<button type="submit" name="action" value="ypcf-campaign-add-news" class="button">
<span class="button-text">
<?php _e('Publier', 'yproject'); ?>
</span>
<span class="button-loading loading align-center hidden">
<img class="alignverticalmiddle marginright" src="<?php echo $stylesheet_directory_uri; ?>/images/loading-grey.gif" width="30" alt="chargement" /><?php _e( 'common.REGISTERING', 'yproject' ); ?>
</span>
</button><br /><br />
<?php wp_nonce_field('ypcf-campaign-add-news'); ?>
<?php wp_nonce_field('ypcf-campaign-preview-news'); ?>
<hr>
<?php /* Je n'assume pas trop cette modification, mais je ne sais pas trop où le mettre proprement. common.js ? */ ?>
<script type="text/javascript">
$('form button[value="ypcf-campaign-add-news"]').click(function (e) {
$(this).find(".button-text").hide();
$(this).find(".button-loading").show();
if ($(this).hasClass("disabled")) {
e.preventDefault();
}
$(this).addClass("disabled");
});
</script>
</form>
<?php endif; ?>
<h2><?php printf( __( 'Dernières actualités du projet %1$s', 'yproject' ), $campaign_post->post_title); ?></h2>
<?php if ( have_posts() ) : ?>
<?php while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="post-content">
<h3 class="posttitle">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php if ($can_modify): ?>
<a href="<?php echo get_permalink($page_edit_news->ID); ?>?campaign_id=<?php echo $campaign_post->ID; ?>&edit_post_id=<?php echo $post->ID; ?>" class="button"><?php _e('Editer', 'yproject'); ?></a>
<?php endif; ?>
</h3>
<p class="date"><?php echo get_the_date(); ?></p>
<div class="entry">
<?php the_content( __( "Lire la suite...", 'yproject' ) ); ?>
</div>
<div class="clear"></div>
<span class="comments"><?php comments_popup_link( __( 'Aucun commentaire »', 'yproject' ), __( '1 commentaire »', 'yproject' ), __( '% commentaires »', 'yproject' ) ); ?></span></p>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<?php if (isset($campaign_post)) : ?>
Retrouvez bientôt les actualités de ce projet !
<?php else : ?>
<h2 class="center"><?php _e( "Aucun...", 'yproject' ); ?></h2>
<?php get_search_form(); ?>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
</div><!-- .padder -->
</div><!-- #content -->
<?php get_footer();