PageRenderTime 26ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/mywords/trunk/widgets/widget_publish.php

http://bitcero-modules.googlecode.com/
PHP | 166 lines | 142 code | 11 blank | 13 comment | 13 complexity | c7d1edc4a8489ce29f3dd02014538d69 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. // $Id: widget_publish.php 824 2011-12-08 23:50:30Z i.bitcero $
  3. // --------------------------------------------------------------
  4. // MyWords
  5. // Complete Blogging System
  6. // Author: BitC3R0 <bitc3r0@gmail.com>
  7. // Email: i.bitcero@gmail.com
  8. // License: GPL 2.0
  9. // --------------------------------------------------------------
  10. /**
  11. * Publish widget
  12. * @return array
  13. */
  14. function mw_widget_publish(){
  15. global $xoopsUser;
  16. RMTemplate::get()->add_style('publish_widget.css','mywords');
  17. RMTemplate::get()->add_style('forms.css','rmcommon');
  18. RMTemplate::get()->add_style('jquery.css','rmcommon');
  19. RMTemplate::get()->add_script(XOOPS_URL.'/modules/mywords/include/js/scripts.php?file=posts.js');
  20. RMTemplate::get()->add_script(XOOPS_URL.'/modules/mywords/include/js/mktime.js');
  21. RMTemplate::get()->add_script(RMCURL.'/include/js/forms.js');
  22. $widget['title'] = __('Publish','mywords');
  23. $widget['icon'] = '';
  24. $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
  25. $edit = false;
  26. if ($id>0){
  27. $post = new MWPost($id);
  28. if ($post->isNew()){
  29. unset($post);
  30. } else {
  31. $edit = true;
  32. }
  33. }
  34. if ($edit){
  35. switch($post->getVar('status')){
  36. case 'draft':
  37. $status = __('Draft','mywords');
  38. break;
  39. case 'pending':
  40. $status = __('Pending review','mywords');
  41. break;
  42. case 'publish':
  43. $status = __('Published','mywords');
  44. break;
  45. case 'scheduled':
  46. $status = __('Scheduled','mywords');
  47. break;
  48. }
  49. $visibility = $post->getVar('visibility')=='public' ? 'Public' : ($post->getVar('visibility')=='password' ? 'Password Protected' : 'Private');
  50. } else {
  51. $status = 'Published';
  52. $visibility = 'Public';
  53. }
  54. ob_start();
  55. ?>
  56. <div class="rmc_widget_content_reduced publish_container">
  57. <form id="mw-post-publish-form">
  58. <!-- Opciones de Publicaci?n -->
  59. <div class="publish_options">
  60. <?php _e('Status:','mywords'); ?> <strong id="publish-status-legend"><?php _e($status,'mywords'); ?></strong> &nbsp; <a href="javascript:;" id="edit-publish"><?php _e('Edit','mywords'); ?></a>
  61. <div id="publish-options" style="display: none;">
  62. <select name="status" id="status">
  63. <option value="publish"<?php echo $edit && $post->getVar('status')=='publish' ? 'selected="selected"' : ($edit ? '' : 'selected="selected"'); ?>><?php _e('Published','mywords') ?></option>
  64. <option value="draft"<?php echo $edit && $post->getVar('status')=='draft' ? 'selected="selected"' : ''?>><?php _e('Draft','mywords') ?></option>
  65. <option value="pending"<?php echo $edit && $post->getVar('status')=='pending' ? 'selected="selected"' : ''?>><?php _e('Pending Review','mywords') ?></option>
  66. </select>
  67. <input type="button" name="publish-ok" id="publish-ok" class="button" value="<?php _e('Apply','mywords') ?>" /><br />
  68. <a href="javascript:;" onclick="$('#publish-options').slideUp('slow'); $('#edit-publish').show();"><?php _e('Cancel','mywords') ?></a>
  69. </div>
  70. </div>
  71. <!-- //Opciones de Publicaci?n -->
  72. <!-- Visibilidad -->
  73. <div class="publish_options">
  74. <?php _e('Visibility:','mywords'); ?> <strong id="visibility-caption"><?php _e($visibility,'mywords'); ?></strong> &nbsp; <a href="javascript:;" id="visibility-edit"><?php _e('Edit','mywords'); ?></a>
  75. <?php
  76. if (!$edit){
  77. $visibility = 'public';
  78. } else {
  79. $visibility = $post->getVar('visibility');
  80. }
  81. ?>
  82. <div id="visibility-options">
  83. <input type="radio" name="visibility" value="public" id="visibility-public"<?php echo $visibility=='public' ? ' checked="checked"' : ''; ?> /> <label for="visibility-public"><?php _e('Public','mywords'); ?></label><br />
  84. <input type="radio" name="visibility" value="password" id="visibility-password"<?php echo $visibility=='password' ? ' checked="checked"' : ''; ?> /> <label for="visibility-password"><?php _e('Password protected','mywords'); ?></label><br />
  85. <span id="vis-password-text" style="<?php _e($visibility=='password' ? '' : 'display: none') ?>">
  86. <label>
  87. <?php _e('Password:','mywords') ?>
  88. <input type="text" name="vis_password" id="vis-password" value="<?php echo $edit ? $post->getVar('password') : ''; ?>" class="options_input" />
  89. </label>
  90. <br /></span>
  91. <input type="radio" name="visibility" value="private" id="visibility-private"<?php echo $visibility=='private' ? ' checked="checked"' : ''; ?> /> <label for="visibility-private"><?php _e('Private','mywords') ?></label><br /><br />
  92. <input type="button" name="vis-button" id="vis-button" value="<?php _e('Apply','mywords') ?>" class="button" />
  93. <a href="javascript:;" id="vis-cancel"><?php _e('Cancel','mywords') ?></a>
  94. </div>
  95. </div>
  96. <!-- /Visibilidad -->
  97. <!-- Schedule -->
  98. <div class="publish_options">
  99. <?php _e('Publish','mywords'); ?> <strong id="schedule-caption"><?php echo $edit ? ($post->getVar('pubdate')>0?__('Inmediatly','mywords'):date("d, M Y \@ H:i", $post->getVar('schedule'))) : __('Inmediatly','mywords'); ?></strong> &nbsp; <a href="javascript:;" class="edit-schedule"><?php _e('Edit','mywords'); ?></a>
  100. <div class="schedule-options" style="display: none;">
  101. <?php
  102. // Determinamos la fecha correcta
  103. $time = $edit ? ($post->getVar('pubdate')>0?$post->getVar('pubdate'):$post->getVar('schedule')) : time();
  104. $day = date("d", $time);
  105. $month = date("n", $time);
  106. $year = date("Y", $time);
  107. $hour = date("H", $time);
  108. $minute = date("i", $time);
  109. $months = array(
  110. __('Jan','mywords'),
  111. __('Feb','mywords'),
  112. __('Mar','mywords'),
  113. __('Apr','mywords'),
  114. __('May','mywords'),
  115. __('Jun','mywords'),
  116. __('Jul','mywords'),
  117. __('Aug','mywords'),
  118. __('Sep','mywords'),
  119. __('Oct','mywords'),
  120. __('Nov','mywords'),
  121. __('Dec','mywords')
  122. );
  123. ?>
  124. <input type="text" name="schedule_day" id="schedule-day" size="2" maxlength="2" value="<?php _e($day) ?>" />
  125. <select name="schedule_month" id="schedule-month">
  126. <?php for($i=1;$i<=12;$i++){ ?>
  127. <option value="<?php _e($i) ?>" "<?php if ($month==$i) echo('selected="selected"') ?>"><?php _e($months[$i-1]) ?></option>
  128. <?php } ?>
  129. </select>
  130. <input type="text" name="schedule_year" id="schedule-year" size="2" maxlength="4" value="<?php _e($year) ?>" /> @
  131. <input type="text" name="schedule_hour" id="schedule-hour" size="2" maxlength="2" value="<?php _e($hour) ?>" /> :
  132. <input type="text" name="schedule_minute" id="schedule-minute" size="2" maxlength="2" value="<?php _e($minute) ?>" /><br /><br />
  133. <input type="button" class="button" name="schedule-ok" id="schedule-ok" value="<?php _e('Apply','mywords') ?>" />
  134. <a href="javascript:;" class="schedule-cancel"><?php _e('Cancel','mywords') ?></a>
  135. <input type="hidden" name="schedule" id="schedule" value="<?php _e("$day-$month-$year-$hour-$minute") ?>" />
  136. </div>
  137. </div>
  138. <!-- /Shedule -->
  139. <div class="publish_options no_border">
  140. <?php _e('Author:','mywords'); ?>
  141. <?php
  142. $user = new RMFormUser('', 'author', 0, $edit ? array($post->getVar('author')) : array($xoopsUser->uid()));
  143. if (!$xoopsUser->isAdmin()) $user->button(false);
  144. echo $user->render();
  145. ?>
  146. </div>
  147. <div class="widget_button">
  148. <input type="submit" value="<?php _e($edit ? 'Update Post' : 'Publish','mywords'); ?>" class="button default" id="publish-submit" />
  149. </div>
  150. </form>
  151. </div>
  152. <?php
  153. $widget['content'] = ob_get_clean();
  154. return $widget;
  155. }