當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Komento::mergeOptions方法代碼示例

本文整理匯總了PHP中Komento::mergeOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Komento::mergeOptions方法的具體用法?PHP Komento::mergeOptions怎麽用?PHP Komento::mergeOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Komento的用法示例。


在下文中一共展示了Komento::mergeOptions方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getTotalPopularComments

 function getTotalPopularComments($component = 'all', $cid = 'all', $options = array())
 {
     // define default values
     $defaultOptions = array('start' => 0, 'limit' => 10, 'userid' => 'all', 'sticked' => 'all', 'published' => 1, 'minimumlikes' => 0, 'random' => 0);
     $querySelect = '';
     $queryWhere = array();
     $queryGroup = '';
     $queryOrder = '';
     $queryLimit = '';
     // take the input values and clear unexisting keys
     $options = Komento::mergeOptions($defaultOptions, $options);
     $querySelect = 'SELECT comments.*, COUNT(actions.comment_id) AS likes FROM ' . $this->db->nameQuote('#__komento_comments') . ' AS comments';
     $querySelect .= ' LEFT JOIN ' . $this->db->nameQuote('#__komento_actions') . ' AS actions ON comments.id = actions.comment_id';
     if ($component !== 'all') {
         $queryWhere[] = 'comments.component = ' . $this->db->quote($component);
     }
     if ($cid !== 'all') {
         if (is_array($cid)) {
             $cid = implode(',', $cid);
         }
         if (empty($cid)) {
             $queryWhere[] = 'comments.cid = 0';
         } else {
             $queryWhere[] = 'comments.cid IN (' . $cid . ')';
         }
     }
     if ($options['userid'] !== 'all') {
         $queryWhere[] = 'comments.created_by = ' . $this->db->quote($options['userid']);
     }
     if ($options['published'] !== 'all') {
         $queryWhere[] = 'comments.published = ' . $this->db->quote($options['published']);
     }
     if ($options['sticked'] !== 'all') {
         $queryWhere[] = 'comments.sticked = ' . $this->db->quote(1);
     }
     $queryWhere[] = 'actions.type = ' . $this->db->quote('likes');
     if (count($queryWhere) > 0) {
         $queryWhere = ' WHERE ' . implode(' AND ', $queryWhere);
     } else {
         $queryWhere = '';
     }
     $queryGroup = ' GROUP BY actions.comment_id';
     if ($options['minimumlikes'] > 0) {
         $queryGroup .= ' HAVING likes >= ' . $options['minimumlikes'];
     }
     $query = 'SELECT COUNT(1) FROM (' . $querySelect . $queryWhere . $queryGroup . ') AS x';
     $this->db->setQuery($query);
     return $this->db->loadResult();
 }
開發者ID:BetterBetterBetter,項目名稱:B3App,代碼行數:49,代碼來源:comments.php

示例2: addJomSocialActivity

	public static function addJomSocialActivity( $options = array() )
	{
		$defaultOptions = array(
			'comment'		=> '',
			'title'			=> '',
			'content'		=> '',
			'cmd'			=> '',
			'actor'			=> '',
			'target'		=> 0,
			'app'			=> '',
			'cid'			=> '',
			'comment_id'	=> '',
			'comment_type'	=> '',
			'like_id'		=> '',
			'like_type'		=> ''

		);

		$options = Komento::mergeOptions( $defaultOptions, $options );

		$jsCoreFile	= JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php';
		$config		= Komento::getConfig();

		if( !JFile::exists( $jsCoreFile ) )
		{
			return false;
		}
		require_once( $jsCoreFile );

		$obj				= (object) $options;

		// add JomSocial activities
		CFactory::load ( 'libraries', 'activities' );
		CActivityStream::add( $obj );
	}
開發者ID:kosmosby,項目名稱:medicine-prof,代碼行數:35,代碼來源:activity.php

示例3: getCommentCount

 function getCommentCount($options = array())
 {
     $query = 'SELECT COUNT(1) FROM `#__easyblog_comment`';
     $defaultOptions = array('post_id' => 'all');
     $options = Komento::mergeOptions($defaultOptions, $options);
     $queryWhere = array();
     if (!empty($options['post_id']) && $options['post_id'] !== 'all') {
         $options['post_id'] = (array) $options['post_id'];
         $queryWhere[] = $this->_db->namequote('post_id') . ' IN (' . implode(',', $options['post_id']) . ')';
     }
     if (count($queryWhere) > 0) {
         $query .= ' WHERE ' . implode(' AND ', $queryWhere);
     }
     $this->_db->setQuery($query);
     return $this->_db->loadResult();
 }
開發者ID:kosmosby,項目名稱:medicine-prof,代碼行數:16,代碼來源:migrators.php


注:本文中的Komento::mergeOptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。