Example #1
0
function buildNestedList($arrMenu, $parent = 0)
{
    print "<ol class='dd-list'>";
    foreach ($arrMenu as $x => $val) {
        if ($val["menu_parent_id"] == $parent) {
            print " <li class='dd-item' data-id='" . $val["menu_id"] . "'>";
            print "<div class='dd-handle'>" . $val["menu_text"] . "</div>";
            if (has_children($arrMenu, $val["menu_id"]) == TRUE) {
                buildNestedList($arrMenu, $val["menu_parent_id"]);
            }
            print "</li>";
        }
    }
    print "</ul>";
}
Example #2
0
function build_menu($rows, $parent = 0)
{
    $result = "<ul>";
    foreach ($rows as $row) {
        if ($row['parent_id'] == $parent) {
            $result .= "<li>{$row['title']}";
            if (has_children($rows, $row['id'])) {
                $result .= build_menu($rows, $row['id']);
            }
            $result .= "</li>";
        }
    }
    $result .= "</ul>";
    return $result;
}
Example #3
0
<?php

get_header();
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
        <article class="post page">
            <?php 
        if (has_children() || $post->post_parent > 0) {
            ?>
            <nav class="site-nav children-links clearfix">
                <span class="parent-link">
                    <a href="<?php 
            get_the_permalink(get_top_ancestor_id());
            ?>
"><?php 
            echo get_the_title(get_top_ancestor_id());
            ?>
</a>
                </span>
                <ul>
                    <?php 
            $args = array('child_of' => get_top_ancestor_id(), 'title_li' => '');
            ?>
                    <?php 
            wp_list_pages($args);
            ?>
                </ul>
            </nav>
            <?php 
Example #4
0
// easy CSS style linking
$url = $baseurl . basename(__FILE__);
$this_url = new moodle_url($url);
$index_url = new moodle_url($baseurl . "index.php");
$submit_url = new moodle_url($baseurl . basename(__FILE__));
$page_title = get_string("pluginname", $plugin);
$page_heading = get_string("pluginadministration", $plugin);
$view_button = get_string("viewbutton", $plugin);
// get group info
$group = $DB->get_record('ketlicense', array('id' => $groupid));
$group_heading = $group->cohortname;
// get children of group and subchildren
$children = get_children($groupid);
$where_items = "( ";
$query_arr = array();
if (has_children($group->id)) {
    // build where statements
    foreach ($children as $child => $value) {
        $where_items .= 'member.license = ? OR ';
        // put values into array
        $query_arr[] = $value;
    }
    $where_items = substr($where_items, 0, strlen($where_items) - 3);
    $where_items .= ") ";
} else {
    $where_items = 'member.license = ? ';
    $query_arr[] = $groupid;
}
// make additional where parameters
// build start date
if ($start_date) {
Example #5
0
                }
                ?>
							<?php 
            }
            wp_reset_postdata();
            ?>
							<?php 
            if ($show_sub_chapters) {
                ?>
								<ul class="sub-chapter">
								<?php 
                while ($sub_chapters->have_posts()) {
                    $sub_chapters->the_post();
                    ?>
									<?php 
                    if (has_children($post)) {
                        ?>
									<?php 
                        $is_active = $active_post->ID == $sub_chapters->post->ID || $active_post->post_parent == $sub_chapters->post->ID;
                        ?>
									<li <?php 
                        if ($is_active) {
                            echo "class='active'";
                        }
                        ?>
>
										<a href="<?php 
                        the_permalink();
                        ?>
">
											<?php 
Example #6
0
/**
 * Grabs all children of id
 *
 * returns array contains children id #s
**/
function get_children($id)
{
    global $DB;
    $sql = "SELECT * FROM {ketlicense} WHERE parent = ?";
    $childs = $DB->get_records_sql($sql, array($id));
    $output_array = array();
    if (sizeof($childs) > 0) {
        foreach ($childs as $row) {
            if (has_children($row->id)) {
                $subchildren = get_children($row->id);
                foreach ($subchildren as $subrow => $subval) {
                    $output_array[] = $subval;
                }
            } else {
                $output_array[] = $row->id;
            }
        }
        return $output_array;
    } else {
        return false;
    }
}
Example #7
0
</h1>
					</div>
		    	</div>
			</div>
		</div>
		
	<?php 
    }
    // if is page and is a sub-page, show the parent and siblings in a menu
    if (is_page()) {
        // WP variables
        $current = $post->ID;
        $parent = $post->post_parent;
        $grandparent_get = get_post($parent);
        $grandchild = $grandparent_get->post_parent;
        $has_children = has_children($post->ID);
        // ACF variables
        $sub_menu = get_field('show_top_sub_menu', $post->ID);
        if ($sub_menu == 'true_sub_menu') {
            if ($parent) {
                if (!$grandchild && $parent) {
                    $child_of_value = $post->post_parent ? $post->post_parent : $post->ID;
                    // Depth of 2 if parent page, else depth of 1
                    $depth_value = $post->post_parent ? 2 : 1;
                    $walker = new Short_Name_Walker();
                    $wp_list_pages = wp_list_pages(array('child_of' => $post->post_parent, 'depth' => 1, 'title_li' => '', 'walker' => $walker, 'echo' => 0));
                    // Remove last |
                    //$wp_list_pages = preg_replace('/\|[^|]*$/', '', $wp_list_pages);
                    //echo '2';
                } elseif ($grandchild) {
                    $child_of_value = $post->post_parent ? $post->post_parent : $post->ID;
Example #8
0
<?php

global $post;
switch (true) {
    case is_page('work'):
        // Redirect to first child page.
        $pagekids = get_pages("child_of=" . $post->ID . "&sort_column=menu_order");
        $firstchild = $pagekids[0];
        if ($firstchild) {
            wp_redirect(get_permalink($firstchild->ID), 301);
            exit;
        } else {
            get_template_part('index');
        }
        break;
    case has_children($post->ID):
        // If has child pages
        get_template_part('template-work-grid');
        break;
    case is_tree(5):
        // Is in the "About" tree.
        get_template_part('template-work-grid');
        break;
    case !empty($post->_custom_video_url):
        // Page has a video URL metabox value saved, so use the work detail template.
        get_template_part('template-work-detail');
        break;
    default:
        get_template_part('index');
        break;
}
Example #9
0
function build_comment($arrData, $parent = 0, $depth = 1)
{
    ?>
    	 <?php 
    if ($depth > 1) {
        ?>
            	<ul class="children">
            <?php 
    }
    ?>
	
           
		<?php 
    foreach ($arrData as $x => $val) {
        ?>
        	<?php 
        if ($val['parent_id'] == $parent) {
            ?>
            <?php 
            $even = $x % 2 == 0 ? "even" : "odd";
            ?>
            	<li class="comment even thread-<?php 
            echo $even;
            ?>
 depth-<?php 
            echo $depth;
            ?>
">
				<div class="comment-header">
                	<div class="comment-author vcard">
                    	<i class="icon-user"></i>&nbsp; <cite class="fn" style="text-transform:uppercase"><?php 
            echo $val["name"];
            ?>
 </cite> <span class="says">says:</span>
                    	<div class="help-block">
                    	<?php 
            echo date("d M Y (H:i)", strtotime($val["created"]));
            ?>
                    </div>
                    </div>
                    
                </div>
                <div class="comment-content" style="padding:0 10px">
				<p><?php 
            echo $val["body"];
            ?>
</p>
                </div>
                <div class="reply" style="padding:0 10px">
                	<?php 
            echo "<a href='#' class='comments_reply' data-idx='" . $val["idx"] . "' data-parent='" . $parent . "' rel='wg/comments/comments_reply/" . $val["idx"] . "'>Reply</a>";
            ?>
	
                </div>
                <?php 
            if (has_children($arrData, $val["idx"])) {
                ?>
               		<?php 
                build_comment($arrData, $val["idx"], $depth + 1);
                ?>
                <?php 
            }
            ?>
              
            </li>
            <?php 
        }
        ?>
		<?php 
    }
    ?>
          <?php 
    if ($depth > 1) {
        ?>
            		</ul>
            	<?php 
    }
    ?>
	
	<?php 
}
Example #10
0
function buildNestedList($arrMenu, $parent = 0)
{
    print "<ol class='dd-list'>";
    foreach ($arrMenu as $x => $val) {
        if ($val["menu_parent_id"] == $parent) {
            //rendering data
            $data_tmp = array();
            foreach ($val as $key => $value) {
                $data_tmp[] = "data-" . $key . "='" . $value . "'";
            }
            if (cek_array($data_tmp)) {
                $data_str = join(" ", $data_tmp);
            }
            $div_str = $val["menu_text"];
            $div_str = '<table class="dd_table">
                    	<tr><td>' . $val["menu_text"] . '</td><td class="dd-menu-url">' . $val["menu_url"] . '</td><td class="dd-menu-class"><i class=' . $val["menu_icon"] . '></i></td>
				';
            $div_str .= "<td class='dd-menu-action tc'>\n\t\t\t\t\t<a href='#' class='menu_edit blue'>\n\t\t\t\t\t<i class='icon-pencil bigger-130'></i>\n\t\t\t\t\t</a>\n\t\t\t\t\t<a href='#' class='menu_delete red'>\n\t\t\t\t\t\t<i class='icon-trash bigger-130'></i>\n\t\t\t\t\t</a>\n\t\t\t\t\t</td>";
            $div_str .= '</tr></table>';
            /*
            $div_str="<div class='menu-text pull-left'>".
            				$val["menu_text"]
            		  ."</div";
            $div_str.="<div class='menu-url pull-right'>".
            				$val["menu_url"]
            		  ."</div";
            */
            print " <li class='dd-item' data-id='" . $val["menu_id"] . "' {$data_str}>";
            print "<div class='dd-handle'>\n\t\t\t\t\t{$div_str}\n\t\t\t\t\t</div>";
            if (has_children($arrMenu, $val["menu_id"]) == TRUE) {
                buildNestedList($arrMenu, $val["menu_id"]);
            }
            print "</li>";
        }
    }
    print "</ol>";
}
Example #11
0
 // Check to see if coloured content blocks are set. If they are, then we want an extra space above the page children blocks
 if (have_rows('content_blocks')) {
     while (have_rows('content_blocks')) {
         the_row();
         // Find out if the coloured rows have been set. If they have then set a
         if (get_row_layout() == 'step_block' || get_row_layout() == 'video_block') {
             $big_margin_top = 'big_margin_top';
         }
     }
 }
 //Work out what level page this is
 $parent = $post->post_parent;
 if ($parent) {
     $grandparent_get = get_post($parent);
     $has_grandparent = $grandparent_get->post_parent;
     if (has_children()) {
         $middle = true;
     }
 }
 if ($has_grandparent) {
     $post_id = $parent;
 } elseif (!($has_grandparent || $middle) && $parent) {
     $post_id = $parent;
 } elseif ($middle == true) {
     $post_id = $post->ID;
 } else {
     $post_id = $post->ID;
 }
 $args = array('child_of' => $post_id, 'sort_column' => 'menu_order', 'post_type' => 'page', 'post_status' => 'publish');
 $query = null;
 $key = 'child-pages-' . $post_id;
Example #12
0
/**
 * Actually print the categories
 *
 * @param The $categories array $categories
 */
function displayCategories($categories)
{
    $attributed = array();
    $string = '';
    ?>
    <div class="menudiv">
<?php 
    foreach ($categories as $id => $detail) {
        $level = 0;
        if (!in_array($id, $attributed)) {
            $string = $detail['name'];
            ULLI($detail['path'], $string, $level, $parent = $id);
            $attributed = has_children($id, $categories, $attributed);
        }
        if (!in_array($id, $attributed)) {
            CloseULLI($level);
        }
    }
    ?>
    </div>
<?php 
}
Example #13
0
function get_json_data($service, $object = NULL, $params = '', $repo = NULL)
{
    $service_url = $GLOBALS[$service . '_api_url'];
    $service_id = $GLOBALS[$service . '_id'];
    $cache_file = $GLOBALS[$service . '_cache_file'];
    global $cache_dir;
    // Attempt to make the cache directory if it doesn't already exist
    if (!file_exists($cache_dir)) {
        mkdir($cache_dir);
    }
    // Local 'tmp' cache file on the webserver, preferably out of public reach, i.e.
    // htdocs/tmp/.json_github_lmms_releases.
    $tmp_suffix = ($repo ? $repo : $service_id) . ($object ? '_' . $object : '');
    $tmp_suffix = str_replace('/', '', str_replace('.', '', str_replace('__', '_', $tmp_suffix)));
    // For "resolve" requests, hash the track URL for cache filename
    if ($service == 'soundcloud' && $params && strpos($params, '://') !== false) {
        $tmp_suffix = md5($params) . $tmp_suffix;
    }
    $tmp_cache = $cache_dir . $cache_file . $tmp_suffix;
    // If the repository isn't specified, assume it's the same as the project name and build accordingly
    // i.e. "https://api.github.com/repos/lmms/lmms/releases?param=value"
    // i.e. "https://www.googleapis.com/plus/v1/people/113001340835122723950/activities/public?maxResults=25
    switch ($service) {
        case 'youtube':
            $full_api = $service_url . ($object ? $object : 'playlists') . '?channelId=' . ($repo ? $repo : $service_id) . $params;
            break;
        case 'soundcloud':
            $full_api = $service_url . ($repo ? $repo : $service_id) . '/' . ($object ? $object : 'tracks') . '.json' . $params;
            break;
        case 'facebook':
            $full_api = $service_url . '?id=' . ($repo ? $repo : $service_id) . '&format=json' . $params;
            break;
        case 'google':
            $full_api = $service_url . ($repo ? $repo : $service_id) . '/' . $object . '/public/' . $params;
            break;
        case 'github':
        default:
            $full_api = $service_url . ($repo ? $repo : $service_id) . '/' . $service_id . '/' . $object . $params;
    }
    $using_url = false;
    if (cache_expired($tmp_cache)) {
        $json = file_get_contents_curl(realurl($full_api), $service);
        $using_url = true;
    } else {
        $json = file_get_contents($tmp_cache);
    }
    $obj = json_decode($json);
    /*
     * If there's valid JSON data, AND it came from the web cache it
     * If not, fall back to the previous cache
     */
    if (has_children($obj, $service)) {
        if ($using_url) {
            @file_put_contents($tmp_cache, $json, LOCK_EX);
        }
        return $obj;
    } else {
        $json = @file_get_contents($tmp_cache);
        return json_decode($json);
    }
}
Example #14
0
<?php

get_header();
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
	
		<article class="post page">
		<?php 
        has_children() or $post->post_parent > 0;
        ?>
		<nav class="site-nav children-links clearfix">
		<span class="parent_link"><a href="<?php 
        get_the_permalink(get_top_id());
        ?>
"><?php 
        echo get_the_title(get_top_id());
        ?>
</a></span>
		<ul>
			<?php 
        $args = array('child_of' => get_top_id(), 'title_li' => '');
        ?>
			<?php 
        wp_list_pages($args);
        ?>
			</ul>
		</nav>
			<h2><?php 
        the_title();