function actionGetlinkdata() { $input = array('url' => trim($_REQUEST['url'])); $api = Api_InterfaceAbstract::instance(); $video = $api->callApi('content_video', 'getVideoFromUrl', array($input['url'])); $data = $api->callApi('content_link', 'parsePage', array($input['url'])); if ($video and empty($video['errors'])) { $result = vB5_Template::staticRenderAjax('video_edit', array('video' => $video, 'existing' => 0, 'editMode' => 1, 'title' => $data['title'], 'url' => $input['url'], 'meta' => $data['meta'])); } else { if ($data and empty($data['errors'])) { $result = vB5_Template::staticRenderAjax('link_edit', array('images' => $data['images'], 'title' => $data['title'], 'url' => $input['url'], 'meta' => $data['meta'])); } else { $result = array('template' => array('error' => 'invalid_url'), 'css_links' => array()); } } $this->sendAsJson($result); return; }
public function actionLoadPreview() { $input = array('parentid' => isset($_POST['parentid']) ? intval($_POST['parentid']) : 0, 'channelid' => isset($_POST['channelid']) ? intval($_POST['channelid']) : 0, 'pagedata' => isset($_POST['pagedata']) ? (array) $_POST['pagedata'] : array(), 'conversationtype' => isset($_POST['conversationtype']) ? trim(strval($_POST['conversationtype'])) : '', 'posttags' => isset($_POST['posttags']) ? trim(strval($_POST['posttags'])) : '', 'rawtext' => isset($_POST['rawtext']) ? trim(strval($_POST['rawtext'])) : '', 'filedataid' => isset($_POST['filedataid']) ? (array) $_POST['filedataid'] : array(), 'link' => isset($_POST['link']) ? (array) $_POST['link'] : array(), 'poll' => isset($_POST['poll']) ? (array) $_POST['poll'] : array(), 'video' => isset($_POST['video']) ? (array) $_POST['video'] : array(), 'htmlstate' => isset($_POST['htmlstate']) ? trim(strval($_POST['htmlstate'])) : '', 'disable_bbcode' => isset($_POST['disable_bbcode']) ? intval($_POST['disable_bbcode']) : 0); $results = array(); if ($input['parentid'] < 1) { $results['error'] = 'invalid_parentid'; $this->sendAsJson($results); return; } if (!in_array($input['htmlstate'], array('off', 'on_nl2br', 'on'), true)) { $input['htmlstate'] = 'off'; } // when creating a new content item, channelid == parentid $input['channelid'] = $input['channelid'] == 0 ? $input['parentid'] : $input['channelid']; $templateName = 'display_contenttype_conversationreply_'; $templateName .= ucfirst($input['conversationtype']); $api = Api_InterfaceAbstract::instance(); $channelBbcodes = $api->callApi('content_channel', 'getBbcodeOptions', array($input['channelid'])); // The $node['starter'] and $node['nodeid'] values are just there to differentiate starters and replies $node = array('rawtext' => '', 'userid' => vB5_User::get('userid'), 'authorname' => vB5_User::get('username'), 'tags' => $input['posttags'], 'taglist' => $input['posttags'], 'approved' => true, 'created' => time(), 'avatar' => $api->callApi('user', 'fetchAvatar', array('userid' => vB5_User::get('userid'))), 'parentid' => $input['parentid'], 'starter' => $input['channelid'] == $input['parentid'] ? 0 : $input['parentid'], 'nodeid' => $input['channelid'] == $input['parentid'] ? 0 : 1); if ($input['conversationtype'] == 'gallery') { $node['photopreview'] = array(); foreach ($input['filedataid'] as $filedataid) { $node['photopreview'][] = array('nodeid' => $filedataid, 'htmltitle' => isset($_POST['title_' . $filedataid]) ? vB_String::htmlSpecialCharsUni($_POST['title_' . $filedataid]) : ''); //photo preview is up to 3 photos only if (count($node['photopreview']) == 3) { break; } } $node['photocount'] = count($input['filedataid']); } if ($input['conversationtype'] == 'link') { $node['url_title'] = !empty($input['link']['title']) ? $input['link']['title'] : ''; $node['url'] = !empty($input['link']['url']) ? $input['link']['url'] : ''; $node['meta'] = !empty($input['link']['meta']) ? $input['link']['meta'] : ''; $node['previewImage'] = !empty($input['link']['url_image']) ? $input['link']['url_image'] : ''; } if ($input['conversationtype'] == 'poll') { $node['multiple'] = !empty($input['poll']['mutliple']); $node['options'] = array(); if (!empty($input['poll']['options']) and is_array($input['poll']['options'])) { $optionIndex = 1; foreach ($input['poll']['options'] as $option) { $node['options'][] = array('polloptionid' => $optionIndex, 'title' => $option); $optionIndex++; } } $node['permissions']['canviewthreads'] = 1; //TODO: Fix this!! } if ($input['conversationtype'] == 'video') { $node['url_title'] = !empty($input['video']['title']) ? $input['video']['title'] : ''; $node['url'] = !empty($input['video']['url']) ? $input['video']['url'] : ''; $node['meta'] = !empty($input['video']['meta']) ? $input['video']['meta'] : ''; $node['items'] = !empty($input['video']['items']) ? $input['video']['items'] : ''; } try { $results = vB5_Template::staticRenderAjax($templateName, array('nodeid' => $node['nodeid'], 'conversation' => $node, 'currentConversation' => $node, 'bbcodeOptions' => $channelBbcodes, 'pagingInfo' => array(), 'postIndex' => 0, 'reportActivity' => false, 'showChannelInfo' => false, 'showInlineMod' => false, 'commentsPerPage' => 1, 'view' => 'stream', 'previewMode' => true)); } catch (Exception $e) { if (vB5_Config::instance()->debug) { $results['error'] = 'error_rendering_preview_template ' . (string) $e; } else { $results['error'] = 'error_rendering_preview_template'; } $this->sendAsJson($results); return; } $bbcodeoptions = array('allowhtml' => in_array($input['htmlstate'], array('on', 'on_nl2br'), true), 'allowbbcode' => !$input['disable_bbcode'], 'htmlstate' => $input['htmlstate']); $results = array_merge($results, $this->parseBbCodeForPreview(fetch_censored_text($input['rawtext']), $bbcodeoptions)); $this->sendAsJson($results); }
/** * Renders the admin template for each widget and adds it to the passed widget array. * Handles recursive 'subModules' as well. * * @param array Reference to an array of widgets (this array is modified) * @param array Reference to an array of css links (this array is modified) */ protected function addRenderedWidgetAdminTemplates(array &$widgets, array &$css_links) { foreach ($widgets as $key => $widget) { // add template & css links $template = !empty($widget['admintemplate']) ? $widget['admintemplate'] : 'widget_admin_default'; $rendered = vB5_Template::staticRenderAjax($template, array('widget' => $widget)); $widgets[$key]['rendered_template'] = $rendered['template']; $css_links = array_merge($css_links, $rendered['css_links']); // handle any sub modules if (!empty($widget['subModules']) and is_array($widget['subModules'])) { $this->addRenderedWidgetAdminTemplates($widgets[$key]['subModules'], $css_links); } } }
/** * This renders a template from an ajax call */ protected function callRender() { $routeInfo = explode('/', $_REQUEST['routestring']); if (count($routeInfo) < 3) { throw new vB5_Exception_Api('ajax', 'api', array(), 'invalid_request'); } $params = array_merge($_POST, $_GET); $this->router = new vB5_Frontend_Routing(); $this->router->setRouteInfo(array('action' => 'actionRender', 'arguments' => $params, 'template' => $routeInfo[2], 'queryParameters' => $_GET)); Api_InterfaceAbstract::setLight(); $this->sendAsJson(vB5_Template::staticRenderAjax($routeInfo[2], $params)); }
/** * Fetch Profile Media content. */ public function actionfetchMedia() { $userId = isset($_POST['userid']) ? intval($_POST['userid']) : 0; if ($userId < 1) { return ''; } $perpage = (isset($_POST['perpage']) and intval($_POST['perpage']) > 0) ? intval($_POST['perpage']) : 15; $allowHistory = isset($_POST['allowHistory']) ? intval($_POST['allowHistory']) : 0; $includeJS = isset($_POST['includeJs']) ? (bool) $_POST['includeJs'] : false; $api = Api_InterfaceAbstract::instance(); $userInfo = $api->callApi('user', 'fetchProfileInfo', array($userId)); $templateData = array('userInfo' => $userInfo, 'page' => array('userid' => $userId), 'perpage' => $perpage, 'uploadFrom' => 'profile', 'allowHistory' => $allowHistory); $results = vB5_Template::staticRenderAjax('profile_media', $templateData); $this->sendAsJson($results); }