function uihelper_generate_center_content_permalink($cid, $show = 0) { global $app; $image_media_gallery = FALSE; $back_page = PA::$url . $app->current_route; $content = CNContent::load_content((int) $cid, (int) PA::$login_uid); // filter content fields for output $content->title = _out($content->title); $content->body = _out($content->body); if (strstr($back_page, PA_ROUTE_CONTENT) || strstr($back_page, PA_ROUTE_PERMALINK)) { if ($content->parent_collection_id > 0) { $collection = ContentCollection::load_collection((int) $content->parent_collection_id, PA::$login_uid); if ($collection->type == GROUP_COLLECTION_TYPE) { $back_page = PA::$url . PA_ROUTE_GROUP . "/gid=" . $content->parent_collection_id; } else { $back_page = PA::$url . PA_ROUTE_MEDIA_GALLEY_IMAGES . "/uid=" . $content->author_id; } // IF permalink content is a group content redirect to group homepage } else { //if coming from permalink page then redirect to user page $back_page = PA::$url . PA_ROUTE_USER_PRIVATE; } } $moderateduser = Group::is_admin((int) $content->parent_collection_id, (int) PA::$login_uid) ? 1 : 0; $back_page = urlencode($back_page); if (!$content->is_html) { $content->body = nl2br($content->body); } $media_gallery_content = NULL; $media_gallery_content = in_array(trim($content->type), array('Image', 'Audio', 'Video')); $editable = PA::$login_uid == $content->author_id || $moderateduser; $comments = Comment::get_comment_for_content($cid, '', 'ASC'); $number_of_comments = count($comments); $content->no_of_comments = $number_of_comments; $trackback = CNContent::get_trackbacks_for_content($cid); $number_of_trackbacks = count($trackback); $content->no_of_trackbacks = $number_of_trackbacks; $content->trackback_url = PA::$url . "/pa_trackback.php?cid=" . $cid; $content_user = new User(); $content_user->load((int) $content->author_id); $content->create_time = PA::date($content->changed, 'long'); // date("l, F d, Y", $content->changed); $tags = Tag::load_tags_for_content($cid); if ($tags) { $t = array(); for ($i = 0; $i < count($tags); $i++) { $name = _out($tags[$i]['name']); $uid = PA::$login_uid; $url = PA::$url . '/' . FILE_TAG_SEARCH . '?name_string=content_tag&keyword=' . $tags[$i]["name"]; $t[] = "<a href={$url}>" . $name . "</a>"; } $tag_string = "<b>Tags : </b>" . implode(", ", $t); } else { $tag_string = ""; } $content->tag_entry = $tag_string; if (property_exists($content, 'sbname')) { if (substr($content->sbname, 0, 5) == 'event') { $content->type = 'SBEvent'; } elseif (substr($content->sbname, 0, 6) == 'review') { $content->type = 'Review'; } elseif (substr($content->sbname, 0, 11) == 'media/audio') { $content->type = 'Audio'; } elseif (substr($content->sbname, 0, 11) == 'media/video') { $content->type = 'Video'; } elseif (substr($content->sbname, 0, 11) == 'media/image') { $content->type = 'Image'; } elseif (substr($content->sbname, 0, 14) == 'showcase/group') { $content->type = 'GroupShowCase'; } elseif (substr($content->sbname, 0, 15) == 'showcase/person') { $content->type = 'PersonShowCase'; } } // replace magic strings $content->replace_percent_strings(PA::$url); $type = $content->type; $type = $type . 'Permalink'; // comments $comments_list_tpl = new Template(CURRENT_THEME_FSPATH . "/cncontent_comments.php"); $comments_list_tpl->set('current_theme_path', PA::$theme_url); $comments_list_tpl->set('comments', $comments); $comments_list_tpl->set('author_id', $content->author_id); // Setting the variable for the abuse form ... $comments_list = $comments_list_tpl->fetch(); //comment form $cnform_comment_tpl = new Template(CURRENT_THEME_FSPATH . "/cnform_comment.php"); $cnform_comment_tpl->set('current_theme_path', PA::$theme_url); if (isset(PA::$login_uid)) { $user = new User(); $user->load((int) PA::$login_uid); $login_name = $user->login_name; $cnform_comment_tpl->set('name', $login_name); $cnform_comment_tpl->set('login_name', $user->login_name); } $cnform_comment_tpl->set('cid', $cid); if ($content->parent_collection_id > 0) { $cnform_comment_tpl->set('ccid', $content->parent_collection_id); } // abuse form $cnform_abuse_tpl = new Template(CURRENT_THEME_FSPATH . "/cnform_abuse.php"); /* Permalink and edit links for content */ if ($content->parent_collection_id != -1) { $perma_link = PA::$url . PA_ROUTE_PERMALINK . "/cid=" . $content->content_id . '&ccid=' . $content->parent_collection_id; } else { $perma_link = PA::$url . PA_ROUTE_PERMALINK . "/cid=" . $content->content_id; } $params = array('permissions' => 'edit_content', 'uid' => PA::$login_uid, 'cid' => $content->content_id); if (PermissionsHandler::can_user(PA::$login_uid, $params)) { if ($media_gallery_content) { $edit_link = PA::$url . '/edit_media.php?cid=' . $content->content_id; } else { $edit_link = PA::$url . "/cncontent_blog.php?cid=" . $content->content_id; } $delete_link = PA::$url . PA_ROUTE_CONTENT . "?action=deleteContent&cid=" . $content->content_id . '&back_page=' . $back_page; // handle Event separately if ($type == "EventPermalink") { $edit_link = PA::$url . '/calendar.php?cid=' . $content->content_id; $delete_link = $edit_link . "&delete=1" . '&back_page=' . $back_page; } } else { $edit_link = $delete_link = NULL; } $user_link = PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $content->author_id; /* Code for Approval and Denial links for a content */ if ($moderateduser && $content->is_active == 2) { $approval_link = PA::$url . PA_ROUTE_PERMALINK . '/cid=' . $content->content_id . '&ccid=' . $content->parent_collection_id . '&apv=1'; $denial_link = PA::$url . PA_ROUTE_PERMALINK . '/cid=' . $content->content_id . '&ccid=' . $content->parent_collection_id . '&dny=1'; } else { $approval_link = $denial_link = NULL; } // Show comments form to logged in users, only if comments enabled. global $comments_disabled; // fix by Z.Hron; if group content - only members of group can comment it $can_user_comment = true; if (isset($_GET['gid']) && isset(PA::$login_uid)) { $can_user_comment = Group::member_exists((int) $_GET['gid'], PA::$login_uid); } if (!$comments_disabled && !empty(PA::$login_uid) && $can_user_comment) { $cnform_comment = $cnform_comment_tpl->fetch(); $cnform_abuse = $cnform_abuse_tpl->fetch(); } else { $cnform_comment = $cnform_abuse = NULL; } if (getShadowedPath(CURRENT_THEME_FSPATH . "/{$type}.php")) { $middle_content = new Template(getShadowedPath(CURRENT_THEME_FSPATH . "/{$type}.php")); $middle_content->set_object('contents', $content); $middle_content->set('editable', $editable); $middle_content->set('picture_name', $content_user->picture); // to set picture name for diplaying in contets $middle_content->set('user_id', $content_user->user_id); $middle_content->set('user_name', $content_user->first_name . ' ' . $content_user->last_name); $middle_content->set('current_theme_path', PA::$theme_url); $middle_content->set('back_page', $back_page); $middle_content->set('comments', $comments_list); $middle_content->set('cnform_comment', $cnform_comment); $middle_content->set('cnform_abuse', $cnform_abuse); $middle_content->set('media_gallery_content', $media_gallery_content); if ($show == 1) { $middle_content->set('show', $show); } $middle_content->set('permalink', $perma_link); $middle_content->set('edit_link', $edit_link); $middle_content->set('approval_link', $approval_link); $middle_content->set('denial_link', $denial_link); $middle_content->set('delete_link', $delete_link); $middle_content->set('user_link', $user_link); $return_content = $middle_content->fetch(); } else { $return_content = '<p>Content does not have a display template.</p><p>Create a ' . $type . '.php file to display this content type.</p>'; } return $return_content; }