function nvweb_comments($vars = array()) { global $website; global $DB; global $current; global $webgets; global $dictionary; global $webuser; global $theme; global $events; global $session; $webget = 'comments'; if (!isset($webgets[$webget])) { $webgets[$webget] = array(); global $lang; if (empty($lang)) { $lang = new language(); $lang->load($current['lang']); } // default translations $webgets[$webget]['translations'] = array('post_a_comment' => t(379, 'Post a comment'), 'name' => t(159, 'Name'), 'email' => t(44, 'E-Mail'), 'website' => t(177, 'Website'), 'message' => t(380, 'Message'), 'email_will_not_be_published' => t(381, 'E-Mail will not be published'), 'submit' => t(382, 'Submit'), 'sign_in_or_sign_up_to_post_a_comment' => t(383, 'Sign in or Sign up to post a comment'), 'comments_on_this_entry_are_closed' => t(384, 'Comments on this entry are closed'), 'please_dont_leave_any_field_blank' => t(385, 'Please don\'t leave any field blank'), 'your_comment_has_been_received_and_will_be_published_shortly' => t(386, 'Your comment has been received and will be published shortly'), 'new_comment' => t(387, 'New comment'), 'review_comments' => t(388, 'Review comments')); // theme translations // if the web theme has custom translations for this string subtypes, use it (for the user selected language) /* just add the following translations to your json theme dictionary: "post_a_comment": "Post a comment", "name": "Name", "email": "E-Mail", "website": "Website", "message": "Message", "email_will_not_be_published": "E-Mail will not be published", "submit": "Submit", "sign_in_or_sign_up_to_post_a_comment": "Sign in or Sign up to post a comment", "comments_on_this_entry_are_closed": "Comments on this entry are closed", "please_dont_leave_any_field_blank": "Please don't leave any field blank", "your_comment_has_been_received_and_will_be_published_shortly": "Your comment has been received and will be published shortly", "new_comment": "New comment", "review_comments": "Review comments" */ if (!empty($website->theme) && method_exists($theme, 't')) { foreach ($webgets[$webget]['translations'] as $code => $text) { $theme_translation = $theme->t($code); if (!empty($theme_translation) && $theme_translation != $code) { $webgets[$webget]['translations'][$code] = $theme_translation; } } } } // set default callback if (empty($vars['callback'])) { $vars['callback'] = 'alert'; } // check callback attributes $callback = $vars['callback']; if (!empty($vars['alert_callback'])) { $callback = $vars['alert_callback']; } else { if (!empty($vars['callback_alert'])) { $callback = $vars['callback_alert']; } } $callback_error = $callback; if (!empty($vars['error_callback'])) { $callback_error = $vars['error_callback']; } else { if (!empty($vars['callback_error'])) { $callback_error = $vars['callback_error']; } } $out = ''; // if the current page belongs to a structure entry // we need to get the associated elements to retrieve and post its comments // (because structure entry pages can't have associated comments) // so, ONLY the FIRST element associated to a category can have comments in a structure entry page // (of course if the element has its own page, it can have its own comments) $element = $current['object']; if ($current['type'] == 'structure') { if (empty($current['structure_elements'])) { $current['structure_elements'] = $element->elements(); } $element = $current['structure_elements'][0]; } switch (@$vars['mode']) { case 'process': if (isset($_GET['nv_approve_comment'])) { // process 1-click comment approval $comment = new comment(); $comment->load($_GET['id']); if (!empty($comment->id) && $comment->status == -1) { $hash = $_GET['hash']; if ($hash == sha1($comment->id . $comment->email . APP_UNIQUE . serialize($website->contact_emails))) { // hash check passed $comment->status = 0; $comment->save(); $response = t(555, "Item has been successfully published."); if ($vars['notify'] == 'inline' || $callback == 'inline') { $out = '<div class="comment-success">' . $response . '</div>'; } else { if (!isset($vars['notify']) || $vars['notify'] == 'callback') { nvweb_after_body("js", $callback . '("' . $response . '");'); } } } else { $response = t(344, "Security error"); if ($vars['notify'] == 'inline' || $callback_error == 'inline') { $out = '<div class="comment-error">' . $response . '</div>'; } else { if (!isset($vars['notify']) || $vars['notify'] == 'callback') { nvweb_after_body("js", $callback_error . '("' . $response . '");'); } } } } else { $response = t(56, "Unexpected error"); if ($vars['notify'] == 'inline' || $callback_error == 'inline') { $out = '<div class="comment-error">' . $response . '</div>'; } else { if (!isset($vars['notify']) || $vars['notify'] == 'callback') { nvweb_after_body("js", $callback_error . '("' . $response . '");'); } } } } if (isset($_GET['nv_remove_comment'])) { // process 1-click comment removal $comment = new comment(); $comment->load($_GET['id']); if (!empty($comment->id) && $comment->status == -1) { $hash = $_GET['hash']; if ($hash == sha1($comment->id . $comment->email . APP_UNIQUE . serialize($website->contact_emails))) { // hash check passed $comment->delete(); $response = t(55, "Item successfully deleted"); if ($vars['notify'] == 'inline' || $callback == 'inline') { $out = '<div class="comment-success">' . $response . '</div>'; } else { if (!isset($vars['notify']) || $vars['notify'] == 'callback') { nvweb_after_body("js", $callback . '("' . $response . '");'); } } } else { $response = t(344, "Security error"); if ($vars['notify'] == 'inline' || $callback_error == 'inline') { $out = '<div class="comment-error">' . $response . '</div>'; } else { if (!isset($vars['notify']) || $vars['notify'] == 'callback') { nvweb_after_body("js", $callback_error . '("' . $response . '");'); } } } } else { $response = t(56, "Unexpected error"); if ($vars['notify'] == 'inline' || $callback_error == 'inline') { $out = '<div class="comment-error">' . $response . '</div>'; } else { if (!isset($vars['notify']) || $vars['notify'] == 'callback') { nvweb_after_body("js", $callback_error . '("' . $response . '");'); } } } } if ($_REQUEST['form-type'] == 'comment-reply' || isset($_POST[$vars['field-message']])) { // add comment if (empty($vars['field-name'])) { $vars['field-name'] = 'reply-name'; } if (empty($vars['field-email'])) { $vars['field-email'] = 'reply-email'; } if (empty($vars['field-url'])) { $vars['field-url'] = 'reply-url'; } if (empty($vars['field-message'])) { $vars['field-message'] = 'reply-message'; } if (!empty($vars['element'])) { $element = $vars['element']; } $comment_name = @$_REQUEST[$vars['field-name']]; $comment_email = @$_REQUEST[$vars['field-email']]; $comment_url = @$_REQUEST[$vars['field-url']]; $comment_message = @$_REQUEST[$vars['field-message']]; if ((empty($comment_name) || empty($comment_email)) && empty($webuser->id) || empty($comment_message)) { $response = $webgets[$webget]['translations']['please_dont_leave_any_field_blank']; if ($vars['notify'] == 'inline' || $callback_error == 'inline') { $out = '<div class="comment-error">' . $response . '</div>'; } else { if (!isset($vars['notify']) || $vars['notify'] == 'callback') { nvweb_after_body("js", $callback_error . '("' . $response . '");'); } } return $out; } $status = -1; // new comment, not approved if (empty($element->comments_moderator)) { $status = 0; } // all comments auto-approved // remove any <nv /> or {{nv}} tag $comment_name = core_remove_nvtags($comment_name); $comment_name = strip_tags($comment_name); $comment_message = core_remove_nvtags($comment_message); $comment = new comment(); $comment->id = 0; $comment->website = $website->id; $comment->item = $element->id; $comment->user = empty($webuser->id) ? 0 : $webuser->id; $comment->name = $comment_name; $comment->email = filter_var($comment_email, FILTER_SANITIZE_EMAIL); $comment->url = filter_var($comment_url, FILTER_SANITIZE_URL); $comment->ip = core_ip(); $comment->date_created = core_time(); $comment->date_modified = 0; $comment->status = $status; $comment->message = $comment_message; $properties = array(); // check if there are comment properties values if (isset($vars['field-properties-prefix'])) { // check every possible property $e_properties = property::elements($element->template, 'comment'); for ($ep = 0; $ep < count($e_properties); $ep++) { if (isset($_POST[$vars['field-properties-prefix'] . $e_properties[$ep]->id])) { $properties[$e_properties[$ep]->id] = $_POST[$vars['field-properties-prefix'] . $e_properties[$ep]->id]; } } } // trigger the "new_comment" event through the extensions system before inserting it! $extensions_messages = $events->trigger('comment', 'before_insert', array('comment' => $comment, 'properties' => $properties)); foreach ($extensions_messages as $ext_name => $ext_result) { if (isset($ext_result['error'])) { $response = $ext_result['error']; if ($vars['notify'] == 'inline' || $callback_error == 'inline') { $out = '<div class="comment-error">' . $response . '</div>'; } else { if (!isset($vars['notify']) || $vars['notify'] == 'callback') { nvweb_after_body("js", $callback_error . '("' . $response . '");'); } } return $out; } } $comment->insert(); if (!empty($properties)) { property::save_properties_from_array('comment', $comment->id, $element->template, $properties); } // reload the element to retrieve the new comments $element = new item(); $element->load($comment->item); if ($current['type'] == 'item' && !isset($vars['element'])) { $current['object'] = $element; } // trigger the "new_comment" event through the extensions system $events->trigger('comment', 'after_insert', array('comment' => &$comment, 'properties' => $properties)); if (!empty($comment->id)) { if ($status == -1) { $response = $webgets[$webget]['translations']['your_comment_has_been_received_and_will_be_published_shortly']; if ($vars['notify'] == 'inline' || $callback_error == 'inline') { $out = '<div class="comment-success">' . $response . '</div>'; } else { if (!isset($vars['notify']) || $vars['notify'] == 'callback') { nvweb_after_body("js", $callback . '("' . $response . '");'); } } } else { $response = $webgets[$webget]['translations']['your_comment_has_been_received_and_will_be_published_shortly']; if ($vars['notify'] == 'inline' || $callback_error == 'inline') { $out = '<div class="comment-success">' . $response . '</div>'; } else { if (!isset($vars['notify']) || $vars['notify'] == 'callback') { nvweb_after_body("js", $callback . '("' . $response . '");'); } } } } $notify_addresses = $website->contact_emails; if (!empty($element->comments_moderator)) { $notify_addresses[] = user::email_of($element->comments_moderator); } $hash = sha1($comment->id . $comment->email . APP_UNIQUE . serialize($website->contact_emails)); $base_url = nvweb_source_url('element', $element->id); // default colors $background_color = '#E5F1FF'; $text_color = '#595959'; $title_color = '#595959'; $background_color_db = $DB->query_single('value', 'nv_permissions', 'name = ' . protect("nvweb.comments.background_color") . ' AND website = ' . protect($website->id), 'id DESC'); $text_color_db = $DB->query_single('value', 'nv_permissions', 'name = ' . protect("nvweb.comments.text_color") . ' AND website = ' . protect($website->id), 'id DESC'); $title_color_db = $DB->query_single('value', 'nv_permissions', 'name = ' . protect("nvweb.comments.titles_color") . ' AND website = ' . protect($website->id), 'id DESC'); if (!empty($background_color_db)) { $background_color = str_replace('"', '', $background_color_db); } if (!empty($text_color_db)) { $text_color = str_replace('"', '', $text_color_db); } if (!empty($title_color_db)) { $title_color = str_replace('"', '', $title_color_db); } $message = navigate_compose_email(array(array('title' => t(9, 'Content'), 'content' => $element->dictionary[$current['lang']]['title']), array('title' => $webgets[$webget]['translations']['name'], 'content' => $comment_name . @$webuser->username), array('title' => $webgets[$webget]['translations']['email'], 'content' => $comment_email . @$webuser->email), array('title' => $webgets[$webget]['translations']['website'], 'content' => $comment_url . @$webuser->social_website), array('title' => $webgets[$webget]['translations']['message'], 'content' => nl2br($comment_message)), array('footer' => '<a href="' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?wid=' . $website->id . '&fid=10&act=2&tab=5&id=' . $element->id . '"><strong>' . $webgets[$webget]['translations']['review_comments'] . '</strong></a>' . ' | ' . '<a style=" color: #008830" href="' . $base_url . '?nv_approve_comment&id=' . $comment->id . '&hash=' . $hash . '">' . t(258, "Publish") . '</a>' . ' | ' . '<a style=" color: #FF0090" href="' . $base_url . '?nv_remove_comment&id=' . $comment->id . '&hash=' . $hash . '">' . t(525, "Remove comment (without confirmation)") . '</a>')), array('background' => $background_color, 'title-color' => $title_color, 'content-color' => $text_color)); // trying to implement One-Click actions (used in Google GMail) // You need to be registered with Google first: https://developers.google.com/gmail/markup/registering-with-google $one_click_actions = ' <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "name": "' . $webgets[$webget]['translations']['review_comments'] . '", "url": "' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?wid=' . $website->id . '&fid=10&act=2&tab=5&id=' . $element->id . '" } } </script> '; $message = '<html><head>' . $one_click_actions . '</head><body>' . $message . '</body></html>'; foreach ($website->contact_emails as $contact_address) { @nvweb_send_email($website->name . ' | ' . $webgets[$webget]['translations']['new_comment'], $message, $contact_address, null, true); } } break; case 'reply': if ($element->comments_enabled_to == 2 && empty($webuser->id)) { // Post a comment form (unsigned users) $out = ' <div class="comments-reply"> <div><div class="comments-reply-info">' . $webgets[$webget]['translations']['post_a_comment'] . '</div></div> <br /> <form action="' . NVWEB_ABSOLUTE . '/' . $current['route'] . '" method="post"> <input type="hidden" name="form-type" value="comment-reply" /> <div class="comments-reply-field"><label>' . $webgets[$webget]['translations']['name'] . '</label> <input type="text" name="reply-name" value="" /></div> <div class="comments-reply-field"><label>' . $webgets[$webget]['translations']['email'] . ' *</label> <input type="text" name="reply-email" value="" /></div> <div class="comments-reply-field"><label>' . $webgets[$webget]['translations']['message'] . '</label> <textarea name="reply-message"></textarea></div> <!-- {{navigate-comments-reply-extra-fields-placeholder}} --> <div class="comments-reply-field comments-reply-field-info-email"><label> </label> * ' . $webgets[$webget]['translations']['email_will_not_be_published'] . '</div> <div class="comments-reply-field comments-reply-field-submit"><input class="comments-reply-submit" type="submit" value="' . $webgets[$webget]['translations']['submit'] . '" /></div> </form> </div> '; $extensions_messages = $events->trigger('comment', 'reply_extra_fields', array('html' => &$out)); // add any extra field generated if (!empty($extensions_messages)) { $extra_fields = array_map(function ($v) { return $v; }, array_values($extensions_messages)); $out = str_replace('<!-- {{navigate-comments-reply-extra-fields-placeholder}} -->', implode("\n", $extra_fields), $out); } } else { if ($element->comments_enabled_to > 0 && !empty($webuser->id)) { // Post a comment form (signed in users) if (empty($vars['avatar_size'])) { $vars['avatar_size'] = 32; } $avatar_url = NVWEB_OBJECT . '?type=blank'; if (!empty($webuser->avatar)) { $avatar_url = NVWEB_OBJECT . '?wid=' . $website->id . '&id=' . $webuser->avatar . '&disposition=inline&width=' . $vars['avatar_size'] . '&height=' . $vars['avatar_size']; } $out = ' <div class="comments-reply"> <div><div class="comments-reply-info">' . $webgets[$webget]['translations']['post_a_comment'] . '</div></div> <br /> <form action="' . NVWEB_ABSOLUTE . '/' . $current['route'] . '" method="post"> <input type="hidden" name="form-type" value="comment-reply" /> <div class="comments-reply-field"><label style="display: none;"> </label> <img src="' . $avatar_url . '" width="' . $vars['avatar_size'] . '" height="' . $vars['avatar_size'] . '" align="absmiddle" /> <span class="comments-reply-username">' . $webuser->username . '</span><a class="comments-reply-signout" href="?webuser_signout">(x)</a></div> <br /> <div class="comments-reply-field"><label>' . $webgets[$webget]['translations']['message'] . '</label> <textarea name="reply-message"></textarea></div> <!-- {{navigate-comments-reply-extra-fields-placeholder}} --> <div class="comments-reply-field-submit"><input class="comments-reply-submit" type="submit" value="' . $webgets[$webget]['translations']['submit'] . '" /></div> </form> </div> '; $extensions_messages = $events->trigger('comment', 'reply_extra_fields', array('html' => $out)); // add any extra field generated if (!empty($extensions_messages)) { $extra_fields = array_map(function ($v) { return $v; }, array_values($extensions_messages)); $out = str_replace('<!-- {{navigate-comments-reply-extra-fields-placeholder}} -->', implode("\n", $extra_fields), $out); } } else { if ($element->comments_enabled_to == 1) { $out = '<div class="comments-reply"> <div class="comments-reply-info">' . $webgets[$webget]['translations']['sign_in_or_sign_up_to_post_a_comment'] . '</div> </div>'; } else { $out = '<div class="comments-reply"> <div class="comments-reply-info">' . $webgets[$webget]['translations']['comments_on_this_entry_are_closed'] . '</div> </div>'; } } } break; case 'comments': setlocale(LC_ALL, $website->languages[$session['lang']]['system_locale']); list($comments, $comments_total) = nvweb_comments_list(0, NULL, NULL, $vars['order']); // get all comments of the current entry if (empty($vars['avatar_size'])) { $vars['avatar_size'] = '48'; } if (empty($vars['date_format'])) { $vars['date_format'] = '%d %B %Y %H:%M'; } for ($c = 0; $c < $comments_total; $c++) { $avatar = $comments[$c]->avatar; if (!empty($avatar)) { $avatar = '<img src="' . NVWEB_OBJECT . '?type=image&id=' . $avatar . '" width="' . $vars['avatar_size'] . 'px" height="' . $vars['avatar_size'] . 'px"/>'; } else { $avatar = '<img src="data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" width="' . $vars['avatar_size'] . 'px" height="' . $vars['avatar_size'] . 'px"/>'; } $comment = new comment(); $comment->load_from_resultset(array($comments[$c])); $depth = 'data-depth="' . $comment->depth() . '"'; $out .= ' <div class="comment"' . $depth . '> <div class="comment-avatar">' . $avatar . '</div> <div class="comment-username">' . (!empty($comments[$c]->username) ? $comments[$c]->username : $comments[$c]->name) . '</div> <div class="comment-date">' . Encoding::toUTF8(strftime($vars['date_format'], $comments[$c]->date_created)) . '</div> <div class="comment-message">' . nl2br($comments[$c]->message) . '</div> <div style="clear:both"></div> </div> '; } break; } return $out; }
public static function export_sample($a_categories, $a_items, $a_block_groups, $a_blocks, $a_comments, $folder) { global $website; global $theme; global $DB; @set_time_limit(0); $categories = array(); $items = array(); $blocks = array(); $block_groups = array(); $comments = array(); $properties = array(); $files = array(); $settings = array(); // structure for ($c = 0; $c < count($a_categories); $c++) { $tmp = new structure(); $tmp->load($a_categories[$c]); //$properties['structure'][$tmp->id] = property::load_properties_associative('structure', $tmp->template, 'structure', $tmp->id); $properties['structure'][$tmp->id] = property::load_properties('structure', $tmp->template, 'structure', $tmp->id); $categories[$tmp->id] = $tmp; // add files referenced in properties if (is_array($properties['structure'][$tmp->id])) { foreach ($properties['structure'][$tmp->id] as $property) { if ($property->type == 'image' || $property->type == 'file') { $files[] = $property->value; } } } } // comments for ($c = 0; $c < count($a_comments); $c++) { $tmp = new comment(); $tmp->load($a_comments[$c]); $comments[$tmp->id] = $tmp; } // items for ($i = 0; $i < count($a_items); $i++) { $tmp = new item(); $tmp->load($a_items[$i]); $template_id = $tmp->template; if ($tmp->association != "free" && $tmp->embedding == 1) { // we have to get the template set in the category of the item $template_id = $DB->query_single('template', 'nv_structure', ' id = ' . protect($tmp->category) . ' AND website = ' . $website->id); } $properties['item'][$tmp->id] = property::load_properties('item', $template_id, 'item', $tmp->id); list($tmp->dictionary, $files) = theme::export_sample_parse_dictionary($tmp->dictionary, $files); // add files referenced in properties if (is_array($properties['item'][$tmp->id])) { foreach ($properties['item'][$tmp->id] as $property) { if ($property->type == 'image' || $property->type == 'file') { $files[] = $property->value; } } } // add files referenced in gallery if (is_array($tmp->galleries[0])) { $gallery_images = array_keys($tmp->galleries[0]); $files = array_merge($files, $gallery_images); } $items[$tmp->id] = $tmp; } // block_groups for ($i = 0; $i < count($a_block_groups); $i++) { $tmp = new block_group(); $tmp->load($a_block_groups[$i]); $block_groups[$tmp->id] = $tmp; if (is_array($tmp->blocks)) { foreach ($tmp->blocks as $bgb) { if ($bgb['type'] == 'block_group_block') { $properties['block_group_block'][$a_block_groups[$i]][$bgb['uid']] = property::load_properties($bgb['id'], $tmp->code, 'block_group_block', $bgb['id'], $bgb['uid']); } else { if ($bgb['type'] == 'extension') { $properties['block_group_block'][$a_block_groups[$i]][$bgb['uid']] = property::load_properties(NULL, $bgb['id'], "extension_block", NULL, $bgb['uid']); } } } } // note: maybe not all blocks in the group have been selected in the "blocks" tab // here we only export the block group definition, the block group blocks properties and the extension blocks properties, not adding anything else to export } // blocks for ($i = 0; $i < count($a_blocks); $i++) { $tmp = new block(); $tmp->load($a_blocks[$i]); $properties['block'][$tmp->id] = property::load_properties('block', $tmp->type, 'block', $tmp->id); list($tmp->dictionary, $files) = theme::export_sample_parse_dictionary($tmp->dictionary, $files); list($tmp->trigger['trigger-content'], $files) = theme::export_sample_parse_array($tmp->trigger['trigger-content'], $files); list($tmp->trigger['trigger-html'], $files) = theme::export_sample_parse_array($tmp->trigger['trigger-html'], $files); if (!empty($tmp->trigger['trigger-image'])) { $files = array_merge($files, array_values($tmp->trigger['trigger-image'])); } if (!empty($tmp->trigger['trigger-rollover'])) { $files = array_merge($files, array_values($tmp->trigger['trigger-rollover'])); } if (!empty($tmp->trigger['trigger-rollover-active'])) { $files = array_merge($files, array_values($tmp->trigger['trigger-rollover-active'])); } if (!empty($tmp->trigger['trigger-flash'])) { $files = array_merge($files, array_values($tmp->trigger['trigger-flash'])); } if (!empty($tmp->action['action-image'])) { $files = array_merge($files, array_values($tmp->action['action-image'])); } if (!empty($tmp->action['action-file'])) { $files = array_merge($files, array_values($tmp->action['action-file'])); } // add files referenced in properties if (is_array($properties['block'][$tmp->id])) { foreach ($properties['block'][$tmp->id] as $property) { if ($property->type == 'image' || $property->type == 'file') { $files[] = $property->value; } } } $blocks[$tmp->id] = $tmp; } // folders // save references and get their files list $folders = array(); $folders_to_check = array(); if (!empty($folder)) { array_push($folders_to_check, $folder); while (!empty($folders_to_check)) { $f = array_shift($folders_to_check); $f = file::filesOnPath($f); foreach ($f as $file) { if ($file->type == 'folder') { array_push($folders_to_check, $file->id); array_push($folders, $file); } else { $files[] = $file->id; } } } } // add files selected as theme_options foreach ($theme->options as $to) { if ($to->type == 'image' || $to->type == 'file') { $to_value = $website->theme_options->{$to->id}; if (is_array($to_value)) { $files = array_merge($files, $to_value); } else { $files[] = $to_value; } } } // include favicon in file list if (!empty($website->favicon)) { $files[] = $website->favicon; } // files $files = array_unique($files); for ($f = 0; $f < count($files); $f++) { $file = new file(); $file->load($files[$f]); $files[$f] = $file; } // settings $settings['homepage'] = $website->homepage; $settings['favicon'] = $website->favicon; $zip = new zipfile(); $zip->addFile(var_export($website->languages, true), 'languages.var_export'); $zip->addFile(var_export($website->theme_options, true), 'theme_options.var_export'); $zip->addFile(var_export($categories, true), 'structure.var_export'); $zip->addFile(var_export($items, true), 'items.var_export'); $zip->addFile(var_export($block_groups, true), 'block_groups.var_export'); $zip->addFile(var_export($blocks, true), 'blocks.var_export'); $zip->addFile(var_export($comments, true), 'comments.var_export'); $zip->addFile(var_export($files, true), 'files.var_export'); $zip->addFile(var_export($folders, true), 'folders.var_export'); $zip->addFile(var_export($properties, true), 'properties.var_export'); $zip->addFile(var_export($settings, true), 'settings.var_export'); foreach ($files as $file) { $zip->addFile(file_get_contents($file->absolute_path()), 'files/' . $file->id); } $contents = $zip->file(); header('Content-Disposition: attachment; filename="' . $website->theme . '_sample.zip"'); header("Content-type: application/octet-stream"); header('Content-Length: ' . strlen($contents)); echo $contents; }
function comments_form($item) { global $DB; global $website; global $layout; global $events; global $theme; $navibars = new navibars(); $naviforms = new naviforms(); if (empty($item->id)) { $navibars->title(t(250, 'Comments') . ' / ' . t(38, 'Create')); } else { $navibars->title(t(250, 'Comments') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']'); } if (empty($item->id)) { $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>')); } else { $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>', '<a href="#" onclick="navigate_delete_dialog();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"> ' . t(35, 'Delete') . '</a>')); $delete_html = array(); $delete_html[] = '<div id="navigate-delete-dialog" class="hidden">' . t(57, 'Do you really want to delete this item?') . '</div>'; $delete_html[] = '<script language="javascript" type="text/javascript">'; $delete_html[] = 'function navigate_delete_dialog()'; $delete_html[] = '{'; $delete_html[] = '$("#navigate-delete-dialog").removeClass("hidden");'; $delete_html[] = '$("#navigate-delete-dialog").dialog({ resizable: true, height: 150, width: 300, modal: true, title: "' . t(59, 'Confirmation') . '", buttons: { "' . t(35, 'Delete') . '": function() { $(this).dialog("close"); window.location.href = "?fid=' . $_REQUEST['fid'] . '&act=remove&id=' . $item->id . '"; }, "' . t(58, 'Cancel') . '": function() { $(this).dialog("close"); } } });'; $delete_html[] = '}'; $delete_html[] = '</script>'; $navibars->add_content(implode("\n", $delete_html)); } $navibars->add_actions(array(!empty($item->id) ? '<a href="?fid=comments&act=edit"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=comments&act=0"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>', 'search_form')); $navibars->form(); $navibars->add_tab(t(43, "Main")); $navibars->add_tab_content($naviforms->hidden('form-sent', 'true')); $navibars->add_tab_content($naviforms->hidden('id', $item->id)); $navibars->add_tab_content_row(array('<label>ID</label>', '<span>' . (!empty($item->id) ? $item->id : t(52, '(new)')) . '</span>')); $navibars->add_tab_content($naviforms->hidden('comment-item', $item->item)); if ($item->item > 0) { $content = new item(); $content->load($item->item); $title = $content->dictionary[$website->languages_list[0]]['title']; } $navibars->add_tab_content_row(array('<label>' . t(180, 'Item') . '</label>', $naviforms->textfield('comment-item-text', $title))); $layout->add_script(' $("#comment-item-text").autocomplete( { source: function(request, response) { var toFind = { "title": request.term, "lang": "' . $website->languages[0] . '", nd: new Date().getTime() }; $.ajax( { url: "' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=' . $_REQUEST['fid'] . '&act=91", dataType: "json", method: "GET", data: toFind, success: function( data ) { response( data ); } }); }, minLength: 1, select: function(event, ui) { $("#comment-item").val(ui.item.id); } }); '); $webuser_id = ''; if (!empty($item->user)) { $webuser_username = $DB->query_single('username', 'nv_webusers', ' id = ' . $item->user); if (!empty($webuser_username)) { $webuser_username = array($webuser_username); $webuser_id = array($item->user); } } $navibars->add_tab_content_row(array('<label>' . t(1, 'User') . '</label>', $naviforms->selectfield('comment-user', $webuser_id, $webuser_username, $item->user, null, false, null, null, false), '<span style="display: none;" id="comment-user-helper">' . t(535, "Find user by name") . '</span>')); $layout->add_script(' $("#comment-user").select2( { placeholder: $("#comment-user-helper").text(), minimumInputLength: 1, ajax: { url: "' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=' . $_REQUEST['fid'] . '" + "&act=json_find_webuser", dataType: "json", delay: 100, data: function (params) { return { username: params.term, nd: new Date().getTime(), page_limit: 30, // page size page: params.page // page number }; }, processResults: function (data, params) { params.page = params.page || 1; return { results: data.items, pagination: { more: (params.page * 30) < data.total_count } }; } }, templateSelection: function(row) { if(row.id) return row.text + " <helper style=\'opacity: .5;\'>#" + row.id + "</helper>"; else return row.text; }, escapeMarkup: function (markup) { return markup; }, triggerChange: true, allowClear: true }); '); $navibars->add_tab_content_row(array('<label>' . t(159, 'Name') . '</label>', $naviforms->textfield('comment-name', $item->name))); $navibars->add_tab_content_row(array('<label>' . t(44, 'E-Mail') . '</label>', $naviforms->textfield('comment-email', $item->email))); $navibars->add_tab_content_row(array('<label>' . t(177, 'Website') . '</label>', $naviforms->textfield('comment-url', $item->url))); $reply_to_comment = ''; if (empty($item->reply_to)) { $item->reply_to = ''; } else { $c = new comment(); $c->load($item->reply_to); $reply_to_comment = $c->author_name() . ' ' . core_ts2date($c->date_created, true); } $navibars->add_tab_content_row(array('<label>' . t(649, 'In reply to') . '</label>', $naviforms->selectfield('comment-reply_to', $item->reply_to, array($reply_to_comment), $item->reply_to, null, false, null, null, false))); $layout->add_script(' $("#comment-reply_to").select2( { placeholder: "", minimumInputLength: 1, ajax: { url: "' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=comments&act=json_find_comment", dataType: "json", delay: 100, data: function (params) { return { search: params.term, node_id: $("#comment-item").val(), maxdate: ' . ($item->date_created + 0) . ', exclude: ' . ($item->id + 0) . ', nd: new Date().getTime(), page_limit: 30, // page size page: params.page // page number }; }, processResults: function (data, params) { params.page = params.page || 1; return { results: data.items, pagination: { more: (params.page * 30) < data.total_count } }; } }, templateSelection: function(row) { if(row.id) return row.text + " <helper style=\'opacity: .5;\'>#" + row.id + "</helper>"; else return row.text; }, escapeMarkup: function (markup) { return markup; }, triggerChange: true, allowClear: true }); '); $navibars->add_tab_content_row(array('<label>' . t(54, 'Text') . '</label>', $naviforms->textarea('comment-message', $item->message, 10))); if (!empty($item->ip)) { $navibars->add_tab_content_row(array('<label>IP</label>', $item->ip)); } if (empty($item->date_created)) { $item->date_created = time(); } $navibars->add_tab_content_row(array('<label>' . t(226, 'Date created') . '</label>', $naviforms->datefield('comment-date_created', $item->date_created, true))); if ($item->date_modified > 0) { $navibars->add_tab_content_row(array('<label>' . t(227, 'Date modified') . '</label>', core_ts2date($item->date_modified, true), empty($item->last_modified_by) ? '' : '(' . user::username_of($item->last_modified_by) . ')')); } $navibars->add_tab_content_row(array('<label>' . t(68, 'Status') . '</label>', $naviforms->selectfield('comment-status', array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => -1), array(0 => t(64, 'Published'), 1 => t(251, 'Private'), 2 => t(181, 'Hidden'), 3 => t(466, 'Spam'), 4 => t(257, 'To review')), $item->status, '', false, array(0 => t(360, 'Visible to everybody'), 1 => t(359, 'Visible only to Navigate CMS users'), 2 => t(358, 'Hidden to everybody'), 3 => t(358, 'Hidden to everybody'), 4 => t(358, 'Hidden to everybody'))))); if (!empty($item->item)) { $element = new item(); $element->load($item->item); $template = $theme->templates($element->template); if (is_object($template->comments) && isset($template->comments->properties)) { $properties_html = navigate_property_layout_form('comment', $element->template, 'comment', $item->id); if (!empty($properties_html)) { $navibars->add_tab(t(77, "Properties")); $navibars->add_tab_content($properties_html); } } } $events->trigger('comment', 'edit', array('comment' => &$item, 'navibars' => &$navibars, 'naviforms' => &$naviforms)); return $navibars->generate(); }