Example #1
0
 /**
  * CallBack function for the ListFactory class
  *
  * This function gets called by the ListFactory class and formats
  * each row accordingly for example pulling usernames from the
  * users table and displaying a link to their profile.
  *
  * @author Sami Barakat <s.m.barakat AT gmail DOT com>
  * @access public
  * @param array $row An array of plain data to format
  * @return array A reformatted version of the input array
  *
  */
 function searchFormatCallBack($preSort, $row)
 {
     global $_CONF, $_USER;
     $dt = new Date('now', $_USER['tzid']);
     if ($preSort) {
         $row[SQL_TITLE] = is_array($row[SQL_TITLE]) ? implode($_CONF['search_separator'], $row[SQL_TITLE]) : $row[SQL_TITLE];
         if (is_numeric($row['uid'])) {
             if (empty($this->_names[$row['uid']])) {
                 $this->_names[$row['uid']] = htmlspecialchars(COM_getDisplayName($row['uid']));
                 if ($row['uid'] != 1) {
                     $this->_names[$row['uid']] = COM_createLink($this->_names[$row['uid']], $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $row['uid']);
                 }
             }
             $row['uid'] = $this->_names[$row['uid']];
         }
     } else {
         $row[SQL_TITLE] = COM_createLink($row[SQL_TITLE], $this->_searchURL . '&amp;type=' . $row[SQL_NAME] . '&amp;mode=search');
         $row['url'] = ($row['url'][0] == '/' ? $_CONF['site_url'] : '') . $row['url'];
         if ($this->_url_rewrite[$row[SQL_NAME]]) {
             $row['url'] = COM_buildUrl($row['url']);
         }
         if ($row['title'] == '') {
             $row['title'] = $row[SQL_TITLE];
         }
         $row['title'] = $row['title'];
         // $this->_shortenText($this->_query, $row['title'], 6);
         $row['title'] = str_replace('$', '&#36;', $row['title']);
         $row['title'] = COM_createLink($row['title'], $row['url']);
         if ($row['description'] == '') {
             $row['description'] = $_CONF['search_no_data'];
         } else {
             $row['description'] = $row['description'];
         }
         if ($row['description'] != $_CONF['search_no_data']) {
             $row['description'] = $this->_shortenText($this->_query, $row['description'], $this->_wordlength);
         }
         $dt->setTimestamp($row['date']);
         $row['date'] = $dt->format($_CONF['daytime'], true);
         $row['hits'] = COM_NumberFormat($row['hits']) . ' ';
         // simple solution to a silly problem!
     }
     return $row;
 }
Example #2
0
 /**
  * Callback function for the ListFactory class
  *
  * This function gets called by the ListFactory class and formats
  * each row accordingly for example pulling usernames from the
  * users table and displaying a link to their profile.
  *
  * @param array $row An array of plain data to format
  * @return array A reformatted version of the input array
  *
  */
 public function searchFormatCallback($preSort, $row)
 {
     global $_CONF, $LANG09;
     if ($preSort) {
         if (is_array($row[LF_SOURCE_TITLE])) {
             $row[LF_SOURCE_TITLE] = implode($_CONF['search_separator'], $row[LF_SOURCE_TITLE]);
         }
         if (is_numeric($row['uid'])) {
             if (empty($this->_names[$row['uid']])) {
                 $this->_names[$row['uid']] = htmlspecialchars(COM_getDisplayName($row['uid']));
                 if ($row['uid'] != 1) {
                     $this->_names[$row['uid']] = COM_createLink($this->_names[$row['uid']], $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $row['uid']);
                 }
             }
             $row['uid'] = $this->_names[$row['uid']];
         }
     } else {
         $row[LF_SOURCE_TITLE] = COM_createLink($row[LF_SOURCE_TITLE], $this->_searchURL . '&amp;type=' . $row[LF_SOURCE_NAME] . '&amp;mode=search');
         if ($row['url'] != '#') {
             $row['url'] = ($row['url'][0] == '/' ? $_CONF['site_url'] : '') . $row['url'];
             if (isset($this->_url_rewrite[$row[LF_SOURCE_NAME]]) && $this->_url_rewrite[$row[LF_SOURCE_NAME]]) {
                 $row['url'] = COM_buildUrl($row['url']);
             }
             if (isset($this->_append_query[$row[LF_SOURCE_NAME]]) && $this->_append_query[$row[LF_SOURCE_NAME]]) {
                 if (!empty($this->_query)) {
                     $row['url'] .= (strpos($row['url'], '?') ? '&amp;' : '?') . 'query=' . urlencode($this->_query);
                 }
             }
         }
         $row['title'] = $this->_shortenText($this->_query, $row['title'], 8);
         $row['title'] = stripslashes(str_replace('$', '&#36;', $row['title']));
         $row['title'] = COM_createLink($row['title'], $row['url']);
         if ($row['description'] == 'LF_NULL') {
             $row['description'] = '<i>' . $LANG09[70] . '</i>';
         } elseif ($row['description'] != '<i>' . $LANG09[70] . '</i>') {
             $row['description'] = stripslashes($this->_shortenText($this->_query, PLG_replaceTags($row['description']), $this->_wordlength));
         }
         if ($row['date'] != 'LF_NULL') {
             $dt = COM_getUserDateTimeFormat(intval($row['date']));
             $row['date'] = $dt[0];
         }
         if ($row['hits'] != 'LF_NULL') {
             $row['hits'] = COM_NumberFormat($row['hits']) . ' ';
             // simple solution to a silly problem!
         }
     }
     return $row;
 }
Example #3
0
/**
* 訪問者数を表示するブロック。
* 2006-10-21 Yohichi Yagi.
*/
function phpblock_stats()
{
    global $_TABLES;
    $disp = '<div id="phpblock_stats">' . COM_NumberFormat(DB_getItem($_TABLES['vars'], 'value', "name = 'totalhits'")) . '</div>';
    return $disp;
}
Example #4
0
 /**
  * Provide access to story elements. For display.
  *
  * This is a peudo-property, implementing a getter for story
  * details as if as an associative array. Personally, I'd
  * rather be able to assign getters and setters to actual
  * properties to mask controlled access to private member
  * variables. But, you get what you get with PHP. So here it
  * is in all it's nastyness.
  *
  * @param   string  $item   Item to fetch.
  * @return  mixed   The clean and ready to use value requested.
  */
 function DisplayElements($item = 'title')
 {
     global $_CONF, $_TABLES;
     $return = '';
     switch (strtolower($item)) {
         case 'introtext':
             if ($this->_postmode == 'plaintext') {
                 $return = nl2br($this->_introtext);
             } elseif ($this->_postmode == 'wikitext') {
                 $return = COM_renderWikiText($this->_editUnescape($this->_introtext));
             } else {
                 $return = $this->_introtext;
             }
             $return = PLG_replaceTags($this->_displayEscape($return));
             break;
         case 'bodytext':
             if ($this->_postmode == 'plaintext' && !empty($this->_bodytext)) {
                 $return = nl2br($this->_bodytext);
             } elseif ($this->_postmode == 'wikitext' && !empty($this->_bodytext)) {
                 $return = COM_renderWikiText($this->_editUnescape($this->_bodytext));
             } elseif (!empty($this->_bodytext)) {
                 $return = $this->_displayEscape($this->_bodytext);
             }
             $return = PLG_replaceTags($return);
             break;
         case 'title':
             $return = $this->_displayEscape($this->_title);
             break;
         case 'meta_description':
             $return = $this->_meta_description;
             break;
         case 'meta_keywords':
             $return = $this->_meta_keywords;
             break;
         case 'shortdate':
             $return = strftime($_CONF['shortdate'], $this->_date);
             break;
         case 'dateonly':
             $return = strftime($_CONF['dateonly'], $this->_date);
             break;
         case 'date':
             $return = COM_getUserDateTimeFormat($this->_date);
             $return = $return[0];
             break;
         case 'unixdate':
             $return = $this->_date;
             break;
         case 'hits':
             $return = COM_NumberFormat($this->_hits);
             break;
         case 'topic':
             $return = htmlspecialchars($this->_topic);
             break;
         case 'expire':
             if (empty($this->_expire)) {
                 $return = time();
             } else {
                 $return = $this->_expire;
             }
             break;
         case 'commentcode':
             // check to see if comment_time has passed
             if ($this->_comment_expire != 0 && time() > $this->_comment_expire && $this->_commentcode == 0) {
                 // if comment code is not 1, change it to 1
                 DB_query("UPDATE {$_TABLES['stories']} SET commentcode = '1' WHERE sid = '{$this->_sid}'");
                 $return = 1;
             } else {
                 $return = $this->_commentcode;
             }
             break;
         default:
             $varname = '_' . $item;
             if (isset($this->{$varname})) {
                 $return = $this->{$varname};
             }
             break;
     }
     return $return;
 }
Example #5
0
    } else {
        $display .= COM_startBlock($LANG10[25]);
        $display .= $LANG10[26];
        $display .= COM_endBlock();
    }
}
// Top Ten Emailed Stories
$sql = "SELECT sid,title,numemails\n    FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n    WHERE ta.type = 'article' AND ta.id = sid\n    AND (numemails > 0) AND (draft_flag = 0) AND (date <= NOW())" . COM_getPermSQL('AND') . $topicsql . " ORDER BY numemails DESC LIMIT 10";
$result = DB_query($sql);
$nrows = DB_numRows($result);
if ($nrows > 0) {
    $header_arr = array(array('text' => $LANG10[8], 'field' => 'sid', 'header_class' => 'stats-header-title'), array('text' => $LANG10[23], 'field' => 'numemails', 'header_class' => 'stats-header-count', 'field_class' => 'stats-list-count'));
    $data_arr = array();
    $text_arr = array('has_menu' => false, 'title' => $LANG10[22], 'form_url' => $_CONF['site_url'] . '/stats.php');
    for ($i = 0; $i < $nrows; $i++) {
        $A = DB_fetchArray($result);
        $A['title'] = stripslashes(str_replace('$', '&#36;', $A['title']));
        $A['sid'] = COM_createLink($A['title'], COM_buildUrl($_CONF['site_url'] . "/article.php?story={$A['sid']}"));
        $A['numemails'] = COM_NumberFormat($A['numemails']);
        $data_arr[$i] = $A;
    }
    $display .= ADMIN_simpleList('', $header_arr, $text_arr, $data_arr);
} else {
    $display .= COM_startBlock($LANG10[22]);
    $display .= $LANG10[24];
    $display .= COM_endBlock();
}
// Now show stats for any plugins that want to be included
$display .= PLG_getPluginStats(2);
$display = COM_createHTMLDocument($display, array('pagetitle' => $LANG10[1]));
COM_output($display);
Example #6
0
 /**
  * Provide access to story elements. For display.
  *
  * This is a peudo-property, implementing a getter for story
  * details as if as an associative array. Personally, I'd
  * rather be able to assign getters and setters to actual
  * properties to mask controlled access to private member
  * variables. But, you get what you get with PHP. So here it
  * is in all it's nastyness.
  *
  * @param   string  $item   Item to fetch.
  * @return  mixed   The clean and ready to use value requested.
  */
 function DisplayElements($item = 'title')
 {
     global $_CONF, $_USER, $_TABLES;
     $filter = sanitizer::getInstance();
     $filter->setPostmode($this->_postmode);
     $allowedElements = $filter->makeAllowedElements($_CONF['htmlfilter_story']);
     $filter->setAllowedElements($allowedElements);
     $filter->setCensorData(true);
     $filter->setReplaceTags(true);
     $filter->setNamespace('glfusion', 'story');
     $dtObject = new Date($this->_date, $_USER['tzid']);
     if (isset($this->_expire) && $this->_expire != 0) {
         $dtExpire = new Date($this->_expire, $_USER['tzid']);
     } else {
         $dtExpire = new Date($this->_date + 7 * 86400, $_USER['tzid']);
     }
     $return = '';
     switch (strtolower($item)) {
         case 'introtext':
             $out = $this->replaceImages($this->_introtext);
             $clean = $filter->displayText($out);
             $return = $this->renderImages($clean);
             break;
         case 'bodytext':
             $out = $this->replaceImages($this->_bodytext);
             $clean = $filter->displayText($out);
             $return = $this->renderImages($clean);
             break;
         case 'title':
             $return = $this->_displayEscape($this->_title);
             break;
         case 'shortdate':
             $return = $dtObject->format($_CONF['shortdate'], true);
             break;
         case 'dateonly':
             $return = $dtObject->format($_CONF['dateonly'], true);
             break;
         case 'date':
             $return = $dtObject->format($dtObject->getUserFormat(), true);
             break;
         case 'unixdate':
             $return = $dtObject->toUnix();
             break;
         case 'hits':
             $return = COM_NumberFormat($this->_hits);
             break;
         case 'rating':
             $return = @number_format($this->_rating, 2);
             break;
         case 'votes':
             $return = COM_NumberFormat($this->_votes);
             break;
         case 'topic':
             $return = $filter->htmlspecialchars($this->_topic);
             break;
         case 'alternate_topic':
             $return = $filter->htmlspecialchars($this->_alternate_topic);
             break;
         case 'expire':
             $return = $dtExpire->toUnix();
             break;
         case 'commentcode':
             // check to see if comment_time has passed
             if ($this->_comment_expire != 0 && time() > $this->_comment_expire && $this->_commentcode == 0) {
                 $return = 1;
                 //if comment code is not 1, change it to 1
                 DB_query("UPDATE {$_TABLES['stories']} SET commentcode = '1' WHERE sid = '{$this->_sid}'");
                 //die('changed cc');
             } else {
                 $return = $this->_commentcode;
             }
             break;
         default:
             $varname = '_' . $item;
             if (isset($this->{$varname})) {
                 $return = $this->{$varname};
             }
             break;
     }
     return $return;
 }