示例#1
0
function writeTagsProposition($tagsCloud, $title)
{
    static $id = 0;
    ++$id;
    echo <<<JS
    \$('.edit-tagclouds')
        .append(
'<div class="collapsible" id="edit-tagcloud-{$id}">'
+ '  <h3>{$title}</h3>'
+ '  <p class="popularTags tags"></p>'
+ '</div>');
JS;
    $taglist = '';
    foreach (array_keys($tagsCloud) as $key) {
        $row = $tagsCloud[$key];
        $entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']);
        $taglist .= '<span' . ' title="' . $row['bCount'] . ' ' . $entries . '"' . ' style="font-size:' . $row['size'] . '"' . ' onclick="addTag(this)">' . filter($row['tag']) . '</span> ';
    }
    echo '$(\'#edit-tagcloud-' . $id . ' p\').append(' . json_encode($taglist) . ");\n";
}
<?php 
print "<p>";
foreach ($supported_locales as $l) {
    print "[<a href=\"?lang={$l}\">{$l}</a>] ";
}
print "</p>\n";
if (!locale_emulation()) {
    print "<p>locale '{$locale}' is supported by your system, using native gettext implementation.</p>\n";
} else {
    print "<p>locale '{$locale}' is <strong>not</strong> supported on your system, using custom gettext implementation.</p>\n";
}
?>

<hr />

<?php 
// using PHP-gettext
print "<pre>";
print T_("This is how the story goes.\n\n");
for ($number = 6; $number >= 0; $number--) {
    print sprintf(T_ngettext("%d pig went to the market\n", "%d pigs went to the market\n", $number), $number);
}
print "</pre>\n";
?>

<hr />
<p>&laquo; <a href="./">back</a></p>
</body>
</html>
示例#3
0
/**
 * Smarty block function, provides gettext support for smarty.
 *
 * The block content is the text that should be translated.
 *
 * Any parameter that is sent to the function will be represented as %n in the translation text,
 * where n is 1 for the first parameter. The following parameters are reserved:
 *   - escape - sets escape mode:
 *       - 'html' for HTML escaping, this is the default.
 *       - 'js' for javascript escaping.
 *       - 'url' for url escaping.
 *       - 'no'/'off'/0 - turns off escaping
 *   - plural - The plural version of the text (2nd parameter of ngettext())
 *   - count - The item count for plural mode (3rd parameter of ngettext())
 */
function smarty_block_t($params, $text, $smarty)
{
    // stop smarty from rendering on the opening tag
    if (!$text) {
        return;
    }
    $text = stripslashes($text);
    // set escape mode
    if ($params['escape'] !== null) {
        $escape = $params['escape'];
        unset($params['escape']);
    }
    // set plural version
    if ($params['plural'] !== null) {
        $plural = $params['plural'];
        unset($params['plural']);
        // set count
        if ($params['count'] !== null) {
            $count = $params['count'];
            unset($params['count']);
        }
    }
    // use plural if required parameters are set
    if ($count !== null and $plural !== null) {
        $text = T_ngettext($text, $plural, $count);
        // vain: prefixed "T_" for usage of php-gettext
    } else {
        // use normal
        $text = T_gettext($text);
        // vain: prefixed "T_" for usage of php-gettext
    }
    // run strarg if there are parameters
    if (count($params)) {
        $text = smarty_gettext_strarg($text, $params);
    }
    if (false === isset($escape) or $escape == 'html') {
        // html escape, default
        $text = nl2br(htmlspecialchars($text));
    } elseif ($escape !== null) {
        switch ($escape) {
            case 'javascript':
            case 'js':
                // javascript escape
                $text = str_replace('\'', '\\\'', stripslashes($text));
                break;
            case 'url':
                // url escape
                $text = urlencode($text);
                break;
        }
    }
    if ($text !== null) {
        return $text;
    }
}
示例#4
0
 function translatePlural($msg, $plural, $count)
 {
     if (defined('_poMMo_gettext')) {
         return T_ngettext($msg, $plural, $count);
     }
     return ngettext($msg, $plural, $count);
 }
/**
 * Smarty block function, provides gettext support for smarty.
 *
 * The block content is the text that should be translated.
 *
 * Any parameter that is sent to the function will be represented as %n in the translation text, 
 * where n is 1 for the first parameter. The following parameters are reserved:
 *   - escape - sets escape mode:
 *       - 'html' for HTML escaping, this is the default.
 *       - 'js' for javascript escaping.
 *       - 'url' for url escaping.
 *       - 'no'/'off'/0 - turns off escaping
 *   - plural - The plural version of the text (2nd parameter of ngettext())
 *   - count - The item count for plural mode (3rd parameter of ngettext())
 */
function smarty_block_t($params, $text, &$smarty)
{
    $text = stripslashes($text);
    // set escape mode
    if (isset($params['escape'])) {
        $escape = $params['escape'];
        unset($params['escape']);
    }
    // set plural version
    if (isset($params['plural'])) {
        $plural = $params['plural'];
        unset($params['plural']);
        // set count
        if (isset($params['count'])) {
            $count = $params['count'];
            unset($params['count']);
        }
    }
    // use plural if required parameters are set
    if (isset($count) && isset($plural)) {
        $text = T_ngettext($text, $plural, $count);
    } else {
        // use normal
        $text = T_gettext($text);
    }
    // run strarg if there are parameters
    if (count($params)) {
        $text = smarty_gettext_strarg($text, $params);
    }
    if (!isset($escape) || $escape == 'html') {
        // html escape, default
        $text = nl2br(htmlspecialchars($text));
    } elseif (isset($escape)) {
        switch ($escape) {
            case 'javascript':
            case 'js':
            case 'json':
                // javascript escape {12-12-2007, mike: modified for JSON support in ZMG}
                $json =& zmgFactory::getJSON();
                $text = $json->encode($text);
                break;
            case 'url':
                // url escape
                $text = urlencode($text);
                break;
        }
    }
    return $text;
}
示例#6
0
/**
 * Smarty block function, provides gettext support for smarty.
 *
 * The block content is the text that should be translated.
 *
 * Any parameter that is sent to the function will be represented as %n in the translation text,
 * where n is 1 for the first parameter. The following parameters are reserved:
 *   - escape - sets escape mode:
 *       - 'html' for HTML escaping, this is the default.
 *       - 'js' for javascript escaping.
 *       - 'url' for url escaping.
 *       - 'no'/'off'/0 - turns off escaping
 *   - plural - The plural version of the text (2nd parameter of ngettext())
 *   - count - The item count for plural mode (3rd parameter of ngettext())
 */
function smarty_block_t($params, $text, &$smarty)
{
    if (!$text) {
        return;
    }
    $text = stripslashes($text);
    // set escape mode
    if (isset($params['escape'])) {
        $escape = $params['escape'];
        unset($params['escape']);
    }
    // set plural version
    if (isset($params['plural'])) {
        $plural = $params['plural'];
        unset($params['plural']);
        // set count
        if (isset($params['count'])) {
            $count = $params['count'];
            unset($params['count']);
        }
    }
    // use plural if required parameters are set
    if (isset($count) && isset($plural)) {
        $text = T_ngettext($text, $plural, $count);
    } else {
        // use normal
        $text = T_gettext($text);
    }
    // run strarg if there are parameters
    if (count($params)) {
        $text = smarty_gettext_strarg($text, $params);
    }
    if (!isset($escape) || $escape == 'html') {
        // html escape, default
        $text = nl2br(htmlspecialchars($text));
    } elseif (isset($escape)) {
        switch ($escape) {
            case 'javascript':
            case 'js':
                // javascript escape
                $text = str_replace('\'', '\\\'', stripslashes($text));
                break;
            case 'url':
                // url escape
                $text = urlencode($text);
                break;
        }
    }
    return $text;
}
示例#7
0
function displayRelatedTagsList($output, $current_tags, $current_page = "tags.php?tag=")
{
    $strResult = "";
    if ($output != null) {
        $strResult = "<table class=\"related_tags\">";
        foreach ($output as $current_row) {
            $resultsStr = T_ngettext('bookmark', 'bookmarks', $current_row['amount']);
            $strResult .= "<tr><td style=\"width: 1em; text-align: center;\"><a href=\"" . $current_page . $current_tags . "+" . $current_row['title'] . "\" title=\"" . T_("Add tag") . "\" alt=\"" . T_("Add tag") . "\">+</a></td><td style=\"margin-left: 0.5em;\"><a href=\"" . $current_page . $current_row['title'] . "\" title=\"" . $current_row['amount'] . " {$resultsStr}\">" . $current_row['title'] . "</a></td></tr>\n";
        }
        $strResult .= "</table>";
    }
    return $strResult;
}
示例#8
0
<?php 
print "<p>";
foreach ($supported_locales as $l) {
    print "[<a href=\"?lang={$l}\">{$l}</a>] ";
}
print "</p>\n";
if (!locale_emulation()) {
    print "<p>locale '{$locale}' is supported by your system, using native gettext implementation.</p>\n";
} else {
    print "<p>locale '{$locale}' is <strong>not</strong> supported on your system, using custom gettext implementation.</p>\n";
}
?>

<hr />

<?php 
// using PHP-gettext
print "<pre>";
print T_("This is how the story goes.\n\n");
for ($number = 6; $number >= 0; $number--) {
    print sprintf(gettext("Address Name"));
    print sprintf(T_ngettext("%d  Address Name", "%d pigs went to the market\n", $number), $number);
}
print "</pre>\n";
?>

<hr />
<p>&laquo; <a href="./">back</a></p>
</body>
</html>
示例#9
0
 /**
  * importAddressCsv
  *
  * Imports a CSV file into the address book
  *
  * @param array $file The csv file
  *
  * @return void
  */
 function importAddressCsv($file)
 {
     if (!in_array($file['type'], array('text/plain', 'text/x-csv', 'text/csv', 'application/vnd.ms-excel', 'application/octet-stream'))) {
         echo '
         <p class="error-alert">' . sprintf(T_('%s (%s) is not a CSV file.'), $file['name'], $file['type']) . '</p>';
         return;
     }
     // Read in the file and parse the data to an array of arrays
     $addresses = array();
     $handle = fopen($file['tmp_name'], "r");
     $row = 0;
     while (($data = fgetcsv($handle, 4096, ",")) !== false) {
         if ($row == 0) {
             // Get Column headers
             $headers = $data;
             $row++;
         } else {
             $num = count($data);
             $row++;
             for ($i = 0; $i < $num; $i++) {
                 if ($data[$i]) {
                     $addresses[$row][$headers[$i]] = $data[$i];
                 }
             }
         }
     }
     // Loop through the multidimensional array and insert valid addresses into db
     $i = 0;
     foreach ($addresses as $address) {
         // First Name
         $fname = '';
         if (isset($address['fname'])) {
             // FCMS
             $fname = $address['fname'];
         } elseif (isset($address['First Name'])) {
             // Outlook
             $fname = $address['First Name'];
         } elseif (isset($address['Given Name'])) {
             // Gmail
             $fname = $address['Given Name'];
         }
         // Last Name
         $lname = '';
         if (isset($address['lname'])) {
             // FCMS
             $lname = $address['lname'];
         } elseif (isset($address['Last Name'])) {
             // Outlook
             $lname = $address['Last Name'];
         } elseif (isset($address['Family Name'])) {
             // Gmail
             $lname = $address['Family Name'];
         }
         // Email
         $email = '';
         if (isset($address['email'])) {
             // FCMS
             $email = $address['email'];
         } elseif (isset($address['E-mail Address'])) {
             // Outlook
             $email = $address['E-mail Address'];
         } elseif (isset($address['E-mail 1 - Value'])) {
             // Gmail
             $email = $address['E-mail 1 - Value'];
         }
         // Street Address
         $street = '';
         $city = '';
         $state = '';
         $zip = '';
         if (isset($address['address'])) {
             // FCMS
             $street = $address['address'];
         } elseif (isset($address['Home Address'])) {
             // Outlook (all in one)
             // Try to parse the data into individual fields
             // This only works for US formatted addressess
             $endStreet = strpos($address['Home Address'], "\n");
             if ($endStreet !== false) {
                 $street = substr($address['Home Address'], 0, $endStreet - 1);
                 $endCity = strpos($address['Home Address'], ",", $endStreet);
                 if ($endCity !== false) {
                     $city = substr($address['Home Address'], $endStreet + 1, $endCity - $endStreet - 1);
                     $tmpZip = substr($address['Home Address'], -5);
                     if (is_numeric($tmpZip)) {
                         $endZip = strpos($address['Home Address'], $tmpZip, $endCity);
                         if ($endZip !== false) {
                             $state = substr($address['Home Address'], $endCity + 2);
                             $state = substr($state, 0, -6);
                             // 5 zip + space
                             $zip = $tmpZip;
                         }
                     } else {
                         $state = substr($address['Home Address'], $endCity);
                     }
                 }
             } else {
                 $street = $address['Home Address'];
             }
         } elseif (isset($address['Home Street'])) {
             // Outlook
             $street = $address['Home Street'];
         } elseif (isset($address['Address 1 - Formatted'])) {
             // Gmail (all in one)
             // Try to parse the data into individual fields
             // This only works for US formatted addressess
             $endStreet = strpos($address['Address 1 - Formatted'], "\n");
             if ($endStreet !== false) {
                 $street = substr($address['Address 1 - Formatted'], 0, $endStreet - 1);
                 $endCity = strpos($address['Address 1 - Formatted'], ",", $endStreet);
                 if ($endCity !== false) {
                     $city = substr($address['Address 1 - Formatted'], $endStreet + 1, $endCity - $endStreet - 1);
                     $tmpZip = substr($address['Address 1 - Formatted'], -5);
                     if (is_numeric($tmpZip)) {
                         $endZip = strpos($address['Address 1 - Formatted'], $tmpZip, $endCity);
                         if ($endZip !== false) {
                             $state = substr($address['Address 1 - Formatted'], $endCity + 2);
                             $state = substr($state, 0, -6);
                             // 5 zip + space
                             $zip = $tmpZip;
                         }
                     } else {
                         $state = substr($address['Address 1 - Formatted'], $endCity);
                     }
                 }
             } else {
                 $street = $address['Address 1 - Formatted'];
             }
         } elseif (isset($address['Address 1 - Street'])) {
             // Gmail
             $street = $address['Address 1 - Street'];
         }
         // City
         if (isset($address['city'])) {
             // FCMS
             $city = $address['city'];
         } elseif (isset($address['Home City'])) {
             // Outlook
             $city = $address['Home City'];
         } elseif (isset($address['Address 1 - City'])) {
             // Gmail
             $city = $address['Address 1 - City'];
         }
         // State
         if (isset($address['state'])) {
             // FCMS
             $state = $address['state'];
         } elseif (isset($address['Home State'])) {
             // Outlook
             $state = $address['Home State'];
         } elseif (isset($address['Address 1 - Region'])) {
             // Gmail
             $state = $address['Address 1 - Region'];
         }
         // Zip
         if (isset($address['zip'])) {
             // FCMS
             $zip = $address['zip'];
         } elseif (isset($address['Home Postal Code'])) {
             // Outlook
             $zip = $address['Home Postal Code'];
         } elseif (isset($address['Address 1 - Postal Code'])) {
             // Gmail
             $zip = $address['Address 1 - Postal Code'];
         }
         // Phone Numbers
         $home = '';
         $work = '';
         $cell = '';
         // FCMS
         if (isset($address['home'])) {
             $home = $address['home'];
         }
         if (isset($address['work'])) {
             $work = $address['work'];
         }
         if (isset($address['cell'])) {
             $cell = $address['cell'];
         }
         // Outlook
         if (isset($address['Home Phone'])) {
             $home = $address['Home Phone'];
         }
         if (isset($address['Business Phone'])) {
             $work = $address['Business Phone'];
         }
         if (isset($address['Mobile Phone'])) {
             $cell = $address['Mobile Phone'];
         }
         // Gmail
         if (isset($address['Phone 1 - Type'])) {
             switch ($address['Phone 1 - Type']) {
                 case 'Home':
                     $home = $address['Phone 1 - Value'];
                     break;
                 case 'Work':
                     $work = $address['Phone 1 - Value'];
                     break;
                 case 'Mobile':
                     $cell = $address['Phone 1 - Value'];
                     break;
             }
         }
         if (isset($address['Phone 2 - Type'])) {
             switch ($address['Phone 2 - Type']) {
                 case 'Home':
                     $home = $address['Phone 2 - Value'];
                     break;
                 case 'Work':
                     $work = $address['Phone 2 - Value'];
                     break;
                 case 'Mobile':
                     $cell = $address['Phone 2 - Value'];
                     break;
             }
         }
         if (isset($address['Phone 3 - Type'])) {
             switch ($address['Phone 3 - Type']) {
                 case 'Home':
                     $home = $address['Phone 3 - Value'];
                     break;
                 case 'Work':
                     $work = $address['Phone 3 - Value'];
                     break;
                 case 'Mobile':
                     $cell = $address['Phone 3 - Value'];
                     break;
             }
         }
         // Create non-member
         $uniq = uniqid("");
         $pw = 'NONMEMBER';
         if (isset($_POST['private'])) {
             $pw = 'PRIVATE';
         }
         $sql = "INSERT INTO `fcms_users`\n                        (`access`, `joindate`, `fname`, `lname`, `email`, `username`, `phpass`)\n                    VALUES (3, NOW(), ?, ?, ?, 'NONMEMBER-{$uniq}', ?)";
         $params = array($fname, $lname, $email, $pw);
         $id = $this->fcmsDatabase->insert($sql, $params);
         if ($id === false) {
             $this->fcmsError->displayError();
             return;
         }
         // Create address for non-member
         $sql = "INSERT INTO `fcms_address`\n                        (`user`, `created_id`, `created`, `updated_id`, `updated`, `address`, `city`, `state`, `zip`, `home`, `work`, `cell`)\n                    VALUES\n                        (?, ?, NOW(), ?, NOW(), ?, ?, ?, ?, ?, ?, ?)";
         $params = array($id, $this->fcmsUser->id, $this->fcmsUser->id, $street, $city, $state, $zip, $home, $work, $cell);
         if ($this->fcmsDatabase->insert($sql, $params)) {
             $this->fcmsError->displayError();
             return;
         }
         $i++;
     }
     echo '
         <p class="ok-alert">
             ' . sprintf(T_ngettext('%d Address Added Successfully', '%d Addresses Added Successfully', $i), $i) . '
         </p>';
 }
示例#10
0
function get_formatted_timediff($then, $timeout = 24, $now = false)
{
    $then = strtotime($then);
    define('INT_SECOND', 1);
    define('INT_MINUTE', 60);
    define('INT_HOUR', 3600);
    define('INT_DAY', 86400);
    define('INT_WEEK', 604800);
    $now = !$now ? time() : $now;
    $timediff = $now - $then;
    $weeks = (int) intval($timediff / INT_WEEK);
    $timediff = (int) intval($timediff - INT_WEEK * $weeks);
    $days = (int) intval($timediff / INT_DAY);
    $timediff = (int) intval($timediff - INT_DAY * $days);
    $hours = (int) intval($timediff / INT_HOUR);
    $timediff = (int) intval($timediff - INT_HOUR * $hours);
    $mins = (int) intval($timediff / INT_MINUTE);
    $timediff = (int) intval($timediff - INT_MINUTE * $mins);
    $sec = (int) intval($timediff / INT_SECOND);
    $timediff = (int) intval($timediff - $sec * INT_SECOND);
    if ($hours < $timeout && $days < 1 && $weeks < 1) {
        $str = '';
        if ($weeks) {
            $str .= intval($weeks);
            $str .= ' ' . T_ngettext('week', 'weeks', $weeks);
        }
        if ($days) {
            $str .= $str ? ', ' : '';
            $str .= intval($days);
            $str .= ' ' . T_ngettext('day', 'days', $days);
        }
        if ($hours) {
            $str .= $str ? ', ' : '';
            $str .= intval($hours);
            $str .= ' ' . T_ngettext('hour', 'hours', $hours);
        }
        if ($mins) {
            $str .= $str ? ', ' : '';
            $str .= intval($mins);
            $str .= ' ' . T_ngettext('minute', 'minutes', $mins);
        }
        if ($sec) {
            $str .= $str ? ', ' : '';
            $str .= intval($sec);
            $str .= ' ' . T_ngettext('second', 'seconds', $sec);
        }
        if (!$weeks && !$days && !$hours && !$mins && !$sec) {
            $str .= T_('0 seconds ago');
        } else {
            $str = sprintf(T_('%s ago'), $str);
        }
    }
    return $str;
}
示例#11
0
                    if (empty($results[$row['bid']])) {
                        $results[$row['bid']] = 0;
                    }
                    $results[$row['bid']] += 2 * (100 - $total_rows / $total_bookmarks * 100) / $mod;
                }
            }
        }
        $number_of_results = count($results) + count($group_results);
    }
    include 'bheader.php';
    if ($keywords != null) {
        echo "<br><b>" . T_("Search") . " -- " . T_("Results") . "</b>";
        if ($number_of_results == 0) {
            $number_of_results = "" . T_("No") . "";
        }
        $resultsStr = T_ngettext('result', 'results', $number_of_results);
        // Added all the entities stripslashes stuff to the search results. [LBS 20020211]
        echo "<p><b>{$number_of_results}</b> {$resultsStr} " . T_("for") . " \"<b>" . htmlentities(stripslashes($keywords)) . "</b>\"";
    } else {
        echo "<br><b>" . T_("Search in your own bookmarks") . "</b>";
    }
    ?>
		<!-- Search Box -->

		<p>
		<form method="post">
		<input type='hidden' name='action' value='search' />
		<input name='keywords' value="" size="30" value="<?php 
    echo htmlentities(stripslashes($keywords));
    ?>
" class="formtext" onfocus="this.select()" />
示例#12
0
文件: video.php 项目: lmcro/fcms
 /**
  * displayMembersListPage 
  * 
  * @return void
  */
 function displayMembersListPage()
 {
     $this->displayHeader();
     $sql = "SELECT v.`id`, COUNT(*) AS 'count', v.`created_id` AS 'user_id', u.`fname`, u.`lname`, u.`avatar`, u.`gravatar`\n                FROM `fcms_video` AS v\n                LEFT JOIN `fcms_users` AS u ON v.`created_id` = u.`id`\n                WHERE `active` = 1\n                GROUP BY v.`created_id`\n                ORDER BY v.`updated` DESC";
     $rows = $this->fcmsDatabase->getRows($sql);
     if ($rows === false) {
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     echo '
     <div id="sections_menu">
         <ul>
             <li><a href="video.php">Latest Videos</a></li>
         </ul>
     </div>
     <ul id="large_video_users">';
     foreach ($rows as $row) {
         $name = cleanOutput($row['fname']) . ' ' . cleanOutput($row['lname']);
         $avatarPath = getAvatarPath($row['avatar'], $row['gravatar']);
         echo '
         <li>
             <a href="?u=' . $row['user_id'] . '"><img src="' . $avatarPath . '" alt="' . $name . '"/></a><br/>
             <a href="?u=' . $row['user_id'] . '">' . $name . '</a>
             <span>' . sprintf(T_ngettext('%d video', '%d videos', $row['count']), $row['count']) . '</span>
         </li>';
     }
     echo '
     </ul>
 </div>';
     $this->displayFooter();
 }
                                $unit = ngettext('month ago', 'months ago', $interval);
                            } else {
                                if ($interval < 631138519) {
                                    $interval = floor($interval / 31556926);
                                    $unit = ngettext('year ago', 'years ago', $interval);
                                } else {
                                    $interval = floor($interval / 315569260);
                                    $unit = ngettext('decade ago', 'decades ago', $interval);
                                }
                            }
                        }
                    }
                }
            }
        }
        $time_string = sprintf('%d ' . T_ngettext($unit, $unit, $interval), $interval);
    }
    $song->format();
    ?>
    <tr class="<?php 
    echo UI::flip_class();
    ?>
">
        <td class="cel_play">
            <span class="cel_play_content">&nbsp;</span>
            <div class="cel_play_hover">
            <?php 
    if (AmpConfig::get('directplay')) {
        ?>
                <?php 
        echo Ajax::button('?page=stream&action=directplay&playtype=song&song_id=' . $song->id, 'play', T_('Play'), 'play_song_' . $nb . '_' . $song->id);
示例#14
0
文件: datetime.php 项目: lmcro/fcms
/**
 * getHumanTimeSince 
 * 
 * Returns a nice, human readable difference between two dates.
 * ex: "5 days", "24 minutes"
 *
 * to time will be set to time() if not supplied
 * 
 * @param int $from 
 * @param int $to 
 * 
 * @return void
 */
function getHumanTimeSince($from, $to = 0)
{
    if ($to == 0) {
        $to = time();
    }
    $diff = (int) abs($to - $from);
    // now
    if ($diff < 1) {
        $since = T_('right now');
    } elseif ($diff < 60) {
        $since = sprintf(T_ngettext('%s second ago', '%s seconds ago', $diff), $diff);
    } elseif ($diff <= 3600) {
        $mins = round($diff / 60);
        if ($mins <= 1) {
            $mins = 1;
        }
        $since = sprintf(T_ngettext('%s minute ago', '%s minutes ago', $mins), $mins);
    } elseif ($diff <= 86400 && $diff > 3600) {
        $hours = round($diff / 3600);
        if ($hours <= 1) {
            $hours = 1;
        }
        $since = sprintf(T_ngettext('%s hour ago', '%s hours ago', $hours), $hours);
    } elseif ($diff >= 86400) {
        $days = round($diff / 86400);
        if ($days <= 1) {
            $days = 1;
        }
        $since = sprintf(T_ngettext('%s day ago', '%s days ago', $days), $days);
    }
    return $since;
}
$logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) {
    $logged_on_userid = NULL;
}
$popularTags =& $b2tservice->getPopularTags($userid, $popCount, $logged_on_userid);
$popularTags =& $b2tservice->tagCloud($popularTags, 5, 90, 225, 'alphabet_asc');
if ($popularTags && count($popularTags) > 0) {
    ?>

<h2><?php 
    echo T_('Popular Tags');
    ?>
</h2>
<div id="popular">
    <p class="tags">
    <?php 
    $contents = '';
    if (strlen($user) == 0) {
        $cat_url = createURL('tags', '%2$s');
    }
    foreach ($popularTags as $row) {
        $entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']);
        $contents .= '<a href="' . sprintf($cat_url, $user, filter($row['tag'], 'url')) . '" title="' . $row['bCount'] . ' ' . $entries . '" rel="tag" style="font-size:' . $row['size'] . '">' . filter($row['tag']) . '</a> ';
    }
    echo $contents . "\n";
    ?>
    </p>
</div>

<?php 
}
示例#16
0
文件: settings.php 项目: lmcro/fcms
 /**
  * displayImportBlogPosts 
  * 
  * @return void
  */
 function displayImportBlogPosts()
 {
     $this->displayHeader();
     // setup familynew obj
     $newsObj = new FamilyNews($this->fcmsError, $this->fcmsDatabase, $this->fcmsUser);
     // get external ids
     $external_ids = $newsObj->getExternalPostIds();
     // Get import blog settings
     $sql = "SELECT `user`, `blogger`, `tumblr`, `wordpress`, `posterous`\n                FROM `fcms_user_settings`\n                WHERE `user` = ?";
     $r = $this->fcmsDatabase->getRow($sql, $this->fcmsUser->id);
     if ($r === false) {
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     if (empty($r)) {
         echo '<div class="error-alert">' . T_('Nothing to import.') . '</div>';
         $this->fcmsSettings->displayFamilyNews();
         $this->displayFooter();
         return;
     }
     $count = 0;
     switch ($_GET['import']) {
         case 'blogger':
             $count = $newsObj->importBloggerPosts($r['blogger'], $this->fcmsUser->id, '', $external_ids);
             if ($count === false) {
                 $this->fcmsSettings->displayFamilyNews();
                 $this->displayFooter();
                 return;
             }
             break;
         case 'tumblr':
             $count = $newsObj->importTumblrPosts($r['tumblr'], $this->fcmsUser->id, '', $external_ids);
             if ($count === false) {
                 $this->fcmsSettings->displayFamilyNews();
                 $this->displayFooter();
                 return;
             }
             break;
         case 'wordpress':
             $count = $newsObj->importWordpressPosts($r['wordpress'], $this->fcmsUser->id, '', $external_ids);
             if ($count === false) {
                 $this->fcmsSettings->displayFamilyNews();
                 $this->displayFooter();
                 return;
             }
             break;
         case 'posterous':
             $count = $newsObj->importPosterousPosts($r['posterous'], $this->fcmsUser->id, '', $external_ids);
             if ($count === false) {
                 $this->fcmsSettings->displayFamilyNews();
                 $this->displayFooter();
                 return;
             }
             break;
     }
     displayOkMessage(sprintf(T_ngettext('%d post has been imported.', '%d posts have been imported.', $count), $count));
     $this->fcmsSettings->displayFamilyNews();
     $this->displayFooter();
     return;
 }
示例#17
0
    /**
     * displayAward 
     * 
     * Displays details about the given award type.
     * Along with who the award was awarded to and any other awards they own.
     * 
     * @param int $userid 
     * @param int $type
     * 
     * @return void
     */
    function displayAward($userid, $type)
    {
        $userid = (int) $userid;
        $sql = "SELECT a.`id`, a.`user`, a.`award`, a.`month`, a.`date`, a.`item_id`, a.`count`, u.`fname`\n                FROM `fcms_user_awards` AS a,\n                    `fcms_users` AS u\n                WHERE a.`user` = '{$userid}'\n                AND a.`award` = '{$type}'\n                AND a.`user` = u.`id`";
        $rows = $this->fcmsDatabase->getRows($sql, array($userid, $type));
        if ($rows === false) {
            $this->fcmsError->displayError();
            return;
        }
        if (count($rows) <= 0) {
            echo '
            <p class="error-alert">' . T_('Invalid Member/Award.') . '</p>';
            return;
        }
        $awardList = array();
        foreach ($rows as $r) {
            $awardList[] = $r;
            $fname = $r['fname'];
        }
        $currentAward = array('id' => $awardList[0]['id'], 'award' => $awardList[0]['award'], 'month' => $awardList[0]['month'], 'date' => $awardList[0]['date'], 'item_id' => $awardList[0]['item_id'], 'count' => $awardList[0]['count']);
        $awardsInfo = $this->getAwardsInfoList();
        $totalTimesAwarded = count($awardList);
        $string = T_ngettext('%s has been given this award %d time.', '%s has been given this award %d times.', $totalTimesAwarded);
        $awardedCount = sprintf($string, $fname, $totalTimesAwarded) . '</h5>';
        if ($userid == $this->fcmsUser->id) {
            $string = T_ngettext('You have been given this award %d time.', 'You have been given this award %d times.', $totalTimesAwarded);
            $awardedCount = sprintf($string, $totalTimesAwarded) . '</h5>';
        }
        echo '
            <div id="current-award">
                <div class="' . $currentAward['award'] . '"></div>
                <h1>' . $awardsInfo[$currentAward['award']]['name'] . '</h1>
                <h2>' . $awardsInfo[$currentAward['award']]['description'] . '</h2>
            </div>

            <h5 class="times-awarded">' . $awardedCount . '</h5>';
        foreach ($awardList as $r) {
            $details = '';
            $date = '';
            if (strlen($r['month']) == 6) {
                $year = substr($r['month'], 0, 4);
                $month = substr($r['month'], 4, 2);
                $date = date('F, Y', strtotime("{$year}-{$month}-01"));
            }
            switch ($r['award']) {
                case 'board':
                    $details = sprintf(T_pgettext('Ex: December, 2011 - 10 posts', '%s - %s posts'), $date, $r['count']);
                    break;
                case 'gallery':
                    $details = sprintf(T_pgettext('Ex: December, 2011 - 10 photos', '%s - %s photos'), $date, $r['count']);
                    break;
                case 'recipes':
                    $details = sprintf(T_pgettext('Ex: December, 2011 - 10 recipes', '%s - %s recipes'), $date, $r['count']);
                    break;
                case 'news':
                    $details = sprintf(T_pgettext('Ex: December, 2011 - 10 posts', '%s - %s posts'), $date, $r['count']);
                    break;
                case 'docs':
                    $details = sprintf(T_pgettext('Ex: December, 2011 - 10 documents', '%s - %s documents'), $date, $r['count']);
                    break;
                case 'icebreaker':
                    $thread = (int) $r['item_id'];
                    $replies = sprintf(T_pgettext('Ex: 21 replies', '%d replies'), $r['count']);
                    $details = $date . ' - <a href="messageboard.php?thread=' . $thread . '">' . $this->fcmsMessageBoard->getThreadSubject($thread) . '</a> - ' . $replies;
                    break;
                case 'shutterbug':
                    $id = (int) $r['item_id'];
                    $photo = $this->fcmsPhotoGallery->getPhotoInfo($id);
                    $views = sprintf(T_pgettext('Ex: 210 views', '%d views'), $r['count']);
                    $photoSrc = $this->fcmsPhotoGallery->getPhotoSource($photo);
                    $details = $date . ' - ' . $views . '<br/>';
                    $details .= '<a href="gallery/index.php?uid=' . $photo['user'] . '&amp;cid=' . $photo['category'] . '&amp;pid=' . $photo['id'] . '">';
                    $details .= '<img src="' . $photoSrc . '"/>';
                    $details .= '</a>';
                    break;
                case 'interesting':
                    $id = (int) $r['item_id'];
                    $views = sprintf(T_pgettext('Ex: 21 comments', '%d comments'), $r['count']);
                    $sql = "SELECT `title`\n                            FROM `fcms_news`\n                            WHERE `id` = '{$id}'";
                    $news = $this->fcmsDatabase->getRow($sql, $id);
                    if ($news === false) {
                        $this->fcmsError->displayError();
                        return;
                    }
                    $title = cleanOutput($news['title']);
                    $details = $date . ' - <a href="familynews.php?getnews=' . $r['user'] . '&amp;newsid=' . $id . '">' . $title . '</a> - ' . $views;
                    break;
                case 'secretive':
                    $views = sprintf(T_pgettext('Ex: 210 private messages', '%d private messages'), $r['count']);
                    $details = $date . ' - ' . $views . '<br/>';
                    break;
                case 'planner':
                    $views = sprintf(T_pgettext('Ex: 53 events', '%d events'), $r['count']);
                    $details = $date . ' - ' . $views . '<br/>';
                    break;
                case 'photogenic':
                    $views = sprintf(T_pgettext('Ex: 53 photos', '%d photos'), $r['count']);
                    $details = $date . ' - ' . $views . '<br/>';
                    break;
            }
            echo '
                <p>' . $details . '</p>';
        }
    }
<?php

$userservice =& ServiceFactory::getServiceInstance('UserService');
if ($userservice->isLoggedOn()) {
    $currentUser = $userservice->getCurrentUser();
    $currentUsername = $currentUser[$userservice->getFieldName('username')];
    if ($currentUsername == $user) {
        $tags = explode('+', $currenttag);
        $renametext = T_ngettext('Rename Tag', 'Rename Tags', count($tags));
        $renamelink = createURL('tagrename', $currenttag);
        $deletelink = createURL('tagdelete', $currenttag);
        ?>

<h2><?php 
        echo T_('Actions');
        ?>
</h2>
<div id="tagactions">
    <ul>
        <li><a href="<?php 
        echo $renamelink;
        ?>
"><?php 
        echo $renametext;
        ?>
</a></li>
        <?php 
        if (count($tags) == 1) {
            ?>
        <li><a href="<?php 
            echo $deletelink;
示例#19
0
    include 'conn.php';
    echo "<div id=\"mainHr\"><hr></div>";
    echo "<p style=\"text-align: center;\">";
    $Query = "select count(name) as total from " . TABLE_PREFIX . "session where status!='disabled'";
    //echo($Query . "<br>\n");
    $dbResult = $dblink->query($Query);
    $count = 0;
    if ($row =& $dbResult->fetchRow(DB_FETCHMODE_ASSOC)) {
        $rec_total_users = "{$row["total"]}";
    }
    $Query = "select count(*) as total from " . TABLE_PREFIX . "favourites";
    //echo($Query . "<br>\n");
    $dbResult = $dblink->query($Query);
    $count = 0;
    if ($row =& $dbResult->fetchRow(DB_FETCHMODE_ASSOC)) {
        $rec_total_bookmarks = "{$row["total"]}";
    }
    $usersStr = T_ngettext('user', 'users', $rec_total_users);
    $thereStr = T_ngettext('There is', 'There are', $rec_total_users);
    echo "{$thereStr} <b>" . $rec_total_users . " {$usersStr}</b> " . sprintf(T_("registered on %s"), WEBSITE_NAME) . ".\n";
    echo "<br>" . sprintf(T_("There are <b>%s bookmarks</b> stored on %s"), $rec_total_bookmarks, WEBSITE_NAME) . ".</p>\n";
    if (IS_GETBOO) {
        // Paypal button
        $pAlign = "center";
        include 'paypal.php';
    }
}
?>
</div>
</body>
</html>
示例#20
0
                $donorLogo = " <img src=\"images/donor-mini.gif\" alt=\"" . T_("Donor") . "\" title=\"" . T_("Donor") . "\" />";
            } else {
                $donorLogo = "";
            }
            echo T_("by") . " <a href=\"userb.php?uname=" . $userName . "\">" . $userName . "{$donorLogo}</a> ";
        }
        echo "... ";
        if ($time_between) {
            echo T_("added") . " " . $time_between;
        } else {
            echo T_("on") . " " . $date_added;
        }
        /*if($username == $userName)
        		echo(" / Delete");*/
        echo "</div>\n";
        //Comments
        $nbOfComments = getNbOfComments($rec_id);
        echo "<div class=\"tagfooter\"{$footerCSS}><a href=\"comment.php?bID=" . $rec_id . "\" ";
        if ($nbOfComments == 0) {
            echo "class=\"tagCommentSingle\">" . T_("submit comment");
        } else {
            $resultsStr = T_ngettext('comment', 'comments', $nbOfComments);
            echo "class=\"tagCommentMultiple\">" . "{$resultsStr}(" . $nbOfComments . ")";
        }
        echo "</a></div>\n";
        if (USE_SCREENSHOT && SCREENSHOT_URL) {
            echo "</div>\n";
        }
        echo "<br>\n";
    }
}