Example #1
0
/**
 * Do stuff to the list elements
 *
 * @param pq obj $list
 * @param bool $child Whether or not this list is a child of another list (replace now vs with wrapping 'figure')
 * @return void
 */
function anno_xml_to_html_iterate_list($list, $child = false)
{
    // Get list type
    $list_type = $list->attr('list-type');
    $list_type = $list_type == 'order' ? 'ol' : 'ul';
    // Loop over our items
    $items = $list->children('list-item');
    if (count($items)) {
        foreach ($items as $item) {
            $pq_item = pq($item);
            anno_xml_to_html_iterate_list_item($pq_item);
        }
    }
    if ($child) {
        $list->replaceWith('<' . $list_type . '>' . $list->html() . '</' . $list_type . '>');
    }
}
/**
 * Do stuff to the list elements
 * 
 * @param pq obj $list
 * @return void
 */
function anno_xml_to_html_iterate_list($list)
{
    // Get list type
    $list_type = $list->attr('list-type');
    $list_type = $list_type == 'order' ? 'ol' : 'ul';
    // Get list title if there is one
    $figcaption = $list->find('title:first')->html();
    // Now that we have the title, get rid of the element
    $list->find('title:first')->remove();
    // Loop over our items
    $items = $list->children('list-item');
    if (count($items)) {
        foreach ($items as $item) {
            $pq_item = pq($item);
            anno_xml_to_html_iterate_list_item($pq_item);
        }
    }
    // Replace our list with our built-out HTML
    $html = '';
    $html .= '<figure class="list">';
    $html .= empty($figcaption) ? '' : '<figcaption>' . $figcaption . '</figcaption>';
    $html .= '<' . $list_type . '>' . $list->html() . '</' . $list_type . '>';
    $html .= '</figure>';
    $list->replaceWith($html);
}