本文整理汇总了PHP中Section::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Section::exists方法的具体用法?PHP Section::exists怎么用?PHP Section::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section::exists方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetURI
public static function GetURI($p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null)
{
$translator = \Zend_Registry::get('container')->getService('translator');
$languageObj = new Language($p_languageId);
if (!$languageObj->exists()) {
return new PEAR_Error($translator->trans('Language does not exist.'));
}
$uri = '/' . $languageObj->getCode() . '/';
if (!is_null($p_issueNo) && is_null($p_articleNo)) {
$issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo);
if (!$issueObj->exists()) {
return new PEAR_Error($translator->trans('Issue does not exist.'));
}
$uri .= $issueObj->getUrlName() . '/';
}
if (!is_null($p_sectionNo) && is_null($p_articleNo)) {
$sectionObj = new Section($p_publicationId, $p_issueNo, $p_languageId, $p_sectionNo);
if (!$sectionObj->exists()) {
return new PEAR_Error($translator->trans('Section does not exist.'));
}
$uri .= $sectionObj->getUrlName() . '/';
}
if (!is_null($p_articleNo)) {
$articleObj = new Article($p_languageId, $p_articleNo);
if (!$articleObj->exists()) {
return new PEAR_Error($translator->trans('Article does not exist.'));
}
$issueObj = new Issue($p_publicationId, $p_languageId, $articleObj->getIssueNumber());
$sectionObj = new Section($p_publicationId, $articleObj->getIssueNumber(), $p_languageId, $articleObj->getSectionNumber());
$uri .= $issueObj->getUrlName() . '/';
$uri .= $sectionObj->getUrlName() . '/';
$uri .= $articleObj->getUrlName() . '/';
}
return $uri;
}
示例2: GetURI
public static function GetURI($p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null)
{
$languageObj = new Language($p_languageId);
if (!$languageObj->exists()) {
return new PEAR_Error(getGS('Language does not exist.'));
}
$uri = $GLOBALS['Campsite']['SUBDIR'] . '/' . $languageObj->getCode() . '/';
if (!is_null($p_issueNo) && is_null($p_articleNo)) {
$issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo);
if (!$issueObj->exists()) {
return new PEAR_Error(getGS('Issue does not exist.'));
}
$uri .= $issueObj->getUrlName() . '/';
}
if (!is_null($p_sectionNo) && is_null($p_articleNo)) {
$sectionObj = new Section($p_publicationId, $p_issueNo, $p_languageId, $p_sectionNo);
if (!$sectionObj->exists()) {
return new PEAR_Error(getGS('Section does not exist.'));
}
$uri .= $sectionObj->getUrlName() . '/';
}
if (!is_null($p_articleNo)) {
$articleObj = new Article($p_languageId, $p_articleNo);
if (!$articleObj->exists()) {
return new PEAR_Error(getGS('Article does not exist.'));
}
$issueObj = new Issue($p_publicationId, $p_languageId, $articleObj->getIssueNumber());
$sectionObj = new Section($p_publicationId, $articleObj->getIssueNumber(), $p_languageId, $articleObj->getSectionNumber());
$uri .= $issueObj->getUrlName() . '/';
$uri .= $sectionObj->getUrlName() . '/';
$uri .= $articleObj->getUrlName() . '/';
}
return $uri;
}
示例3: Section
function get_section()
{
$CI =& get_instance();
if ($this->installed()) {
if (!isset($CI->uri)) {
$CI->load->library('URI');
}
$sec = new Section();
$sec->get_by_id($CI->uri->segment(1));
if (!$sec->exists()) {
$sec->get();
}
return $sec;
}
}
示例4: array
if (!Input::IsValid()) {
camp_html_display_error($translator->trans('Invalid input: $1', array('$1' => Input::GetErrorString())));
exit;
}
$srcPublicationObj = new Publication($f_src_publication_id);
if (!$srcPublicationObj->exists()) {
camp_html_display_error($translator->trans('Publication does not exist.'));
exit;
}
$srcIssueObj = new Issue($f_src_publication_id, $f_language_id, $f_src_issue_number);
if (!$srcIssueObj->exists()) {
camp_html_display_error($translator->trans('Issue does not exist.'));
exit;
}
$srcSectionObj = new Section($f_src_publication_id, $f_src_issue_number, $f_language_id, $f_src_section_number);
if (!$srcSectionObj->exists()) {
camp_html_display_error($translator->trans('Section does not exist.'));
exit;
}
$dstPublicationObj = new Publication($f_dest_publication_id);
$dstIssueObj = new Issue($f_dest_publication_id, $f_language_id, $f_dest_issue_number);
$dstSectionObj = new Section($f_dest_publication_id, $f_dest_issue_number, $f_language_id, $f_dest_section_number);
$topArray = array('Pub' => $srcPublicationObj, 'Issue' => $srcIssueObj, 'Section' => $srcSectionObj);
camp_html_content_top($translator->trans('Duplicating section', array(), 'sections'), $topArray);
?>
<P>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="8" class="message_box">
<TR>
<TD COLSPAN="2">
<B> <?php
echo $translator->trans("Duplicating section", array(), 'sections');
示例5: Publication
}
if ($f_publication_id > 0) {
$publicationObj = new Publication($f_publication_id);
if (!$publicationObj->exists()) {
camp_html_display_error($translator->trans('Publication does not exist.'));
exit;
}
if ($f_issue_number > 0) {
$issueObj = new Issue($f_publication_id, $f_language_id, $f_issue_number);
if (!$issueObj->exists()) {
camp_html_display_error($translator->trans('Issue does not exist.'));
exit;
}
if ($f_section_number > 0) {
$sectionObj = new Section($f_publication_id, $f_issue_number, $f_language_id, $f_section_number);
if (!$sectionObj->exists()) {
camp_html_display_error($translator->trans('Section does not exist.'));
exit;
}
}
}
}
// Get all the publications
$allPublications = Publication::GetPublications();
// Automatically select the publication if there is only one.
if (count($allPublications) == 1) {
$tmpPublication = camp_array_peek($allPublications);
$f_destination_publication_id = $tmpPublication->getPublicationId();
}
// Get the most recent issues.
$allIssues = array();
示例6: getSection
/**
* Get the section that this article is in.
* @return object
*/
public function getSection()
{
$section = new Section($this->getPublicationId(), $this->getIssueNumber(),
$this->getLanguageId(), $this->getSectionNumber());
if (!$section->exists()) {
$sections = Section::GetSections($this->getPublicationId(), $this->getIssueNumber());
if (count($sections) > 0) {
return $sections[0];
}
}
return $section;
} // fn getSection
示例7: Section
camp_html_add_msg(getGS('Unable to create the issue for translation $1.', $translationLanguageObj->getName()));
camp_html_goto_page($backLink);
}
} else {
$f_issue_name = Input::Get('f_issue_name', 'string', $issueObj->getName());
$f_issue_urlname = Input::Get('f_issue_urlname', 'string', $issueObj->getUrlName());
$translationIssueObj->update(array('Name' => $f_issue_name, 'ShortName' => $f_issue_urlname));
}
$f_section_number = $articleObj->getSectionNumber();
$sectionObj = new Section($f_publication_id, $f_issue_number, $f_language_id, $f_section_number);
if (!$sectionObj->exists()) {
camp_html_display_error(getGS('No such section.'), $backLink);
exit;
}
$translationSectionObj = new Section($f_publication_id, $f_issue_number, $f_translation_language, $f_section_number);
if (!$translationSectionObj->exists()) {
if (!$g_user->hasPermission("ManageSection")) {
camp_html_add_msg(getGS('A section must be created for the selected language but you do not have the right to create a section.'));
camp_html_goto_page($backLink);
}
foreach ($sectionObj->getData() as $field => $fieldValue) {
if ($field != 'IdLanguage') {
$translationSectionObj->setProperty($field, $fieldValue, false);
}
}
$f_section_name = Input::Get('f_section_name', 'string', $sectionObj->getName());
$f_section_urlname = Input::Get('f_section_urlname', 'string', $sectionObj->getUrlName());
if ($f_section_urlname == "") {
camp_html_add_msg(getGS('You must fill in the $1 field.', '"' . getGS('New section URL name') . '"'));
camp_html_goto_page($backLink);
}
示例8: putGS
}
?>
</SELECT>
</TD>
</TR>
<?php
$canCreate = true;
if ($f_language_selected > 0 && $f_issue_number > 0) {
// Every article must live inside a cooresponding issue of the same language.
if (!$translationIssueObj->exists()) {
if ($g_user->hasPermission("ManageIssue")) {
// If a section needs to be translated, but the user doesnt have the permission
// to create a section, then we dont want to display anything here. Even
// if they can create the issue, they still need to create a cooresponding section.
// If they dont have the permission to do that, then no use in creating the issue.
if ($translationSectionObj->exists() || $g_user->hasPermission("ManageSection")) {
?>
<TR>
<TD colspan="2" align="left" style="padding-left: 40px; padding-right: 40px; padding-top: 20px;"><strong><?php
putGS("An issue must be created for the selected language. Please enter the issue name and URL name.");
?>
</strong></TD>
</TR>
<TR>
<TD ALIGN="RIGHT" ><?php
putGS("New issue name");
?>
:</TD>
<TD>
<INPUT TYPE="TEXT" NAME="f_issue_name" SIZE="32" value="<?php
echo htmlspecialchars($f_translation_issue_name);
示例9: getSection
/**
* Get the section that this article is in.
* @return object
*/
public function getSection()
{
$section = new Section($this->getPublicationId(), $this->getIssueNumber(), $this->getLanguageId(), $this->getSectionNumber());
if (!$section->exists()) {
$params = array(new ComparisonOperation('idpublication', new Operator('is', 'integer'), $this->getPublicationId()), new ComparisonOperation('idlanguage', new Operator('is', 'integer'), $this->getLanguageId()), new ComparisonOperation('number', new Operator('is', 'integer'), $this->getSectionNumber()));
if ($this->getIssueNumber()) {
$params[] = new ComparisonOperation('nrissue', new Operator('is', 'integer'), $this->getIssueNumber());
}
$sections = Section::GetList($params, null, 0, 1, $count = 0);
if (!empty($sections)) {
return $sections[0];
}
}
return $section;
}
示例10: Section
function attach_section($section = '')
{
// check if that place it took
$cont = new Section();
$cont->where('parent_section', $this->id);
//same section
$cont->where('sort', $section->sort);
//greater sort
$cont->get();
//get them to process
if ($cont->exists()) {
$cont->where('parent_section', $this->id);
//same section
$cont->where('sort >=', $section->sort);
//greater sort
$cont->get();
//get them to process
foreach ($cont->all as $item) {
$item->sort++;
$item->save();
}
}
$section->save();
}
示例11: GetList
//.........这里部分代码省略.........
$p_start = 0, $p_limit = 0, &$p_count, $p_skipCache = false)
{
global $g_ado_db;
if (!$p_skipCache && CampCache::IsEnabled()) {
$paramsArray['parameters'] = serialize($p_parameters);
$paramsArray['order'] = (is_null($p_order)) ? 'null' : $p_order;
$paramsArray['start'] = $p_start;
$paramsArray['limit'] = $p_limit;
$cacheListObj = new CampCacheList($paramsArray, __METHOD__);
$sectionsList = $cacheListObj->fetchFromCache();
if ($sectionsList !== false && is_array($sectionsList)) {
return $sectionsList;
}
}
$hasPublicationId = false;
$selectClauseObj = new SQLSelectClause();
$countClauseObj = new SQLSelectClause();
// sets the where conditions
foreach ($p_parameters as $param) {
$comparisonOperation = self::ProcessListParameters($param);
if (empty($comparisonOperation)) {
break;
}
if (strpos($comparisonOperation['left'], 'IdPublication') !== false) {
$hasPublicationId = true;
}
$whereCondition = $comparisonOperation['left'] . ' '
. $comparisonOperation['symbol'] . " '"
. $g_ado_db->escape($comparisonOperation['right']) . "' ";
$selectClauseObj->addWhere($whereCondition);
$countClauseObj->addWhere($whereCondition);
}
// validates whether publication identifier was given
if ($hasPublicationId == false) {
CampTemplate::singleton()->trigger_error('missed parameter Publication '
.'Identifier in statement list_sections');
return;
}
// sets the columns to be fetched
$tmpSection = new Section();
$columnNames = $tmpSection->getColumnNames(true);
foreach ($columnNames as $columnName) {
$selectClauseObj->addColumn($columnName);
}
$countClauseObj->addColumn('COUNT(*)');
// sets the main table for the query
$selectClauseObj->setTable($tmpSection->getDbTableName());
$countClauseObj->setTable($tmpSection->getDbTableName());
unset($tmpSection);
if (!is_array($p_order)) {
$p_order = array();
}
// sets the order condition if any
foreach ($p_order as $orderColumn => $orderDirection) {
$selectClauseObj->addOrderBy($orderColumn . ' ' . $orderDirection);
}
$selectClauseObj->addGroupField('Number');
$selectClauseObj->addGroupField('IdLanguage');
// sets the limit
$selectClauseObj->setLimit($p_start, $p_limit);
// builds the query and executes it
$selectQuery = $selectClauseObj->buildQuery();
$countQuery = $countClauseObj->buildQuery();
$sections = $g_ado_db->GetAll($selectQuery);
if (is_array($sections)) {
$p_count = $g_ado_db->GetOne($countQuery);
// builds the array of section objects
$sectionsList = array();
foreach ($sections as $section) {
$secObj = new Section($section['IdPublication'],
$section['NrIssue'],
$section['IdLanguage'],
$section['Number']);
if ($secObj->exists()) {
$sectionsList[] = $secObj;
}
}
} else {
$sectionsList = array();
$p_count = 0;
}
if (!$p_skipCache && CampCache::IsEnabled()) {
$cacheListObj->storeInCache($sectionsList);
}
return $sectionsList;
} // fn GetList
示例12: Section
function get_section()
{
$CI =& get_instance();
$sec = new Section();
$section_segment = $CI->uri->segment(1);
if (substr($section_segment, 0, 1) == '+') {
$sec->get_by_name(substr($section_segment, 1));
} else {
$sec->get_by_id($section_segment);
}
if (!$sec->exists()) {
$sec->get_by_id('1');
}
return $sec;
}
示例13: make
public function make($section_title, $content, $title, $url, $nsfw, $nsfl, Section $section)
{
$section_title = strtolower($section_title);
$block = new SuccessBlock();
$block->data->section_title = $section_title;
$block->data->item_title = Utility::prettyUrl($title);
if ($block->success) {
if (Auth::user()->points < 1) {
$block->success = false;
$block->errors[] = 'You need at least one point to post';
}
}
if ($block->success) {
if (!$this->canPost()) {
$block->success = false;
$block->errors[] = 'can only post ' . Utility::availablePosts() . ' per day';
}
}
if ($block->success) {
$data = $this->prepareData(['data' => $content, 'title' => $title, 'url' => $url, 'user_id' => Auth::user()->id, 'nsfw' => $nsfw, 'nsfl' => $nsfl]);
$rules = $this->generateRules($data);
$validate = Validator::make($data, $this->generateRules($data));
if ($validate->fails()) {
$block->success = false;
foreach ($validate->messages()->all() as $v) {
$block->errors[] = $v;
}
}
}
if ($block->success) {
//check if .gif & gfycat it
$data['url'] = $this->gfycatUrl($data['url']);
if (!$section->exists($section_title)) {
$ssect = new Section(['title' => $section_title]);
if (!$ssect->save()) {
$block->success = false;
$block->errors[] = 'unable to create new spreadit';
$block->data->section_title = str_replace(' ', '_', $block->data->section_title);
}
}
}
if ($block->success) {
$section = $section->sectionFromSections($section->getByTitle(Utility::splitByTitle($section_title)));
if ($section->id < 1) {
$block->success = false;
$block->errors[] = 'can only post to a real section(you probably tried to post to /s/all)';
}
}
if ($block->success) {
$data['section_id'] = $section->id;
$item = new Post($data);
$item->save();
if (isset($rules['url'])) {
if (Utility::urlExists($data['url'])) {
Utility::thumbnailScript($item->id, $data['url']);
}
}
//add a point for adding posts
if (Auth::user()->anonymous == 0) {
Auth::user()->increment('points');
}
$block->data->item_id = $item->id;
} else {
$block->data->item_id = null;
}
return $block;
}