本文整理汇总了PHP中SemanticScuttle_Service_Factory类的典型用法代码示例。如果您正苦于以下问题:PHP SemanticScuttle_Service_Factory类的具体用法?PHP SemanticScuttle_Service_Factory怎么用?PHP SemanticScuttle_Service_Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SemanticScuttle_Service_Factory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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');
}
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:8,代码来源:VoteTest.php
示例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();
}
开发者ID:hrepp,项目名称:SemanticScuttle,代码行数:12,代码来源:Tag2TagTest.php
示例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]++;
}
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:52,代码来源:import.php
示例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);
}
开发者ID:lcorbasson,项目名称:SemanticScuttle,代码行数:21,代码来源:GetAdminLinkedTagsTest.php
示例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();
}
开发者ID:hrepp,项目名称:SemanticScuttle,代码行数:21,代码来源:TestBaseApi.php
示例6: getAdminUser
/**
* Retrieves the UID of an admin user.
* If that user does not exist in the database, it is created.
*
* @return integer UID of admin user
*/
protected function getAdminUser()
{
if (count($GLOBALS['admin_users']) == 0) {
$this->fail('No admin users configured');
}
$adminUserName = reset($GLOBALS['admin_users']);
$us = SemanticScuttle_Service_Factory::get('User');
$uid = $us->getIdFromUser($adminUserName);
if ($uid === null) {
//that user does not exist in the database; create it
$uid = $us->addUser($adminUserName, rand(), 'unittest-admin-' . $adminUserName . '@example.org');
}
return $uid;
}
开发者ID:hrepp,项目名称:SemanticScuttle,代码行数:20,代码来源:TestBase.php
示例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 <[email protected]>
* @author Christian Weiske <[email protected]>
* @author Eric Dane <[email protected]>
* @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);
开发者ID:lcorbasson,项目名称:SemanticScuttle,代码行数:31,代码来源:getadmintags.php
示例8:
<?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
开发者ID:hrepp,项目名称:SemanticScuttle,代码行数:31,代码来源:export_sioc.php
示例9: 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;
}
开发者ID:hrepp,项目名称:SemanticScuttle,代码行数:20,代码来源:Bookmark2Tag.php
示例10: foreach
*
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @subcategory Templates
* @author Benjamin Huynh-Kim-Bang <[email protected]>
* @author Christian Weiske <[email protected]>
* @author Eric Dane <[email protected]>
* @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']);
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:31,代码来源:sidebar.block.search.php
示例11: deleteAll
function deleteAll()
{
$query = 'TRUNCATE TABLE `' . $this->getTableName() . '`';
$this->db->sql_query($query);
$tsts = SemanticScuttle_Service_Factory::get('TagStat');
$tsts->deleteAll();
}
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:7,代码来源:Tag2Tag.php
示例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';
开发者ID:lcorbasson,项目名称:SemanticScuttle,代码行数:31,代码来源:header.php
示例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);
}
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:69,代码来源:sidebar.linkedtags.inc.php
示例14: setUp
protected function setUp()
{
$this->us = SemanticScuttle_Service_Factory::get('User');
$this->us->deleteAll();
}
开发者ID:hrepp,项目名称:SemanticScuttle,代码行数:5,代码来源:UserTest.php
示例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'];
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:31,代码来源:register.php
示例16: getCurrentUserId
/**
* Return current user id based on session or cookie
*
* @return mixed Integer user id or boolean false when user
* could not be found or is not logged on.
*/
public function getCurrentUserId()
{
if ($this->currentuserId !== null) {
return $this->currentuserId;
}
if (isset($_SESSION[$this->getSessionKey()])) {
$this->currentuserId = (int) $_SESSION[$this->getSessionKey()];
return $this->currentuserId;
}
if (isset($_COOKIE[$this->getCookieKey()])) {
$cook = explode(':', $_COOKIE[$this->getCookieKey()]);
//cookie looks like this: 'id:md5(username+password)'
$query = 'SELECT * FROM ' . $this->getTableName() . ' WHERE MD5(CONCAT(' . $this->getFieldName('username') . ', ' . $this->getFieldName('password') . ')) = \'' . $this->db->sql_escape($cook[1]) . '\' AND ' . $this->getFieldName('primary') . ' = ' . $this->db->sql_escape($cook[0]);
if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not get user', '', __LINE__, __FILE__, $query, $this->db);
return false;
}
if ($row = $this->db->sql_fetchrow($dbresult)) {
$this->setCurrentUserId((int) $row[$this->getFieldName('primary')], true);
$this->db->sql_freeresult($dbresult);
return $this->currentuserId;
}
}
$ssls = SemanticScuttle_Service_Factory::get('User_SslClientCert');
if ($ssls->hasValidCert()) {
$id = $ssls->getUserIdFromCert();
if ($id !== false) {
$this->setCurrentUserId($id, true);
return $this->currentuserId;
}
}
return false;
}
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:39,代码来源:User.php
示例17: testGetDb
public function testGetDb()
{
$this->assertInstanceOf('sql_db', SemanticScuttle_Service_Factory::getDb());
}
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:4,代码来源:FactoryTest.php
示例18: testCountOthersWatchlistComplex
/**
* Test what countOther() returns when the user is logged in
* and friends (people on the watchlist) have bookmarked
* and shared the same address.
*
* @return void
*/
public function testCountOthersWatchlistComplex()
{
$uid = $this->addUser();
$address = 'http://example.org';
//log user in
$this->us->setCurrentUserId($uid);
//setup users
$otherPublic1 = $this->addUser();
$otherPublic2 = $this->addUser();
$otherShared1 = $this->addUser();
$otherPrivate1 = $this->addUser();
$friendPublic1 = $this->addUser();
$friendShared1 = $this->addUser();
$friendShared2 = $this->addUser();
$friendPrivate1 = $this->addUser();
$friendSharing1 = $this->addUser();
//setup watchlists
$us = SemanticScuttle_Service_Factory::get('User');
$this->us->setCurrentUserId($friendPublic1);
$us->setWatchStatus($uid);
$this->us->setCurrentUserId($friendShared1);
$us->setWatchStatus($uid);
$this->us->setCurrentUserId($friendShared2);
$us->setWatchStatus($uid);
$this->us->setCurrentUserId($friendPrivate1);
$us->setWatchStatus($uid);
//back to login of main user
$this->us->setCurrentUserId($uid);
$us->setWatchStatus($friendSharing1);
//add bookmarks
$this->addBookmark($uid, $address, 0);
$this->addBookmark($otherPublic1, $address, 0);
$this->addBookmark($otherPublic2, $address, 0);
$this->addBookmark($otherShared1, $address, 1);
$this->addBookmark($otherPrivate1, $address, 2);
$this->addBookmark($friendPublic1, $address, 0);
$this->addBookmark($friendShared1, $address, 1);
$this->addBookmark($friendShared2, $address, 1);
$this->addBookmark($friendPrivate1, $address, 2);
//this user is on our watchlist, but we not on his
$this->addBookmark($friendSharing1, $address, 1);
//2 public
//1 public (friend)
//2 shared
//-> 5
$this->assertEquals(5, $this->bs->countOthers($address));
}
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:54,代码来源:BookmarkTest.php
示例19: createTagArray
* Creates an jsTree json array for the given tag
*
* @param string $tag Tag name
* @param boolean $hasChildren If the tag has subtags (children) or not.
* If unsure, set it to "true".
* @param boolean $isOpen If the tag has children: Is the tree node open
* or closed?
* @param boolean $autoParent If the tag is an automatically generated parent tag
*
* @return array Array to be sent back to the browser as json
*/
function createTagArray($tag, $hasChildren = true, $isOpen = false, $autoParent = false)
{
if ($autoParent) {
$title = '(' . $tag . ')';
} else {
$title = $tag;
}
$ar = array('data' => array('title' => $title, 'attr' => array('href' => createUrl('tags', $tag))), 'attr' => array('rel' => $tag));
if ($hasChildren) {
//jstree needs that to show the arrows
$ar['state'] = $isOpen ? 'open' : 'closed';
}
if ($autoParent) {
//FIXME: use css class
$ar['data']['attr']['style'] = 'color: #AAA';
}
return $ar;
}
$tagData = assembleLinkedTagData($tags, 0, $loadParentTags, SemanticScuttle_Service_Factory::get('Tag2Tag'));
echo json_encode($tagData);
开发者ID:MarxGonzalez,项目名称:SemanticScuttle,代码行数:31,代码来源:getlinkedtags.php
示例20: htmlspecialchars
<?php
/**
* Bookmark thumbnail image
* Shows the website thumbnail for the bookmark.
*
* Expects a $row variable with bookmark data.
*/
$thumbnailer = SemanticScuttle_Service_Factory::get('Thumbnails')->getThumbnailer();
$imgUrl = $thumbnailer->getThumbnailUrl($address, 120, 90);
if ($imgUrl !== false) {
echo '<a href="' . htmlspecialchars($address) . '">' . '<img class="thumbnail" width="120" height="90" src="' . htmlspecialchars($imgUrl) . '" />' . '</a>';
}
开发者ID:lcorbasson,项目名称:SemanticScuttle,代码行数:13,代码来源:bookmarks-thumbnail.inc.tpl.php
注:本文中的SemanticScuttle_Service_Factory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论