<?php
$you_tube_regExp = '/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/';
$vimo_regExp = '/(?:vimeo)\.com.*(?:videos|video|channels|)\/([\d]+)/i';
if ($post_type == 'note') {
    ?>
    <div >
        <?php
        foreach ($public_note_alert as $note_alert_value) {
            ?>
            <div class="col-sm-12 gray text-left">
                <div class="col-sm-6" style="padding:10px 9px 0px  19px ">
                    <p class="text-justify" <?php
                    if ($note_alert_value->post_type == 2) {
                        echo 'style="color: #a70b0c"';
                    }
                    ?>
                       id="post_detail<?php echo $note_alert_value->post_id ?>" >
                           <?php
                           $post_original_value = $this->tt_post->get_post_details($note_alert_value->post_details);
                           if (strlen($post_original_value) > 100) {
                               $limited_string = mb_substr($post_original_value, 0, 100, 'utf-8');
                               echo $this->cf->view_emoticons($limited_string);
                               ?>
                            <a href="javascript:void(0)" style="padding-left: 10px;"
                               onclick="viewDetails('<?php echo base_url() . 'welcome/view_post_details/' . $note_alert_value->post_id . '/post' ?>', 'post_detail', '<?php echo $note_alert_value->post_id ?>')" >
                                more...
                            </a>
                            <?php
                        } else {
                            echo $this->cf->view_emoticons($post_original_value);
                        }
                        ?>

                        <span>
                            <?php
                            if ($post_url[$note_alert_value->post_id]) {
                                $url_value = explode("URL: ", $post_url[$note_alert_value->post_id]->post_comment_url_info);

                                if (preg_match($you_tube_regExp, $url_value[1])) {
                                    ?>
                                    <div class="embed-responsive embed-responsive-16by9">
                                        <iframe class="embed-responsive-item" width="420" height="345" webkitallowfullscreen mozallowfullscreen allowfullscreen
                                                src="<?php echo $url_value[1]; ?>">
                                        </iframe>
                                    </div> 
                                    <?php
                                } else if (preg_match($vimo_regExp, $url_value[1])) {
                                    ?>
                                    <div class="embed-responsive embed-responsive-16by9">
                                        <iframe class="embed-responsive-item"  src="<?php echo $url_value[1]; ?>" 
                                                width="420" height="345" 
                                                frameborder="0" 
                                                webkitallowfullscreen mozallowfullscreen allowfullscreen>
                                        </iframe>
                                    </div>     
                                    <?php
                                } else {
                                    ?>
                                    <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457">
                                        <?php echo $url_value[2]; ?>
                                    </a>
                                    <?php
                                }
                            }
                            ?>
                        </span>

                    </p>
                </div>
                <div class="col-sm-3" style="padding: 10px 0 0 0  ">
                    <?php
                    echo $this->utility_model->date_time_format_with_offset($note_alert_value->post_date_time);
                    ?>
                </div>
                <?php
                $posted_public_note_link = base_url() . 'view-content/' . $this->utility_model->encode_id($note_alert_value->post_id, '/', 'Tt') . '/1';
                $this->session->set_flashdata('$posted_public_note_details', $note_alert_value->post_details);
                ?>
                <div class="col-sm-3" style="padding: 10px 0 0 0  ">
                    <a class="btn btn-facebook-custom" title="Share in Facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($posted_public_note_link); ?>">
                        <i class="fa fa-facebook" aria-hidden="true"></i>
                    </a>
                    <a class="btn btn-twitter-custom" title="Share in Twitter" target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo $posted_public_note_link; ?>">
                        <i class="fa fa-twitter" aria-hidden="true"></i>
                    </a>
                    <a class="btn btn-google-custom" title="Share in G+" target="_blank" href="https://plus.google.com/share?url=<?php echo urlencode($posted_public_note_link); ?>">
                        <i class="fa fa-google-plus"></i>
                    </a>
                    <a class="btn btn-linkedin-custom" title="Share in Linkedin" target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo urlencode($posted_public_note_link); ?>&summary=<?php echo $note_alert_value->post_details; ?>">
                        <i class="fa fa-linkedin"></i>
                    </a>
                </div>
            </div>
            <?php
        }
        ?>
    </div>
    <?php
    if ($total_public_note_alert->total_note_alert > 5) {
        ?>
        <div class="col-sm-12">
            <?php
            if ($note_alert_counter >= 5 && $note_alert_counter < $total_public_note_alert->total_note_alert) {
                ?>
                <a href="javascript:void(0)"
                   onclick="nextPostValue('<?php echo base_url() . 'welcome/view_next_post_value/' . $total_public_note_alert->posted_by . '/' . ($note_alert_counter - 5) . '/note' ?>', 'note')"
                   class="pull-left">
                    Previous
                </a>
                <?php
            }
            if ($total_public_note_alert->total_note_alert > ($note_alert_counter + 5)) {
                ?>
                <a href="javascript:void(0)"
                   onclick="nextPostValue('<?php echo base_url() . 'welcome/view_next_post_value/' . $total_public_note_alert->posted_by . '/' . ($note_alert_counter + 5) . '/note' ?>', 'note')"
                   class="pull-right">
                    Next
                </a>
            <?php } ?>
        </div>
        <?php
    }
} else if ($post_type == 'alert') {
    ?>
    <div >
        <?php
        foreach ($public_note_alert as $note_alert_value) {
            ?>
            <div class="col-sm-12 gray text-left">
                <div class="col-sm-6" style="padding:10px 9px 0px  19px ">
                    <p class="text-justify" <?php
        if ($note_alert_value->post_type == 2) {
            echo 'style="color: #a70b0c"';
        }
            ?>
                       id="post_detail<?php echo $note_alert_value->post_id ?>" >
                           <?php
                           $post_original_value = $this->tt_post->get_post_details($note_alert_value->post_details);
                           if (strlen($post_original_value) > 100) {
                               $limited_string = mb_substr($post_original_value, 0, 100, 'utf-8');
                               echo $this->cf->view_emoticons($limited_string);
                               ?>
                            <a href="javascript:void(0)" style="padding-left: 10px;"
                               onclick="viewDetails('<?php echo base_url() . 'welcome/view_post_details/' . $note_alert_value->post_id . '/post' ?>', 'post_detail', '<?php echo $note_alert_value->post_id ?>')" >
                                more...
                            </a>
                            <?php
                        } else {
                            echo $this->cf->view_emoticons($post_original_value);
                        }
                        ?>

                        <span>
                            <?php
                            if ($post_url[$note_alert_value->post_id]) {
                                $url_value = explode("URL: ", $post_url[$note_alert_value->post_id]->post_comment_url_info);

                                if (preg_match($you_tube_regExp, $url_value[1])) {
                                    ?>
                                    <div class="embed-responsive embed-responsive-16by9">
                                        <iframe class="embed-responsive-item" width="420" height="345" webkitallowfullscreen mozallowfullscreen allowfullscreen
                                                src="<?php echo $url_value[1]; ?>">
                                        </iframe>
                                    </div> 
                                    <?php
                                } else if (preg_match($vimo_regExp, $url_value[1])) {
                                    ?>
                                    <div class="embed-responsive embed-responsive-16by9">
                                        <iframe class="embed-responsive-item"  src="<?php echo $url_value[1]; ?>" 
                                                width="420" height="345" 
                                                frameborder="0" 
                                                webkitallowfullscreen mozallowfullscreen allowfullscreen>
                                        </iframe>
                                    </div>     
                                    <?php
                                } else {
                                    ?>
                                    <a href="<?php echo $url_value[1]; ?>" target="_blank" style="color: #545457">
                                        <?php echo $url_value[2]; ?>
                                    </a>
                                    <?php
                                }
                            }
                            ?>
                        </span>

                    </p>
                </div>
                <div class="col-sm-3" style="padding: 10px 0 0 0  ">
                    <?php
                    echo $this->utility_model->date_time_format_with_offset($note_alert_value->post_date_time);
                    ?>
                </div>
                <?php
                $posted_public_alert_link = base_url() . 'view-content/' . $this->utility_model->encode_id($note_alert_value->post_id, '/', 'Tt') . '/1';
                $this->session->set_flashdata('$posted_public_alert_details', $note_alert_value->post_details);
                ?>
                <div class="col-sm-3" style="padding: 10px 0 0 0  ">
                    <a class="btn btn-facebook-custom" title="Share in Facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($posted_public_alert_link); ?>">
                        <i class="fa fa-facebook" aria-hidden="true"></i>
                    </a>
                    <a class="btn btn-twitter-custom" title="Share in Twitter" target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo $posted_public_alert_link; ?>">
                        <i class="fa fa-twitter" aria-hidden="true"></i>
                    </a>
                    <a class="btn btn-google-custom" title="Share in G+" target="_blank" href="https://plus.google.com/share?url=<?php echo urlencode($posted_public_alert_link); ?>">
                        <i class="fa fa-google-plus"></i>
                    </a>
                    <a class="btn btn-linkedin-custom" title="Share in Linkedin" target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo urlencode($posted_public_alert_link); ?>&summary=<?php echo $note_alert_value->post_details; ?>">
                        <i class="fa fa-linkedin"></i>
                    </a>
                </div>
            </div>
            <?php
        }
        ?>
    </div>
    <?php
    if ($total_public_note_alert->total_note_alert > 5) {
        ?>
        <div class="col-sm-12">
            <?php
            if ($note_alert_counter >= 5 && $note_alert_counter < $total_public_note_alert->total_note_alert) {
                ?>
                <a href="javascript:void(0)"
                   onclick="nextPostValue('<?php echo base_url() . 'welcome/view_next_post_value/' . $total_public_note_alert->posted_by . '/' . ($note_alert_counter - 5) . '/alert' ?>', 'alert')"
                   class="pull-left">
                    Previous
                </a>
                <?php
            }
            if ($total_public_note_alert->total_note_alert > ($note_alert_counter + 5)) {
                ?>
                <a href="javascript:void(0)"
                   onclick="nextPostValue('<?php echo base_url() . 'welcome/view_next_post_value/' . $total_public_note_alert->posted_by . '/' . ($note_alert_counter + 5) . '/alert' ?>', 'alert')"
                   class="pull-right">
                    Next
                </a>
            <?php } ?>
        </div>
        <?php
    }
} else if ($post_type == 'assignment') {
    foreach ($public_assaignment as $assaignment_value) {
        ?>
        <div class="col-sm-12 gray text-left ">
            <div class="col-sm-2" style="padding:10px 9px 0px  19px" >
        <?php
        $file_name = explode(".", $assaignment_value->post_details);
        switch (strtolower($file_name[1])) {
            case 'pdf':
                ?>
                        <a href="javascript:void(0)" 
                           onclick="downloadPublicContentLibrary('<?php echo base_url() . 'download-public-content-library' ?>', '<?php echo $assaignment_value->post_id; ?>')" >
                            <img src=" <?php echo base_url() . 'image/assignment/pdf.png' ?>">
                        </a>
                <?php
                break;
            case $file_name[1] == 'zip' || $file_name[1] == 'rar':
                ?>
                        <a href="javascript:void(0)" 
                           onclick="downloadPublicContentLibrary('<?php echo base_url() . 'download-public-content-library' ?>', '<?php echo $assaignment_value->post_id; ?>')" >
                            <img src=" <?php echo base_url() . 'image/assignment/rar.png' ?>">
                        </a>
                <?php
                break;
            case $file_name[1] == 'doc' || $file_name[1] == 'docx':
                ?>
                        <a href="javascript:void(0)" 
                           onclick="downloadPublicContentLibrary('<?php echo base_url() . 'download-public-content-library' ?>', '<?php echo $assaignment_value->post_id; ?>')" >
                            <img src=" <?php echo base_url() . 'image/assignment/word.png' ?>">
                        </a>
                <?php
                break;
            case $file_name[1] == 'xls' || $file_name[1] == 'xlsx':
                ?>
                        <a href="javascript:void(0)" 
                           onclick="downloadPublicContentLibrary('<?php echo base_url() . 'download-public-content-library' ?>', '<?php echo $assaignment_value->post_id; ?>')" >
                            <img src=" <?php echo base_url() . 'image/assignment/excel.png' ?>">
                        </a>
                <?php
                break;
            case $file_name[1] == 'ppt' || $file_name[1] == 'pptx':
                ?>
                        <a href="javascript:void(0)" 
                           onclick="downloadPublicContentLibrary('<?php echo base_url() . 'download-public-content-library' ?>', '<?php echo $assaignment_value->post_id; ?>')" >
                            <img src=" <?php echo base_url() . 'image/assignment/powerpoint.png' ?>">
                        </a>
                <?php
                break;
            default :
                ?>
                        <a href="javascript:void(0)" 
                           onclick="downloadPublicContentLibrary('<?php echo base_url() . 'download-public-content-library' ?>', '<?php echo $assaignment_value->post_id; ?>')" >
                            <img src=" <?php echo base_url() . 'image/assignment/unknown.png' ?>">
                        </a>
                <?php
                break;
        }
        ?>

            </div>
            <div class="col-sm-4 text-justify " style="padding: 10px 0 0 0  ">
        <?php echo $assaignment_value->post_file_original_name ?>
            </div>
            <div class="col-sm-3" style="padding: 10px 0 0 0  ">
        <?php
        echo $this->utility_model->date_time_format_with_offset($assaignment_value->post_date_time);
        ?>
            </div>
                <?php
                $posted_public_assignment_link = base_url() . 'view-content/' . $this->utility_model->encode_id($assaignment_value->post_id, '/', 'Tt') . '/2';
                ?>
            <div class="col-sm-3 text-left" style="color: #80c12c; padding: 10px 0 0 0 ">
                <a class="btn btn-facebook-custom" title="Share in Facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($posted_public_assignment_link); ?>">
                    <i class="fa fa-facebook" aria-hidden="true"></i>
                </a>
                <a class="btn btn-twitter-custom" title="Share in Twitter" target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo $posted_public_assignment_link; ?>">
                    <i class="fa fa-twitter" aria-hidden="true"></i>
                </a>
                <a class="btn btn-google-custom" title="Share in G+" target="_blank" href="https://plus.google.com/share?url=<?php echo urlencode($posted_public_assignment_link); ?>">
                    <i class="fa fa-google-plus"></i>
                </a>
                <a class="btn btn-linkedin-custom" title="Share in Linkedin" target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo urlencode($posted_public_assignment_link); ?>&title=<?php echo $profile_name . ' posted file on TalhaTraining'; ?>&summary=<?php echo $assaignment_value->post_file_original_name; ?>">
                    <i class="fa fa-linkedin"></i>
                </a>
            </div>
        </div>
        <?php
    }
    ?>
    <?php
    if ($total_public_assaignment->total_assignment > 5) {
        ?>
        <div class="col-sm-12">
        <?php
        if ($assignment_counter >= 5 && $assignment_counter < $total_public_assaignment->total_assignment) {
            ?>
                <a href="javascript:void(0)"
                   onclick="nextPostValue('<?php echo base_url() . 'welcome/view_next_post_value/' . $total_public_assaignment->posted_by . '/' . ($assignment_counter - 5) . '/assignment' ?>', 'assignment')"
                   class="pull-left">
                    Previous
                </a>
            <?php
        }
        if ($total_public_assaignment->total_assignment > ($assignment_counter + 5)) {
            ?>
                <a href="javascript:void(0)"
                   onclick="nextPostValue('<?php echo base_url() . 'welcome/view_next_post_value/' . $total_public_assaignment->posted_by . '/' . ($assignment_counter + 5) . '/assignment' ?>', 'assignment')"
                   class="pull-right">
                    Next
                </a>
        <?php } ?>
        </div>
            <?php
        }
    } else if ($post_type == 'image') {
        foreach ($public_image as $image_value) {
            ?>
        <div class="col-sm-4 media-hover">
            <div class="media col-sm-12 ">
                <div class="media-body ">
                    <a href="javascript:void(0)">
                        <center> 
                            <img class=" media-object"
                                 onclick="downloadPublicContentLibrary('<?php echo base_url() . 'download-public-content-library' ?>', '<?php echo $image_value->post_id; ?>')"
                                 src="<?php echo base_url() . 'content-library/' . $image_value->url . '/' . $image_value->post_details; ?>" 
                                 style="width: 200px; height: 200px;" alt=" ">
                        </center>
                    </a>
                </div>
                <br>
        <?php
        $posted_public_image_link = base_url() . 'content-library/' . $image_value->url . '/' . $image_value->post_details;
        ?>
                <div class=" padding-zero text-left" style="color: #80c12c;">
                    <center>
                        <a class="btn btn-facebook-custom" title="Share in Facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($posted_public_image_link); ?>">
                            <i class="fa fa-facebook" aria-hidden="true"></i>
                        </a>
                        <a class="btn btn-twitter-custom" title="Share in Twitter" target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo $posted_public_image_link; ?>">
                            <i class="fa fa-twitter" aria-hidden="true"></i>
                        </a>
                        <a class="btn btn-google-custom" title="Share in G+" target="_blank" href="https://plus.google.com/share?url=<?php echo urlencode($posted_public_image_link); ?>">
                            <i class="fa fa-google-plus"></i>
                        </a>
                        <a class="btn btn-linkedin-custom" title="Share in Linkedin" target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo urlencode($posted_public_image_link); ?>">
                            <i class="fa fa-linkedin"></i>
                        </a>
                    </center>
                </div>
                <div class="col-sm-12"><hr></div>
            </div>
        </div>
        <?php
    }
    ?>
    <?php
    if ($total_public_image->total_image > 6) {
        ?>
        <div class="col-sm-12">
        <?php
        if ($image_counter >= 6 && $image_counter < $total_public_image->total_image) {
            ?>
                <a href="javascript:void(0)"
                   onclick="nextPostValue('<?php echo base_url() . 'welcome/view_next_post_value/' . $total_public_image->posted_by . '/' . ($image_counter - 6) . '/image' ?>', 'image')"
                   class="pull-left">
                    Previous
                </a>
            <?php
        }
        if ($total_public_image->total_image > ($image_counter + 6)) {
            ?>
                <a href="javascript:void(0)"
                   onclick="nextPostValue('<?php echo base_url() . 'welcome/view_next_post_value/' . $total_public_image->posted_by . '/' . ($image_counter + 6) . '/image' ?>', 'image')"
                   class="pull-right">
                    Next
                </a>
        <?php } ?>
        </div>
            <?php
        }
    } else if ($post_type == 'video') {
        $video_post_id = '';
        $video_post_url = '';
        foreach ($public_video as $video_value) {
            ?>
        <div class="col-sm-12 media-hover">
            <div class="media col-sm-12 ">
                <div class="media-body">

        <?php
        $video_post_id .= $video_value->post_id . '##';
        $video_post_url .= base_url() . 'content-library/' . $video_value->url . '/' . $video_value->post_details . '##';
        ?>                   

                    <div class="col-sm-12">
                        <div class="row">
                            <video controls>
                                <source src="<?php echo base_url() . 'content-library/' . $video_value->url . '/' . $video_value->post_details; ?>" type="video/mp4">                                                              
                            </video>
                        </div>
                    </div>
                </div>
                <br>
        <?php
        $posted_public_video_link = base_url() . 'view-content/' . $this->utility_model->encode_id($video_value->post_id, '/', 'Tt') . '/2';
        $this->session->set_flashdata('public_video_link', $posted_public_video_link);
        ?>
                <div class="col-sm-12 text-left" style="color: #80c12c;">
                    <center>
                        <a class="btn btn-facebook-custom" title="Share in Facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($posted_public_video_link); ?>">
                            <i class="fa fa-facebook" aria-hidden="true"></i>
                        </a>
                        <a class="btn btn-twitter-custom" title="Share in Twitter" target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo $profile_name . ' posted this video on TalhaTraining'; ?>&url=<?php echo $posted_public_video_link; ?>">
                            <i class="fa fa-twitter" aria-hidden="true"></i>
                        </a>
                        <a class="btn btn-google-custom" title="Share in G+" target="_blank" href="https://plus.google.com/share?url=<?php echo urlencode($posted_public_video_link); ?>">
                            <i class="fa fa-google-plus"></i>
                        </a>
                        <a class="btn btn-linkedin-custom" title="Share in Linkedin" target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo urlencode($posted_public_video_link); ?>&title=<?php echo $profile_name . ' posted video on TalhaTraining'; ?>&summary=<?php echo $video_value->post_file_original_name; ?>">
                            <i class="fa fa-linkedin"></i>
                        </a>
                    </center>
                </div>
                <div class="col-sm-12 form-group"><hr></div>
            </div>
        </div>
        <?php
    }
    ?>
    <div class="col-sm-12">
    <?php
    if ($total_public_video->total_video > 1) {
        ?>
            <div class="col-sm-12">
            <?php
            if ($video_counter >= 1 && $video_counter < $total_public_video->total_video) {
                ?>
                    <a href="javascript:void(0)"
                       onclick="nextPostValue('<?php echo base_url() . 'welcome/view_next_post_value/' . $total_public_video->posted_by . '/' . ($video_counter - 1) . '/video' ?>', 'video')"
                       class="pull-left">
                        Previous
                    </a>
            <?php
        }
        if ($total_public_video->total_video > ($video_counter + 1)) {
            ?>
                    <a href="javascript:void(0)"
                       onclick="nextPostValue('<?php echo base_url() . 'welcome/view_next_post_value/' . $total_public_video->posted_by . '/' . ($video_counter + 1) . '/video' ?>', 'video')"
                       class="pull-right">
                        Next
                    </a>
        <?php } ?>
            </div>
            <?php } ?>
    </div>
    <input type="hidden" id="hiddin_post_video_id" name="hiddin_post_video_id" value="<?php echo $video_post_id; ?>">
    <input type="hidden" id="hiddin_post_video_url" name="hiddin_post_video_url" value="<?php echo $video_post_url; ?>">
    <?php
}
