当前位置: 首页>>代码示例>>PHP>>正文


PHP JemHelper::getValidIds方法代码示例

本文整理汇总了PHP中JemHelper::getValidIds方法的典型用法代码示例。如果您正苦于以下问题:PHP JemHelper::getValidIds方法的具体用法?PHP JemHelper::getValidIds怎么用?PHP JemHelper::getValidIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JemHelper的用法示例。


在下文中一共展示了JemHelper::getValidIds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getList

	/**
	 * Method to get the events
	 *
	 * @access public
	 * @return array
	 */
	public static function getList(&$params)
	{
		mb_internal_encoding('UTF-8');

		$db     = JFactory::getDBO();
		$user   = JemFactory::getUser();
		$levels = $user->getAuthorisedViewLevels();

		# Retrieve Eventslist model for the data
		$model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true));

		# Set params for the model
		# has to go before the getItems function
		$model->setState('params', $params);

		# filter published
		#  0: unpublished
		#  1: published
		#  2: archived
		# -2: trashed

		# type:
		#  0: upcoming (not started) - dates,times > now+offset
		#  1: unfinished (not ended) - enddates,endtimes > now+offset
		#  2: archived               - no limit, but from now back to the past
		#  3: running (today)        - enddates,endtimes > today+offset AND dates,times < tomorrow+offset
		#  4: featured               - ? (same as upcoming yet)
		$type = (int)$params->get('type');
		$offset_hours = (int)$params->get('offset_hours', 0);
		$max_title_length = (int)$params->get('cuttitle', '25');

		# clean parameter data
		$catids = JemHelper::getValidIds($params->get('catid'));
		$venids = JemHelper::getValidIds($params->get('venid'));
		$eventids = JemHelper::getValidIds($params->get('eventid'));
		$stateloc      = $params->get('stateloc');
		$stateloc_mode = $params->get('stateloc_mode', 0);

		# Open date support
		$opendates = empty($eventids) ? 0 : 1; // allow open dates if limited to specific events
		$model->setState('filter.opendates', $opendates);

		# all upcoming or unfinished events
		if (($type == 0) || ($type == 1)) {
			$offset_minutes = $offset_hours * 60;

			$model->setState('filter.published',1);
			$model->setState('filter.orderby',array('a.dates ASC','a.times ASC'));

			$cal_from = "(a.dates IS NULL OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > $offset_minutes) ";
			$cal_from .= ($type == 1) ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > $offset_minutes)) " : ") ";
		}

		# archived events only
		elseif ($type == 2) {
			$model->setState('filter.published',2);
			$model->setState('filter.orderby',array('a.dates DESC','a.times DESC'));
			$cal_from = "";
		}

		# currently running events only (today + offset is inbetween start and end date of event)
		elseif ($type == 3) {
			$offset_days = (int)round($offset_hours / 24);

			$model->setState('filter.published',1);
			$model->setState('filter.orderby',array('a.dates ASC','a.times ASC'));

			$cal_from = " ((DATEDIFF(a.dates, CURDATE()) <= $offset_days) AND (DATEDIFF(IFNULL(a.enddates,a.dates), CURDATE()) >= $offset_days))";
		}

		# featured
		elseif ($type == 4) {
			$offset_minutes = $offset_hours * 60;

			$model->setState('filter.featured',1);
			$model->setState('filter.orderby',array('a.dates ASC','a.times ASC'));

			$cal_from  = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > $offset_minutes) ";
			$cal_from .= " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > $offset_minutes)) ";
		}

		$model->setState('filter.calendar_from',$cal_from);
		$model->setState('filter.groupby','a.id');

		# filter category's
		if ($catids) {
			$model->setState('filter.category_id', $catids);
			$model->setState('filter.category_id.include', true);
		}

		# filter venue's
		if ($venids) {
			$model->setState('filter.venue_id', $venids);
			$model->setState('filter.venue_id.include', true);
//.........这里部分代码省略.........
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:101,代码来源:helper.php

示例2: getdays

	public static function getdays ($greq_year, $greq_month, &$params)
	{
		$db			= JFactory::getDBO();

		# Retrieve Eventslist model for the data
		$model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true));

		# Set params for the model
		//$app = JFactory::getApplication();
		//$appParams = $app->getParams('com_jem');
		$model->setState('params', $params);

		$user		= JemFactory::getUser();
		$levels		= $user->getAuthorisedViewLevels();
		$settings 	= JemHelper::globalattribs();

		$catids 			= JemHelper::getValidIds($params->get('catid'));
		$venids 			= JemHelper::getValidIds($params->get('venid'));
		$StraightToDetails	= $params->get('StraightToDetails', '1');
		$DisplayCat			= $params->get('DisplayCat', '0');
		$DisplayVenue		= $params->get('DisplayVenue', '0');
		$ArchivedEvents		= $params->get('ArchivedEvents', '0');
		$CurrentEvents		= $params->get('CurrentEvents', '1');
		$FixItemID			= $params->get('FixItemID', '0');
		$defaultItemid	 	= $settings->get('default_Itemid','');
		$daylinkparams		= ''; // collects additional params for link to day view

		# filter category's
		if ($catids) {
			$model->setState('filter.category_id',$catids);
			$model->setState('filter.category_id.include',true);
			$daylinkparams .= '&catids=' . implode(',', $catids);
		}

		# filter venue's
		if ($venids) {
			$model->setState('filter.venue_id',$venids);
			$model->setState('filter.venue_id.include',true);
			$daylinkparams .= '&locids=' . implode(',', $venids);
		}

		# filter published
		#  0: unpublished
		#  1: published
		#  2: archived
		# -2: trashed

		if ($CurrentEvents && $ArchivedEvents) {
			$model->setState('filter.published',array(1,2));
			$daylinkparams .= '&pub=1,2';
		} else {
			if ($CurrentEvents == 1) {
				$model->setState('filter.published',1);
				$daylinkparams .= '&pub=1';
			}

			# filter archived
			if ($ArchivedEvents == 1) {
				$model->setState('filter.published',2);
				$daylinkparams .= '&pub=2';
			}
		}

		$model->setState('filter.groupby','a.id');

		# Retrieve the available Items
		$events = $model->getItems();

		# create an array to catch days
		$days = array();

		foreach ($events as $index => $event) {
			# adding categories
			$nr 		= count($event->categories);
			$catname 	= '';
			$ix 		= 0;

			# walk through categories assigned to an event
			foreach($event->categories AS $category) {
				$catname .= htmlspecialchars($category->catname);

				$ix++;
				if ($ix != $nr) {
					$catname .= ', ';
				}
			}

			// Cope with no end date set i.e. set it to same as start date
			if (is_null($event->enddates)) {
				$eyear = $event->created_year;
				$emonth = $event->created_month;
				$eday = $event->created_day;
			} else {
				list($eyear, $emonth, $eday) = explode('-', $event->enddates);
			}
			// The two cases for roll over the year end with an event that goes across the year boundary.
			if ($greq_year < $eyear) {
				$emonth = $emonth + 12;
			}

//.........这里部分代码省略.........
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:101,代码来源:helper.php

示例3: getList

 /**
  * Method to get the events
  *
  * @access public
  * @return array
  */
 public static function getList(&$params)
 {
     mb_internal_encoding('UTF-8');
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $levels = $user->getAuthorisedViewLevels();
     # Retrieve Eventslist model for the data
     $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true));
     # Set params for the model
     # has to go before the getItems function
     $model->setState('params', $params);
     # filter published
     #  0: unpublished
     #  1: published
     #  2: archived
     # -2: trashed
     $type = (int) $params->get('type');
     $offset_hours = (int) $params->get('offset_hours', 0);
     $max_title_length = (int) $params->get('cuttitle', '25');
     # clean parameter data
     $catids = JemHelper::getValidIds($params->get('catid'));
     $venids = JemHelper::getValidIds($params->get('venid'));
     # all upcoming or unfinished events
     if ($type == 0 || $type == 1) {
         $offset_minutes = $offset_hours * 60;
         $model->setState('filter.published', 1);
         $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC'));
         $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'23:59:59'))) > {$offset_minutes}) ";
         $cal_from .= $type == 1 ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) " : ") ";
     } elseif ($type == 2) {
         $model->setState('filter.published', 2);
         $model->setState('filter.orderby', array('a.dates DESC', 'a.times DESC'));
         $cal_from = "";
     } elseif ($type == 3) {
         $offset_days = (int) round($offset_hours / 24);
         $model->setState('filter.published', 1);
         $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC'));
         $cal_from = " ((DATEDIFF(a.dates, CURDATE()) <= {$offset_days}) AND (DATEDIFF(IFNULL(a.enddates,a.dates), CURDATE()) >= {$offset_days}))";
     }
     $model->setState('filter.calendar_from', $cal_from);
     $model->setState('filter.groupby', 'a.id');
     # filter category's
     if ($catids) {
         $model->setState('filter.category_id', $catids);
         $model->setState('filter.category_id.include', true);
     }
     # filter venue's
     if ($venids) {
         $model->setState('filter.venue_id', $venids);
         $model->setState('filter.venue_id.include', true);
     }
     # count
     $count = $params->get('count', '2');
     $model->setState('list.limit', $count);
     if ($params->get('use_modal', 0)) {
         JHtml::_('behavior.modal', 'a.flyermodal');
     }
     # date/time
     $dateFormat = $params->get('formatdate', '');
     $timeFormat = $params->get('formattime', '');
     $addSuffix = empty($timeFormat);
     // if we use component's default time format we can also add corresponding suffix
     # Retrieve the available Events
     $events = $model->getItems();
     # Loop through the result rows and prepare data
     $lists = array();
     $i = 0;
     foreach ($events as $row) {
         # create thumbnails if needed and receive imagedata
         $dimage = $row->datimage ? JEMImage::flyercreator($row->datimage, 'event') : null;
         $limage = $row->locimage ? JEMImage::flyercreator($row->locimage, 'venue') : null;
         #################
         ## DEFINE LIST ##
         #################
         $lists[$i] = new stdClass();
         # cut titel
         $fulltitle = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8');
         if (mb_strlen($fulltitle) > $max_title_length) {
             $title = mb_substr($fulltitle, 0, $max_title_length) . '...';
         } else {
             $title = $fulltitle;
         }
         ## Also trim venue name to same as title
         $fullvenuename = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8');
         if (mb_strlen($fullvenuename) > $max_title_length) {
             $venue = mb_substr($fullvenuename, 0, $max_title_length) . '...';
         } else {
             $venue = $fullvenuename;
         }
         $lists[$i]->title = $title;
         $lists[$i]->fulltitle = $fulltitle;
         $lists[$i]->venue = $venue;
         $lists[$i]->fullvenue = $fullvenuename;
         $lists[$i]->catname = implode(", ", JemOutput::getCategoryList($row->categories, $params->get('linkcategory', 1)));
//.........这里部分代码省略.........
开发者ID:abradbury,项目名称:Orienteering-Website,代码行数:101,代码来源:helper.php


注:本文中的JemHelper::getValidIds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。