function echo_publish_buttons($Form, $creating, $edited_Item, $inskin = false, $display_preview = false) { global $Blog, $current_User; global $next_action, $highest_publish_status; // needs to be passed out for echo_publishnowbutton_js( $action ) // ---------- PREVIEW ---------- if (!$inskin || $display_preview) { $url = url_same_protocol($Blog->get('url')); // was dynurl $Form->button(array('button', '', T_('Preview'), 'PreviewButton', 'b2edit_open_preview(this.form, \'' . $url . '\');')); } // ---------- SAVE ---------- $next_action = $creating ? 'create' : 'update'; if (!$inskin) { // Show Save & Edit only on admin mode $Form->submit(array('actionArray[' . $next_action . '_edit]', T_('Save & edit'), 'SaveEditButton')); } $Form->submit(array('actionArray[' . $next_action . ']', T_('Save'), 'SaveButton')); list($highest_publish_status, $publish_text) = get_highest_publish_status('post', $Blog->ID); if (!isset($edited_Item->status)) { $edited_Item->status = $highest_publish_status; } if ($edited_Item->status != $highest_publish_status) { // Only allow publishing if in draft mode. Other modes are too special to run the risk of 1 click publication. $publish_style = 'display: inline'; } else { $publish_style = 'display: none'; } $Form->hidden('publish_status', $highest_publish_status); $Form->submit(array('actionArray[' . $next_action . '_publish]', $publish_text, 'SaveButton', '', $publish_style)); }
$Form->fieldstart = '<div class="tile">'; $Form->fieldend = '</div>'; ?> <script type="text/javascript" language="JavaScript"> <!-- // This is for toolbar plugins var b2evoCanvas = document.getElementById('itemform_post_content'); //--> </script> <?php // ------------------------------- ACTIONS ---------------------------------- echo '<div class="edit_actions">'; if ($use_preview) { // ---------- PREVIEW ---------- $url = url_same_protocol($Blog->get('url')); // was dynurl $Form->button(array('button', '', T_('Preview'), '', 'b2edit_open_preview(this.form, \'' . $url . '\');')); } // ---------- SAVE ---------- $Form->submit(array('', T_('Save !'), 'SaveButton')); // ---------- DELETE ---------- if (!$creating) { // Editing post // Display delete button if current user has the rights: $edited_Item->delete_link(' ', ' ', '#', '#', 'DeleteButton', true); } if ($Settings->get('fm_enabled')) { // ---------- UPLOAD ---------- // Note: we try to land in the Blog media folder if possible // fp> TODO: check what happens if blog folders are disabled
/** * Display buttons to update a post * * @param object Form * @param boolean Is creating action * @param object edited Item * @param boolean Is in-skin editing * @param boolean TRUE to display a preview button */ function echo_publish_buttons($Form, $creating, $edited_Item, $inskin = false, $display_preview = false) { global $Blog, $current_User, $UserSettings; global $next_action, $highest_publish_status; // needs to be passed out for echo_publishnowbutton_js( $action ) list($highest_publish_status, $publish_text) = get_highest_publish_status('post', $Blog->ID); if (!isset($edited_Item->status)) { $edited_Item->status = $highest_publish_status; } // ---------- PREVIEW ---------- if (!$inskin || $display_preview) { $url = url_same_protocol($Blog->get('url')); // was dynurl $Form->button(array('button', '', T_('Preview'), 'PreviewButton', 'b2edit_open_preview(this.form, \'' . $url . '\');')); } // ---------- VISIBILITY ---------- if (!$inskin) { // Only for back-office global $AdminUI; echo '<span class="edit_actions_text">' . T_('Visibility') . get_manual_link('visibility-status') . ': </span>'; // Get those statuses which are not allowed for the current User to create posts in this blog $exclude_statuses = array_merge(get_restricted_statuses($Blog->ID, 'blog_post!', 'create'), array('trash')); // Get allowed visibility statuses $status_options = get_visibility_statuses('', $exclude_statuses); if (isset($AdminUI, $AdminUI->skin_name) && $AdminUI->skin_name == 'bootstrap') { // Use dropdown for bootstrap skin $status_icon_options = get_visibility_statuses('icons', $exclude_statuses); $Form->hidden('post_status', $edited_Item->status); echo '<div class="btn-group dropup post_status_dropdown">'; echo '<button type="button" class="btn btn-status-' . $edited_Item->status . ' dropdown-toggle" data-toggle="dropdown" aria-expanded="false" id="post_status_dropdown">' . '<span>' . $status_options[$edited_Item->status] . '</span>' . ' <span class="caret"></span></button>'; echo '<ul class="dropdown-menu" role="menu" aria-labelledby="post_status_dropdown">'; foreach ($status_options as $status_key => $status_title) { echo '<li rel="' . $status_key . '" role="presentation"><a href="#" role="menuitem" tabindex="-1">' . $status_icon_options[$status_key] . ' <span>' . $status_title . '</span></a></li>'; } echo '</ul>'; echo '</div>'; } else { // Use standard select element for other skins echo '<select name="post_status">'; foreach ($status_options as $status_key => $status_title) { echo '<option value="' . $status_key . '"' . ($edited_Item->status == $status_key ? ' selected="selected"' : '') . ' class="btn-status-' . $status_key . '">' . $status_title . '</option>'; } echo '</select>'; } } echo '<span class="btn-group">'; // ---------- SAVE ---------- $next_action = $creating ? 'create' : 'update'; if (!$inskin && $current_User->check_perm('item_post!CURSTATUS', 'edit', false, $edited_Item)) { // Show Save & Edit only on admin mode $Form->submit(array('actionArray[' . $next_action . '_edit]', T_('Save & edit'), 'SaveEditButton btn-status-' . $edited_Item->status)); } if ($inskin) { // Front-office: display a save button with title depending on post status $button_titles = get_visibility_statuses('button-titles'); $button_title = isset($button_titles[$edited_Item->status]) ? T_($button_titles[$edited_Item->status]) : T_('Save Changes!'); } else { // Use static button title on back-office $button_title = T_('Save'); } $Form->submit(array('actionArray[' . $next_action . ']', $button_title, 'SaveButton btn-status-' . $edited_Item->status)); echo '</span>'; $Form->hidden('publish_status', $highest_publish_status); if ($highest_publish_status == 'published' && $UserSettings->get_collection_setting('show_quick_publish', $Blog->ID)) { // Display this button to make a post published // Only allow publishing if in draft mode. Other modes are too special to run the risk of 1 click publication. $publish_style = $edited_Item->status == $highest_publish_status ? 'display: none' : 'display: inline'; $Form->submit(array('actionArray[' . $next_action . '_publish]', T_('Publish!'), 'SaveButton btn-status-published quick-publish', '', $publish_style)); } }
/** * Get the absolute URL to the plugin's directory (where the plugins classfile is). * Trailing slash included. * * @param string Get absolute URL? (or make it relative to $ReqHost) * @return string */ function get_plugin_url($abs = false) { global $plugins_url, $plugins_path; // Get sub-path below $plugins_path, if any: $sub_path = preg_replace(':^' . preg_quote($plugins_path, ':') . ':', '', dirname($this->classfile_path) . '/'); $r = $plugins_url . $sub_path; // Use the same protocol as with current host (so includes from within https do not fail when on http): $r = url_same_protocol($r); // Make it relative to current host, if absolute is not required: if (!$abs) { global $ReqHost; $r = url_rel_to_same_host($r, $ReqHost); } return $r; }
/** * Get the absolute URL to the plugin's directory (where the plugins classfile is). * Trailing slash included. * * @param string Get absolute URL? (or make it relative to $ReqHost) * @return string */ function get_plugin_url($abs = false) { global $ReqHost, $plugins_url, $plugins_path; $key = $abs ? 'abs' : 'rel'; if (empty($this->_plugin_url)) { // Get sub-path below $plugins_path, if any $sub_path = preg_replace(':^' . preg_quote($plugins_path, ':') . ':', '', dirname($this->classfile_path) . '/'); $r = $plugins_url . $sub_path; // Use the same protocol as with current host (so includes from within https do not fail when on http) $r = url_same_protocol($r); $this->_plugin_url = array('abs' => $r, 'rel' => url_rel_to_same_host($r, $ReqHost)); } return $this->_plugin_url[$key]; }