コード例 #1
0
ファイル: model.php プロジェクト: Julietdragonfly/commentTree
 public function build_comment($cats, $parent_id, $ansver, $fio)
 {
     if (is_array($cats) and isset($cats[$parent_id])) {
         $tree = '<ul>';
         foreach ($cats[$parent_id] as $cat) {
             $date = Dates::output_date($cat['date_update']);
             $time = Dates::output_time($cat['date_update']);
             $id = $cat['id'];
             $author = $cat['author'];
             $tree .= '<li>' . '<div><p>' . $date . ' ' . $time . ' ' . $author . '</p>';
             $tree .= "<p class=\"message_p\" id=\"message_full_" . $id . "\">";
             $tree .= $cat['message'] . '</p>';
             if ($ansver == true) {
                 $tree .= "<p class=\"half\">";
                 $tree .= "<a data-toggle=\"modal\" href=\"#modal\" data-target=\"#modal\" data-id=\"{$id}\" id=\"modal_act\">Ответить</a>";
                 $tree .= '</p>';
             }
             if ($fio == $author) {
                 $tree .= "<p class=\"half\">";
                 $tree .= "<a data-toggle=\"modal\" href=\"#modal_1\" data-target=\"#modal_1\" data-id=\"{$id}\" id=\"modal_edit\">Редактировать</a>";
                 $tree .= '</p>';
             }
             $tree .= '</div>';
             $tree .= $this->build_comment($cats, $cat['id'], $ansver, $fio);
             $tree .= '</li>';
         }
         $tree .= '</ul>';
     } else {
         return null;
     }
     return $tree;
 }