private function _displayblogPost() { global $currentIndex, $cookie; $errors = array(); $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT'); $languages = Language::getLanguages(false); $iso = Language::getIsoById((int) $cookie->id_lang); $divLangName = 'title¤image¤td_image¤image¤description¤tdcatname'; $this->_checkModerateComment(); $this->_checkDeleteComment(); $this->context = Context::getContext(); $id_shop = $this->context->shop->id; $id_lang = $this->context->language->id; if (Tools::isSubmit('tdSubmitCategory')) { Db::getInstance()->Execute(' INSERT INTO `' . _DB_PREFIX_ . 'tdpsblog_category` (`category_parent`,`active`,`id_shop`) VALUES(' . (int) Tools::getValue('parent_cat') . ',' . (int) Tools::getValue('td_activeblog') . ',' . (int) $id_shop . ')'); $id_tdpsblogcat = Db::getInstance()->Insert_ID(); foreach ($languages as $language) { $sttolower = strtolower(Tools::getValue('td_catname_' . $language['id_lang'])); $catlinksrewrite = str_replace(' ', '-', $sttolower); Db::getInstance()->Execute(' INSERT INTO `' . _DB_PREFIX_ . 'tdpsblog_category_lang` (`id_tdpsblog_category`, `id_lang`, `category_name`, `cat_rewrite`) VALUES(' . (int) $id_tdpsblogcat . ', ' . (int) $language['id_lang'] . ', "' . pSQL(Tools::getValue('td_catname_' . $language['id_lang'])) . '","' . $catlinksrewrite . '")'); } } elseif (Tools::isSubmit('deleteBlogCat') && Tools::isSubmit('id_tdpsblog_category')) { Db::getInstance()->Execute(' DELETE FROM `' . _DB_PREFIX_ . 'tdpsblog_category` WHERE `id_tdpsblog_category` = ' . (int) Tools::getValue('id_tdpsblog_category')); Db::getInstance()->Execute(' DELETE FROM `' . _DB_PREFIX_ . 'tdpsblog_category_lang` WHERE `id_tdpsblog_category` = ' . (int) Tools::getValue('id_tdpsblog_category')); } if (count($errors)) { $this->_html .= $this->displayError(implode('<br />', $errors)); } elseif (Tools::isSubmit('tdSubmitCategory')) { $this->_html .= $this->displayConfirmation($this->l('Category added Successfully')); } elseif (Tools::isSubmit('deleteBlogCat') && Tools::isSubmit('id_tdpsblog_category')) { $this->_html .= $this->displayConfirmation($this->l('Deletion successful')); } $blogcat = tdpsblogModel::getAllblogCategory(); $blogpost = tdpsblogModel::getAllblogPost(); $getinactivecom = tdpsblogModel::getAllInactiveComments(); $getactivecom = tdpsblogModel::getAllActiveComments(); // print_r($blogpost) ; /* foreach ($blogcat as $blogcategory){ $this->_html .='<option value="'.$blogcategory['id_tdpsblog_category'].'">'.$blogcategory['category_name'].'</option>'; } */ $this->context->controller->addJqueryUI('ui.sortable'); $this->_html .= '<script type="text/javascript" src="' . $this->_path . 'js/moderate.js"></script><style> .language_flags { display: none; } .discount_name { background: none repeat scroll 0 0 #FFEBCC; padding: 2px; text-transform: uppercase; } .displayed_flag { float: left; margin: 4px 0 0 4px; } .language_flags { background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #555555; display: none; float: left; margin: 4px; padding: 8px; width: 80px; } .pointer { cursor: pointer; } .clear{ clear:both; } .pull-left > small { display: block; padding-top: 15px; } </style><script type="text/javascript"> $(function() { var $mySlides = $("#slides"); $mySlides.sortable({ opacity: 0.6, cursor: "move", update: function() { var order = $(this).sortable("serialize") + "&action=updateSlidesPosition"; $.post("' . $this->context->shop->physical_uri . $this->context->shop->virtual_uri . 'modules/' . $this->name . '/' . $this->name . 'Ajax.php?secure_key=' . $this->secure_key . '", order); } }); $mySlides.hover(function() { $(this).css("cursor","move"); }, function() { $(this).css("cursor","auto"); }); }); </script><fieldset> <legend>ThemesDeveloper Blog Options</legend>'; $this->_html .= '<div class="panel"><h3><i class="icon-list-ul"></i> Post list <span class="panel-heading-action"><span class="panel-heading-action"> <a href="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&addNewPost" class="list-toolbar-btn" id="desc-product-new"> <span data-html="true" data-original-title="Add new" class="label-tooltip" data-toggle="tooltip" title=""> <i class="process-icon-new "></i> </span> </a> </span> </h3> <div id="slidesContent"> <div id="slides" class="ui-sortable" style="cursor: auto;">'; if ($blogpost) { foreach ($blogpost as $tdblogdata) { $categorypost = tdpsblogModel::getCategoryByID($tdblogdata['tdpost_category']); if (isset($categorypost[0]) && is_array($categorypost[0])) { $postcateogry = $categorypost[0]['category_name']; } else { $postcateogry = ''; } $this->_html .= '<div class="panel" id="slides_' . $tdblogdata['id_tdpsblog'] . '"> <div class="row"> <div class="col-lg-1"> <span><i class="icon-arrows "></i></span> </div> <div class="col-md-3"> <img class="img-thumbnail" src="' . __PS_BASE_URI__ . $tdblogdata['image_url'] . '" width="80%"> </div> <div class="col-md-8"> <h4 class="pull-left">#' . $tdblogdata['id_tdpsblog'] . ' - ' . $tdblogdata['tdpost_title'] . '<small>' . $postcateogry . '</small></h4> <div class="btn-group-action pull-right">'; if ($tdblogdata['active'] == 1) { $this->_html .= '<a title="Enabled" href="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&changeStatus=0&id_tdpsblog=' . (int) $tdblogdata['id_tdpsblog'] . '" class="btn btn-success"><i class="icon-check"></i> Enabled</a>'; } else { $this->_html .= '<a title="Disabled" href="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&changeStatus=1&id_tdpsblog=' . (int) $tdblogdata['id_tdpsblog'] . '" class="btn btn-danger"><i class="icon-remove"></i> Disabled</a>'; } $this->_html .= '<a href="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&updateBlogPost&id_tdpsblog=' . (int) $tdblogdata['id_tdpsblog'] . '" class="btn btn-default"> <i class="icon-edit"></i> Edit </a> <a href="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&deleteBlogPost&id_tdpsblog=' . (int) $tdblogdata['id_tdpsblog'] . '" class="btn btn-default"> <i class="icon-trash"></i> Delete </a> </div> </div> </div> </div> '; } } $this->_html .= '</table></div></fieldset>'; $this->_html .= '<form id="productcomments" class="form-horizontal clearfix" name="comment_form" method="post" action="' . Tools::safeOutput($this->_baseUrl) . '"> <div class="panel col-lg-12"> <h3>Moderate Comments</h3> <div class="table-responsive clearfix"> <input type="hidden" id="id_product_comment" name="id_product_comment[]"> <input type="hidden" id="moderate_action" name="moderate_action"> <table class="table productcomments"> <thead>'; if (count($getinactivecom) > 0) { $this->_html .= '<tr> <th style="width:50px;"><input class="noborder" type="checkbox" onclick="checkDelBoxes(this.form, \'id_product_comment[]\', this.checked)" /></th> <th style="width:50px;">Post-ID</th> <th style="width:150px;">Author</th> <th style="width:500px;">Comment</th> <th style="width:30px;">Actions</th> </tr> </thead> <tbody>'; foreach ($getinactivecom as $tdcomments) { $this->_html .= ' <tr><td><input type="checkbox" name="id_product_comment[]" value="' . $tdcomments['id_tdpsblog_comments'] . '" class="noborder"></td> <td style="text-align:center">#' . $tdcomments['id_tdpsblog'] . '</td> <td>' . $tdcomments['comment_author_name'] . '</td> <td>' . $tdcomments['comments_text'] . '</td> <td> <a onclick="acceptComment(' . $tdcomments['id_tdpsblog_comments'] . ');" href="javascript:;"><img title="Accept" alt="Accept" src="' . __PS_BASE_URI__ . 'modules/tdpsblog/img/accept.png"></a> <a onclick="deleteComment(' . $tdcomments['id_tdpsblog_comments'] . ');" href="javascript:;"><img title="Delete" alt="Delete" src="' . __PS_BASE_URI__ . 'modules/tdpsblog/img/delete.png"></a></td> </tr> '; } $this->_html .= '<tr> <td style="font-weight:bold;text-align:right" colspan="4">Selection:</td> <td><a onclick="acceptComment(0);" href="javascript:;"><img title="Accept" alt="Accept" src="' . __PS_BASE_URI__ . 'modules/tdpsblog/img/accept.png"></a> <a onclick="deleteComment(0);" href="javascript:;"><img title="Delete" alt="Delete" src="' . __PS_BASE_URI__ . 'modules/tdpsblog/img/delete.png"></a></td> </tr>'; } else { $this->_html .= '<tr> <td colspan="8" class="list-empty"> <div class="list-empty-msg"> <i class="icon-warning-sign list-empty-icon"></i> No records found </div> </td> </tr>'; } $this->_html .= '</tbody> </table> </div></div> </form> <form class="form-horizontal clearfix" name="delete_comment_form" method="post" action="' . Tools::safeOutput($this->_baseUrl) . '"> <div class="panel col-lg-12"> <h3>Manage Comments</h3> <div class="table-responsive clearfix"> <input type="hidden" id="delete_id_product_comment" name="delete_id_product_comment[]"> <input type="hidden" id="delete_action" name="delete_action"> <table class="table productcomments"> <thead>'; if (count($getactivecom) > 0) { $this->_html .= '<tr> <th style="width:50px;"><input class="noborder" type="checkbox" onclick="checkDelBoxes(this.form, \'delete_id_product_comment[]\', this.checked)" /></th> <th style="width:50px;">Post-ID</th> <th style="width:150px;">Author</th> <th style="width:500px;">Comment</th> <th style="width:30px;">Actions</th> </tr> </thead> <tbody>'; foreach ($getactivecom as $tdactivecomments) { $this->_html .= '<tr> <td><input type="checkbox" name="delete_id_product_comment[]" value="' . $tdactivecomments['id_tdpsblog_comments'] . '" class="noborder"></td> <td style="text-align:center">#' . $tdactivecomments['id_tdpsblog'] . '</td> <td>' . $tdactivecomments['comment_author_name'] . '</td> <td>' . $tdactivecomments['comments_text'] . '</td> <td><a onclick="delComment(\'' . (int) $tdactivecomments['id_tdpsblog_comments'] . '\',\'' . $this->l('Are you sure?') . '\');" href="javascript:;"><img title="Delete" alt="Delete" src="' . __PS_BASE_URI__ . 'modules/tdpsblog/img/delete.png"></a></td> </tr>'; } $this->_html .= '<tr> <tr> <td style="font-weight:bold;text-align:right" colspan="4">Selection:</td> <td><a onclick="delComment(0,\'' . $this->l('Are you sure?') . '\'); " href="javascript:;"><img title="Delete" alt="Delete" src="' . __PS_BASE_URI__ . 'modules/tdpsblog/img/delete.png"></a></td> </tr>'; } else { $this->_html .= '<tr> <td colspan="8" class="list-empty"> <div class="list-empty-msg"> <i class="icon-warning-sign list-empty-icon"></i> No records found </div> </td> </tr>'; } $this->_html .= '</tbody> </table> </div></div> </form> <form class="form-horizontal clearfix" name="criterion_form" method="post" action="' . Tools::safeOutput($this->_baseUrl) . '"> <div class="panel col-lg-12"> <h3>Manage Blog Category</h3> <div class="table-responsive clearfix"> '; $this->_html .= '<div class="form-group "> <label class="control-label col-lg-3 " for="url_1"> ' . $this->l('Category Name') . ' </label> <div class="col-lg-9 ">'; foreach ($languages as $language) { $this->_html .= ' <div id="tdcatname_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;"> <input type="text" name="td_catname_' . $language['id_lang'] . '" id="td_catname_' . $language['id_lang'] . '" size="64" value="' . (Tools::getValue('td_catname_' . $language['id_lang']) ? Tools::getValue('td_catname_' . $language['id_lang']) : (isset($updatevalue['td_catname'][$language['id_lang']]) ? $updatevalue['td_catname'][$language['id_lang']] : '')) . '"/> </div>'; } $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'tdcatname', true); $this->_html .= '</div><div class="clear"> </div> <div class="margin-form" style="display:none"> <select name="parent_cat"> <option value="0">Root</option>'; $this->_html .= ' </select> </div>'; $this->_html .= '</div> <div class="form-group "> '; $this->_html .= ' <label class="control-label col-lg-3 " for="active_slide"> Active </label> <div class="col-lg-9 "> <div "col-lg-9"=""> <span class="switch prestashop-switch fixed-width-lg"> <input type="radio" ' . (isset($updatevalue[0]['active']) && $updatevalue[0]['active'] == 0 ? '' : 'checked="checked" ') . ' value="1" id="active_slide_on" name="td_activeblog"> <label for="active_slide_on"> Yes </label> <input type="radio" value="0" ' . (isset($updatevalue[0]['active']) && $updatevalue[0]['active'] == 0 ? 'checked="checked" ' : '') . ' id="active_slide_off" name="td_activeblog"> <label for="active_slide_off"> No </label> <a class="slide-button btn"></a> </span> </div> </div> </div>'; $this->_html .= ' <div class="clear"></div> <div class="panel-footer"> <button type="submit" value="1" id="module_form_submit_btn" name="tdSubmitCategory" class="btn btn-default pull-right"> <i class="process-icon-save"></i> Add Category </button> </div></div><h3>Blog Category List</h3> '; $this->_html .= ' <br> <table class="table"> <thead> <tr> <th style="width:80px;">id</th> <th style="width:460px;">Category Name</th> <th style="width:50px;">Status</th> <th style="width:30px;">Actions</th> </tr> </thead> <tbody> '; foreach ($blogcat as $blogcate) { $this->_html .= '<tr> <td>' . $blogcate['id_tdpsblog_category'] . '</td> <td>' . $blogcate['category_name'] . '</td> <td style="text-align:center;">'; if ($blogcate['active'] == 1) { $this->_html .= '<img title="Enabled" alt="Enabled" src="../img/admin/enabled.gif">'; } else { $this->_html .= '<img title="Disabled" alt="Disabled" src="../img/admin/disabled.gif">'; } $this->_html .= '</td> <td><a href="' . $currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&deleteBlogCat&id_tdpsblog_category=' . (int) $blogcate['id_tdpsblog_category'] . '" "><img alt="Delete" src="../img/admin/delete.gif"></a> </td></tr>'; } $this->_html .= ' <tr></tr></tbody></table></form> </div></div>'; }
} } global $smarty; $id_shop = $context->shop->id; $id_lang = $context->language->id; $id_tdpost = Tools::getValue('tdpost'); if (Tools::getValue('replytocom')) { $replytocom = Tools::getValue('replytocom'); } else { $replytocom = 0; } $numofrepost = Configuration::get('td_numofrepost') ? Configuration::get('td_numofrepost') : 5; $numofcomments = Configuration::get('td_numofcomments') ? Configuration::get('td_numofcomments') : 5; $postcomments = tdpsblogModel::getComments($id_tdpost); $posttotalcomments = count(tdpsblogModel::getTotalCommentsByPost($id_tdpost)); $postcateogyr = tdpsblogModel::getPostCategory(); //print_r($postcateogyr); // print_r($postcomments); $tdblogpspost = $psblogobject->gettdBlogPostByID($id_tdpost, $id_lang, $id_shop); $data = array(); foreach ($tdblogpspost as $tdblogps) { $data[] = $tdblogps; } if (file_exists(_PS_THEME_DIR_ . 'modules/tdpsblog/form.tpl')) { $smarty->assign('comments_form', _PS_THEME_DIR_ . 'modules/tdpsblog/form.tpl'); } else { $smarty->assign('comments_form', _PS_MODULE_DIR_ . 'tdpsblog/views/templates/front/form.tpl'); } if (file_exists(_PS_THEME_DIR_ . 'modules/tdpsblog/comments.tpl')) { $smarty->assign('comments_tmp', _PS_THEME_DIR_ . 'modules/tdpsblog/comments.tpl'); } else {
public static function getPostCategory($parent = 0) { $context = Context::getContext(); $id_shop = $context->shop->id; $id_lang = $context->language->id; $results = Db::getInstance()->ExecuteS(' SELECT ctd.`id_tdpsblog_category`, ctd.`category_parent`, ctd.`active`, ctd.`id_shop`, ctd1.`category_name`, ctd1.`id_lang`, ctd1.`cat_rewrite` FROM `' . _DB_PREFIX_ . 'tdpsblog_category` ctd INNER JOIN `' . _DB_PREFIX_ . 'tdpsblog_category_lang` ctd1 ON (ctd.`id_tdpsblog_category` = ctd1.`id_tdpsblog_category`) WHERE ctd1.`id_lang` = ' . (int) $context->language->id . ' AND ctd.active = 1 ' . 'AND ctd.category_parent =' . (int) $parent . ' ORDER BY ctd.id_tdpsblog_category ASC'); foreach ($results as $result) { $sub_cat = tdpsblogModel::getPostCategory($result['id_tdpsblog_category']); if ($sub_cat && count($sub_cat) > 0) { $result['sub_category'] = $sub_cat; } $tdpspostcategory[] = $result; } return isset($tdpspostcategory) ? $tdpspostcategory : false; }