Skip to content

Commit

Permalink
refs #1604 : desktop-mobile change now works.
Browse files Browse the repository at this point in the history
  • Loading branch information
inureyes committed Oct 2, 2012
1 parent 95f19a3 commit fcadc1d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
5 changes: 5 additions & 0 deletions framework/model/URIHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,15 @@ private function __URIvariableParser() {
$this->uri['blog'] = $this->uri['path'].$this->__getFancyURLpostfix();
$this->uri['folder'] = rtrim($this->uri['blog'] . $suri['directive'], '/');

$this->uri['basicblog'] = $this->uri['blog'];
if (defined('__TEXTCUBE_MOBILE__')) {
$this->uri['blog'] .= '/m';
$_SESSION['mode'] = 'mobile';
} else if (defined('__TEXTCUBE_IPHONE__')) {
$this->uri['blog'] .= '/i';
$_SESSION['mode'] = 'mobile';
} else {
$_SESSION['mode'] = 'desktop';
}

$this->blog = $blog;
Expand Down
6 changes: 5 additions & 1 deletion interface/blog/entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
'GET' => array(
'category' => array('int',0,'mandatory'=>false),
'page' => array('int', 1, 'default' => 1),
'mode' => array(array('mobile','desktop','tablet'),'mandatory'=>false),
'commentId' => array('int',0,'mandatory'=>false),
'commentInput' => array('bool','mandatory'=>false)
)
);

require ROOT . '/library/preprocessor.php';

if(Setting::getBlogSettingGlobal('useiPhoneUI',true) && (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'],'iPod') || strpos($_SERVER['HTTP_USER_AGENT'],'iPhone')))){
$browserUtil = Utils_Browser::getInstance();
if(Setting::getBlogSettingGlobal('useiPhoneUI',true) && ($browserUtil->isMobile() == true)
&& (!isset($_GET['mode']) || $_GET['mode'] != 'desktop')
&& (!isset($_SESSION['mode']) || !in_array($_SESSION['mode'],array('desktop')))) {
if(empty($suri['value'])) {
header("Location: $blogURL/i"); exit;
} else {
Expand Down
3 changes: 3 additions & 0 deletions interface/common/owner/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,11 @@
<link rel="stylesheet" href="<?php echo $service['path'];?>/resources/style/helper/moodalbox.css" type="text/css" media="screen" />
<?php
}
if (file_exists(ROOT . $context->getProperty('panel.skin')."/custom.js")) {
?>
<script type="text/javascript" src="<?php echo $context->getProperty('service.path').$context->getProperty('panel.skin');?>/custom.js"></script>
<?php
}
if($service['interface'] == 'simple') {
if(!in_array($blogMenu['contentMenu'],array('post','edit'))) {
?>
Expand Down
2 changes: 1 addition & 1 deletion interface/i/category/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$category = $suri['id'];
if(isset($category)) {
$blog['entriesOnList'] = 8;
if(!$listWithPaging = getEntryListWithPagingByCategory($blogid, $category, $suri['page'], $blog['entriesOnList']))
if(!$listWithPaging = getEntriesWithPagingByCategory($blogid, $category, $suri['page'], $blog['entriesOnList'],1))
$listWithPaging = array(array(), array('total' => 0));
$list = array('title' => (empty($suri['value']) ? getCategoryLabelById($blogid, 0) : $suri['value']), 'items' => $listWithPaging[0], 'count' => $listWithPaging[1]['total']);
$paging = $listWithPaging[1];
Expand Down
6 changes: 5 additions & 1 deletion interface/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
$IV = array(
'GET' => array(
'page' => array('int', 1, 'default' => 1),
'mode' => array(array('mobile','desktop','tablet'),'mandatory'=>false),
'category' => array('int', 0, 'mandatory'=>false)
)
);
Expand All @@ -48,7 +49,9 @@

// Redirect for ipod touch / iPhone
$browserUtil = Utils_Browser::getInstance();
if(Setting::getBlogSettingGlobal('useiPhoneUI',true) && ($browserUtil->isMobile() == true)){
if(Setting::getBlogSettingGlobal('useiPhoneUI',true) && ($browserUtil->isMobile() == true)
&& (!isset($_GET['mode']) || $_GET['mode'] != 'desktop')
&& (!isset($_SESSION['mode']) || !in_array($_SESSION['mode'],array('desktop')))) {
if(isset($suri['id'])) {
$slogan = getSloganById($blogid, $suri['id']);
if(!empty($slogan)) {
Expand All @@ -58,6 +61,7 @@
header("Location: $blogURL/i"); exit;
}
}
$_SESSION['mode'] = 'desktop';
publishEntries();

if (!empty($_POST['mode']) && $_POST['mode'] == 'fb') { // Treat comment notifier.
Expand Down
20 changes: 15 additions & 5 deletions library/view/iphoneView.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function printMobileCategoriesView($totalPosts, $categories) {
array('id' => $category2['id'],
'label' => $category2['name'],
'value' => (doesHaveOwnership() ? $category2['entriesinlogin'] : $category2['entries']),
'link' => "$context->getProperty('uri.blog')/category/" . $category2['id'],
'link' => $context->getProperty('uri.blog')."/category/" . $category2['id'],
'children' => array()
)
);
Expand All @@ -98,7 +98,7 @@ function printMobileCategoriesView($totalPosts, $categories) {
array('id' => $category1['id'],
'label' => $category1['name'],
'value' => $categoryCount + $parentCategoryCount,
'link' => "$context->getProperty('uri.blog')/category/" . $category1['id'],
'link' => $context->getProperty('uri.blog')."/category/" . $category1['id'],
'children' => $children)
);
}
Expand Down Expand Up @@ -246,9 +246,19 @@ function printMobileHTMLHeader($title = '') {
}

function printMobileHTMLFooter() {
global $blogURL;
$context = Model_Context::getInstance();
if(!is_null($context->getProperty('suri.id'))) {
$slogan = getSloganById($context->getProperty('blog.id'), $context->getProperty('suri.id'));
} else if(!is_null($context->getProperty('suri.value'))) {
$slogan = $context->getProperty('suri.value');
}
$link = $context->getProperty('uri.basicblog').substr($context->getProperty('suri.directive'),2).'/'.
URL::encode($slogan)."?mode=desktop";

?>
<div data-role="content" class="ui-bar" data-theme="c"><span class="footer_text"><?php echo _textf('이 페이지는 %1 %2 로 구동됩니다',TEXTCUBE_NAME,TEXTCUBE_VERSION);?></span>
<a data-role="button" data-theme="d" data-inline="true" data-icon="refresh"><?php echo _text('데스크탑 화면');?></a>
<a href="<?php echo $link;?>" data-role="button" data-theme="d" data-inline="false" data-icon="refresh" rel="external"><?php echo _text('데스크탑 화면');?></a>
</div>

</body>
Expand Down Expand Up @@ -301,7 +311,7 @@ function printMobileFreeImageResizer($content) {
$context = Model_Context::getInstance();
$blogid = $context->getProperty('blog.id');
$pattern1 = "@<img.+src=['\"](.+)['\"].*>@Usi";
$pattern2 = $service['path'] . "/attach/{$blogid}/";
$pattern2 = $context->getProperty('service.path') . "/attach/{$blogid}/";

if (preg_match_all($pattern1, $content, $matches)) {
foreach($matches[0] as $imageTag) {
Expand Down Expand Up @@ -688,4 +698,4 @@ function printMobileSimpleMessage($message, $redirectMessage, $redirectURL, $tit
<?php
printMobileHTMLFooter();
}
?>
?>

0 comments on commit fcadc1d

Please sign in to comment.