当前位置: 首页>>代码示例>>PHP>>正文


PHP Pressbooks\Book类代码示例

本文整理汇总了PHP中Pressbooks\Book的典型用法代码示例。如果您正苦于以下问题:PHP Book类的具体用法?PHP Book怎么用?PHP Book使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Book类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set_locale

/**
 * Hook for add_filter('locale ', ...), change the user interface language
 *
 * @param string $lang
 *
 * @return string
 */
function set_locale($lang)
{
    // Cheap cache
    static $loc = '__UNSET__';
    if (is_admin()) {
        // go with the user setting
        // get_current_user_id uses wp_get_current_user which may not be available the first time(s) get_locale is called
        if ('__UNSET__' == $loc && function_exists('wp_get_current_user')) {
            $loc = get_user_option('user_interface_lang');
        }
    } elseif ($GLOBALS['pagenow'] == 'wp-signup.php') {
        // use global setting
        $loc = get_site_option('WPLANG');
    } else {
        // go with the book info setting
        $metadata = \PressBooks\Book::getBookInformation();
        if ('__UNSET__' == $loc && !empty($metadata['pb_language'])) {
            $locations = \PressBooks\L10n\wplang_codes();
            $loc = $locations[$metadata['pb_language']];
        }
    }
    // Return
    if ('__UNSET__' == $loc) {
        return $lang;
    } else {
        return $loc ? $loc : $lang;
    }
}
开发者ID:jflowers45,项目名称:pressbooks,代码行数:35,代码来源:pb-l10n.php

示例2: Array

 /**
 *  Imports user selected chapters from an instance of PB 
 * 
 * @param array $chapters
 * Array(
  [5] => Array(
    [222] => chapter
    )
  [14] => Array(
    [164] => front-matter
    )
  )
 * @return type
 */
 function import(array $chapters)
 {
     $this->chapters = $chapters;
     $chapters_to_import = $this->getChapters();
     libxml_use_internal_errors(true);
     foreach ($chapters_to_import as $new_post) {
         // Load HTMl snippet into DOMDocument using UTF-8 hack
         $utf8_hack = '<?xml version="1.0" encoding="UTF-8"?>';
         $doc = new \DOMDocument();
         $doc->loadHTML($utf8_hack . $new_post['post_content']);
         // Download images, change image paths
         $doc = $this->scrapeAndKneadImages($doc);
         $html = $doc->saveXML($doc->documentElement);
         // Remove auto-created <html> <body> and <!DOCTYPE> tags.
         $html = preg_replace('/^<!DOCTYPE.+?>/', '', str_replace(array('<html>', '</html>', '<body>', '</body>'), array('', '', '', ''), $html));
         $import_post = array('post_title' => $new_post['post_title'], 'post_content' => $html, 'post_type' => $new_post['post_type'], 'post_status' => $new_post['post_status']);
         // set post parent
         if ('chapter' == $new_post['post_type']) {
             $post_parent = $this->getChapterParent();
             $import_post['post_parent'] = $post_parent;
         }
         // woot, woot!
         $pid = wp_insert_post($import_post);
         // check for errors, redirect and record
         if (is_wp_error($pid)) {
             error_log('\\PBT\\Import\\PBImport()->import error at `wp_insert_post()`: ' . $pid->get_error_message());
             \PBT\Search\ApiSearch::revokeCurrentImport();
             \Pressbooks\Redirect\location(get_bloginfo('url') . '/wp-admin/admin.php?page=api_search_import');
         }
         // set post metadata
         $this->setPostMeta($pid, $new_post);
         \Pressbooks\Book::consolidatePost($pid, get_post($pid));
     }
     return \PBT\Search\ApiSearch::revokeCurrentImport();
 }
开发者ID:pressbooks,项目名称:pressbooks-textbook,代码行数:49,代码来源:class-pbt-pbimport.php

示例3: thincc_ajax

function thincc_ajax()
{
    $sitename = sanitize_key(get_bloginfo('name'));
    if (!empty($sitename)) {
        $sitename .= '.';
    }
    $filename = $sitename . 'wordpress.' . date('Y-m-d');
    $options = process_thincc_options($_POST);
    if (isset($_POST['download']) && $_POST['download'] == '0') {
        $options['version'] = 'thin';
        $options['inline'] = true;
        $manifest = new \CC\Manifest(\PressBooks\Book::getBookStructure('', true), $options);
        $manifest->build_manifest();
        header('Content-Description: File Transfer');
        header('Content-Disposition: attachment; filename=' . $filename . '.xml');
        header('Content-Type: text/plain; charset=' . get_option('blog_charset'), true);
        echo '<pre>', htmlentities($manifest), '</pre>';
    } else {
        if (!isset($options['version'])) {
            $options['version'] = '1.2';
        }
        $manifest = new \CC\Manifest(\PressBooks\Book::getBookStructure('', true), $options);
        $manifest->build_manifest();
        $file = $manifest->build_zip();
        header('Content-Type: application/vnd.ims.imsccv1p2+application/zip');
        header('Content-Length: ' . filesize($file));
        header('Content-Disposition: attachment; filename="' . $filename . '.zip"');
        readfile($file);
    }
}
开发者ID:BCcampus,项目名称:candela,代码行数:30,代码来源:candela-thin-export.php

示例4: pbt_get_microdata_meta_elements

function pbt_get_microdata_meta_elements()
{
    // map items that are already captured
    $html = '';
    $micro_mapping = array('about' => 'pb_bisac_subject', 'alternativeHeadline' => 'pb_subtitle', 'author' => 'pb_author', 'contributor' => 'pb_contributing_authors', 'copyrightHolder' => 'pb_copyright_holder', 'copyrightYear' => 'pb_copyright_year', 'datePublished' => 'pb_publication_date', 'description' => 'pb_about_50', 'editor' => 'pb_editor', 'image' => 'pb_cover_image', 'inLanguage' => 'pb_language', 'keywords' => 'pb_keywords_tags', 'publisher' => 'pb_publisher');
    $metadata = \PressBooks\Book::getBookInformation();
    // create microdata elements
    foreach ($micro_mapping as $itemprop => $content) {
        if (array_key_exists($content, $metadata)) {
            if ('pb_publication_date' == $content) {
                $content = date('Y-m-d', $metadata[$content]);
            } else {
                $content = $metadata[$content];
            }
            $html .= "<meta itemprop='" . $itemprop . "' content='" . $content . "' id='" . $itemprop . "'>\n";
        }
    }
    // add elements that aren't captured, and don't need user input
    $pb_bisac_subject = '';
    // Pressbooks Metadata: fixes the undefined index pb_bisac_subject notice
    if (isset($metadata['pb_bisac_subject'])) {
        $pb_bisac_subject = $metadata['pb_bisac_subject'];
    }
    $lrmi_meta = array('educationalAlignment' => $pb_bisac_subject, 'educationalUse' => 'Open textbook study', 'audience' => 'student', 'interactivityType' => 'mixed', 'learningResourceType' => 'textbook', 'typicalAgeRange' => '17-');
    foreach ($lrmi_meta as $itemprop => $content) {
        // @todo parse educationalAlignment items into alignmentOjects
        $html .= "<meta itemprop='" . $itemprop . "' content='" . $content . "' id='" . $itemprop . "'>\n";
    }
    return $html;
}
开发者ID:Books4Languages,项目名称:Pressbooks-Lingua-Theme,代码行数:30,代码来源:functions.php

示例5: display_book_widget

/**
 * Displays a Book widget
 */
function display_book_widget()
{
    $book_structure = \PressBooks\Book::getBookStructure();
    // front-matter
    echo "<ul><li><h4>" . __('Front Matter', 'pressbooks') . "</h4></li><ul>";
    foreach ($book_structure['front-matter'] as $fm) {
        $title = !empty($fm['post_title']) ? $fm['post_title'] : '&hellip;';
        echo "<li class='front-matter'><a href='post.php?post=" . $fm['ID'] . "&action=edit'>" . $title . "</a></li>\n";
    }
    echo "</ul>";
    // parts
    foreach ($book_structure['part'] as $part) {
        $title = !empty($part['post_title']) ? $part['post_title'] : '&hellip;';
        echo "<ul><li><h4><a href='post.php?post=" . $part['ID'] . "&action=edit'>" . $title . "</a></h4></li><ul>\n";
        // chapters
        foreach ($part['chapters'] as $chapter) {
            $title = !empty($chapter['post_title']) ? $chapter['post_title'] : '&hellip;';
            echo "<li class='chapter'><a href='post.php?post=" . $chapter['ID'] . "&action=edit'>" . $title . "</a></li>\n";
        }
        echo "</ul>\n";
    }
    // back-matter
    echo "<li><h4>" . __('Back Matter', 'pressbooks') . "</h4></li><ul>";
    foreach ($book_structure['back-matter'] as $bm) {
        $title = !empty($bm['post_title']) ? $bm['post_title'] : '&hellip;';
        echo "<li class='back-matter'><a href='post.php?post=" . $bm['ID'] . "&action=edit'>" . $title . "</a></li>\n";
    }
    echo "</ul>";
    // add, organize
    echo "</ul>\n";
    echo '<div class="part-buttons"><a href="post-new.php?post_type=chapter">' . __('Add', 'pressbooks') . '</a> | <a class="remove" href="admin.php?page=pressbooks">' . __('Organize', 'pressbooks') . '</a></div>';
}
开发者ID:cumi,项目名称:pressbooks,代码行数:35,代码来源:pb-dashboard.php

示例6: revokeCurrentImport

 /**
  * Delete 'pressbooks_current_import' option, delete the file too.
  *
  * @return bool
  */
 function revokeCurrentImport()
 {
     $current_import = get_option('pressbooks_current_import');
     if (is_array($current_import) && isset($current_import['file']) && is_file($current_import['file'])) {
         unlink($current_import['file']);
     }
     \Pressbooks\Book::deleteBookObjectCache();
     delete_transient('dirsize_cache');
     /** @see get_dirsize() */
     return delete_option('pressbooks_current_import');
 }
开发者ID:pressbooks,项目名称:pressbooks,代码行数:16,代码来源:class-pb-import.php

示例7: import

 /**
  * @param array $current_import
  */
 function import(array $current_import)
 {
     try {
         $imscc = new IMSCCParser($current_import['file']);
     } catch (\Exception $e) {
         return FALSE;
     }
     $items = $imscc->manifestGetItems();
     $match_ids = array_flip(array_keys($current_import['chapters']));
     $total = 0;
     if (!empty($items)) {
         $current_post_parent = -1;
         foreach ($items as $id => $item) {
             // Skip
             if (!$this->flaggedForImport($id)) {
                 continue;
             }
             if (!isset($match_ids[$id])) {
                 continue;
             }
             $post_type = $this->determinePostType($id);
             $new_post = array('post_title' => wp_strip_all_tags($item['title']), 'post_type' => $post_type, 'post_status' => 'part' == $post_type ? 'publish' : 'draft');
             if ('part' != $post_type) {
                 $new_post['post_content'] = $imscc->getContent($id);
             }
             if ('chapter' == $post_type) {
                 if ($current_post_parent == -1) {
                     $new_post['post_parent'] = $this->getChapterParent();
                 } else {
                     $new_post['post_parent'] = $current_post_parent;
                 }
             }
             $pid = wp_insert_post(add_magic_quotes($new_post));
             //store part post ID to use as parent for subsequent chapters
             if ('part' == $post_type) {
                 $current_post_parent = $pid;
             }
             // @todo postmeta like author
             update_post_meta($pid, 'pb_show_title', 'on');
             update_post_meta($pid, 'pb_export', 'on');
             if ('part' == $post_type && $imscc->getContent($id)) {
                 update_post_meta($pid, 'pb_part_content', $imscc->getContent($id));
             }
             Book::consolidatePost($pid, get_post($pid));
             ++$total;
         }
     }
     // Done
     $_SESSION['pb_notices'][] = sprintf(__('Imported %d chapters.', 'pressbooks'), $total);
     $imscc->cleanUp();
     return $this->revokeCurrentImport();
 }
开发者ID:BCcampus,项目名称:candela,代码行数:55,代码来源:class-pb-imscc.php

示例8: adminMenuAdjuster

	/**
	 * Adds and Removes some admin buttons
	 * 
	 * @since 1.0.1
	 */
	function adminMenuAdjuster() {
		if ( \Pressbooks\Book::isBook() ) {
			add_menu_page( __( 'Import', $this->plugin_slug ), __( 'Import', $this->plugin_slug ), 'edit_posts', 'pb_import', '\PressBooks\Admin\Laf\display_import', '', 15 );
			add_options_page( __( 'PressBooks Textbook Settings', $this->plugin_slug ), __( 'PB Textbook', $this->plugin_slug ), 'manage_options', $this->plugin_slug . '-settings', array( $this, 'displayPluginAdminPage' ) );
			add_menu_page( __( 'PressBooks Textbook', $this->plugin_slug ), __( 'PB Textbook', $this->plugin_slug ), 'edit_posts', $this->plugin_slug , array( $this, 'displayPBTPage' ), '', 64 );
			// check if the functionality we need is available
			if ( class_exists('\PressBooks\Api_v1\Api') ){
				add_submenu_page( $this->plugin_slug, __('Search and Import', $this->plugin_slug), __('Search and Import', $this->plugin_slug), 'edit_posts', 'api_search_import',array( $this, 'displayApiSearchPage' ), '', 65 );
			}
			add_submenu_page( $this->plugin_slug, __('Download Textbooks', $this->plugin_slug), __('Download Textbooks', $this->plugin_slug), 'edit_posts', 'download_textbooks',array( $this, 'displayDownloadTextbooks' ), '', 66 );
			add_menu_page( 'Plugins', 'Plugins', 'manage_network_plugins', 'plugins.php', '', 'dashicons-admin-plugins', 67 );
			remove_menu_page( 'pb_sell' );
		}
	}
开发者ID:hughmcguire,项目名称:pressbooks-textbook,代码行数:19,代码来源:class-pbt-textbook-admin.php

示例9: registerThemeDirectories

 /**
  * Register theme directories, set a filter that hides themes under certain conditions
  */
 function registerThemeDirectories()
 {
     // No trailing slash, otherwise we get a double slash bug
     // @see \PressBooks\Metadata::fixDoubleSlashBug
     register_theme_directory(PB_PLUGIN_DIR . 'themes-root');
     register_theme_directory(PB_PLUGIN_DIR . 'themes-book');
     if (is_admin()) {
         if (Book::isBook()) {
             add_filter('allowed_themes', array($this, 'allowedBookThemes'));
         } else {
             add_filter('allowed_themes', array($this, 'allowedRootThemes'));
         }
     }
 }
开发者ID:jflowers45,项目名称:pressbooks,代码行数:17,代码来源:class-pb-pressbooks.php

示例10: add_theme

function add_theme($themes)
{
    $merge_themes = array();
    if (\Pressbooks\Book::isBook()) {
        $registered_themes = search_theme_directories();
        foreach ($registered_themes as $key => $val) {
            if ($val['theme_root'] == __DIR__ . '/themes') {
                $merge_themes[$key] = 1;
            }
        }
        // add our theme
        $themes = array_merge($themes, $merge_themes);
    }
    return $themes;
}
开发者ID:BCcampus,项目名称:candela,代码行数:15,代码来源:candela-utility.php

示例11: add_themes_to_filter

 /**
  * Add the plugin's specific themes to the PressBooks theme filter.
  * Inspirated from Textbook's one.
  *
  * @since    0.1
  * @param    array $themes The currently allowed themes in PressBooks
  * @return   array The array from the input, with the plugin's themes
  */
 public function add_themes_to_filter($themes)
 {
     $pbt_themes = array();
     if (\Pressbooks\Book::isBook()) {
         $registered_themes = search_theme_directories();
         foreach ($registered_themes as $key => $val) {
             if ($val['theme_root'] == plugin_dir_path(dirname(__FILE__)) . 'themes') {
                 $pbt_themes[$key] = 1;
             }
         }
         // add our theme to the whitelist
         $themes = array_merge($themes, $pbt_themes);
         return $themes;
     } else {
         return $themes;
     }
 }
开发者ID:Books4Languages,项目名称:Pressbooks-Lingua-Theme,代码行数:25,代码来源:class-pressbooks-lingua-theme-themes.php

示例12: hide_menus

function hide_menus()
{
    global $wpdb;
    $user = wp_get_current_user();
    $restricted = $wpdb->get_results('SELECT * FROM wp_sitemeta WHERE meta_key = "pressbooks_network_managers"');
    if ($restricted) {
        $restricted = maybe_unserialize($restricted[0]->meta_value);
    } else {
        $restricted = array();
    }
    if (in_array($user->ID, $restricted) && !\PressBooks\Book::isBook()) {
        remove_menu_page("themes.php");
        remove_menu_page("plugins.php");
        remove_menu_page("settings.php");
        remove_menu_page("update-core.php");
        remove_menu_page("admin.php?page=pb_stats");
    }
}
开发者ID:samsruti,项目名称:pressbooks,代码行数:18,代码来源:pb-network-managers.php

示例13: adminMenuAdjuster

 /**
  * Adds and Removes some admin buttons
  * 
  * @since 1.0.1
  */
 function adminMenuAdjuster()
 {
     if (\Pressbooks\Book::isBook()) {
         add_menu_page(__('Import', $this->plugin_slug), __('Import', $this->plugin_slug), 'edit_posts', 'pb_import', '\\Pressbooks\\Admin\\Laf\\display_import', 'dashicons-upload', 15);
         add_options_page(__('Pressbooks Textbook Settings', $this->plugin_slug), __('PB Textbook', $this->plugin_slug), 'manage_options', $this->plugin_slug . '-settings', array($this, 'displayPluginAdminPage'));
         add_menu_page(__('Pressbooks Textbook', $this->plugin_slug), __('PB Textbook', $this->plugin_slug), 'edit_posts', $this->plugin_slug, array($this, 'displayPBTPage'), 'dashicons-tablet', 64);
         // check if the functionality we need is available
         if (class_exists('\\Pressbooks\\Modules\\Api_v1\\Api')) {
             add_submenu_page($this->plugin_slug, __('Search and Import', $this->plugin_slug), __('Search and Import', $this->plugin_slug), 'edit_posts', 'api_search_import', array($this, 'displayApiSearchPage'), '', 65);
         }
         add_submenu_page($this->plugin_slug, __('Download Textbooks', $this->plugin_slug), __('Download Textbooks', $this->plugin_slug), 'edit_posts', 'download_textbooks', array($this, 'displayDownloadTextbooks'), '', 66);
         if (version_compare(PB_PLUGIN_VERSION, '2.7') >= 0) {
             remove_menu_page('pb_publish');
         } else {
             remove_menu_page('pb_sell');
         }
     }
 }
开发者ID:pressbooks,项目名称:pressbooks-textbook,代码行数:23,代码来源:class-pbt-textbook-admin.php

示例14: pbt_get_microdata_meta_elements

function pbt_get_microdata_meta_elements()
{
    // map items that are already captured
    $html = '';
    $micro_mapping = array('about' => 'pb_bisac_subject', 'alternativeHeadline' => 'pb_subtitle', 'author' => 'pb_author', 'contributor' => 'pb_contributing_authors', 'copyrightHolder' => 'pb_copyright_holder', 'copyrightYear' => 'pb_copyright_year', 'datePublished' => 'pb_publication_date', 'description' => 'pb_about_50', 'editor' => 'pb_editor', 'image' => 'pb_cover_image', 'inLanguage' => 'pb_language', 'keywords' => 'pb_keywords_tags', 'publisher' => 'pb_publisher');
    $metadata = \PressBooks\Book::getBookInformation();
    // create microdata elements
    foreach ($micro_mapping as $itemprop => $content) {
        if (array_key_exists($content, $metadata)) {
            if ('pb_publication_date' == $content) {
                $content = date('Y-m-d', $metadata[$content]);
            } else {
                $content = $metadata[$content];
            }
            $html .= "<meta itemprop='" . $itemprop . "' content='" . $content . "' id='" . $itemprop . "'>\n";
        }
    }
    return $html;
}
开发者ID:lumenlearning,项目名称:candela-utility,代码行数:19,代码来源:functions.php

示例15: convert

 /**
  * Create $this->outputPath
  *
  * @return bool
  */
 function convert()
 {
     // Create ICML
     $vars = array('meta' => \PressBooks\Book::getBookInformation(), 'book_contents' => $this->preProcessBookContents(\PressBooks\Book::getBookContents()));
     $cc_copyright = strip_tags($this->doCopyrightLicense($vars['meta']));
     $vars['do_copyright_license'] = $cc_copyright;
     $book_html = $this->loadTemplate(__DIR__ . '/templates/xhtml.php', $vars);
     $content = $this->transformXML($book_html, PB_PLUGIN_DIR . 'symbionts/icml/tkbr2icml-v044.xsl');
     // Save ICML as file in exports folder
     $filename = $this->timestampedFileName('.icml');
     file_put_contents($filename, $content);
     $this->outputPath = $filename;
     if (!filesize($this->outputPath)) {
         $this->logError($this->bookHtmlError($book_html));
         unlink($this->outputPath);
         return false;
     }
     return true;
 }
开发者ID:Emaratilicious,项目名称:oddibooks,代码行数:24,代码来源:class-pb-icml.php


注:本文中的Pressbooks\Book类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。