Changeset 1103
- Timestamp:
- 04/30/10 12:48:48 (22 months ago)
- Location:
- plugins/apostropheBlogPlugin/trunk
- Files:
-
- 1 removed
- 6 modified
-
lib/model/doctrine/PluginaBlogItem.class.php (modified) (2 diffs)
-
lib/model/doctrine/PluginaBlogPost.class.php (modified) (1 diff)
-
lib/model/doctrine/PluginaEvent.class.php (modified) (1 diff)
-
modules/aEventAdmin/config/generator.yml (modified) (2 diffs)
-
modules/aEventAdmin/templates/_form.php (modified) (1 diff)
-
modules/aEventAdmin/templates/_optionsForm.php (deleted)
-
modules/aEventAdmin/templates/editSuccess.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
plugins/apostropheBlogPlugin/trunk/lib/model/doctrine/PluginaBlogItem.class.php
r1102 r1103 14 14 { 15 15 protected $update = true; 16 protected $engine = 'aBlog'; 16 17 17 18 /** … … 218 219 return false; 219 220 } 221 222 /** 223 * This function attempts to find the "best" engine to route a given post to. 224 */ 225 public function findBestEngine() 226 { 227 $engines = Doctrine::getTable('aPage')->createQuery() 228 ->addWhere('engine = ?', $this->engine) 229 ->execute(); 230 231 if(count($engines) == 0) 232 return ''; 233 else if(count($engines) == 1) 234 return $engines[0]; 235 236 //When there are more than one engine page we need to use some heuristics to 237 //guess what the best page is. 238 $catIds = array(); 239 foreach($this->Categories as $category) 240 { 241 $catIds[$category['id']] = $category['id']; 242 } 243 244 if(count($catIds) < 1) 245 return $engines[0]; 246 247 $best = array(0, ''); 248 249 foreach($engines as $engine) 250 { 251 $score = 0; 252 foreach($engine->BlogCategories as $category) 253 { 254 if(isset($catIds[$category['id']])) 255 $score = $score + 1; 256 } 257 if($score > $best[0]) 258 { 259 $best = $engine; 260 } 261 } 262 263 return $best; 264 } 220 265 } -
plugins/apostropheBlogPlugin/trunk/lib/model/doctrine/PluginaBlogPost.class.php
r1095 r1103 13 13 abstract class PluginaBlogPost extends BaseaBlogPost 14 14 { 15 16 /** 17 * This function attempts to find the "best" engine to route a given post to. 18 */ 19 public function findBestEngine() 20 { 21 $engines = Doctrine::getTable('aPage')->createQuery() 22 ->addWhere('engine = ?', 'aBlog') 23 ->execute(); 24 25 if(count($engines) == 0) 26 return ''; 27 else if(count($engines) == 1) 28 return $engines[0]; 29 30 //When there are more than one engine page we need to use some heuristics to 31 //guess what the best page is. 32 $catIds = array(); 33 foreach($this->Categories as $category) 34 { 35 $catIds[$category['id']] = $category['id']; 36 } 37 38 if(count($catIds) < 1) 39 return $engines[0]; 40 41 $best = array(0, ''); 42 43 foreach($engines as $engine) 44 { 45 $score = 0; 46 foreach($engine->BlogCategories as $category) 47 { 48 if(isset($catIds[$category['id']])) 49 $score = $score + 1; 50 } 51 if($score > $best[0]) 52 { 53 $best = $engine; 54 } 55 } 56 57 return $best; 58 } 59 15 protected $engine = 'aBlog'; 60 16 } -
plugins/apostropheBlogPlugin/trunk/lib/model/doctrine/PluginaEvent.class.php
r857 r1103 13 13 abstract class PluginaEvent extends BaseaEvent 14 14 { 15 15 protected $engine = 'aEvent'; 16 16 } -
plugins/apostropheBlogPlugin/trunk/modules/aEventAdmin/config/generator.yml
r1087 r1103 13 13 14 14 config: 15 actions: [wef, _new]16 15 fields: 17 16 author_id: { label: created by } 18 17 _editors_list: { label: edited by } 19 18 _categories_list: { label: categories } 20 tags_list: { label: tagged } 21 19 tags_list: { label: tagged } 20 22 21 list: 23 title: " Event Admin"22 title: "Blog Post Admin" 24 23 display: [ _title, _author_id, _editors_list, _tags_list, _categories_list, status, published_at ] 25 24 fields: … … 34 33 label: Categories 35 34 type: ManyKey 36 actions: 35 published_at: 36 label: Date 37 actions: 37 38 new: 38 label: New Event 39 action: new 40 params: 41 class: a-btn big icon a-add alt 42 39 label: New Post 40 action: new 41 params: 42 class: a-btn big icon a-add alt 43 batch_actions: 44 delete: 45 label: Delete 46 publish: 47 label: Publish 48 unpublish: 49 label: Unpublish 50 43 51 filter: 44 52 fields: [ author_id, editors_list, categories_list, status, _tags_list ] 45 53 display: [ author_id, editors_list, categories_list, status, _tags_list ] 46 54 47 form:48 fields: [ author_id ]49 display: [ author_id ]50 51 edit:52 fields: [ author_id ]53 -
plugins/apostropheBlogPlugin/trunk/modules/aEventAdmin/templates/_form.php
r862 r1103 1 <?php echo rand(0, 500) ?> 2 <?php use_helper('jQuery') ?> 3 <?php echo jq_form_remote_tag(array('url' => '@a_event_admin_update?slug='.$a_event['slug'], 'update' => 'a-admin-blog-post-form'), array('id'=>'a-admin-form')) ?> 4 <?php if (!$form->getObject()->isNew()): ?> 5 <input type="hidden" name="sf_method" value="PUT" /> 6 <?php endif; ?> 7 <div class="a-blog-post-title"> 8 <h2>Title</h2> 9 <?php echo $form['title']->render() ?> 10 <?php echo $form['title']->renderError() ?> 11 </div> 1 <?php use_helper('I18N','jQuery') ?> 12 2 13 <div class="a-blog-post-slug"> 14 <h2>Permalink</h2> 15 <?php echo $form['slug']->getWidget()->render('a_event[slug]', $a_event['slug']) ?> 16 <?php //echo $form['slug']->render() ?> 3 <?php echo jq_form_remote_tag(array('url' => url_for('a_blog_admin_update',$a_blog_post) , 'update' => 'a-admin-blog-post-form'), array('id'=>'a-admin-form', 'class' => 'blog')) ?> 4 5 <?php if (!$form->getObject()->isNew()): ?><input type="hidden" name="sf_method" value="PUT" /><?php endif; ?> 6 7 <?php echo $form->renderHiddenFields() ?> 8 9 10 11 <?php // Title and Slug are hidden and handled with inputs in the editSuccess ?> 12 <div class="post-title post-slug option"> 13 <?php echo $form['title']->renderRow() ?> 14 <?php echo $form['slug']->getWidget()->render('a_blog_post[slug]', $a_blog_post['slug']) ?> 17 15 <?php echo $form['slug']->renderError() ?> 18 16 </div> 19 17 20 <?php include_partial('aBlogAdmin/optionsForm', array('a_event' => $a_event, 'form' => $form)) ?>21 18 22 <script type="text/javascript"> 23 $(function () { 24 $('#a-admin-form').change(function() { 25 jQuery.ajax({ 26 type:'POST', 27 dataType:'html', 28 data:jQuery(this).serialize(), 29 success:function(data, textStatus){ 30 jQuery('#a-admin-blog-post-form').html(data); 31 }, 32 url: '<?php echo url_for('@a_event_admin_update?slug='.$a_event['slug']) ?>' 33 }); 34 }); 19 20 <?php // Huge Publish Button and Publish Date ?> 21 <div class="published section"> 22 <a href="#" class="a-btn big a-publish-post <?php echo ($a_blog_post['status'] == 'published')? 'published':'' ?>" onclick="return false;" id="a-blog-publish-button"> 23 <span class="publish"><?php echo __('Publish', array(), 'apostrophe_blog') ?></span> 24 <span class="unpublish"><?php echo __('Unpublish', array(), 'apostrophe_blog') ?></span> 25 </a> 26 <div id="a-blog-post-update" class="a-btn big a-publish-post">Saved</div> 27 28 <div class="post-status option"> 29 <?php echo $form['status']->renderRow() ?> 30 </div> 31 32 <?php echo __('Publish now or', array(), 'apostrophe_blog') ?> <a href="#" onclick="return false;" class="post-date-toggle a-sidebar-toggle"><?php echo __('set a date', array(), 'apostrophe_blog') ?></a> 33 34 <div class="post-published-at option"> 35 <?php echo $form['published_at']->render() ?> 36 <?php echo $form['published_at']->renderError() ?> 37 38 <?php 39 // Dan: 40 // All of a sudden we have save and cancel buttons now. 41 // So apparently when you click save it makes this change 42 // If you click cancel it some how restores it to 'Publish Now' â It doesn't just simply hide this options pane 43 ?> 44 <ul class="a-controls published_at"> 45 <li><a href="#" onclick="checkAndSetPublish('<?php echo $blog_post_url ?>'); return false;" class="a-btn a-save"><?php echo __('Save', array(), 'apostrophe_blog') ?></a></li> 46 <li><a href="#" onclick="checkAndSetPublish('<?php echo $blog_post_url ?>'); return false;" class="a-btn a-cancel"><?php echo __('Cancel', array(), 'apostrophe_blog') ?></a></li> 47 </ul> 48 </div> 49 </div> 50 51 52 53 <?php // Author & Editors Section ?> 54 <hr /> 55 <div class="author section"> 56 57 <div class="post-author"> 58 <h4><?php echo __('Author', array(), 'apostrophe_blog') ?>: 59 <?php if ($sf_user->hasCredential('admin')): ?> 60 </h4> 61 <div class="author_id option"> 62 <?php echo $form['author_id']->render() ?> 63 <?php echo $form['author_id']->renderError() ?> 64 </div> 65 <?php else: ?> 66 <span><?php echo $a_blog_post->Author ?></span></h4> 67 <?php endif ?> 68 69 </div> 70 71 <div class="post-editors"> 72 73 <?php if (!count($a_blog_post->Editors)): ?> 74 <a href="#" onclick="return false;" class="post-editors-toggle a-sidebar-toggle"><?php echo __('allow others to edit this post', array(), 'apostrophe_blog') ?></a> 75 <div class="post-editors-options option" id="editors-section"> 76 <?php else: ?> 77 <hr/> 78 <div class="post-editors-options option show-editors" id="editors-section"> 79 <?php endif ?> 80 81 <h4><?php echo __('Editors', array(), 'apostrophe_blog') ?>: </h4> 82 <?php echo $form['editors_list']->render()?> 83 <?php echo $form['editors_list']->renderError() ?> 84 85 </div> 86 </div> 87 </div> 88 89 90 91 <?php // Blog Post Categories ?> 92 <hr /> 93 <div class="categories section" id="categories-section"> 94 <h4><?php echo __('Categories', array(), 'apostrophe_blog') ?></h4> 95 <?php echo $form['categories_list']->render() ?> 96 <?php echo $form['categories_list']->renderError() ?> 97 </div> 98 99 100 101 <?php // Blog Post Tags ?> 102 <hr /> 103 <div class="tags section"> 104 <h4><?php echo __('Tags', array(), 'apostrophe_blog') ?></h4> 105 106 <?php echo $form['tags']->render() ?> 107 <?php echo $form['tags']->renderError() ?> 108 109 <script src='/sfDoctrineActAsTaggablePlugin/js/pkTagahead.js'></script> 110 <script type="text/javascript" charset="utf-8"> 111 $(function() { 112 pkTagahead(<?php echo json_encode(url_for("taggableComplete/complete")) ?>); 113 }); 114 </script> 115 <?php include_component('aBlogAdmin','tagList', array('a_blog_post' => $form->getObject())) ?> 116 </div> 117 118 119 120 <?php // Blog Post Templates ?> 121 <?php if(isset($form['template'])): ?> 122 <hr /> 123 <div class="template section"> 124 <h4><?php echo __('Template', array(), 'apostrophe_blog') ?></h4> 125 126 <?php echo $form['template']->render() ?> 127 <?php echo $form['template']->renderError() ?> 128 </div> 129 <?php endif ?> 130 131 132 133 <?php if(isset($form['allow_comments'])): ?> 134 <hr /> 135 <div class="comments section"> 136 <h4><a href="#" class="allow_comments_toggle <?php echo ($a_blog_post['allow_comments'])? 'enabled' : 'disabled' ?>"><span class="enabled" title="<?php echo __('Click to disable comments', array(), 'apostrophe_blog') ?>"><?php echo __('Comments are enabled', array(), 'apostrophe_blog') ?></span><span class="disabled" title="<?php echo __('Click to enable comments', array(), 'apostrophe_blog') ?>"><?php echo __('Comments are disabled', array(), 'apostrophe_blog') ?></span></a></h4> 137 <div class="allow_comments option"> 138 <?php echo $form['allow_comments']->render() ?> 139 <?php echo $form['allow_comments']->renderError() ?> 140 </div> 141 142 </div> 143 <?php endif ?> 144 145 <script type="text/javascript" charset="utf-8"> 146 function updateBlogMulti() 147 { 148 updateBlogForm('<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); 149 } 150 151 $(document).ready(function(){ 152 153 $('#a-admin-form').change(function(event) { 154 updateBlog(event); 35 155 }); 156 157 checkAndSetPublish('<?php echo $a_blog_post->status ?>','<?php echo url_for('a_blog_admin_update',$a_blog_post) ?>'); 158 159 $('.a-sidebar-toggle').click(function(){ 160 $(this).toggleClass('open').next().toggle(); 161 }) 162 163 aMultipleSelect('#categories-section', { 'choose-one': '<?php echo __('Choose Categories', array(), 'apostrophe_blog') ?>', 'add': '<?php echo __('+ New Category', array(), 'apostrophe_blog') ?>', 'onChange': updateBlogMulti}); 164 aMultipleSelect('#editors-section', { 'choose-one': '<?php echo __('Choose Editors', array(), 'apostrophe_blog') ?>','onChange': updateBlogMulti }); 165 166 }); 36 167 </script> -
plugins/apostropheBlogPlugin/trunk/modules/aEventAdmin/templates/editSuccess.php
r879 r1103 1 <?php slot('body_class') ?>a-blog <?php echo $sf_params->get('module'); ?> <?php echo $sf_params->get('action') ?><?php end_slot() ?> 1 <?php use_helper('I18N', 'Date', 'jQuery', 'a') ?> 2 <?php include_partial('assets') ?> 3 <?php slot('body_class') ?>a-admin a-blog-admin <?php echo $sf_params->get('module'); ?> <?php echo $sf_params->get('action') ?> <?php echo $a_event['template'] ?><?php end_slot() ?> 2 4 3 <?php use_helper('I18N', 'Date', 'jQuery', 'a') ?> 4 <?php include_partial('aEventAdmin/assets') ?> 5 <div class="a-admin-container a-blog-admin <?php echo $sf_params->get('module') ?>"> 5 6 6 <div class="a-admin-container <?php echo $sf_params->get('module') ?>"> 7 8 <?php include_partial('aEventAdmin/form_bar', array('title' => __('Edit Event Post', array(), 'messages'))) ?> 7 <?php // include_partial('form_bar', array('title' => __('Edit Blog Post', array(), 'apostrophe-blog'))) ?> 9 8 10 9 <?php slot('a-subnav') ?> 11 <div class="a-subnav-wrapper blog"> 12 <div class="a-subnav-inner"> 13 <ul class="a-admin-action-controls"> 14 <?php include_partial('aEventAdmin/list_actions', array('helper' => $helper)) ?> 15 </ul> 16 </div> 17 </div> 10 <div class="a-subnav-wrapper blog"> 11 <div class="a-subnav-inner"> 12 <ul class="a-admin-action-controls"> 13 <li><a href="<?php echo url_for('@a_blog_admin'); ?>" class="all-posts-btn"><?php echo __('All Posts', array(), 'apostrophe-blog') ?></a></li> 14 <?php include_partial('list_actions', array('helper' => $helper)) ?> 15 </ul> 16 <div id="a-blog-post-status-indicator"></div> 17 </div> 18 </div> 18 19 <?php end_slot() ?> 19 20 <?php include_partial('aEventAdmin/flashes') ?>21 22 20 23 <div class="a-admin-content main"> 24 <?php include_partial('aEvent/'.$a_event->getTemplate(), array('a_event' => $a_event)) ?> 21 <?php include_partial('flashes') ?> 22 23 <div class="a-admin-content main"> 24 25 <?php if (0): ?> 26 <?php // We aren't using status messages right now ?> 27 <dl id="a-blog-post-status-messages"></dl> 28 <?php endif ?> 29 30 <div id="a-blog-post-title-interface" class="a-blog-post-title-interface"> 31 <input type="text" id="a_blog_post_title_interface" value="<?php echo ($a_event->title == 'untitled')? '':$a_event->title ?>" /> 32 <div id="a-blog-post-title-placeholder"><?php echo __('Title your post...', array(), 'apostrophe-blog') ?></div> 33 </div> 34 35 <div id="a-blog-post-permalink-interface"> 36 <h6>Permalink:</h6> 37 <div class="a-blog-post-permalink-wrapper url"> 38 <span><?php echo aTools::urlForPage($a_event->findBestEngine()->getSlug()).'/' ?></span><?php // Dan, Can you echo the REAL URL prefix here -- I don't know how to build a URL based on the complex blog route business we are doing ?> 39 </div> 40 <div class="a-blog-post-permalink-wrapper slug"> 41 <input type="text" name="a_blog_post_permalink_interface" value="<?php echo $a_event->slug ?>" id="a_blog_post_permalink_interface"> 42 <ul class="a-controls slug"> 43 <li><a href="#" class="a-btn a-save mini"><?php echo __('Save', array(), 'apostrophe_blog') ?></a></li> 44 <li><a href="#" class="a-btn a-cancel no-label mini"><?php echo __('Cancel', array(), 'apostrophe_blog') ?></a></li> 45 </ul> 46 </div> 47 </div> 48 49 <?php include_partial('aBlog/'.$a_event->getTemplate(), array('a_blog_post' => $a_event)) ?> 50 25 51 </div> 26 52 27 53 <div class="a-admin-sidebar"> 28 54 <div id='a-admin-blog-post-form'> 29 <?php include_partial(' aEventAdmin/form', array('a_event' => $a_event, 'form' => $form)) ?>55 <?php include_partial('form', array('a_blog_post' => $a_event, 'form' => $form)) ?> 30 56 </div> 31 57 </div> 32 58 33 59 <div class="a-admin-footer"> 34 <?php include_partial(' aEventAdmin/form_footer', array('a_event' => $a_event, 'form' => $form, 'configuration' => $configuration)) ?>60 <?php include_partial('form_footer', array('a_blog_post' => $a_event, 'form' => $form, 'configuration' => $configuration)) ?> 35 61 </div> 36 62 </form> 37 <?php //include_partial(' aEventAdmin/form_actions', array('a_event' => $a_event, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?>63 <?php //include_partial('form_actions', array('a_blog_post' => $a_event, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?> 38 64 </div> 65 66 67 <script type="text/javascript" charset="utf-8"> 68 function updateBlog(event) 69 { 70 if(event.target.name == 'select-<?php echo $form['categories_list']->renderName() ?>[]' && 71 event.target.options[0].selected == true) 72 { 73 74 } 75 else if(event.target.name == 'add-text') {} 76 else 77 { 78 updateBlogForm('<?php echo url_for('a_blog_admin_update', $a_event) ?>', event); 79 } 80 } 81 82 $(document).ready(function(){ 83 84 // Title Interface 85 // ============================================= 86 var titleInterface = $('#a_blog_post_title_interface'); 87 var titlePlaceholder = $('#a-blog-post-title-placeholder'); 88 var originalTitle = "<?php echo $a_event->title ?>"; 89 90 <?php if ($a_event->title == 'untitled'): ?> 91 titleInterface.focus(); // The blog post is 'Untitled' -- Focus the input 92 <?php endif ?> 93 94 // Title: On Change Compare 95 titleInterface.change(function(){ 96 if ($(this).val() != '') { // If the input is not empty 97 $('#a_blog_post_title').val($(this).val()); // Pass the value to the admin form and update 98 updateBlogForm('<?php echo url_for('a_blog_admin_update',$a_event) ?>'); 99 }; 100 }); 101 102 titleInterface.blur(function(){ 103 // Check for Empty Title Field 104 if ($(this).val() == '') 105 { 106 $(this).next().show(); 107 } 108 }); 109 110 titleInterface.focus(function(){ 111 // Always hide the placeholder on focus 112 $(this).next().hide(); 113 }); 114 115 titlePlaceholder.mousedown(function(){ 116 // If you click the placeholder text 117 // focus the input (Mousedown is faster than click here) 118 titleInterface.focus(); 119 }).hide(); 120 121 // Permalink Interface 122 // ============================================= 123 var permalinkInterface = $('#a-blog-post-permalink-interface'); 124 var pInput = permalinkInterface.find('input'); 125 var pControls = permalinkInterface.find('ul.a-controls'); 126 var originalSlug = '<?php echo $a_event->slug ?>'; 127 128 // Permalink: On Focus Listen for Changes 129 pInput.focus(function(){ 130 $(this).select(); 131 $(this).keyup(function(){ 132 if ($(this).val().trim() != originalSlug) 133 { 134 permalinkInterface.addClass('has-changes'); 135 pControls.fadeIn(); 136 } 137 }); 138 }); 139 140 // Permalink Interface Controls: Save | Cancel 141 // ============================================= 142 pControls.click(function(event){ 143 event.preventDefault(); 144 $target = $(event.target); 145 146 if ($target.hasClass('a-save')) 147 { 148 if (pInput.val() == '') { 149 pInput.val(originalSlug); 150 pControls.hide(); 151 } 152 if ((pInput.val() != '') && (pInput.val().trim() != originalSlug)) { 153 $('#a_blog_post_slug').val(pInput.val()); // Pass the value to the admin form and update 154 updateBlogForm('<?php echo url_for('a_blog_admin_update',$a_event) ?>'); 155 } 156 } 157 158 if ($target.hasClass('a-cancel')) 159 { 160 pInput.val(originalSlug); 161 pControls.hide(); 162 } 163 }); 164 165 // Comments Toggle 166 // ============================================= 167 $('.section.comments a.allow_comments_toggle').click(function(event){ 168 event.preventDefault(); 169 toggleCheckbox($('#a_blog_post_allow_comments')); 170 updateBlogForm('<?php echo url_for('a_blog_admin_update',$a_event) ?>'); 171 }); 172 173 }); 174 </script>

