Merge branch 'develop' into pr/advanced-mailer

This commit is contained in:
Kijin Sung 2016-05-15 20:22:55 +09:00
commit 1f39a51c66
48 changed files with 466 additions and 603 deletions

View file

@ -97,6 +97,12 @@ class Context
* @var array
*/
public $opengraph_metadata = array();
/**
* Canonical URL
* @var string
*/
public $canonical_url = '';
/**
* path of Xpress Engine
@ -587,7 +593,7 @@ class Context
$db_info->sitelock_whitelist = count($config['lock']['allow']) ? $config['lock']['allow'] : array('127.0.0.1');
$db_info->embed_white_iframe = $config['mediafilter']['iframe'] ?: $config['embedfilter']['iframe'];
$db_info->embed_white_object = $config['mediafilter']['object'] ?: $config['embedfilter']['object'];
$db_info->use_mobile_view = $config['use_mobile_view'] ? 'Y' : 'N';
$db_info->use_mobile_view = (isset($config['mobile']['enabled']) ? $config['mobile']['enabled'] : $config['use_mobile_view']) ? 'Y' : 'N';
$db_info->use_prepared_statements = $config['use_prepared_statements'] ? 'Y' : 'N';
$db_info->use_rewrite = $config['use_rewrite'] ? 'Y' : 'N';
$db_info->use_sso = $config['use_sso'] ? 'Y' : 'N';
@ -2804,7 +2810,7 @@ class Context
*/
public static function setCanonicalURL($url)
{
self::addHtmlHeader(sprintf('<link rel="canonical" href="%s" />', escape($url)));
self::$_instance->canonical_url = escape($url);
}
}
/* End of file Context.class.php */

View file

@ -414,32 +414,35 @@ class HTMLDisplayHandler
Context::addOpenGraphData('og:site_name', Context::getSiteTitle());
if ($page_type === 'article' && config('seo.og_extract_description'))
{
Context::addOpenGraphData('og:description', trim(utf8_normalize_spaces($oDocument->getContentText(200))));
$description = trim(utf8_normalize_spaces($oDocument->getContentText(200)));
}
else
{
Context::addOpenGraphData('og:description', Context::getMetaTag('description'));
$description = Context::getMetaTag('description');
}
Context::addOpenGraphData('og:description', $description);
Context::addMetaTag('description', $description);
// Add metadata about this page.
Context::addOpenGraphData('og:type', $page_type);
if ($page_type === 'article')
{
$document_canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl);
Context::addOpenGraphData('og:url', $document_canonical_url);
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl);
}
elseif (($page = Context::get('page')) > 1)
{
Context::addOpenGraphData('og:url', getFullUrl('', 'mid', $current_module_info->mid, 'page', $page));
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'page', $page);
}
elseif ($current_module_info->module_srl == $site_module_info->module_srl)
{
Context::addOpenGraphData('og:url', Rhymix\Framework\URL::getCurrentDomainURL(\RX_BASEURL));
$canonical_url = getFullUrl('');
}
else
{
Context::addOpenGraphData('og:url', getFullUrl('', 'mid', $current_module_info->mid));
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid);
}
Context::addOpenGraphData('og:url', $canonical_url);
Context::setCanonicalURL($canonical_url);
// Add metadata about the locale.
$lang_type = Context::getLangType();

View file

@ -12,113 +12,74 @@ class Mobile
* Whether mobile or not mobile mode
* @var bool
*/
public $ismobile = NULL;
protected static $_ismobile = null;
/**
* Get instance of Mobile class(for singleton)
*
* Get instance of Mobile class
*
* @return Mobile
*/
public function getInstance()
{
static $theInstance;
if(!isset($theInstance))
{
$theInstance = new Mobile();
}
return $theInstance;
return new self();
}
/**
* Get current mobile mode
*
* @return bool If mobile mode returns true or false
*
* @return bool
*/
public static function isFromMobilePhone()
{
return self::getInstance()->_isFromMobilePhone();
// Return cached result.
if (self::$_ismobile !== null)
{
return self::$_ismobile;
}
// Not mobile if disabled explicitly.
if (!self::isMobileEnabled() || Context::get('full_browse') || $_COOKIE["FullBrowse"])
{
return self::$_ismobile = false;
}
// Try to detect from URL arguments and cookies, and finally fall back to user-agent detection.
$m = Context::get('m');
$cookie = (isset($_COOKIE['mobile']) && $_SESSION['user_agent'] === md5($_SERVER['HTTP_USER_AGENT'])) ? $_COOKIE['mobile'] : null;
if ($m === '1' || $cookie === 'true')
{
self::$_ismobile = TRUE;
}
elseif ($m === '0' || $cookie === 'false')
{
self::$_ismobile = FALSE;
}
else
{
self::$_ismobile = Rhymix\Framework\UA::isMobile() && (config('mobile.tablets') || !Rhymix\Framework\UA::isTablet());
}
// Set cookie to prevent recalculation.
if (!$cookie)
{
$_SESSION['user_agent'] = md5($_SERVER['HTTP_USER_AGENT']);
$_COOKIE['mobile'] = self::$_ismobile ? 'true' : 'false';
setcookie('mobile', $_COOKIE['mobile'], 0, RX_BASEURL);
}
return self::$_ismobile;
}
/**
* Get current mobile mode
*
* @return bool
*/
public function _isFromMobilePhone()
public static function _isFromMobilePhone()
{
if($this->ismobile !== NULL)
{
return $this->ismobile;
}
if(!config('use_mobile_view') || Context::get('full_browse') || $_COOKIE["FullBrowse"])
{
return $this->ismobile = false;
}
$this->ismobile = FALSE;
$m = Context::get('m');
if(strlen($m) == 1)
{
if($m == "1")
{
$this->ismobile = TRUE;
}
elseif($m == "0")
{
$this->ismobile = FALSE;
}
}
elseif(isset($_COOKIE['mobile']))
{
if($_COOKIE['user-agent'] == md5($_SERVER['HTTP_USER_AGENT']))
{
if($_COOKIE['mobile'] == 'true')
{
$this->ismobile = TRUE;
}
else
{
$this->ismobile = FALSE;
}
}
else
{
setcookie("mobile", FALSE, 0, RX_BASEURL);
setcookie("user-agent", FALSE, 0, RX_BASEURL);
$this->ismobile = Rhymix\Framework\UA::isMobile() && !Rhymix\Framework\UA::isTablet();
}
}
else
{
$this->ismobile = Rhymix\Framework\UA::isMobile() && !Rhymix\Framework\UA::isTablet();
}
if($this->ismobile !== NULL)
{
if($this->ismobile == TRUE)
{
if($_COOKIE['mobile'] != 'true')
{
$_COOKIE['mobile'] = 'true';
setcookie("mobile", 'true', 0, RX_BASEURL);
}
}
elseif(isset($_COOKIE['mobile']) && $_COOKIE['mobile'] != 'false')
{
$_COOKIE['mobile'] = 'false';
setcookie("mobile", 'false', 0, RX_BASEURL);
}
if(isset($_COOKIE['mobile']) && $_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT']))
{
setcookie("user-agent", md5($_SERVER['HTTP_USER_AGENT']), 0, RX_BASEURL);
}
}
return $this->ismobile;
return self::isFromMobilePhone();
}
/**
* Detect mobile device by user agent
*
@ -138,7 +99,7 @@ class Mobile
{
return Rhymix\Framework\UA::isTablet();
}
/**
* Set mobile mode
*
@ -147,11 +108,21 @@ class Mobile
*/
public static function setMobile($ismobile)
{
self::getInstance()->ismobile = (bool)$ismobile;
self::$_ismobile = (bool)$ismobile;
}
/**
* Check if mobile view is enabled
*
* @raturn bool
*/
public static function isMobileEnabled()
{
return config('use_mobile_view');
$mobile_enabled = config('mobile.enabled');
if ($mobile_enabled === null)
{
$mobile_enabled = config('use_mobile_view') ? true : false;
}
return $mobile_enabled;
}
}

View file

@ -1261,19 +1261,19 @@ class ModuleHandler extends Handler
$type = $item->type;
$called_method = $item->called_method;
// do not call if module is blacklisted
if (Context::isBlacklistedPlugin($module))
{
continue;
}
// todo why don't we call a normal class object ?
$oModule = getModule($module, $type);
if(!$oModule || !method_exists($oModule, $called_method))
{
continue;
}
// do not call if module is blacklisted
if (Context::isBlacklistedPlugin($oModule->module))
{
continue;
}
$before_each_trigger_time = microtime(true);
$output = $oModule->{$called_method}($obj);
$after_each_trigger_time = microtime(true);