protected function buildURI(array &$p_params = array(), $p_preview = false)
{
if ($this->isValidCache()) {
return;
}
if (count($p_params) == 0) {
return;
}
$parameter = strtolower(array_shift($p_params));
switch ($parameter) {
case 'static_file':
$staticFile = isset($p_params[0]) ? array_shift($p_params) : null;
$p_params = array();
$this->m_buildQueryArray = array();
if (empty($staticFile)) {
$this->m_buildPath = '';
break;
}
$this->m_buildPath = '/themes/' . $this->getThemePath() . $staticFile;
break;
case 'root_level':
$this->m_buildPath = '/';
if ($p_preview) {
$this->m_buildQueryArray = $this->getQueryArray(CampURI::$m_previewParameters);
} else {
$this->m_buildQueryArray = array();
}
$p_params = array();
break;
case 'articleattachment':
$context = CampTemplate::singleton()->context();
$attachment = new Attachment($context->attachment->identifier);
$this->m_buildPath = $attachment->getAttachmentUri();
$this->m_buildQueryArray = array();
$p_params = array();
break;
case 'articlecomment':
$context = CampTemplate::singleton()->context();
if ($context->comment->defined) {
$this->m_buildQueryArray['acid'] = $context->comment->identifier;
}
break;
case 'image':
$this->m_buildQueryArray = array();
if (isset($p_params[0]) && is_numeric($p_params[0])) {
$this->processOldImageOptions($imageNo, $p_params);
} else {
$this->processImageOptions($imageNo, $p_params);
}
$context = CampTemplate::singleton()->context();
if (!is_null($imageNo)) {
$oldImage = $context->image;
$articleImage = new ArticleImage($context->article->number, null, $imageNo);
$context->image = new MetaImage($articleImage->getImageId());
}
$this->m_buildPath = '/get_img';
$this->m_validURI = $context->image->defined();
$this->m_buildQueryArray['ImageId'] = $context->image->number;
if (!is_null($imageNo)) {
$context->image = $oldImage;
}
$p_params = array();
break;
case 'previous_subtitle':
case 'next_subtitle':
case 'all_subtitles':
$option = isset($p_params[0]) ? array_shift($p_params) : null;
$article = CampTemplate::singleton()->context()->article;
$subtitleNo = $article->current_subtitle_no($option);
if (!$article->defined || !is_null($subtitleNo) && !is_numeric($subtitleNo)) {
return;
}
$fieldObj = $article->{$option};
if ($parameter == 'previous_subtitle' && !$fieldObj->has_previous_subtitles || $parameter == 'next_subtitle' && !$fieldObj->has_next_subtitles) {
return;
}
$subtitleURLId = $article->subtitle_url_id($option);
if ($parameter == 'all_subtitles') {
$newSubtitleNo = 'all';
} else {
$newSubtitleNo = $subtitleNo + ($parameter == 'previous_subtitle' ? -1 : 1);
}
$this->m_buildQueryArray[$subtitleURLId] = $newSubtitleNo;
break;
case 'previous_items':
case 'next_items':
$context = CampTemplate::singleton()->context();
if ($context->current_list == null) {
return;
}
$listId = $context->current_list->id;
$this->m_buildQueryArray[$listId] = $parameter == 'previous_items' ? $context->current_list->previous_start : $context->current_list->next_start;
if ($this->m_buildQueryArray[$listId] == 0) {
unset($this->m_buildQueryArray[$listId]);
}
break;
case 'reset_issue_list':
$context = CampTemplate::singleton()->context();
$listIdPrefix = $context->list_id_prefix('IssuesList');
$this->resetList($listIdPrefix);
break;
case 'reset_section_list':
$context = CampTemplate::singleton()->context();
$listIdPrefix = $context->list_id_prefix('SectionsList');
$this->resetList($listIdPrefix);
break;
case 'reset_article_list':
$context = CampTemplate::singleton()->context();
$listIdPrefix = $context->list_id_prefix('ArticlesList');
$this->resetList($listIdPrefix);
break;
case 'reset_searchresult_list':
$context = CampTemplate::singleton()->context();
$listIdPrefix = $context->list_id_prefix('SearchResultsList');
$this->resetList($listIdPrefix);
break;
case 'reset_subtitle_list':
$context = CampTemplate::singleton()->context();
$listIdPrefix = $context->list_id_prefix('SubtitlesList');
$this->resetList($listIdPrefix);
break;
default:
}
}