本文整理汇总了PHP中SemanticScuttle_Service_Factory::get方法的典型用法代码示例。如果您正苦于以下问题:PHP SemanticScuttle_Service_Factory::get方法的具体用法?PHP SemanticScuttle_Service_Factory::get怎么用?PHP SemanticScuttle_Service_Factory::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SemanticScuttle_Service_Factory
的用法示例。
在下文中一共展示了SemanticScuttle_Service_Factory::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$GLOBALS['enableVoting'] = true;
//FIXME: create true new instance
$this->vs = SemanticScuttle_Service_Factory::get('Vote');
$this->vs->deleteAll();
$this->bs = SemanticScuttle_Service_Factory::get('Bookmark');
}
示例2: setUp
protected function setUp()
{
$this->us = SemanticScuttle_Service_Factory::get('User');
$this->bs = SemanticScuttle_Service_Factory::get('Bookmark');
$this->bs->deleteAll();
$this->b2ts = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$this->b2ts->deleteAll();
$this->tts = SemanticScuttle_Service_Factory::get('Tag2Tag');
$this->tts->deleteAll();
$this->tsts = SemanticScuttle_Service_Factory::get('TagStat');
$this->tsts->deleteAll();
}
示例3: startElement
function startElement($parser, $name, $attrs)
{
global $depth, $status, $tplVars, $userservice;
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
if ($name == 'POST') {
$newstatus = $status;
while (list($attrTitle, $attrVal) = each($attrs)) {
switch ($attrTitle) {
case 'HREF':
$bAddress = $attrVal;
break;
case 'DESCRIPTION':
$bTitle = $attrVal;
break;
case 'EXTENDED':
$bDescription = $attrVal;
break;
case 'TIME':
$bDatetime = $attrVal;
break;
case 'TAG':
$tags = strtolower($attrVal);
break;
case 'PRIVATE':
if ($attrVal == 'yes') {
$newstatus = 2;
}
break;
}
}
if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) {
$tplVars['error'] = T_('You have already submitted this bookmark.');
} else {
// Strangely, PHP can't work out full ISO 8601 dates, so we have to chop off the Z.
$bDatetime = substr($bDatetime, 0, -1);
// If bookmark claims to be from the future, set it to be now instead
if (strtotime($bDatetime) > time()) {
$bDatetime = gmdate('Y-m-d H:i:s');
}
$res = $bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, '', $newstatus, $tags, null, $bDatetime, true, true);
if ($res) {
$tplVars['msg'] = T_('Bookmark imported.');
} else {
$tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.');
}
}
}
if (!isset($depth[(int) $parser])) {
$depth[(int) $parser] = 0;
}
$depth[(int) $parser]++;
}
示例4: testOnlyAdminTags
/**
* Verify that we only get admin tags, not tags from
* non-admin people
*/
public function testOnlyAdminTags()
{
$t2t = SemanticScuttle_Service_Factory::get('Tag2Tag');
$t2t->deleteAll();
$menu2Tag = reset($GLOBALS['menu2Tags']);
//we have a subtag now
$this->addBookmark($this->getAdminUser(), null, 0, $menu2Tag . '>adminsubtag');
//add another bookmark now, but for a normal user
$this->addBookmark(null, null, 0, $menu2Tag . '>normalsubtag');
$res = $this->getRequest('?tag=' . $menu2Tag)->send();
$this->assertResponseJson200($res);
$data = json_decode($res->getBody());
$this->assertInternalType('array', $data);
//we should have only one subtag now, the admin one
$this->assertEquals(1, count($data));
$this->assertEquals('adminsubtag', $data[0]->data->title);
}
示例5: setUp
protected function setUp()
{
if ($GLOBALS['unittestUrl'] === null) {
$this->assertTrue(false, 'Unittest URL not set in config');
}
if ($this->urlPart === null) {
$this->assertTrue(false, 'Set the urlPart variable');
}
$this->url = $GLOBALS['unittestUrl'] . $this->urlPart;
//clean up before test
$configFile = $GLOBALS['datadir'] . '/config.testing-tmp.php';
if (file_exists($configFile)) {
unlink($configFile);
}
$this->us = SemanticScuttle_Service_Factory::get('User');
$this->us->deleteAll();
$this->bs = SemanticScuttle_Service_Factory::get('Bookmark');
$this->bs->deleteAll();
$this->b2t = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$this->b2t->deleteAll();
}
示例6: rewriteVotings
/**
* Re-calculates all votings for all bookmarks
* and updates the voting values in the bookmarks
* table.
* This is mainly meant to be an administrative method
* to fix a broken database.
*
* @return void
*/
public function rewriteVotings()
{
$bm = SemanticScuttle_Service_Factory::get('Bookmark');
$query = 'UPDATE ' . $bm->getTableName() . ' as B SET bVoting = ' . '(SELECT SUM(vote) FROM ' . $this->getTableName() . ' as V' . ' WHERE V.bId = B.bId GROUP BY bid)' . ', bVotes = ' . '(SELECT COUNT(vote) FROM ' . $this->getTableName() . ' as V' . ' WHERE V.bId = B.bId GROUP BY bid)';
$this->db->sql_query($query);
}
示例7: trim
* @param integer $limit Number of tags to return. Defaults to 1000
*
* Part of SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
* @author Christian Weiske <cweiske@cweiske.de>
* @author Eric Dane <ericdane@users.sourceforge.net>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
$httpContentType = 'application/json';
require_once '../www-header.php';
$limit = 30;
$beginsWith = null;
$currentUserId = $userservice->getCurrentUserId();
if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
$limit = (int) $_GET['limit'];
}
if (isset($_GET['beginsWith']) && strlen(trim($_GET['beginsWith']))) {
$beginsWith = trim($_GET['beginsWith']);
}
$listTags = SemanticScuttle_Service_Factory::get('Bookmark2Tag')->getAdminTags($limit, $currentUserId, null, $beginsWith);
$tags = array();
foreach ($listTags as $t) {
$tags[] = $t['tag'];
}
echo json_encode($tags);
示例8: define
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
* @author Christian Weiske <cweiske@cweiske.de>
* @author Eric Dane <ericdane@users.sourceforge.net>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
require_once 'www-header.php';
/* Service creation: only useful services are created */
$b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
$cdservice = SemanticScuttle_Service_Factory::get('CommonDescription');
/* Managing all possible inputs */
isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']) : define('POST_CONFIRM', '');
isset($_POST['cancel']) ? define('POST_CANCEL', $_POST['cancel']) : define('POST_CANCEL', '');
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']) : define('POST_DESCRIPTION', '');
isset($_POST['referrer']) ? define('POST_REFERRER', $_POST['referrer']) : define('POST_REFERRER', '');
/* Managing current logged user */
$currentUser = $userservice->getCurrentObjectUser();
/* Managing path info */
list($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
//permissions
if (!$userservice->isLoggedOn() || !$GLOBALS['enableCommonTagDescriptionEditedByAll'] && !$currentUser->isAdmin()) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit;
}
示例9:
<?php
/* Export data with semantic format (SIOC: http://sioc-project.org/, FOAF, SKOS, Annotea Ontology) */
$httpContentType = 'text/xml';
require_once '../www-header.php';
/* Service creation: only useful services are created */
$userservice = SemanticScuttle_Service_Factory::get('User');
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"\n?>";
?>
<rdf:RDF
xmlns="http://xmlns.com/foaf/0.1/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:rss="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:sioc="http://rdfs.org/sioc/ns#"
xmlns:sioc_t="http://rdfs.org/sioc/types#"
xmlns:bm="http://www.w3.org/2002/01/bookmark#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#">
<?php
//site and community are described using FOAF and SIOC ontology
?>
<sioc:Site rdf:about="<?php
echo ROOT;
?>
" >
<rdf:label><?php
示例10: renameTag
function renameTag($userid, $old, $new, $fromApi = false)
{
$bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark');
$tagservice = SemanticScuttle_Service_Factory::get('Tag');
if (is_null($userid) || is_null($old) || is_null($new)) {
return false;
}
// Find bookmarks with old tag
$bookmarksInfo =& $bookmarkservice->getBookmarks(0, NULL, $userid, $old);
$bookmarks =& $bookmarksInfo['bookmarks'];
// Delete old tag
$this->deleteTag($userid, $old);
// Attach new tags
$new = $tagservice->normalize($new);
foreach (array_keys($bookmarks) as $key) {
$row =& $bookmarks[$key];
$this->attachTags($row['bId'], $new, $fromApi, NULL, false);
}
return true;
}
示例11: foreach
*
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @subcategory Templates
* @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
* @author Christian Weiske <cweiske@cweiske.de>
* @author Eric Dane <ericdane@users.sourceforge.net>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
/* Service creation: only useful services are created */
$searchhistoryservice = SemanticScuttle_Service_Factory::get('SearchHistory');
$lastSearches = $searchhistoryservice->getAllSearches('all', NULL, 3, NULL, true, false);
if ($lastSearches && count($lastSearches) > 0) {
?>
<h2><?php
echo T_('Last Searches');
?>
</h2>
<div id="searches">
<table>
<?php
foreach ($lastSearches as $row) {
echo ' <tr><td>';
echo '<a href="' . htmlspecialchars(createURL('search', $range . '/' . $row['shTerms'])) . '">';
echo htmlspecialchars($row['shTerms']);
示例12: array
if ($GLOBALS['enableVoting']) {
if (isset($_SESSION['lastUrl'])) {
$GLOBALS['lastUrl'] = $_SESSION['lastUrl'];
}
//this here is hacky, but currently the only way to
// differentiate between css/js php files and normal
// http files
if (!isset($GLOBALS['saveInLastUrl']) || $GLOBALS['saveInLastUrl']) {
$_SESSION['lastUrl'] = $_SERVER['REQUEST_URI'];
}
}
}
// 5 // Create mandatory services and objects
$userservice = SemanticScuttle_Service_Factory::get('User');
$currentUser = $userservice->getCurrentObjectUser();
$templateservice = SemanticScuttle_Service_Factory::get('Template');
$tplVars = array();
$tplVars['currentUser'] = $currentUser;
$tplVars['userservice'] = $userservice;
// 6 // Force UTF-8 behaviour for server (cannot be moved into top.inc.php which is not included into every file)
if (!defined('UNIT_TEST_MODE') || defined('HTTP_UNIT_TEST_MODE')) {
//API files define that, so we need a way to support both of them
if (!isset($httpContentType)) {
if (DEBUG_MODE) {
//using that mime type makes all javascript nice in Chromium
// it also serves as test base if the pages really validate
$httpContentType = 'application/xhtml+xml';
} else {
//until we are sure that all pages validate, we
// keep the non-strict mode on for normal installations
$httpContentType = 'text/html';
示例13: displayLinkedTags
function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode = false, $precedentTag = null, $level = 0, $stopList = array())
{
if (in_array($tag, $stopList)) {
return array('output' => '', 'stoplist' => $stopList);
}
$tag2tagservice = SemanticScuttle_Service_Factory::get('Tag2Tag');
$tagstatservice = SemanticScuttle_Service_Factory::get('TagStat');
// link '>'
if ($level > 1) {
if ($editingMode) {
$link = '<small><a href="' . createURL('tag2tagedit', $precedentTag . '/' . $tag) . '" title="' . _('Edit link') . '">></a> </small>';
} else {
$link = '> ';
}
} else {
$link = '';
}
$output = '';
$output .= '<tr>';
$output .= '<td></td>';
$output .= '<td>';
$output .= $level == 1 ? '<b>' : '';
$output .= str_repeat(' ', $level * 2) . $link . '<a href="' . sprintf($cat_url, filter($user, 'url'), filter($tag, 'url')) . '" rel="tag">' . filter($tag) . '</a>';
$output .= $level == 1 ? '</b>' : '';
//$output.= ' - '. $tagstatservice->getMaxDepth($tag, $linkType, $uId);
$synonymTags = $tag2tagservice->getAllLinkedTags($tag, '=', $uId);
$synonymTags = is_array($synonymTags) ? $synonymTags : array($synonymTags);
sort($synonymTags);
$synonymList = '';
foreach ($synonymTags as $synonymTag) {
//$output.= ", ".$synonymTag;
$synonymList .= $synonymTag . ' ';
}
if (count($synonymTags) > 0) {
$output .= ', ' . $synonymTags[0];
}
if (count($synonymTags) > 1) {
$output .= '<span title="' . T_('Synonyms:') . ' ' . $synonymList . '">, etc</span>';
}
/*if($editingMode) {
$output.= ' (';
$output.= '<a href="'.createURL('tag2tagadd', $tag).'" title="'._('Add a subtag').'">+</a>';
if(1) {
$output.= ' - ';
$output.= '<a href="'.createURL('tag2tagdelete', $tag).'">-</a>';
}
$output.= ')';
}*/
$output .= '</td>';
$output .= '</tr>';
$tags = array($tag);
$tags = array_merge($tags, $synonymTags);
foreach ($tags as $tag) {
if (!in_array($tag, $stopList)) {
$linkedTags = $tag2tagservice->getLinkedTags($tag, '>', $uId);
$precedentTag = $tag;
$stopList[] = $tag;
foreach ($linkedTags as $linkedTag) {
$displayLinkedTags = displayLinkedTags($linkedTag, $linkType, $uId, $cat_url, $user, $editingMode, $precedentTag, $level + 1, $stopList);
$output .= $displayLinkedTags['output'];
}
if (isset($displayLinkedTags) && is_array($displayLinkedTags['stopList'])) {
$stopList = array_merge($stopList, $displayLinkedTags['stopList']);
$stopList = array_unique($stopList);
}
}
}
return array('output' => $output, 'stopList' => $stopList);
}
示例14: setUp
protected function setUp()
{
$this->us = SemanticScuttle_Service_Factory::get('User');
$this->us->deleteAll();
}
示例15: T_
$tplVars['error'] = T_('This username already exists, please make another choice.');
// Check if username is valid (length, authorized characters)
} elseif (!$userservice->isValidUsername($posteduser)) {
$tplVars['error'] = T_('This username is not valid (too short, too long, forbidden characters...), please make another choice.');
// Check if e-mail address is valid
} elseif (!$userservice->isValidEmail(POST_MAIL)) {
$tplVars['error'] = T_('E-mail address is not valid. Please try again.');
// Check if antispam answer is valid (doesn't take into account spaces and uppercase)
} elseif (strcasecmp(str_replace(' ', '', POST_ANTISPAMANSWER), str_replace(' ', '', $GLOBALS['antispamAnswer'])) != 0) {
$tplVars['error'] = T_('Antispam answer is not valid. Please try again.');
// Register details
} else {
$uId = $userservice->addUser($posteduser, POST_PASS, POST_MAIL);
if ($uId !== false) {
if (isset($_SERVER['SSL_CLIENT_VERIFY']) && $_SERVER['SSL_CLIENT_VERIFY'] == 'SUCCESS') {
$ssl = SemanticScuttle_Service_Factory::get('User_SslClientCert');
$ssl->registerCurrentCertificate($uId);
$ssl->updateProfileFromCurentCert($uId);
}
// Log in with new username
$login = $userservice->login($posteduser, POST_PASS);
if ($login) {
header('Location: ' . createURL('bookmarks', $posteduser));
}
$tplVars['msg'] = T_('You have successfully registered. Enjoy!');
} else {
$tplVars['error'] = T_('Registration failed. Please try again.');
}
}
}
$tplVars['antispamQuestion'] = $GLOBALS['antispamQuestion'];