/**
  * Display a list of all h5p content.
  *
  * @since 1.1.0
  */
 public function display_contents_page()
 {
     switch (filter_input(INPUT_GET, 'task', FILTER_SANITIZE_STRING)) {
         case NULL:
             include_once 'views/contents.php';
             $headers = array((object) array('text' => __('Title', $this->plugin_slug), 'sortable' => TRUE), (object) array('text' => __('Content type', $this->plugin_slug), 'sortable' => TRUE, 'facet' => TRUE), (object) array('text' => __('Author', $this->plugin_slug), 'sortable' => TRUE, 'facet' => TRUE), (object) array('text' => __('Tags', $this->plugin_slug), 'sortable' => FALSE, 'facet' => TRUE), (object) array('text' => __('Last modified', $this->plugin_slug), 'sortable' => TRUE), (object) array('text' => __('ID', $this->plugin_slug), 'sortable' => TRUE));
             if (get_option('h5p_track_user', TRUE)) {
                 $headers[] = (object) array('class' => 'h5p-results-link');
             }
             $headers[] = (object) array('class' => 'h5p-edit-link');
             $plugin_admin = H5P_Plugin_Admin::get_instance();
             $plugin_admin->print_data_view_settings('h5p-contents', admin_url('admin-ajax.php?action=h5p_contents'), $headers, array(true), __("No H5P content available. You must upload or create new content.", $this->plugin_slug), (object) array('by' => 4, 'dir' => 0));
             return;
         case 'show':
             // Admin preview of H5P content.
             if (is_string($this->content)) {
                 H5P_Plugin_Admin::set_error($this->content);
                 H5P_Plugin_Admin::print_messages();
             } else {
                 $plugin = H5P_Plugin::get_instance();
                 $embed_code = $plugin->add_assets($this->content);
                 include_once 'views/show-content.php';
                 H5P_Plugin::get_instance()->add_settings();
                 // Log view
                 new H5P_Event('content', NULL, $this->content['id'], $this->content['title'], $this->content['library']['name'], $this->content['library']['majorVersion'] . '.' . $this->content['library']['minorVersion']);
             }
             return;
         case 'results':
             // View content results
             if (is_string($this->content)) {
                 H5P_Plugin_Admin::set_error($this->content);
                 H5P_Plugin_Admin::print_messages();
             } else {
                 // Print HTML
                 include_once 'views/content-results.php';
                 $plugin_admin = H5P_Plugin_Admin::get_instance();
                 $plugin_admin->print_data_view_settings('h5p-content-results', admin_url('admin-ajax.php?action=h5p_content_results&id=' . $this->content['id']), array((object) array('text' => __('User', $this->plugin_slug), 'sortable' => TRUE), (object) array('text' => __('Score', $this->plugin_slug), 'sortable' => TRUE), (object) array('text' => __('Maximum Score', $this->plugin_slug), 'sortable' => TRUE), (object) array('text' => __('Opened', $this->plugin_slug), 'sortable' => TRUE), (object) array('text' => __('Finished', $this->plugin_slug), 'sortable' => TRUE), __('Time spent', $this->plugin_slug)), array(true), __("There are no logged results for this content.", $this->plugin_slug), (object) array('by' => 4, 'dir' => 0));
                 // Log content result view
                 new H5P_Event('results', 'content', $this->content['id'], $this->content['title'], $this->content['library']['name'], $this->content['library']['majorVersion'] . '.' . $this->content['library']['minorVersion']);
             }
             return;
     }
     print '<div class="wrap"><h2>' . esc_html__('Unknown task.', $this->plugin_slug) . '</h2></div>';
 }
예제 #2
0
 /**
  * Display details for a given content library.
  *
  * @since 1.1.0
  */
 private function display_library_details()
 {
     global $wpdb;
     $library = $this->get_library();
     H5P_Plugin_Admin::print_messages();
     if (!$library) {
         return;
     }
     // Add settings and translations
     $plugin = H5P_Plugin::get_instance();
     $interface = $plugin->get_h5p_instance('interface');
     $settings = array('containerSelector' => '#h5p-admin-container');
     // Build the translations needed
     $settings['libraryInfo']['translations'] = array('noContent' => __('No content is using this library', $this->plugin_slug), 'contentHeader' => __('Content using this library', $this->plugin_slug), 'pageSizeSelectorLabel' => __('Elements per page', $this->plugin_slug), 'filterPlaceholder' => __('Filter content', $this->plugin_slug), 'pageXOfY' => __('Page $x of $y', $this->plugin_slug));
     $notCached = $interface->getNumNotFiltered();
     if ($notCached) {
         $settings['libraryInfo']['notCached'] = $this->get_not_cached_settings($notCached);
     } else {
         // List content which uses this library
         $contents = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT hc.id, hc.title\n            FROM {$wpdb->prefix}h5p_contents_libraries hcl\n            JOIN {$wpdb->prefix}h5p_contents hc ON hcl.content_id = hc.id\n            WHERE hcl.library_id = %d\n            ORDER BY hc.title", $library->id));
         foreach ($contents as $content) {
             $settings['libraryInfo']['content'][] = array('title' => $content->title, 'url' => admin_url('admin.php?page=h5p&task=show&id=' . $content->id));
         }
     }
     // Build library info
     $settings['libraryInfo']['info'] = array(__('Version', $this->plugin_slug) => H5PCore::libraryVersion($library), __('Fullscreen', $this->plugin_slug) => $library->fullscreen ? __('Yes', $this->plugin_slug) : __('No', $this->plugin_slug), __('Content library', $this->plugin_slug) => $library->runnable ? __('Yes', $this->plugin_slug) : __('No', $this->plugin_slug), __('Used by', $this->plugin_slug) => isset($contents) ? sprintf(_n('1 content', '%d contents', count($contents), $this->plugin_slug), count($contents)) : __('N/A', $this->plugin_slug));
     $this->add_admin_assets();
     H5P_Plugin_Admin::add_script('library-list', 'h5p-php-library/js/h5p-library-details.js');
     include_once 'views/library-details.php';
     $plugin->print_settings($settings, 'H5PAdminIntegration');
 }
<?php

/**
 * List library details.
 *
 * @package   H5P
 * @author    Joubel <*****@*****.**>
 * @license   MIT
 * @link      http://joubel.com
 * @copyright 2014 Joubel
 */
?>

<div class="wrap">
  <h2><?php 
print esc_html($library->title);
?>
</h2>
  <?php 
print H5P_Plugin_Admin::print_messages();
?>
  <div id="h5p-admin-container"></div>
</div>