Ejemplo n.º 1
0
 /**
  * Register variables in template
  * @param vB5_Template $templater
  * @param array $templateArgs
  */
 protected function registerTemplateVariables($templater, $templateArgs)
 {
     // this is for allowing indexed access to variables
     $templater->register('arg', array_values($templateArgs));
     // also registered named variables
     foreach ($templateArgs as $key => $value) {
         if (is_string($key)) {
             $templater->register($key, $value);
         }
     }
 }
Ejemplo n.º 2
0
 function actionGetvideodata()
 {
     $input = array('url' => trim($_POST['url']));
     $api = Api_InterfaceAbstract::instance();
     $video = $api->callApi('content_video', 'getVideoFromUrl', array($input['url']));
     if ($video) {
         $templater = new vB5_Template('video_edit');
         $templater->register('video', $video);
         $templater->register('existing', 0);
         $templater->register('editMode', 1);
         $results['template'] = $templater->render();
     } else {
         $results['error'] = 'Invalid URL.';
     }
     $this->sendAsJson($results);
     return;
 }
Ejemplo n.º 3
0
 /**
  * Redirects the user back to where they were after logging in
  */
 public static function doLoginRedirect()
 {
     $url = '';
     if (isset($_POST['url']) && $_POST['url']) {
         $url = base64_decode(trim($_POST['url']));
     }
     if ($url) {
         $parse = parse_url($url);
         if (!$parse or empty($parse['scheme']) or $parse['scheme'] != 'http' and $parse['scheme'] != 'https') {
             $url = NULL;
         }
     }
     if (!$url or strpos($url, '/auth/') !== false or strpos($url, '/register') !== false) {
         $url = vB5_Template_Options::instance()->get('options.frontendurl');
     }
     if (isset($_POST['associatefb'])) {
         $joinchar = strpos($url, '?') !== false ? '&' : '?';
         $url = $url . $joinchar . 'dofbredirect=1';
     }
     $templater = new vB5_Template('login_redirect');
     $templater->register('url', filter_var($url, FILTER_SANITIZE_STRING));
     echo $templater->render();
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 /**
  * 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));
 }
Ejemplo n.º 6
0
 public function refreshUsers($pagekey = '', $who = '', $pagenumber = 1, $perpage = 0, $sortfield = 'time', $sortorder = 'desc', $resolveIp = false, $pageRouteId = null)
 {
     $result = array();
     $onlineUsers = $this->fetchAll($pagekey, $who, $pagenumber, $perpage, $sortfield, $sortorder, $resolveIp);
     $showIP = false;
     foreach ($onlineUsers as $onlineUser) {
         if (!empty($onlineUser['host'])) {
             $showIP = true;
         }
     }
     $onlineUserCounts = $this->fetchCounts($pagekey);
     $totalMembers = $who == 'members' ? $onlineUserCounts['members'] : $onlineUserCounts['total'];
     $pageRouteInfo = array();
     if ($pageRouteId) {
         $routeInfo = vB5_Route::getRouteByIdent($pageRouteId);
         $args = @unserialize($routeInfo['arguments']);
         $pageRouteInfo = array('routeId' => $routeInfo['routeid'], 'arguments' => array('pageid' => $args['pageid'], 'contentid' => $routeInfo['contentid']), 'queryParameters' => array());
     }
     $template = new vB5_Template('onlineuser_details');
     $template->register('onlineUsers', $onlineUsers);
     $template->register('showIP', $showIP);
     $template->register('totalMembers', $totalMembers);
     $template->register('pagenumber', $pagenumber);
     $template->register('perpage', $perpage);
     $template->register('pageRouteInfo', $pageRouteInfo);
     $template = $template->render();
     $userCounts = $this->fetchCounts($pagekey);
     $result['template'] = $template;
     $result['userCounts'] = $userCounts;
     return $result;
 }
Ejemplo n.º 7
0
 public function actionFetchHiddenModules()
 {
     $api = Api_InterfaceAbstract::instance();
     $result = array();
     if (isset($_POST['modules']) and !empty($_POST['modules'])) {
         $widgets = $api->callApi('widget', 'fetchWidgetInstanceTemplates', array($_POST['modules']));
         if ($widgets) {
             // register the templates, so we use bulk fetch
             $templateCache = vB5_Template_Cache::instance();
             foreach ($widgets as $widget) {
                 $templateCache->register($widget['template'], array());
             }
             // now render them
             foreach ($widgets as $widget) {
                 $result[] = array('widgetinstanceid' => $widget['widgetinstanceid'], 'template' => vB5_Template::staticRender($widget['template'], array('widgetid' => $widget['widgetid'], 'widgetinstanceid' => $widget['widgetinstanceid'], 'isWidget' => 1, 'title' => $widget['title'])));
             }
         }
     }
     return $result;
 }
 public static function getPreheader()
 {
     $templater = new vB5_Template('preheader');
     if (self::$needCharset) {
         $templater->register('charset', vB5_String::getTempCharset());
     } else {
         $templater->register('charset', false);
     }
     return $templater->render();
 }
Ejemplo n.º 9
0
 public function actionFetchTagCloud()
 {
     $taglevels = 5;
     $limit = 20;
     $type = 'search';
     $serverData = array_merge($_GET, $_POST);
     $type = empty($serverData['type']) ? 'search' : $serverData['type'];
     $taglevels = empty($serverData['taglevels']) ? 5 : $serverData['taglevels'];
     $limit = empty($serverData['limit']) ? 20 : $serverData['limit'];
     $tags = vB_Api::instanceInternal('Tags')->fetchTagsForCloud($taglevels, $limit, $type);
     $templater = new vB5_Template('tag_cloud');
     $templater->register('tags', $tags);
     $templater->register('noformat', $serverData['noformat']);
     $this->sendAsJson($templater->render());
 }
Ejemplo n.º 10
0
 /**
  * Updates the specified notificationids to mark them as read, and returns a single "next" notification based
  * on the filter parameters.
  *
  * @param	Int|Int[]	$readIds		Integer(s) notificationid(s) being dismissed.
  * @param	Int|Int[]	$idsOnPage		Notifications on the current page.
  * @param	Array		$filterParams	@see vB_Library_Notification::fetchNotificationsForCurrentUser(),
  *										$data param. If empty or if $skipFetch is true, the function will
  *										skip fetching the "next" notification.
  * @param	Bool 		$skipFetch		Default false. If true or if $filterParams is empty, the function
  *										will skip fetching the "next" notification.
  * @param	Int 		$userid			Optional user who owns the $readIds. Currently unused.
  *
  * @return	Array	Results data including the following type & keys:
  *			- String	'insertNotification'	Rendered template HTML string for a notification row that should
  *												be inserted into the DOM
  *			- Int		'affected_rows'		Number of rows affected by update query
  *			- String	'info'				''|'fetch_skipped'|'page_empty'	If not empty string, indicates the
  *											reason API returned early.
  *			- Int	'lastsenttime'			Lastsenttime of the notification, to be used by the frontend code
  *											for sorting in the future.
  *
  * @throws vB_Exception_Api('no_permission')	If current user does not have permission to read the specified
  *												user's notifications.
  */
 public function dismissNotification($readIds, $idsOnPage = array(), $filterParams = array(), $skipFetch = false, $userid = false)
 {
     $currentUserid = vB::getCurrentSession()->get('userid');
     // assuming we never have a userid = 0 / guest for this...
     if (empty($userid)) {
         $userid = $currentUserid;
     }
     /*
      *	In the future, we may want to allow admins to dismiss notifications for other users.
      *	In that case, we'll check permissions below before just throwing an exception.
      */
     if ($userid !== $currentUserid) {
         throw new vB_Exception_Api('no_permission');
     }
     $timeNow = vB::getRequest()->getTimeNow();
     /*
     	vB_dB_Query_Update->execSQL() will either return the # of affected rows, or
     	throw an exception.
     */
     $result = $this->assertor->assertQuery('vBForum:notification', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'recipient', 'value' => $userid, 'operator' => vB_dB_Query::OPERATOR_EQ), array('field' => 'notificationid', 'value' => $readIds, 'operator' => vB_dB_Query::OPERATOR_EQ)), 'lastreadtime' => $timeNow));
     if (empty($filterParams)) {
         $skipFetch = true;
     }
     // this is used for bulk dismissals, since we will be reloading the page most likely
     // and don't need to fetch the next single notification.
     if ($skipFetch) {
         return array('insertNotification' => '', 'affected_rows' => $result, 'info' => 'fetch_skipped');
     }
     // We need to fetch a notification to insert into the current page.
     $filterParams['skipIds'] = $idsOnPage;
     // todo may want to add a "fetch this many" param since readIds may be more than 1, in case we want to
     // update our frontend to do auto-loading for dismissing the page (currently we just do location.reload())
     $notification = vB_Library::instance('Notification')->fetchNotificationsForCurrentUser($filterParams);
     if (empty($notification)) {
         return array('insertNotification' => '', 'affected_rows' => $result, 'info' => 'page_empty');
     }
     // pop it out. We're only expecting 1 notification array at most.
     $notification = reset($notification);
     $template = new vB5_Template('privatemessage_notificationdetail');
     $template->register('message', $notification);
     $template->register('messageid', $notification['notificationid']);
     $template->register('showCheckbox', 0);
     $template = $template->render();
     return array('insertNotification' => $template, 'affected_rows' => $result, 'lastsenttime' => $notification['lastsenttime'], 'info' => '');
 }
Ejemplo n.º 11
0
 /** Fetch the photo tab content for the photo selector
  *
  ***/
 public function actiongetPhotoTabContent()
 {
     $user = vB::getCurrentSession()->fetch_userinfo();
     if (empty($user) or empty($user['userid'])) {
         //@TODO: return not logged in status?
         return;
     }
     $nodeid = isset($_GET['nodeid']) ? intval($_GET['nodeid']) : 0;
     $nodeid = $nodeid ? $nodeid : -2;
     $photosPerRow = isset($_GET['ppr']) ? intval($_GET['ppr']) : 2;
     $tabContent = "";
     $api = Api_InterfaceAbstract::instance();
     $nodes = $api->callApi('profile', 'getAlbum', array(array('nodeid' => $nodeid, 'page' => 1, 'perpage' => 60, 'userid' => $user['userid'])));
     foreach ($nodes as $nodeid => $node) {
         $items = array();
         $photoFiledataids = array();
         $attachFiledataids = array();
         $photoCount = 0;
         foreach ($node['photo'] as $photoid => $photo) {
             // if it's an attachment, we use the 'id=' param. If it's a photo, 'photoid='
             $paramname = (isset($photo['isAttach']) and $photo['isAttach']) ? 'id' : 'photoid';
             $items[$photoid] = array('title' => $photo['title'], 'imgUrl' => vB5_Template_Options::instance()->get('options.frontendurl') . '/filedata/fetch?' . $paramname . '=' . $photoid . '&type=thumb');
             if (!isset($photo['filedataid']) or !$photo['filedataid']) {
                 if ($photo['isAttach']) {
                     $attachFiledataids[] = $photoid;
                 } else {
                     $photoFiledataids[] = $photoid;
                 }
             } else {
                 $items[$photoid]['filedataid'] = $photo['filedataid'];
             }
             if ($photosPerRow and ++$photoCount % $photosPerRow == 0) {
                 $items[$photoid]['lastinrow'] = true;
             }
         }
         if (!empty($photoFiledataids)) {
             $photoFileids = $api->callApi('filedata', 'fetchPhotoFiledataid', array($photoFiledataids));
             foreach ($photoFileids as $nodeid => $filedataid) {
                 $items[$nodeid]['filedataid'] = $filedataid;
             }
         }
         if (!empty($attachFiledataids)) {
             $attachFileids = $api->callApi('filedata', 'fetchAttachFiledataid', array($attachFiledataids));
             foreach ($attachFileids as $nodeid => $filedataid) {
                 $items[$nodeid]['filedataid'] = $filedataid;
             }
         }
         $templater = new vB5_Template('photo_item');
         $templater->register('items', $items);
         $templater->register('photoSelector', 1);
         $tabContent = $templater->render();
     }
     $this->outputPage($tabContent);
 }
Ejemplo n.º 12
0
 /**
  * Returns a string containing the rendered template
  * @see vB5_Frontend_Controller_Ajax::actionRender
  * @see vB5_Frontend_Controller_Page::renderTemplate
  * @param string $templateName
  * @param array $data
  * @param bool $isParentTemplate
  * @param bool $isAjaxTemplateRender - true if we are rendering for a call to /ajax/render/ and we want CSS <link>s separate
  * @return string
  */
 public static function staticRender($templateName, $data = array(), $isParentTemplate = true, $isAjaxTemplateRender = false)
 {
     if (empty($templateName)) {
         return null;
     }
     $templater = new vB5_Template($templateName);
     foreach ($data as $varname => $value) {
         $templater->register($varname, $value);
     }
     $core_path = vB5_Config::instance()->core_path;
     vB5_Autoloader::register($core_path);
     $result = $templater->render($isParentTemplate, $isAjaxTemplateRender);
     return $result;
 }
Ejemplo n.º 13
0
 /** This method gets a photo edit interface. **/
 public function actionGetPhotoedit()
 {
     //We need a nodeid
     if (empty($_REQUEST['nodeid']) or !intval($_REQUEST['nodeid'])) {
         echo '';
         return;
     }
     $nodeid = intval($_REQUEST['nodeid']);
     $api = Api_InterfaceAbstract::instance();
     $gallery = $api->callApi('content_gallery', 'getContent', array('nodeid' => $nodeid));
     if (empty($gallery) or !empty($gallery['errors'])) {
         echo '';
         return;
     }
     $templater = new vB5_Template('gallery_edit');
     if (!empty($gallery[$nodeid]['photo'])) {
         $templater->register('maxid', max(array_keys($gallery[$nodeid]['photo'])));
     } else {
         $templater->register('maxid', 0);
     }
     $templater->register('gallery', $gallery[$nodeid]);
     $this->outputPage($templater->render());
 }
Ejemplo n.º 14
0
 public function actionLoginForm(array $errors = array(), array $formData = array())
 {
     $disableLoginForm = false;
     //@TODO: Validate URL to check against whitelisted URLs
     // VBV-8394 Remove URLPATH querystring from Login form URL
     // use referer URL instead of querystring
     //  however, if the query string is provided, use that instead to handle older URLs
     if (empty($_REQUEST['url'])) {
         // use referrer
         $url = filter_var(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : vB5_Template_Options::instance()->get('options.frontendurl'), FILTER_SANITIZE_STRING);
     } else {
         // it's an old url. Use the query string
         $url = filter_var(isset($_REQUEST['url']) ? $_REQUEST['url'] : vB5_Template_Options::instance()->get('options.frontendurl'), FILTER_SANITIZE_STRING);
     }
     // if it's encoded, we need to decode it to check if it's gonna try to redirect to the login or registration form.
     $url_decoded = base64_decode($url, true);
     $url_decoded = $url_decoded ? $url_decoded : $url;
     if (!empty($url_decoded) and (strpos($url_decoded, '/auth/') !== false or strpos($url_decoded, '/register') !== false)) {
         $url = '';
     }
     // Try to resolve some XSS attack. See VBV-1124
     // Make sure the URL hasn't been base64 encoded already
     if (!base64_decode($url, true)) {
         $url = base64_encode($url);
     }
     // VBV-7835 Stop search engine index this page
     header("X-Robots-Tag: noindex, nofollow");
     // START: Enforce using https for login if frontendurl_login is set to https (VBV-8474)
     // get the current URL and the base login URL for comparison
     $requestBaseUrl = vB5_Request::instance()->get('vBUrlWebroot');
     $loginBaseUrl = vB5_Template_Options::instance()->get('options.frontendurl_login');
     $matchA = preg_match('#^(https?)://#', $requestBaseUrl, $matchResultA);
     $matchB = preg_match('#^(https?)://#', $loginBaseUrl, $matchResultB);
     // if the URL scheme (http or https) doesn't match, redirect to the right one
     if (!($matchA and $matchB and $matchResultA[1] === $matchResultB[1])) {
         // avoid infinite redirects
         if (isset($_REQUEST['vb_login_redirected']) and $_REQUEST['vb_login_redirected'] == 1) {
             // Something exteral to vB is redirecting back from https to http.
             // Since we can't allow logging in over http if configured for https,
             // we can't show the login form here
             if (!isset($errors['errors'])) {
                 $errors['errors'] = array();
             }
             $errors['errors'][] = 'unable_to_redirect_to_the_correct_login_url';
             $disableLoginForm = true;
         } else {
             header('Location: ' . $loginBaseUrl . '/auth/login-form?vb_login_redirected=1&url=' . urlencode($url));
             exit;
         }
     }
     // END: Enforce using https for login if frontendurl_login is set to https
     $user = vB5_User::instance();
     $templater = new vB5_Template('login_form');
     $templater->register('charset', $user['lang_charset']);
     $templater->register('errors', $errors);
     $templater->register('formData', $formData);
     $templater->register('url', $url);
     $templater->register('urlpath', $url);
     $templater->register('disableLoginForm', $disableLoginForm);
     $this->outputPage($templater->render());
 }
Ejemplo n.º 15
0
 /**
  * Place a subscription order
  */
 public function placeOrder($subscriptionid, $subscriptionsubid, $paymentapiclass, $currency)
 {
     $this->checkStatus();
     $this->checkPermission();
     $sub = $this->subobj->subscriptioncache["{$subscriptionid}"];
     $sub['newoptions'] = @unserialize($sub['newoptions']);
     // Verify that the payment api is allowed for this subscription
     if (empty($sub['newoptions']['api'][$paymentapiclass]['show'])) {
         throw new vB_Exception_Api('invalid_paymentapiclass');
     }
     $userinfo = vB::getCurrentSession()->fetch_userinfo();
     $usercontext = vB::getUserContext();
     $membergroupids = fetch_membergroupids_array($userinfo);
     $allow_secondary_groups = $usercontext->hasPermission('genericoptions', 'allowmembergroups');
     if (empty($sub) or !$sub['active']) {
         throw new vB_Exception_Api('invalidid');
     }
     if (!empty($sub['deniedgroups']) and ($allow_secondary_groups and !count(array_diff($membergroupids, $sub['deniedgroups'])) or !$allow_secondary_groups and in_array($userinfo['usergroupid'], $sub['deniedgroups']))) {
         throw new vB_Exception_Api('invalidid');
     }
     $costs = unserialize($sub['cost']);
     if (empty($costs["{$subscriptionsubid}"]['cost']["{$currency}"])) {
         throw new vB_Exception_Api('invalid_currency');
     }
     $hash = md5($userinfo['userid'] . $userinfo['secret'] . $subscriptionid . uniqid(microtime(), 1));
     /* insert query */
     vB::getDbAssertor()->insert('vBForum:paymentinfo', array('hash' => $hash, 'completed' => 0, 'subscriptionid' => $subscriptionid, 'subscriptionsubid' => $subscriptionsubid, 'userid' => $userinfo['userid']));
     $method = vB::getDbAssertor()->getRow('vBForum:paymentapi', array('active' => 1, 'classname' => $paymentapiclass));
     $supportedcurrencies = explode(',', $method['currency']);
     if (!in_array($currency, $supportedcurrencies)) {
         throw new vB_Exception_Api('currency_not_supported');
     }
     // TODO: vB_Template::create() has many PHP notices. We need to fix them.
     error_reporting(E_ALL & ~E_NOTICE);
     $form = $this->subobj->construct_payment($hash, $method, $costs["{$subscriptionsubid}"], $currency, $sub, $userinfo);
     $typetext = $method['classname'] . '_order_instructions';
     $templater = new vB5_Template('subscription_paymentbit');
     $templater->register('form', $form);
     $templater->register('method', $method);
     $templater->register('typetext', $typetext);
     $orderbit = $templater->render();
     return $orderbit;
 }
Ejemplo n.º 16
0
 /**
  * Generates HTML for the subscription form page
  *
  * @param	string		Hash used to indicate the transaction within vBulletin
  * @param	string		The cost of this payment
  * @param	string		The currency of this payment
  * @param	array		Information regarding the subscription that is being purchased
  * @param	array		Information about the user who is purchasing this subscription
  * @param	array		Array containing specific data about the cost and time for the specific subscription period
  *
  * @return	array		Compiled form information
  */
 function generate_form_html($hash, $cost, $currency, $subinfo, $userinfo, $timeinfo)
 {
     $item = $hash;
     $currency = strtoupper($currency);
     $show['notax'] = $subinfo['newoptions']['api']['paypal']['tax'] ? false : true;
     $show['recurring'] = ($this->supports_recurring and $timeinfo['recurring']) ? true : false;
     $no_shipping = '1';
     switch ($subinfo['newoptions']['api']['paypal']['shipping_address']) {
         case 'none':
             $no_shipping = '1';
             break;
         case 'optional':
             $no_shipping = '0';
             break;
         case 'required':
             $no_shipping = '2';
             break;
     }
     $form['action'] = 'https://www.paypal.com/cgi-bin/webscr';
     $form['method'] = 'post';
     $vbphrase = vB_Api::instanceInternal('phrase')->fetch('sub' . $subinfo['subscriptionid'] . '_title');
     $subinfo['title'] = $vbphrase['sub' . $subinfo['subscriptionid'] . '_title'];
     // load settings into array so the template system can access them
     $settings =& $this->settings;
     $templater = new vB5_Template('subscription_payment_paypal');
     $templater->register('cost', $cost);
     $templater->register('currency', $currency);
     $templater->register('item', $item);
     $templater->register('no_shipping', $no_shipping);
     $templater->register('settings', $settings);
     $templater->register('subinfo', $subinfo);
     $templater->register('timeinfo', $timeinfo);
     $templater->register('userinfo', $userinfo);
     $templater->register('show', $show);
     $form['hiddenfields'] .= $templater->render();
     return $form;
 }
Ejemplo n.º 17
0
 /**
  * This method is used from template code to render a template and store it in a variable
  * @param string $templateName
  * @param array $data
  * @param bool $isParentTemplate
  */
 public static function renderTemplate($templateName, $data = array(), $isParentTemplate = true)
 {
     if (empty($templateName)) {
         return null;
     }
     return vB5_Template::staticRender($templateName, $data, $isParentTemplate);
 }
Ejemplo n.º 18
0
 protected function renderSinglePostTemplate($node, $view, $channelBbcodes, $additionalData = array())
 {
     if (empty($node)) {
         return '';
     }
     /*
     		TODO: add support for blogs & articles
     */
     if ($view == 'stream') {
         $templatenamePrefix = 'display_contenttype_conversationreply_';
     } else {
         // thread
         $templatenamePrefix = 'display_contenttype_conversationreply_threadview_';
     }
     $template = $templatenamePrefix . $node['contenttypeclass'];
     $templater = new vB5_Template($template);
     $templater->register('nodeid', $node['nodeid']);
     $templater->register('conversation', $node['content']);
     $templater->register('currentConversation', $node);
     $templater->register('bbcodeOptions', $channelBbcodes);
     //$templater->register('hidePostIndex', true);	// TODO: figure post# bits out.
     if (isset($additionalData['pagingInfo'])) {
         $templater->register('pagingInfo', $additionalData['pagingInfo']);
     }
     if (isset($additionalData['pagingInfo'])) {
         $templater->register('postIndex', $additionalData['postIndex']);
     }
     $templater->register('reportActivity', $view == 'stream');
     $templater->register('showChannelInfo', false);
     if ($view == 'thread') {
         $templater->register('showInlineMod', true);
         //$templater->register('commentsPerPage', $additionalData['comments-perpage']); // TODO: comments
     } else {
         if ($view == 'stream' and !$node['isVisitorMessage']) {
             $templater->register('view', 'conversation_detail');
         }
     }
     return $templater->render(true, true);
 }
Ejemplo n.º 19
0
 /**
  * Appends the non-inline attachment UI to the passed $text
  *
  * @param	string	Text to append attachments
  * @param	array	Attachment data
  * @param	bool	Whether to show images
  * @param	array	Array of nodeid => (nodeid, filedataid) attachments that should not be included in the attachment box.
  */
 public function append_noninline_attachments($text, $attachments, $do_imgcode = false, $skiptheseattachments = array())
 {
     foreach ($skiptheseattachments as $nodeid => $arr) {
         unset($attachments[$nodeid]);
     }
     if (!empty($attachments)) {
         foreach ($attachments as &$attachment) {
             $attachment['filesize'] = !empty($attachment['filesize']) ? vb_number_format($attachment['filesize'], 1, true) : 0;
         }
         $attach_url = vB5_Template_Options::instance()->get('options.frontendurl') . "/filedata/fetch?id=";
         if ($this->renderImmediate) {
             $text .= vB5_Template::staticRender('bbcode_attachment_list', array('attachments' => $attachments, 'attachurl' => $attach_url), false);
         } else {
             $text .= vB5_Template_Runtime::includeTemplate('bbcode_attachment_list', array('attachments' => $attachments, 'attachurl' => $attach_url));
         }
     }
     return $text;
 }
 /**
  * Generates HTML for the subscription form page
  *
  * @param	string		Hash used to indicate the transaction within vBulletin
  * @param	string		The cost of this payment
  * @param	string		The currency of this payment
  * @param	array		Information regarding the subscription that is being purchased
  * @param	array		Information about the user who is purchasing this subscription
  * @param	array		Array containing specific data about the cost and time for the specific subscription period
  *
  * @return	array		Compiled form information
  */
 function generate_form_html($hash, $cost, $currency, $subinfo, $userinfo, $timeinfo)
 {
     global $vbphrase, $vbulletin, $show;
     $item = $hash;
     $currency = strtoupper($currency);
     $timenow = vB::getRequest()->getTimeNow();
     $sequence = vbrand(1, 1000);
     $fingerprint = $this->hmac($this->settings['txnkey'], $this->settings['authorize_loginid'] . '^' . $sequence . '^' . $timenow . '^' . $cost . '^' . $currency);
     $form['action'] = $this->form_target;
     $form['method'] = 'post';
     // load settings into array so the template system can access them
     $settings =& $this->settings;
     $templater = new vB5_Template('subscription_payment_authorizenet');
     $templater->register('cost', $cost);
     $templater->register('currency', $currency);
     $templater->register('fingerprint', $fingerprint);
     $templater->register('item', $item);
     $templater->register('sequence', $sequence);
     $templater->register('settings', $settings);
     $templater->register('timenow', $timenow);
     $templater->register('userinfo', $userinfo);
     $form['hiddenfields'] .= $templater->render();
     return $form;
 }
Ejemplo n.º 21
0
 protected function processTopics($nodes, $stickynodes, $maxpages = 0)
 {
     $result = array('total' => 0, 'total_with_sticky' => 0, 'lastDate' => 0, 'template' => '', 'pageinfo' => array('pagenumber' => 1, 'totalpages' => 1), 'css_links' => array());
     $templater = new vB5_Template('display_Topics');
     $canmoderate = false;
     if (!isset($nodes['errors']) and !empty($nodes['results'])) {
         foreach ($nodes['results'] as $key => $node) {
             //only include the starter
             if ($node['content']['contenttypeclass'] == 'Channel' or $node['content']['starter'] != $node['content']['nodeid']) {
                 unset($nodes['results'][$key]);
             } else {
                 $result['lastDate'] = max($result['lastDate'], $node['content']['publishdate']);
             }
             if (!empty($node['content']['permissions']['canmoderate']) and !$canmoderate) {
                 $canmoderate = 1;
                 $templater->register('canmoderate', $canmoderate);
             }
         }
         $templater->register('topics', $nodes['results']);
         $result['total_with_sticky'] = $result['total'] = count($nodes['results']);
         $result['pageinfo']['pagenumber'] = $nodes['pagenumber'];
         $result['pageinfo']['totalpages'] = (!empty($maxpages) and $maxpages < $nodes['totalpages']) ? $maxpages : $nodes['totalpages'];
         $result['pageinfo']['resultId'] = $nodes['resultId'];
     } elseif (isset($nodes['errors'])) {
         $templater->register('topics', $nodes);
     }
     if (!isset($stickynodes['errors']) and !empty($stickynodes['results'])) {
         $result['total_with_sticky'] = $result['total'] + count($stickynodes['results']);
         $sticky_templater = new vB5_Template('display_Topics');
         $sticky_templater->register('topics', $stickynodes['results']);
         $sticky_templater->register('topic_list_class', 'sticky-list');
         if (!$canmoderate and empty($nodes['results'])) {
             //It is safe to assume that if user has canmoderate permission for the first topic node in a forum, he/she has the same permission for all the nodes.
             $firstTopic = reset($stickynodes['results']);
             $canmoderate = $firstTopic['content']['permissions']['canmoderate'];
         }
         $sticky_templater->register('canmoderate', $canmoderate);
         $result['template'] .= "\n" . $sticky_templater->render() . "\n";
         $templater->register('no_header', 1);
     }
     if (!empty($nodes['results']) or empty($stickynodes['results'])) {
         $result['template'] .= "\n" . $templater->render(true, true) . "\n";
         $result['css_links'] = vB5_Template_Stylesheet::instance()->getAjaxCssLinks();
     }
     return $result;
 }