From: <ma...@us...> - 2012-12-27 20:46:15
|
Revision: 10574 http://sourceforge.net/p/xoops/svn/10574 Author: mageg Date: 2012-12-27 20:46:10 +0000 (Thu, 27 Dec 2012) Log Message: ----------- add a block in page module Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/blocks/page_blocks.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/form/page_content.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/language/english/blocks.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/rating.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/templates/blocks/page_blocks_id.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/xoops_version.php Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/blocks/page_blocks.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/blocks/page_blocks.php 2012-12-27 20:21:42 UTC (rev 10573) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/blocks/page_blocks.php 2012-12-27 20:46:10 UTC (rev 10574) @@ -16,7 +16,7 @@ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @package page * @since 2.6.0 - * @author Mage Gr\xE9gory (AKA Mage) + * @author Mage Gr�gory (AKA Mage) * @version $Id$ */ function page_blocks_show($options) { @@ -33,9 +33,6 @@ case 'random': $criteria->setSort('RAND()'); break; - case 'id': - $criteria->setSort('RAND()'); - break; case 'rating': $criteria->setSort('content_rating'); $criteria->setOrder('DESC'); @@ -69,24 +66,144 @@ $content[$i]['rating'] = number_format($content_arr[$i]->getVar('content_rating'), 1); $content[$i]['votes'] = $content_arr[$i]->getVar('content_votes'); } + } else { + $content_id = $options[1]; + $view_content = $content_Handler->get($content_id); + // Test if the page exist + if (count($view_content) == 0 || $view_content->getVar('content_status') == 0){ + $content = array(); + } else { + $parsed = parse_url(XOOPS_URL); + $url = isset($parsed['scheme']) ? $parsed['scheme'] . '://' : 'http://'; + if (isset($parsed['host'])) { + $url .= $parsed['host']; + if (isset($parsed['port'])) { + $url .= ':' . $parsed['port']; + } + } else { + $url .= $_SERVER['HTTP_HOST']; + } + $url = $url . $_SERVER['REQUEST_URI']; + // add module css + $xoops->theme()->addStylesheet( $xoops->url('/modules/page/css/styles.css'), null ); + $xoops->theme()->addStylesheet( $xoops->url('/modules/page/css/rating.css'), null ); + // Javascript + $xoops->theme()->addScript( XOOPS_URL . '/modules/page/js/rating.js' ); + $xoops->theme()->addScript( XOOPS_URL . '/modules/page/js/MetaData.js' ); + $xoops->theme()->addScript( XOOPS_URL . '/modules/page/js/rating.pack.js' ); + //Rating form + $content_rating = $view_content->getVar('content_rating'); + $rating_form = '<form id="rating" action="' . XOOPS_URL . '/modules/page/rating.php">'; + for($i=0.5; $i <= 6;){ + if ($content_rating >= ($i - 0.25) && $content_rating < ($i + 0.25)){ + $rating_form .= '<input name="rating" type="radio" class="star_rating {split:2}" value="' . $i . '" checked="checked"/>'; + }else{ + $rating_form .= '<input name="rating" type="radio" class="star_rating {split:2}" value="' . $i . '"/>'; + } + $i += 0.5; + } + $rating_form .= '<input name="content_id" type="hidden" id="content_id" value="' . $content_id .'" />'; + $rating_form .= '<input name="extra_url" type="hidden" id="extra_url" value="' . $url .'" />'; + $rating_form .= '</form>'; + $content['rating_form'] = $rating_form; + + // content + $content['content_id'] = $content_id; + $content['content_title'] = $view_content->getVar('content_title'); + $content['content_shorttext'] = $view_content->getVar('content_shorttext'); + $content['content_text'] = $view_content->getVar('content_text'); + $content['content_author'] = XoopsUser::getUnameFromId($view_content->getVar('content_author')); + $content['content_authorid'] = $view_content->getVar('content_author'); + $content['content_hits'] = sprintf(_MD_PAGE_VIEWPAGE_HITS, $view_content->getVar('content_hits')); + $content['content_date'] = XoopsLocal::formatTimestamp($view_content->getVar('content_create'), $xoops->getModuleConfig('page_dateformat', 'page')); + $content['content_time'] = XoopsLocal::formatTimestamp($view_content->getVar('content_create'), $xoops->getModuleConfig('page_timeformat', 'page')); + $content['content_comments'] = $view_content->getVar('content_comments'); + $content['content_rating'] = number_format($view_content->getVar('content_rating'), 1); + $content['content_votes'] = $view_content->getVar('content_votes'); + $content['content_dopdf'] = $view_content->getVar('content_dopdf'); + $content['content_doprint'] = $view_content->getVar('content_doprint'); + $content['content_dosocial'] = $view_content->getVar('content_dosocial'); + $content['content_doauthor'] = $view_content->getVar('content_doauthor'); + $content['content_dodate'] = $view_content->getVar('content_dodate'); + $content['content_domail'] = $view_content->getVar('content_domail'); + $content['content_dohits'] = $view_content->getVar('content_dohits'); + $content['content_dorating'] = $view_content->getVar('content_dorating'); + $content['content_dotitle'] = $view_content->getVar('content_dotitle'); + $content['content_dosocial'] = $view_content->getVar('content_dosocial'); + $content['content_donotifications'] = $view_content->getVar('content_donotifications'); + $content['content_docoms'] = $view_content->getVar('content_docoms'); + if ($view_content->getVar('content_docoms') == false){ + $ncoms = false; + } elseif ($view_content->getVar('content_doncoms') == false){ + $ncoms = false; + } else { + $ncoms = true; + } + $content['content_doncoms'] = $ncoms; + if ($view_content->getVar('content_dotitle') == false && $view_content->getVar('content_dorating') == false) { + $header = false; + } else { + $header = true; + } + $content['content_doheader'] = $header; + if ($view_content->getVar('content_doauthor') == false && $view_content->getVar('content_dodate') == false && $view_content->getVar('content_dohits') == false && $ncoms == false) { + $footer = false; + } else { + $footer = true; + } + $content['content_dofooter'] = $footer; + + /*$page = new Page(); + + $related = $page->menu_related($content_id); + + if ($related['domenu'] ) { + $content['summary'] = $related['summary']; + } + if ($related['navigation'] != '' ) { + $content['navigation'] = $related['navigation']; + $content['related'] = $related; + }*/ + } } return $content; } function page_blocks_edit($options) { $form = ''; - $form .= _MB_PAGE_DISPLAY . " \n"; - $form .= "<input type=\"hidden\" name=\"options[0]\" value=\"" . $options[0] . "\" />\n"; - $form .= "<input class=\"span1\" name=\"options[1]\" size=\"5\" maxlength=\"255\" value=\"" . $options[1] . "\" type=\"text\" pattern=\"^\d+$\" /> " . _MB_PAGE_CONTENTS . "<br />\n"; - $form .= _MB_PAGE_TLENGTH . " <input class=\"span1\" name=\"options[2]\" size=\"5\" maxlength=\"255\" value=\"" . $options[2] . "\" type=\"text\" pattern=\"^\d+$\" /><br />\n"; - if ($options[3] == false){ - $checked_yes = ''; - $checked_no = 'checked="checked"'; - }else{ - $checked_yes = 'checked="checked"'; - $checked_no = ''; + if ($options[0] != 'id') { + $form .= _MB_PAGE_DISPLAY . " \n"; + $form .= "<input type=\"hidden\" name=\"options[0]\" value=\"" . $options[0] . "\" />\n"; + $form .= "<input class=\"span1\" name=\"options[1]\" size=\"5\" maxlength=\"255\" value=\"" . $options[1] . "\" type=\"text\" pattern=\"^\d+$\" /> " . _MB_PAGE_CONTENTS . "<br />\n"; + $form .= _MB_PAGE_TLENGTH . " <input class=\"span1\" name=\"options[2]\" size=\"5\" maxlength=\"255\" value=\"" . $options[2] . "\" type=\"text\" pattern=\"^\d+$\" /><br />\n"; + if ($options[3] == false){ + $checked_yes = ''; + $checked_no = 'checked="checked"'; + }else{ + $checked_yes = 'checked="checked"'; + $checked_no = ''; + } + $form .= _MB_PAGE_ALLCONTENT . ": <input name=\"options[3]\" value=\"1\" type=\"radio\" " . $checked_yes . "/>" . _YES . " \n"; + $form .= "<input name=\"options[3]\" value=\"0\" type=\"radio\" " . $checked_no . "/>" . _NO . "<br />\n"; + } else { + $xoops = Xoops::getInstance(); + $content_Handler = $xoops->getModuleHandler('page_content', 'page'); + $form .= _MB_PAGE_CONTENTDISPLAY . " \n"; + $form .= "<input type=\"hidden\" name=\"options[0]\" value=\"" . $options[0] . "\" />\n"; + $form .= "<select class=\"span2\" name=\"options[1]\">\n"; + $criteria = new CriteriaCompo(); + $criteria->add(new Criteria('content_status', 0, '!=')); + $criteria->setSort('content_title'); + $criteria->setOrder('ASC'); + $content_arr = $content_Handler->getAll($criteria); + foreach (array_keys($content_arr) as $i) { + if ($content_arr[$i]->getVar('content_id') == $options[1]){ + $form .= "<option value=\"" . $content_arr[$i]->getVar('content_id') . "\" selected=\"selected\">" . $content_arr[$i]->getVar('content_title') . "</option>\n"; + } else { + $form .= "<option value=\"" . $content_arr[$i]->getVar('content_id') . "\">" . $content_arr[$i]->getVar('content_title') . "</option>\n"; + } + } + $form .= "</select>\n"; } - $form .= _MB_PAGE_ALLCONTENT . ": <input name=\"options[3]\" value=\"1\" type=\"radio\" " . $checked_yes . "/>" . _YES . " \n"; - $form .= "<input name=\"options[3]\" value=\"0\" type=\"radio\" " . $checked_no . "/>" . _NO . "<br />\n"; return $form; } \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/form/page_content.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/form/page_content.php 2012-12-27 20:21:42 UTC (rev 10573) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/class/form/page_content.php 2012-12-27 20:46:10 UTC (rev 10574) @@ -76,10 +76,12 @@ } $content_status = $obj->getVar('content_status'); $content_maindisplay = $obj->getVar('content_maindisplay'); + $content_weight = $obj->getVar('content_weight', 'e'); } else { $content_option = array('title', 'author', 'date', 'hits', 'rating', 'coms', 'ncoms', 'notifications', 'pdf', 'print', 'mail', 'social'); $content_status = 1; $content_maindisplay = 1; + $content_weight = '0'; } //title $this->addElement(new XoopsFormText(_AM_PAGE_CONTENT_TITLE, 'content_title', 6, 255, $obj->getVar('content_title'), ''), true); @@ -106,7 +108,7 @@ //content_mdescription $this->addElement(new XoopsFormTextArea(_AM_PAGE_CONTENT_MDESCRIPTION, 'content_mdescription', $obj->getVar('content_mdescription'), 2, 5)); //Weight - $weight = new XoopsFormText(_AM_PAGE_CONTENT_WEIGHT, 'content_weight', 1, 5, $obj->getVar('content_weight', 'e'), ''); + $weight = new XoopsFormText(_AM_PAGE_CONTENT_WEIGHT, 'content_weight', 1, 5, $content_weight, ''); $weight->setPattern('^\d+$', _AM_PAGE_CONTENT_ERROR_WEIGHT); $this->addElement($weight, true); //options Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/language/english/blocks.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/language/english/blocks.php 2012-12-27 20:21:42 UTC (rev 10573) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/language/english/blocks.php 2012-12-27 20:46:10 UTC (rev 10574) @@ -16,10 +16,11 @@ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @package page * @since 2.6.0 - * @author Mage Gr\xE9gory (AKA Mage) + * @author Mage Gr�gory (AKA Mage) * @version $Id$ */ define("_MB_PAGE_DISPLAY","Display"); define("_MB_PAGE_CONTENTS","contents"); define("_MB_PAGE_TLENGTH","Title Length"); -define("_MB_PAGE_ALLCONTENT","Display all de content"); \ No newline at end of file +define("_MB_PAGE_ALLCONTENT","Display all de content"); +define("_MB_PAGE_CONTENTDISPLAY","Content to display"); \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/rating.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/rating.php 2012-12-27 20:21:42 UTC (rev 10573) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/rating.php 2012-12-27 20:46:10 UTC (rev 10574) @@ -16,7 +16,7 @@ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) * @package page * @since 2.6.0 - * @author Mage Gr\xE9gory (AKA Mage) + * @author Mage Gr�gory (AKA Mage) * @version $Id$ */ @@ -33,6 +33,8 @@ $content_id = $system->cleanVars($_REQUEST, 'content_id', 0, 'int'); // Get rating $rating = $system->cleanVars($_REQUEST, 'rating', 0, 'string'); +// Get extra url +$extra_url = $system->cleanVars($_REQUEST, 'extra_url', '', 'string'); $view_content = $content_Handler->get($content_id); // Test if the page exist @@ -43,7 +45,11 @@ //pemissions $perm_rate = ($gperm_handler->checkRight('page_global', 4, $groups, $xoops->module->getVar('mid'), false)) ? true : false ; if ($perm_rate == false || $view_content->getVar('content_dorating') == false){ - $xoops->redirect('viewpage.php?id=' . $content_id, 1, _NOPERM); + if ($extra_url != '') { + $xoops->redirect($extra_url, 1, _NOPERM); + } else { + $xoops->redirect('viewpage.php?id=' . $content_id, 1, _NOPERM); + } } if (is_object($xoops->user)) { @@ -54,7 +60,11 @@ if ($uid != 0) { if ($uid == $view_content->getVar('content_author')){ - $xoops->redirect('viewpage.php?id=' . $content_id, 2, _MD_PAGE_RATING_DONOTVOTE); + if ($extra_url != '') { + $xoops->redirect($extra_url, 2, _MD_PAGE_RATING_DONOTVOTE); + } else { + $xoops->redirect('viewpage.php?id=' . $content_id, 2, _MD_PAGE_RATING_DONOTVOTE); + } exit(); } // Vote for the same resource more than once @@ -64,6 +74,11 @@ $rating_count = $rating_Handler->getCount($criteria); if ($rating_count >= 1) { $xoops->redirect('viewpage.php?id=' . $content_id, 2, _MD_PAGE_RATING_VOTEONCE); + if ($extra_url != '') { + $xoops->redirect($extra_url, 2, _MD_PAGE_RATING_VOTEONCE); + } else { + $xoops->redirect('viewpage.php?id=' . $content_id, 2, _MD_PAGE_RATING_VOTEONCE); + } exit(); } } else { @@ -76,7 +91,11 @@ $criteria->add(new Criteria('rating_date', $yesterday, '>')); $rating_count = $rating_Handler->getCount($criteria); if ($rating_count >= 1) { - $xoops->redirect('viewpage.php?id=' . $content_id, 2, _MD_PAGE_RATING_VOTEONCE); + if ($extra_url != '') { + $xoops->redirect($extra_url, 2, _MD_PAGE_RATING_VOTEONCE); + } else { + $xoops->redirect('viewpage.php?id=' . $content_id, 2, _MD_PAGE_RATING_VOTEONCE); + } exit(); } } @@ -105,7 +124,11 @@ $objcontent->setVar('content_rating', number_format($rating, 1)); $objcontent->setVar('content_votes', $total_vote); if ($content_Handler->insert($objcontent)) { - $xoops->redirect('viewpage.php?id=' . $content_id, 2, _MD_PAGE_RATING_THANKS); + if ($extra_url != '') { + $xoops->redirect($extra_url, 2, _MD_PAGE_RATING_THANKS); + } else { + $xoops->redirect('viewpage.php?id=' . $content_id, 2, _MD_PAGE_RATING_THANKS); + } } echo $objdownloads->getHtmlErrors(); } else { Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/templates/blocks/page_blocks_id.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/templates/blocks/page_blocks_id.html 2012-12-27 20:21:42 UTC (rev 10573) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/templates/blocks/page_blocks_id.html 2012-12-27 20:46:10 UTC (rev 10574) @@ -1 +1,76 @@ -<{$block.contents}> \ No newline at end of file +<script> +$(function(){ + $('.star_rating').rating({ + callback: function(value, link){ + //if (confirm("The value selected was '" + value + "'\n <{$title}>")) { + this.form.submit(); + //} + } + }); +}); +</script> +<{if $block.content_doheader}> +<div class="page_header"> + + <{if $block.content_dotitle}> + <div class="page_headerleft"> + <{$block.content_title}> + </div> + <{/if}> + <{if $block.content_dorating}> + <div class="page_headerright"> + <{$block.rating_form}> + </div> + <{/if}> +</div> +<{if $block.content_dorating}> +<div class="page_vote"> + <{$smarty.const._MD_PAGE_VIEWPAGE_RATING}>: <{$block.content_rating}> (<{$block.content_votes}> <{$smarty.const._MD_PAGE_VIEWPAGE_VOTE}>) +</div> +<{/if}> +<{/if}> +<div class="page_content"> + <{if $summary}> + <h4><{$smarty.const._MD_PAGE_VIEWPAGE_SUMMARY}>:</h4> + <div> + <ul> + <{foreach item=summary from=$summary}> + <li><{$summary}></li> + <{/foreach}> + </ul> + </div> + <{/if}> + <{$block.content_shorttext}> + <br /> + <{$block.content_text}> + <{if $navigation}> + <div class="clear"></div> + <{includeq file="module:page|page_navigation.html"}> + <div class="clear"></div> + <{/if}> + + <div class="right"> + <{if $block.content_doprint}> + <a href="<{$xoops_url}>/modules/page/print.php?id=<{$block.content_id}>" title="<{$smarty.const._MD_PAGE_VIEWPAGE_PRINT}>"><img src="<{xoAppUrl media/xoops/images/icons/16/printer.png}>" alt="<{$smarty.const._MD_PAGE_VIEWPAGE_PRINT}>" /></a> + <{/if}> + <{if $block.content_dopdf}> + <a href="<{$xoops_url}>/modules/page/pdf.php?id=<{$block.content_id}>" title="<{$smarty.const._MD_PAGE_VIEWPAGE_PDF}>"><img src="<{xoAppUrl media/xoops/images/icons/16/pdf.png}>" alt="<{$smarty.const._MD_PAGE_VIEWPAGE_PDF}>" /></a> + <{/if}> + </div> +</div> +<{if $block.content_dofooter}> +<div class="page_footer"> + + <div class="page_footerleft"> + <{if $block.content_doauthor}><{$smarty.const._MD_PAGE_VIEWPAGE_POSTEDBY}> <a href="<{$xoops_url}>/userinfo.php?uid=<{$block.content_authorid}>"><{$block.content_author}></a> <{/if}><{if $block.content_dodate}><{$smarty.const._MD_PAGE_VIEWPAGE_ON}> <{$block.content_date}> <{$block.content_time}> <{/if}><{if $block.content_dohits}><{$block.content_hits}><{/if}> + </div> + <{if $block.content_doncoms}> + <div class="page_footerright"> + <img src="<{$xoops_url}>/modules/page/images/comments.png" alt="<{$block.content_comments}>"/> (<{$block.content_comments}> <{$smarty.const._MD_PAGE_VIEWPAGE_COMMENTS}>) + </div> + <{/if}> +</div> +<{/if}> +<{if $block.content_dosocial}> +<{includeq file='module:xoosocialnetwork|xoosocialnetwork.html'}> +<{/if}> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/xoops_version.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/xoops_version.php 2012-12-27 20:21:42 UTC (rev 10573) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/page/xoops_version.php 2012-12-27 20:46:10 UTC (rev 10574) @@ -75,12 +75,6 @@ $modversion['tables'][2] = "page_related"; $modversion['tables'][3] = "page_rating"; -// Templates -$modversion['templates'][] = array( 'file' => 'page_index.html', 'description' => '' ); -$modversion['templates'][] = array( 'file' => 'page_viewpage.html', 'description' => '' ); -$modversion['templates'][] = array( 'file' => 'page_print.html', 'description' => '' ); -$modversion['templates'][] = array( 'file' => 'page_pdf.html', 'description' => '' ); - // blocks $i = 0; $modversion['blocks'][$i]['file'] = 'page_blocks.php'; @@ -91,14 +85,14 @@ $modversion['blocks'][$i]['options'] = 'random|5|19|0'; $modversion['blocks'][$i]['template'] = 'page_blocks_random.html'; $i++; -/*$modversion['blocks'][$i]['file'] = 'page_blocks.php'; +$modversion['blocks'][$i]['file'] = 'page_blocks.php'; $modversion['blocks'][$i]['name'] = _MI_PAGE_BLOCKS_ID; $modversion['blocks'][$i]['description'] = _MI_PAGE_BLOCKS_IDDSC; $modversion['blocks'][$i]['show_func'] = 'page_blocks_show'; $modversion['blocks'][$i]['edit_func'] = 'page_blocks_edit'; -$modversion['blocks'][$i]['options'] = 'id|5|19|1'; +$modversion['blocks'][$i]['options'] = 'id|0|0|0'; $modversion['blocks'][$i]['template'] = 'page_blocks_id.html'; -$i++;*/ +$i++; $modversion['blocks'][$i]['file'] = 'page_blocks.php'; $modversion['blocks'][$i]['name'] = _MI_PAGE_BLOCKS_RATING; $modversion['blocks'][$i]['description'] = _MI_PAGE_BLOCKS_RATINGDSC; |