• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP book_get_chapter_title函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: booktool_print_get_toc

/**
 * Generate toc structure and titles
 *
 * @param array $chapters
 * @param stdClass $book
 * @param stdClass $cm
 * @return array
 */
function booktool_print_get_toc($chapters, $book, $cm) {
    $first = true;
    $titles = array();

    $context = context_module::instance($cm->id);

    $toc = ''; // Representation of toc (HTML).

    switch ($book->numbering) {
        case BOOK_NUM_NONE:
            $toc .= '<div class="book_toc_none">';
            break;
        case BOOK_NUM_NUMBERS:
            $toc .= '<div class="book_toc_numbered">';
            break;
        case BOOK_NUM_BULLETS:
            $toc .= '<div class="book_toc_bullets">';
            break;
        case BOOK_NUM_INDENTED:
            $toc .= '<div class="book_toc_indented">';
            break;
    }

    $toc .= '<a name="toc"></a>'; // Representation of toc (HTML).

    if ($book->customtitles) {
        $toc .= '<h1>'.get_string('toc', 'mod_book').'</h1>';
    } else {
        $toc .= '<p class="book_chapter_title">'.get_string('toc', 'mod_book').'</p>';
    }
    $toc .= '<ul>';
    foreach ($chapters as $ch) {
        if (!$ch->hidden) {
            $title = book_get_chapter_title($ch->id, $chapters, $book, $context);
            if (!$ch->subchapter) {
                $toc .= $first ? '<li>' : '</ul></li><li>';
            } else {
                $toc .= $first ? '<li><ul><li>' : '<li>';
            }
            $titles[$ch->id] = $title;
            $toc .= '<a title="'.s($title).'" href="#ch'.$ch->id.'">'.$title.'</a>';
            $toc .= (!$ch->subchapter) ? '<ul>' : '</li>';
            $first = false;
        }
    }
    $toc .= '</ul></li></ul>';
    $toc .= '</div>';
    $toc = str_replace('<ul></ul>', '', $toc); // Cleanup of invalid structures.

    return array($toc, $titles);
}
开发者ID:nicusX,项目名称:moodle,代码行数:59,代码来源:locallib.php


示例2: book_pluginfile

/**
 * Serves the book attachments. Implements needed access control ;-)
 *
 * @param stdClass $course course object
 * @param cm_info $cm course module object
 * @param context $context context object
 * @param string $filearea file area
 * @param array $args extra arguments
 * @param bool $forcedownload whether or not force download
 * @param array $options additional options affecting the file serving
 * @return bool false if file not found, does not return if found - just send the file
 */
function book_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
    global $CFG, $DB;
    if ($context->contextlevel != CONTEXT_MODULE) {
        return false;
    }
    require_course_login($course, true, $cm);
    if ($filearea !== 'chapter') {
        return false;
    }
    if (!has_capability('mod/book:read', $context)) {
        return false;
    }
    $chid = (int) array_shift($args);
    if (!($book = $DB->get_record('book', array('id' => $cm->instance)))) {
        return false;
    }
    if (!($chapter = $DB->get_record('book_chapters', array('id' => $chid, 'bookid' => $book->id)))) {
        return false;
    }
    if ($chapter->hidden and !has_capability('mod/book:viewhiddenchapters', $context)) {
        return false;
    }
    // Download the contents of a chapter as an html file.
    if ($args[0] == 'index.html') {
        $filename = "index.html";
        // We need to rewrite the pluginfile URLs so the media filters can work.
        $content = file_rewrite_pluginfile_urls($chapter->content, 'webservice/pluginfile.php', $context->id, 'mod_book', 'chapter', $chapter->id);
        $formatoptions = new stdClass();
        $formatoptions->noclean = true;
        $formatoptions->overflowdiv = true;
        $formatoptions->context = $context;
        $content = format_text($content, $chapter->contentformat, $formatoptions);
        // Remove @@PLUGINFILE@@/.
        $options = array('reverse' => true);
        $content = file_rewrite_pluginfile_urls($content, 'webservice/pluginfile.php', $context->id, 'mod_book', 'chapter', $chapter->id, $options);
        $content = str_replace('@@PLUGINFILE@@/', '', $content);
        $titles = "";
        // Format the chapter titles.
        if (!$book->customtitles) {
            require_once __DIR__ . '/locallib.php';
            $chapters = book_preload_chapters($book);
            if (!$chapter->subchapter) {
                $currtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context);
                // Note that we can't use the $OUTPUT->heading() in WS_SERVER mode.
                $titles = "<h3>{$currtitle}</h3>";
            } else {
                $currtitle = book_get_chapter_title($chapters[$chapter->id]->parent, $chapters, $book, $context);
                $currsubtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context);
                // Note that we can't use the $OUTPUT->heading() in WS_SERVER mode.
                $titles = "<h3>{$currtitle}</h3>";
                $titles .= "<h4>{$currsubtitle}</h4>";
            }
        }
        $content = $titles . $content;
        send_file($content, $filename, 0, 0, true, true);
    } else {
        $fs = get_file_storage();
        $relativepath = implode('/', $args);
        $fullpath = "/{$context->id}/mod_book/chapter/{$chid}/{$relativepath}";
        if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
            return false;
        }
        // Nasty hack because we do not have file revisions in book yet.
        $lifetime = $CFG->filelifetime;
        if ($lifetime > 60 * 10) {
            $lifetime = 60 * 10;
        }
        // Finally send the file.
        send_stored_file($file, $lifetime, 0, $forcedownload, $options);
    }
}
开发者ID:evltuma,项目名称:moodle,代码行数:84,代码来源:lib.php


示例3: book_get_chapter_title

// =====================================================

echo $OUTPUT->header();

// upper nav
echo '<div class="navtop">'.$chnavigation.'</div>';

// chapter itself
echo $OUTPUT->box_start('generalbox book_content');
if (!$book->customtitles) {
    $hidden = $chapter->hidden ? 'dimmed_text' : '';
    if (!$chapter->subchapter) {
        $currtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context);
        echo $OUTPUT->heading($currtitle, 2, array('class' => 'book_chapter_title '.$hidden));
    } else {
        $currtitle = book_get_chapter_title($chapters[$chapter->id]->parent, $chapters, $book, $context);
        $currsubtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context);
        echo $OUTPUT->heading($currtitle, 2, array('class' => 'book_chapter_title '.$hidden));
        echo $OUTPUT->heading($currsubtitle, 3, array('class' => 'book_chapter_title '.$hidden));
    }
}
$chaptertext = file_rewrite_pluginfile_urls($chapter->content, 'pluginfile.php', $context->id, 'mod_book', 'chapter', $chapter->id);
echo format_text($chaptertext, $chapter->contentformat, array('noclean'=>true, 'context'=>$context));

echo $OUTPUT->box_end();

// lower navigation
echo '<div class="navbottom">'.$chnavigation.'</div>';

echo $OUTPUT->footer();
开发者ID:numbas,项目名称:moodle,代码行数:30,代码来源:view.php


示例4: booktool_print_get_toc

/**
 * Generate toc structure and titles
 *
 * @param array $chapters
 * @param stdClass $book
 * @param stdClass $cm
 * @return array
 */
function booktool_print_get_toc($chapters, $book, $cm) {
    $first = true;
    $titles = array();

    $context = context_module::instance($cm->id);

    $toc = ''; // Representation of toc (HTML).

    switch ($book->numbering) {
        case BOOK_NUM_NONE:
            $toc .= html_writer::start_tag('div', array('class' => 'book_toc_none'));
            break;
        case BOOK_NUM_NUMBERS:
            $toc .= html_writer::start_tag('div', array('class' => 'book_toc_numbered'));
            break;
        case BOOK_NUM_BULLETS:
            $toc .= html_writer::start_tag('div', array('class' => 'book_toc_bullets'));
            break;
        case BOOK_NUM_INDENTED:
            $toc .= html_writer::start_tag('div', array('class' => 'book_toc_indented'));
            break;
    }

    $toc .= html_writer::tag('a', '', array('name' => 'toc')); // Representation of toc (HTML).

    $toc .= html_writer::tag('h2', get_string('toc', 'mod_book'), array('class' => 'book_chapter_title'));
    $toc .= html_writer::start_tag('ul');
    foreach ($chapters as $ch) {
        if (!$ch->hidden) {
            $title = book_get_chapter_title($ch->id, $chapters, $book, $context);
            if (!$ch->subchapter) {

                if ($first) {
                    $toc .= html_writer::start_tag('li');
                } else {
                    $toc .= html_writer::end_tag('ul');
                    $toc .= html_writer::end_tag('li');
                    $toc .= html_writer::start_tag('li');
                }

            } else {

                if ($first) {
                    $toc .= html_writer::start_tag('li');
                    $toc .= html_writer::start_tag('ul');
                    $toc .= html_writer::start_tag('li');
                } else {
                    $toc .= html_writer::start_tag('li');
                }

            }
            $titles[$ch->id] = $title;
            $toc .= html_writer::link(new moodle_url('#ch'.$ch->id), $title, array('title' => s($title)));
            if (!$ch->subchapter) {
                $toc .= html_writer::start_tag('ul');
            } else {
                $toc .= html_writer::end_tag('li');
            }
            $first = false;
        }
    }

    $toc .= html_writer::end_tag('ul');
    $toc .= html_writer::end_tag('li');
    $toc .= html_writer::end_tag('ul');
    $toc .= html_writer::end_tag('div');

    $toc = str_replace('<ul></ul>', '', $toc); // Cleanup of invalid structures.

    return array($toc, $titles);
}
开发者ID:JP-Git,项目名称:moodle,代码行数:79,代码来源:locallib.php


示例5: format_text

if ($ebooksettings['includeDescription']) {
    $text = format_text($book->intro, $book->introformat, array('noclean' => true, 'context' => $context));
    $epub->add_spine_item($epub->get_html_wrap($book->intro, get_string('summary'), 'luci.css'), 'intro.html');
    $epub->set_item_toc(get_string('summary'));
}
// Add chapters
$chapters = book_preload_chapters($book);
$allchapters = $DB->get_records('book_chapters', array('bookid' => $book->id), 'pagenum');
$fs = get_file_storage();
$first = true;
foreach ($chapters as $cid => $ch) {
    $chapter = $allchapters[$ch->id];
    if ($chapter->hidden) {
        continue;
    }
    $title = book_get_chapter_title($ch->id, $chapters, $book, $context);
    $text = '';
    $text .= "<div id='ch" . $ch->id . "'>\n";
    if (!$book->customtitles) {
        if ($chapter->subchapter) {
            $text .= '<h3 class="book_chapter_title">' . $title . "</h3>\n";
        } else {
            $text .= '<h2 class="book_chapter_title">' . $title . "</h2>\n";
        }
    }
    // Add images
    $mat = new match_saver();
    $content = preg_replace_callback('~@@PLUGINFILE@@/(.+?)([\'"])~', array($mat, 'callback'), $chapter->content);
    foreach ($mat->matches as $match) {
        $fn = rawurldecode($match);
        $fullpath = '/' . $context->id . '/mod_book/chapter/' . $ch->id . '/' . $fn;
开发者ID:ecampbell,项目名称:moodle-booktool_wordexport,代码行数:31,代码来源:index.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP book_preload_chapters函数代码示例发布时间:2022-05-24
下一篇:
PHP bonus_info函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap