本文整理汇总了PHP中Criteria::addCriteriaAnd方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::addCriteriaAnd方法的具体用法?PHP Criteria::addCriteriaAnd怎么用?PHP Criteria::addCriteriaAnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria::addCriteriaAnd方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
public function build($runData)
{
$pl = $runData->getParameterList();
$this->_pl = $pl;
$site = $runData->getTemp("site");
$categoryName = $this->_readParameter(array('category', 'categories'), false);
$categoryName = strtolower($categoryName);
$startPage = $this->_readParameter(array('startPage', 'targetPage'));
if (!$startPage) {
/* Get curent page. */
$startPage = $runData->getTemp('pageUnixName');
if (!$startPage) {
$startPage = $pl->getParameterValue('page_unix_name');
// from preview
}
}
$categories = array();
$categoryNames = array();
if ($categoryName != '*') {
if (!$categoryName) {
/* No category name specified, use the current category! */
$pageUnixName = $runData->getTemp('pageUnixName');
if (!$pageUnixName) {
$pageUnixName = $pl->getParameterValue('page_unix_name');
// from preview
}
if (strpos($pageUnixName, ":") != false) {
$tmp0 = explode(':', $pageUnixName);
$categoryName = $tmp0[0];
} else {
$categoryName = "_default";
}
}
foreach (preg_split('/[,;\\s]+?/', $categoryName) as $cn) {
$category = DB_CategoryPeer::instance()->selectByName($cn, $site->getSiteId());
if ($category) {
$categories[] = $category;
$categoryNames[] = $category->getName();
}
}
if (count($categories) == 0) {
throw new ProcessException('The requested categories do not (yet) exist.');
}
}
//if(count($categories) == 0){
// throw new ProcessException(_("The category can not be found."));
//}
$attrUrlPrefix = $pl->getParameterValue('urlAttrPrefix');
// now select pages according to the specified criteria
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
if (count($categories) > 0) {
$ccat = new Criteria();
foreach ($categories as $cat) {
$ccat->addOr('category_id', $cat->getCategoryId());
}
$c->addCriteriaAnd($ccat);
}
$c->add('unix_name', '(^|:)_', '!~');
/* Handle tags! */
$tagString = $this->_readParameter(array('tag', 'tags'), true);
//var_dump($tagString);
if ($tagString) {
/* Split tags. */
$tags = preg_split(';[\\s,\\;]+;', $tagString);
$tagsAny = array();
$tagsAll = array();
$tagsNone = array();
foreach ($tags as $t) {
if (substr($t, 0, 1) == '+') {
$tagsAll[] = substr($t, 1);
} elseif (substr($t, 0, 1) == '-') {
$tagsNone[] = substr($t, 1);
} elseif ($t == '=') {
/* It means: any tags of the current page. */
if ($runData->getTemp('page')) {
$pageId = $runData->getTemp('page')->getPageId();
$co = new Criteria();
$co->add("page_id", $pageId);
$co->addOrderAscending("tag");
$tagso = DB_PageTagPeer::instance()->select($co);
foreach ($tagso as $to) {
$tagsAny[] = $to->getTag();
}
if (count($tagsAny) == 0) {
/*
* If someone uses the '=' tag, the line below guarantees that
* only pages that DO have tags and share at least one similar tag with the
* current page are listed.
*/
$tagsAny[] = ' ';
}
}
} else {
$tagsAny[] = $t;
}
}
/* ANY */
if (count($tagsAny) > 0) {
$t = array();
//.........这里部分代码省略.........
示例2: build
public function build($runData)
{
// select recent revisions...
$site = $runData->getTemp("site");
$pl = $runData->getParameterList();
// get options
$pageNumber = $pl->getParameterValue("page");
$op = $pl->getParameterValue("options");
if ($pageNumber === null) {
$pageNumber = 1;
}
if ($op) {
$json = new JSONService(SERVICES_JSON_LOOSE_TYPE);
$o = $json->decode($op);
}
if (count($o) == 0) {
$o['all'] == true;
}
$perPage = $pl->getParameterValue("perpage");
if ($perPage == null) {
$perPage = 20;
}
$offset = ($pageNumber - 1) * $perPage;
$count = $perPage * 2 + 1;
$c = new Criteria();
$c->add("page_revision.site_id", $site->getSiteId());
if (!$o['all'] && count($o) > 0) {
$c2 = new Criteria();
if ($o['new']) {
$c2->addOr("flag_new", true);
}
if ($o['source']) {
$c2->addOr("flag_text", true);
}
if ($o['title']) {
$c2->addOr("flag_title", true);
}
if ($o['move']) {
$c2->addOr("flag_rename", true);
}
if ($o['meta']) {
$c2->addOr("flag_meta", true);
}
if ($o['files']) {
$c2->addOr("flag_file", true);
}
$c->addCriteriaAnd($c2);
}
$categoryId = $pl->getParameterValue("categoryId");
if ($categoryId && is_numeric($categoryId)) {
$c->add("page.category_id", $categoryId);
}
$c->addJoin("page_id", "page.page_id");
$c->addJoin("user_id", "ozone_user.user_id");
$c->addOrderDescending("page_revision.revision_id");
$c->setLimit($count, $offset);
$revisions = DB_PageRevisionPeer::instance()->select($c);
$counted = count($revisions);
$pagerData = array();
$pagerData['currentPage'] = $pageNumber;
if ($counted > $perPage * 2) {
$knownPages = $pageNumber + 2;
$pagerData['knownPages'] = $knownPages;
} elseif ($counted > $perPage) {
$knownPages = $pageNumber + 1;
$pagerData['totalPages'] = $knownPages;
} else {
$totalPages = $pageNumber;
$pagerData['totalPages'] = $totalPages;
}
$revisions = array_slice($revisions, 0, $perPage);
$runData->contextAdd("pagerData", $pagerData);
$runData->contextAdd("revisions", $revisions);
$runData->contextAdd("revisionsCount", count($revisions));
}
示例3: build
public function build($runData)
{
$pl = $runData->getParameterList();
$site = $runData->getTemp("site");
$categoryName = $pl->getParameterValue("category");
$order = $pl->getParameterValue("order");
$limit = $pl->getParameterValue("limit");
$perPage = $pl->getParameterValue("perPage");
$categories = array();
$categoryNames = array();
foreach (preg_split('/[,;\\s]+?/', $categoryName) as $cn) {
$category = DB_CategoryPeer::instance()->selectByName($cn, $site->getSiteId());
if ($category) {
$categories[] = $category;
$categoryNames[] = $category->getName();
}
}
//if(count($categories) == 0){
// throw new ProcessException(_("The category can not be found."));
//}
// now select pages according to the specified criteria
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
if (count($categories) > 0) {
$ccat = new Criteria();
foreach ($categories as $cat) {
$ccat->addOr('category_id', $cat->getCategoryId());
}
$c->addCriteriaAnd($ccat);
}
$c->add('unix_name', '(^|:)_', '!~');
/* Handle tags! */
$tagString = $pl->getParameterValue("tag");
if (!$tagString) {
$tagString = $pl->getParameterValue("tags");
}
if ($tagString) {
/* Split tags. */
$tags = preg_split(';[\\s,\\;]+;', $tagString);
$tagsAny = array();
$tagsAll = array();
$tagsNone = array();
foreach ($tags as $t) {
if (substr($t, 0, 1) == '+') {
$tagsAll[] = substr($t, 1);
} elseif (substr($t, 0, 1) == '-') {
$tagsNone[] = substr($t, 1);
} else {
$tagsAny[] = $t;
}
}
/* Create extra conditions to the SELECT */
/* ANY */
if (count($tagsAny) > 0) {
$t = array();
foreach ($tagsAny as $tag0) {
$t[] = 'tag = \'' . db_escape_string($tag0) . '\'';
}
$tagQuery = "SELECT count(*) FROM page_tag " . "WHERE page_tag.page_id=page.page_id " . "AND (" . implode(' OR ', $t) . ")";
$c->add('(' . $tagQuery . ')', 1, '>=');
}
/* ALL */
if (count($tagsAll) > 0) {
$t = array();
foreach ($tagsAll as $tag0) {
$t[] = 'tag = \'' . db_escape_string($tag0) . '\'';
}
$tagQuery = "SELECT count(*) FROM page_tag " . "WHERE page_tag.page_id=page.page_id " . "AND (" . implode(' OR ', $t) . ")";
$c->add('(' . $tagQuery . ')', count($tagsAll));
}
/* NONE */
if (count($tagsNone) > 0) {
$t = array();
foreach ($tagsNone as $tag0) {
$t[] = 'tag = \'' . db_escape_string($tag0) . '\'';
}
$tagQuery = "SELECT count(*) FROM page_tag " . "WHERE page_tag.page_id=page.page_id " . "AND (" . implode(' OR ', $t) . ")";
$c->add('(' . $tagQuery . ')', 0);
}
}
/* Handle date ranges. */
$date = $pl->getParameterValue("date");
$dateA = array();
if (preg_match(';^[0-9]{4};', $date)) {
$dateA['year'] = $date;
}
if (preg_match(';^[0-9]{4}\\.[0-9]{1,2};', $date)) {
$dateS = explode('.', $date);
$dateA['year'] = $dateS[0];
$dateA['month'] = $dateS[1];
}
if (isset($dateA['year'])) {
$c->add('EXTRACT(YEAR FROM date_created)', $dateA['year']);
}
if (isset($dateA['month'])) {
$c->add('EXTRACT(MONTH FROM date_created)', $dateA['month']);
}
/* Handle pagination. */
if (!$perPage || !preg_match(';^[0-9]+$;', $perPage)) {
$perPage = 20;
//.........这里部分代码省略.........
示例4: build
public function build($runData)
{
$pl = $runData->getParameterList();
$query = trim($pl->getParameterValue("q"));
$site = $runData->getTemp("site");
if (!$query || $query == '') {
return;
}
if (strlen($query) < 3) {
$runData->contextAdd("query", $query);
$runData->contextAdd("errorMessage", _("Your query should be at least 3 characters long."));
return;
}
// pagination
$pageNumber = $pl->getParameterValue("p");
if ($pageNumber == null || !is_numeric($pageNumber) || $pageNumber < 1) {
$pageNumber = 1;
}
$perPage = 10;
// determine the mode: by email or by screenname/realname/unixname
if (strpos($query, '@')) {
// email lookup mode
$c = new Criteria();
$c->add("ozone_user.name", $query);
$user = DB_OzoneUserPeer::instance()->selectOne($c);
$runData->contextAdd("user", $user);
$runData->contextAdd("mode", "email");
sleep(2);
} else {
// normal search. perform a regexp search at the moment.
$qs = preg_split('/ +/', trim($query));
$c = new Criteria();
foreach ($qs as $q) {
$csub = new Criteria();
$csub->add("ozone_user.nick_name", preg_quote($q), '~*');
$csub->addOr("ozone_user.unix_name", preg_quote($q), '~*');
$csub->addOr("profile.real_name", preg_quote($q), '~*');
$c->addCriteriaAnd($csub);
}
$c->addJoin("user_id", "profile.user_id");
$limit = $perPage * 2 + 1;
$offset = ($pageNumber - 1) * $perPage;
$c->setLimit($limit, $offset);
$res = DB_OzoneUserPeer::instance()->select($c);
$counted = count($res);
$pagerData = array();
$pagerData['current_page'] = $pageNumber;
if ($counted > $perPage * 2) {
$knownPages = $pageNumber + 2;
$pagerData['known_pages'] = $knownPages;
} elseif ($counted > $perPage) {
$knownPages = $pageNumber + 1;
$pagerData['total_pages'] = $knownPages;
} else {
$totalPages = $pageNumber;
$pagerData['total_pages'] = $totalPages;
}
$res = array_slice($res, 0, $perPage);
}
$runData->contextAdd("pagerData", $pagerData);
$runData->contextAdd("users", $res);
$runData->contextAdd("countResults", count($res));
$runData->contextAdd("query", $query);
$runData->contextAdd("encodedQuery", urldecode($query));
$runData->contextAdd("queryEncoded", urlencode($query));
}
示例5: build
public function build($runData)
{
$site = $runData->getTemp("site");
$pl = $runData->getParameterList();
$pageId = $pl->getParameterValue("page_id");
$pageNumber = $pl->getParameterValue("page");
$perPage = $pl->getParameterValue("perpage");
$json = new JSONService(SERVICES_JSON_LOOSE_TYPE);
$o = $json->decode($pl->getParameterValue("options"));
$offset = ($pageNumber - 1) * $perPage;
$count = $perPage * 2 + 1;
// get the page
$page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
if ($page == null || $page->getSiteId() !== $site->getSiteId()) {
throw new ProcessException(_("Error selecting the page."), "no_page");
}
$c = new Criteria();
$c->add('page_id', $pageId);
// check options
if (!$o['all'] && count($o) > 0) {
$c2 = new Criteria();
if ($o['new']) {
$c2->addOr("flag_new", true);
}
if ($o['source']) {
$c2->addOr("flag_text", true);
}
if ($o['title']) {
$c2->addOr("flag_title", true);
}
if ($o['move']) {
$c2->addOr("flag_rename", true);
}
if ($o['meta']) {
$c2->addOr("flag_meta", true);
}
if ($o['files']) {
$c2->addOr("flag_file", true);
}
$c->addCriteriaAnd($c2);
}
$c->addJoin("user_id", "ozone_user.user_id");
$c->addOrderDescending('revision_id');
$c->setLimit($count, $offset);
$pr = DB_PageRevisionPeer::instance()->select($c);
// now see if number of selected is equal $perPage + 1. If so -
// there is at least 1 more page to show...
$counted = count($pr);
$pagerData = array();
$pagerData['current_page'] = $pageNumber;
if ($counted > $perPage * 2) {
$knownPages = $pageNumber + 2;
$pagerData['known_pages'] = $knownPages;
} elseif ($counted > $perPage) {
$knownPages = $pageNumber + 1;
$pagerData['total_pages'] = $knownPages;
} else {
$totalPages = $pageNumber;
$pagerData['total_pages'] = $totalPages;
}
$pr = array_slice($pr, 0, $perPage);
$runData->contextAdd("pagerData", $pagerData);
$runData->contextAdd("page", $page);
$runData->contextAdd("currentRevision", $page->getCurrentRevision());
$runData->contextAdd("revisions", $pr);
}
示例6: build
public function build($runData)
{
$pl = $runData->getParameterList();
$site = $runData->getTemp("site");
$categoryIds = $pl->getParameterValue("category");
$limit = $pl->getParameterValue("limit");
$offset = $pl->getParameterValue("offset");
if ($limit == null) {
$limit = 20;
}
if ($categoryIds === null) {
throw new ProcessException(_('No forum category has been specified. Please use attribute category="id" where id is the index number of the category.'), "no_category");
}
if (strlen($categoryIds) > 90) {
throw new ProcessException(_("Category string too long."), "max_categories");
}
$cats = preg_split('/[,;] ?/', $categoryIds);
$ccat = new Criteria();
$categories = array();
if (count($cats) > 20) {
throw new ProcessException(_("Maximum number of categories exceeded."), "max_categories");
}
foreach ($cats as $categoryId) {
if ($categoryId === null || !is_numeric($categoryId)) {
throw new ProcessException(_('Problem parsing attribute "category".'), "no_category");
}
$category = DB_ForumCategoryPeer::instance()->selectByPrimaryKey($categoryId);
if ($category == null) {
throw new ProcessException(_('Requested forum category does not exist.'), "no_category");
}
if ($category->getSiteId() !== $site->getSiteId()) {
$fSite = DB_SitePeer::instance()->selectByPrimaryKey($category->getSiteId());
if ($fSite->getPrivate()) {
throw new ProcessException(_('The requested category belongs to a private site.'), "no_category");
}
}
$category->setTemp("group", $category->getForumGroup());
$categories[$category->getCategoryId()] = $category;
$ccat->addOr("category_id", $category->getCategoryId());
}
$c = new Criteria();
$c->addCriteriaAnd($ccat);
$c->addOrderDescending("thread_id");
$c->setLimit($limit, $offset);
$threads = DB_ForumThreadPeer::instance()->select($c);
$format = $pl->getParameterValue("module_body");
if ($format == null || $format == '') {
$format = "" . "+ %%linked_title%%\n\n" . _("by") . " %%author%% %%date|%O ago (%e %b %Y, %H:%M %Z)%%\n\n" . "%%content%%\n\n%%comments%% | " . _("category") . ": %%category%%";
}
// process the format and create the message template
$wt = new WikiTransformation();
$wt->setMode("feed");
$template = $wt->processSource($format);
$template = preg_replace('/<p\\s*>\\s*(%%((?:short)|(?:description)|(?:summary)|(?:content)|(?:long)|(?:body)|(?:text))%%)\\s*<\\/\\s*p>/smi', "<div>\\1</div>", $template);
$items = array();
foreach ($threads as $thread) {
$post = $thread->getFirstPost();
if (!$post) {
continue;
}
$b = $template;
$b = str_ireplace("%%title%%", htmlspecialchars($thread->getTitle()), $b);
$b = preg_replace("/%%((linked_title)|(title_linked))%%/i", preg_quote_replacement('<a href="/forum/t-' . $thread->getThreadId() . '/' . $thread->getUnixifiedTitle() . '">' . htmlspecialchars($thread->getTitle()) . '</a>'), $b);
$b = str_ireplace("%%author%%", WDRenderUtils::renderUser($thread->getUserOrString(), array("image" => true)), $b);
$dateString = '<span class="odate">' . $thread->getDateStarted()->getTimestamp() . '|%e %b %Y, %H:%M %Z|agohover</span>';
$b = str_ireplace('%%date%%', $dateString, $b);
$b = preg_replace('/%%date\\|(.*?)%%/i', '<span class="odate">' . preg_quote_replacement($thread->getDateStarted()->getTimestamp()) . '|\\1</span>', $b);
$b = str_ireplace("%%comments%%", '<a href="/forum/t-' . $thread->getThreadId() . '/' . $thread->getUnixifiedTitle() . '">' . _('Comments') . ': ' . ($thread->getNumberPosts() - 1) . '</a>', $b);
$b = str_ireplace("%%link%%", '/forum/t-' . $thread->getThreadId() . '/' . $thread->getUnixifiedTitle(), $b);
$category = $categories[$thread->getCategoryId()];
$b = str_ireplace("%%category%%", '<a href="/forum/c-' . $category->getCategoryId() . '/' . $category->getUnixifiedName() . '">' . htmlspecialchars($category->getTemp("group")->getName() . " / " . $category->getName()) . '</a>', $b);
$b = preg_replace("/%%((description)|(short)|(summary))%%/i", preg_quote_replacement(htmlspecialchars($thread->getDescription())), $b);
$b = preg_replace("/%%((body)|(text)|(long)|(content))%%/i", preg_quote_replacement($post->getText()), $b);
$items[] = $b;
}
$runData->contextAdd("items", $items);
// post a feed???
$flabel = WDStringUtils::toUnixName($pl->getParameterValue("feed"));
$page = $runData->getTemp("page");
if ($flabel && $page) {
$ftitle = trim($pl->getParameterValue("feedTitle"));
if ($ftitle == '') {
$ftitle = $site->getName() . " feed";
}
$fdescription = $pl->getParameterValue("feedDescription");
$fcats = trim($categoryIds);
$parmhash = crc32($ftitle . " " . $fcats);
// first check the memcache!!! to avoid db connection.
// get the feed object
$c = new Criteria();
$c->add("page_id", $page->getPageId());
$c->add("label", $flabel);
$feed = DB_FrontForumFeedPeer::instance()->selectOne($c);
if ($feed == null) {
// create the feed
$feed = new DB_FrontForumFeed();
$feed->setLabel($flabel);
$feed->setTitle($ftitle);
$feed->setCategories($fcats);
$feed->setPageId($page->getPageId());
//.........这里部分代码省略.........
示例7: removeSignaturesEvent
public function removeSignaturesEvent($runData)
{
$site = $runData->getTemp("site");
$pl = $runData->getParameterList();
$campaignId = $pl->getParameterValue("campaignId");
$ids = $pl->getParameterValue("ids");
$db = Database::connection();
$db->begin();
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
$c->add("deleted", false);
$c->add("campaign_id", $campaignId);
$camp = DB_PetitionCampaignPeer::instance()->selectOne($c);
if (!$camp) {
throw new ProcessException(_("The campaign can not be found."));
}
$ids = explode(',', $ids);
// create a delete query.
$c1 = new Criteria();
foreach ($ids as $id) {
$c1->addOr("signature_id", $id);
}
$c = new Criteria();
$c->add("campaign_id", $camp->getCampaignId());
$c->addCriteriaAnd($c1);
DB_PetitionSignaturePeer::instance()->delete($c);
$camp->updateNumberSignatures();
$camp->save();
$db->commit();
}
示例8: build
public function build($runData)
{
$site = $runData->getTemp("site");
$pl = $runData->getParameterList();
$pageName = $pl->getParameterValue("page");
$label = $pl->getParameterValue("label");
// get the feed object
$page = DB_PagePeer::instance()->selectByName($site->getSiteId(), $pageName);
if (!$page) {
throw new ProcessException(_("No such page."), "no_page");
}
$c = new Criteria();
$c->add("page_id", $page->getPageId());
$c->add("label", $label);
$feed = DB_FrontForumFeedPeer::instance()->selectOne($c);
$categoryIds = $feed->getCategories();
$cats = preg_split('/[,;] ?/', $categoryIds);
$ccat = new Criteria();
$categories = array();
if (count($cats) > 20) {
throw new ProcessException(_("Maximum number of categories exceeded."), "max_categories");
}
// get page
$page = DB_PagePeer::instance()->selectByPrimaryKey($feed->getPageId());
if (!$page) {
throw new ProcessException(_("Page can not be found."), "no_page");
}
foreach ($cats as $categoryId) {
if ($categoryId === null || !is_numeric($categoryId)) {
throw new ProcessException(_('Problem parsing attribute "category".'), "no_category");
}
$category = DB_ForumCategoryPeer::instance()->selectByPrimaryKey($categoryId);
if ($category == null || $category->getSiteId() !== $site->getSiteId()) {
throw new ProcessException(_("Requested forum category does not exist."), "no_category");
}
$categories[$category->getCategoryId()] = $category;
$ccat->addOr("category_id", $category->getCategoryId());
}
$c = new Criteria();
$c->addCriteriaAnd($ccat);
$c->addOrderDescending("thread_id");
$c->setLimit(30);
$threads = DB_ForumThreadPeer::instance()->select($c);
$channel['title'] = $feed->getTitle();
$channel['link'] = "http://" . $site->getDomain() . "/" . $page->getUnixName();
if ($feed->getDescription()) {
$channel['description'] = $feed->getDescription();
}
$items = array();
foreach ($threads as $thread) {
$item = array();
$item['title'] = $thread->getTitle();
$item['link'] = "http://" . $site->getDomain() . "/forum/t-" . $thread->getThreadId() . '/' . $thread->getUnixifiedTitle();
$item['guid'] = $item['link'];
$item['date'] = date('r', $thread->getDateStarted()->getTimestamp());
$item['category'] = $thread->getCategory()->getName();
//replace relative links with absolute links!
$post = $thread->getFirstPost();
if (!$post) {
continue;
}
$content = $post->getText();
$content = preg_replace(';(<.*?)(src|href)="/([^"]+)"([^>]*>);si', '\\1\\2="http://' . $site->getDomain() . '/\\3"\\4', $content);
$content = preg_replace(';<script\\s+[^>]+>.*?</script>;is', '', $content);
$content = preg_replace(';(<[^>]*\\s+)on[a-z]+="[^"]+"([^>]*>);si', '\\1 \\2', $content);
if ($thread->getDescription()) {
$item['description'] = $thread->getDescription();
}
$item['content'] = $content;
if ($post->getUserId() > 0) {
$item['authorUserId'] = $post->getUserId();
$user = $post->getUser();
$item['author'] = $user->getNickName();
} else {
$item['author'] = $post->getUserString();
}
$items[] = $item;
}
$runData->contextAdd("channel", $channel);
$runData->contextAdd("items", $items);
}
示例9: build
public function build($runData)
{
// select recent revisions...
$site = $runData->getTemp("site");
$pl = $runData->getParameterList();
$userId = $pl->getParameterValue("userId");
if ($runData->getUser() && $userId == $runData->getUser()->getUserId()) {
$own = true;
}
// get user
//if($userId
$user = DB_OzoneUserPeer::instance()->selectByPrimaryKey($userId);
if ($user == null) {
throw new ProcessException(_("Error selecting user."), "no_user");
}
// get options
$pageNumber = $pl->getParameterValue("page");
$op = $pl->getParameterValue("options");
if ($pageNumber === null) {
$pageNumber = 1;
}
if ($op) {
$json = new JSONService(SERVICES_JSON_LOOSE_TYPE);
$o = $json->decode($op);
}
if (count($o) == 0) {
$o['all'] == true;
}
$perPage = $pl->getParameterValue("perpage");
if ($perPage == null) {
$perPage = 20;
}
$offset = ($pageNumber - 1) * $perPage;
$count = $perPage * 2 + 1;
$c = new Criteria();
$c->add("page_revision.user_id", $user->getUserId());
if (!$own) {
$c->add("site.private", false);
}
if (!$o['all'] && count($o) > 0) {
$c2 = new Criteria();
if ($o['new']) {
$c2->addOr("flag_new", true);
}
if ($o['source']) {
$c2->addOr("flag_text", true);
}
if ($o['title']) {
$c2->addOr("flag_title", true);
}
if ($o['move']) {
$c2->addOr("flag_rename", true);
}
if ($o['meta']) {
$c2->addOr("flag_meta", true);
}
if ($o['files']) {
$c2->addOr("flag_file", true);
}
$c->addCriteriaAnd($c2);
}
$c->addJoin("page_revision.page_id", "page.page_id");
$c->addJoin("page.site_id", "site.site_id");
$c->add("site.deleted", false);
$c->addOrderDescending("page_revision.revision_id");
$c->setLimit($count, $offset);
$revisions = DB_PageRevisionPeer::instance()->select($c);
$counted = count($revisions);
$pagerData = array();
$pagerData['currentPage'] = $pageNumber;
if ($counted > $perPage * 2) {
$knownPages = $pageNumber + 2;
$pagerData['knownPages'] = $knownPages;
} elseif ($counted > $perPage) {
$knownPages = $pageNumber + 1;
$pagerData['totalPages'] = $knownPages;
} else {
$totalPages = $pageNumber;
$pagerData['totalPages'] = $totalPages;
}
$revisions = array_slice($revisions, 0, $perPage);
$runData->contextAdd("pagerData", $pagerData);
$runData->contextAdd("revisions", $revisions);
$runData->contextAdd("revisionsCount", count($revisions));
}
示例10: removeSelectedDraftsEvent
public function removeSelectedDraftsEvent($runData)
{
$userId = $runData->getUserId();
$c = new Criteria();
$c->add("from_user_id", $userId);
$c->add("flag", 2);
$selected = $runData->getParameterList()->getParameterValue("selected");
$json = new JSONService(SERVICES_JSON_LOOSE_TYPE);
$selected = $json->decode($selected);
$db = Database::connection();
$db->begin();
$c2 = new Criteria();
foreach ($selected as $s) {
$c2->addOr("message_id", $s);
}
$c->addCriteriaAnd($c2);
DB_PrivateMessagePeer::instance()->delete($c);
$db->commit();
}
示例11: build
public function build($runData)
{
$pl = $runData->getParameterList();
$site = $runData->getTemp("site");
$categoryName = $this->_readParameter(array('category', 'categories'), false);
$categoryName = strtolower($categoryName);
$order = $this->_readParameter("order", true);
$limit = $this->_readParameter("limit", true);
$perPage = $this->_readParameter("perPage", true);
$skipCurrent = $this->_readParameter('skipCurrent');
if ($skipCurrent && ($skipCurrent == 'yes' || $skipCurrent == 'true')) {
$skipCurrent = true;
} else {
$skipCurrent = false;
}
$pageUnixName = $runData->getTemp('pageUnixName');
if (!$pageUnixName) {
$pageUnixName = $pl->getParameterValue('page_unix_name');
// from preview
}
$categories = array();
$categoryNames = array();
if ($categoryName != '*') {
if (!$categoryName) {
/* No category name specified, use the current category! */
if (strpos($pageUnixName, ":") != false) {
$tmp0 = explode(':', $pageUnixName);
$categoryName = $tmp0[0];
} else {
$categoryName = "_default";
}
}
foreach (preg_split('/[,;\\s]+?/', $categoryName) as $cn) {
$category = DB_CategoryPeer::instance()->selectByName($cn, $site->getSiteId());
if ($category) {
$categories[] = $category;
$categoryNames[] = $category->getName();
}
}
if (count($categories) == 0) {
throw new ProcessException('The requested categories do not (yet) exist.');
}
}
//if(count($categories) == 0){
// throw new ProcessException(_("The category can not be found."));
//}
// now select pages according to the specified criteria
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
if (count($categories) > 0) {
$ccat = new Criteria();
foreach ($categories as $cat) {
$ccat->addOr('category_id', $cat->getCategoryId());
}
$c->addCriteriaAnd($ccat);
}
$c->add('unix_name', '(^|:)_', '!~');
/* Handle magic previousBy/nextBy keywords */
$previousBy = $this->_readParameter('previousBy', true);
$nextBy = $this->_readParameter('nextBy', true);
if ($previousBy || $nextBy) {
if ($refPage = $runData->getTemp('page')) {
$refPageId = $refPage->getPageId();
$refPageTitle = $refPage->getTitle() . ' ... ' . $refPage->getUnixName();
if ($previousBy == 'page_id') {
$c->add('page_id', $refPageId, '<');
} elseif ($nextBy == 'page_id') {
$c->add('page_id', $refPageId, '>');
} elseif ($previousBy == 'title') {
$c->add("title || ' ... ' || unix_name", $refPageTitle, '<');
} elseif ($nextBy == 'title') {
$c->add("title || ' ... ' || unix_name", $refPageTitle, '>');
}
} else {
$c->add('page_id', 0);
// this should be simply never;
}
}
/* Handle tags! */
$tagString = $this->_readParameter(array('tag', 'tags'), true);
if ($tagString) {
/* Split tags. */
$tags = preg_split(';[\\s,\\;]+;', $tagString);
$tagsAny = array();
$tagsAll = array();
$tagsNone = array();
foreach ($tags as $t) {
if (substr($t, 0, 1) == '+') {
$tagsAll[] = substr($t, 1);
} elseif (substr($t, 0, 1) == '-') {
$tagsNone[] = substr($t, 1);
} elseif ($t == '=') {
/* It means: any tags of the current page. */
if ($runData->getTemp('page')) {
$pageId = $runData->getTemp('page')->getPageId();
$co = new Criteria();
$co->add("page_id", $pageId);
$co->addOrderAscending("tag");
$tagso = DB_PageTagPeer::instance()->select($co);
foreach ($tagso as $to) {
//.........这里部分代码省略.........
示例12: recompileInclusionDeps
private function recompileInclusionDeps($page)
{
// get deps
$site = $GLOBALS['site'];
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
if (is_string($page)) {
$c->add("included_page_name", $page);
} else {
$c2 = new Criteria();
$c2->add("included_page_id", $page->getPageId());
$c2->addOr("included_page_name", $page->getUnixName());
$c->addCriteriaAnd($c2);
}
$dbinclusions = DB_PageInclusionPeer::instance()->select($c);
foreach ($dbinclusions as $inc) {
$page = DB_PagePeer::instance()->selectByPrimaryKey($inc->getIncludingPageId());
// triger source update (recompile)
$outdater = new Outdater($this->recurrenceLevel);
$outdater->pageEvent("source_changed", $page);
}
}