public static function Create($p_sessionId, &$p_objectId, $p_objectTypeId = null, $p_userId = null, $p_updateStats = false) { if (empty($p_sessionId)) { throw new SessionIdNotSet(); } $session = new Session($p_sessionId); if (!$session->exists()) { $sessionParams = array('start_time' => strftime("%Y-%m-%d %T")); if (!empty($p_userId)) { $sessionParams['user_id'] = $p_userId; } $session->create($sessionParams); } $sessionUserId = $session->getUserId(); if (!empty($p_userId) && !empty($sessionUserId) && $sessionUserId != $p_userId) { throw new InvalidUserId(); } $requestObject = new RequestObject($p_objectId); if (!$requestObject->exists()) { if (empty($p_objectTypeId)) { throw new ObjectTypeIdNotSet(); } $requestObject->create(array('object_type_id' => $p_objectTypeId)); $p_objectId = $requestObject->getObjectId(); } elseif (empty($p_objectId)) { throw new ObjectIdNotSet(); } if ($p_updateStats) { self::UpdateStats($p_sessionId, $p_objectId); } }
<a href="#" tabindex="-1"><?php echo $translator->trans('Info', array(), 'articles'); ?> </a></h3> </div> <div class="padded clearfix"> <dl class="inline-list"> <dt><?php echo $translator->trans('Reads'); ?> </dt> <dd> <?php if ($articleObj->isPublished()) { $requestObject = new RequestObject($articleObj->getProperty('object_id')); echo $requestObject->exists() ? $requestObject->getRequestCount() : '0'; } else { echo $translator->trans('N/A'); } ?> </dd> <dt><?php echo $translator->trans('Type'); ?> </dt> <dd><?php print htmlspecialchars($articleType->getDisplayName()); ?> </dd> <dt><?php echo $translator->trans('Number');
/** * Campsite Map function plugin * * Type: function * Name: count * Purpose: Triggers a statistics counting request * * @param array * $p_params List of parameters from template * @param object * $p_smarty Smarty template object * * @return * string The html content */ function smarty_function_count($p_params, &$p_smarty) { global $Campsite; $campsite = $p_smarty->getTemplateVars('gimme'); $content = ''; $art_number = 0; $art_language_num = 0; $art_language_code = ''; if (isset($p_params['article']) && is_numeric($p_params['article'])) { $art_number = $p_params['article']; } if (isset($p_params['language'])) { $langs = array(); if (is_numeric($p_params['language'])) { $langs = \Language::GetLanguages($p_params['language']); } else { $langs = \Language::GetLanguages(null, $p_params['language']); } if (!isset($langs[0])) { return ''; // 'no lang' } $art_language_obj = $langs[0]; $art_language_num = $art_language_obj->getLanguageId(); $art_language_code = $art_language_obj->getCode(); } $count_automatically = true; if (isset($p_params['dont_count_automatically'])) { $count_automatically = false; } if (!$art_number || !$art_language_num) { $meta_article = $campsite->article; if ($meta_article->defined) { if (!$art_number) { $art_number = $meta_article->number; } if (!$art_language_num) { $art_language_meta = $meta_article->language; $art_language_num = $art_language_meta->number; $art_language_code = $art_language_meta->code; } } } if (!$art_language_num) { $art_language_meta = $campsite->language; $art_language_num = $art_language_meta->number; $art_language_code = $art_language_meta->code; } if (!$art_number || !$art_language_num) { return ''; // 'no art_num or lang' } $article = new \Article($art_language_num, $art_number); if (!$article->exists()) { return ''; // 'no art' } try { $requestObjectId = $article->getProperty('object_id'); $updateArticle = empty($requestObjectId); $objectType = new \ObjectType('article'); $object_type_id = $objectType->getObjectTypeId(); if ($updateArticle) { $requestObject = new \RequestObject($requestObjectId); if (!$requestObject->exists()) { $requestObject->create(array('object_type_id' => $objectType->getObjectTypeId())); $requestObjectId = $requestObject->getObjectId(); } $article->setProperty('object_id', $requestObjectId); } // statistics shall be only gathered if the site admin set it on (and not for editor previews) if (!$campsite->preview) { $stat_web_url = $Campsite['WEBSITE_URL']; if ('/' != $stat_web_url[strlen($stat_web_url) - 1]) { $stat_web_url .= '/'; } $article_number = $article->getProperty('Number'); $name_spec = '_' . $article_number . '_' . $art_language_code; $content .= \Statistics::JavaScriptTrigger(array('count_automatically' => $count_automatically, 'name_spec' => $name_spec, 'object_type_id' => $object_type_id, 'request_object_id' => $requestObjectId)); } } catch (\Exception $ex) { return ''; } return $content; }
/** * Returns the content of the given subtitles of the article body field. * * @param array $p_subtitles * @return string */ private function getContent(array $p_subtitles = array()) { global $Campsite; $printAll = count($p_subtitles) == 0; $content = ''; foreach ($this->m_subtitles as $index => $subtitle) { if (!$printAll && array_search($index, $p_subtitles) === false) { continue; } $content .= $index > 0 ? $subtitle->formatted_name : ''; $content .= $subtitle->content; } if ($this->m_articleTypeField->isContent()) { $objectType = new ObjectType('article'); $requestObjectId = $this->m_parent_article->getProperty('object_id'); $updateArticle = empty($requestObjectId); try { if ($updateArticle) { $requestObject = new RequestObject($requestObjectId); if (!$requestObject->exists()) { $requestObject->create(array('object_type_id' => $objectType->getObjectTypeId())); $requestObjectId = $requestObject->getObjectId(); } $this->m_parent_article->setProperty('object_id', $requestObjectId); } // statistics shall be only gathered if the site admin set it on (and not for editor previews) $context = CampTemplate::singleton()->context(); if (SystemPref::CollectStatisticsAuto() && !$context->preview) { $stat_web_url = $Campsite['WEBSITE_URL']; if ('/' != $stat_web_url[strlen($stat_web_url) - 1]) { $stat_web_url .= '/'; } $article_number = $this->m_parent_article->getProperty('Number'); $language_obj = new MetaLanguage($this->m_parent_article->getProperty('IdLanguage')); $language_code = $language_obj->Code; $name_spec = '_' . $article_number . '_' . $language_code; $object_type_id = $objectType->getObjectTypeId(); $content .= Statistics::JavaScriptTrigger(array('name_spec' => $name_spec, 'object_type_id' => $object_type_id, 'request_object_id' => $requestObjectId)); } } catch (Exception $ex) { $content .= "<p><strong><font color=\"red\">INTERNAL ERROR! " . $ex->getMessage() . "</font></strong></p>\n"; // do something } } return $content; }
<div class="ui-widget-content small-block block-shadow"> <div class="collapsible"> <h3 class="head ui-accordion-header ui-helper-reset ui-state-default ui-widget"> <span class="ui-icon"></span> <a href="#" tabindex="-1"><?php putGS('Info'); ?></a></h3> </div> <div class="padded clearfix"> <dl class="inline-list"> <dt><?php putGS('Reads'); ?></dt> <dd> <?php if ($articleObj->isPublished()) { $requestObject = new RequestObject($articleObj->getProperty('object_id')); if ($requestObject->exists()) { echo $requestObject->getRequestCount(); } else { echo '0'; } } else { putGS('N/A'); } ?> </dd> <dt><?php putGS('Type'); ?></dt> <dd><?php print htmlspecialchars($articleType->getDisplayName()); ?></dd> <dt><?php putGS('Number'); ?></dt> <dd><?php p($articleObj->getArticleNumber()); ?></dd> <dt><?php putGS('Created by'); ?></dt> <dd><?php p(htmlspecialchars($articleCreator->getRealName())); ?></dd> </dl> </div>