当前位置: 首页>>代码示例>>PHP>>正文


PHP comment::load方法代码示例

本文整理汇总了PHP中comment::load方法的典型用法代码示例。如果您正苦于以下问题:PHP comment::load方法的具体用法?PHP comment::load怎么用?PHP comment::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在comment的用法示例。


在下文中一共展示了comment::load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: nvweb_comments

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 . '");');
//.........这里部分代码省略.........
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:comments.php

示例2: export_sample

 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']));
//.........这里部分代码省略.........
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:theme.class.php

示例3: comments_form

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(),
//.........这里部分代码省略.........
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:comments.php


注:本文中的comment::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。