本文整理汇总了PHP中Bookmark类的典型用法代码示例。如果您正苦于以下问题:PHP Bookmark类的具体用法?PHP Bookmark怎么用?PHP Bookmark使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bookmark类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testMisformatedJSON
/**
* @expectedException \Exception
*/
public function testMisformatedJSON()
{
$request = $this->getMockBuilder('\\Kanedo\\Request')->disableOriginalConstructor()->getMock();
$testee = new Bookmark($request);
$json = "{this is wroooong: lols'}";
$testee->setUp($json);
}
开发者ID:Type-of-Read,项目名称:Readability-API-1,代码行数:10,代码来源:BookmarkTest.php
示例2: testGetsUrl
public function testGetsUrl()
{
$url = $this->getUrlMock();
$comment = $this->getBookmarkCommentMock();
$date = new DateTimeImmutable();
$bookmark = new Bookmark($url, $comment, $date);
$this->assertEquals($url, $bookmark->getWebsite());
}
开发者ID:noichl,项目名称:pw-bookmarks,代码行数:8,代码来源:BookmarkTest.php
示例3: create
/**
* Creates a new bookmark
* @param $type
* @param $object_id the object who owns the bookmark
* @param $owner if not set, owner will be current user
* @return bookmark id
*/
public static function create($type, $object_id, $owner = 0)
{
$session = SessionHandler::getInstance();
$o = new Bookmark();
$o->type = $type;
$o->value = $object_id;
$o->owner = $owner ? $owner : $session->id;
return $o->store();
}
开发者ID:martinlindhe,项目名称:core_dev,代码行数:16,代码来源:Bookmark.php
示例4: addDel
/**
* Add or Delete Bookmark.
*/
public function addDel($postId)
{
$row = Bookmark::model()->find('postId=:postId and userId=:userId', array(':postId' => $postId, ':userId' => Yii::app()->user->id));
if (empty($row)) {
$row = new Bookmark();
$row->postId = $postId;
$row->userId = Yii::app()->user->id;
$row->save();
return true;
} else {
$row->delete();
return false;
}
}
开发者ID:Greka163,项目名称:Yii-blog-new,代码行数:17,代码来源:Bookmark.php
示例5: showSelector
/**
* Show a date selector
* @param datetime $date1 date of start
* @param datetime $date2 date of ending
* @param string $randname random string (to prevent conflict in js selection)
* @return nothing
*/
static function showSelector($date1, $date2, $randname)
{
$request_string = self::getRequestString($_GET);
echo "<div class='center'><form method='POST' action='?{$request_string}' name='form'" . " id='mreporting_date_selector'>\n";
echo "<table class='tab_cadre'><tr class='tab_bg_1'>";
echo '<td><table><tr class="tab_bg_1">';
echo "<td>";
Html::showDateFormItem("date1" . $randname, $date1, false);
echo "</td>\n";
echo "<td>";
Html::showDateFormItem("date2" . $randname, $date2, false);
echo "</td>\n";
self::getReportSelectors();
echo "</tr></table></td>";
echo "<td rowspan='2' class='center'>";
echo "<input type='submit' class='button' name='submit' Value=\"" . _sx('button', 'Post') . "\">";
echo "</td>\n";
echo "<td class='center'>";
$_SERVER['REQUEST_URI'] .= "&date1" . $randname . "=" . $date1;
$_SERVER['REQUEST_URI'] .= "&date2" . $randname . "=" . $date2;
Bookmark::showSaveButton(Bookmark::URI);
echo "</td>\n";
echo "</tr>";
echo "</table>";
Html::closeForm();
echo "</div>\n";
}
开发者ID:geldarr,项目名称:hack-space,代码行数:34,代码来源:misc.class.php
示例6: showContent
function showContent()
{
$notice = $this->nli->notice;
$out = $this->nli->out;
$nb = Bookmark::getByNotice($notice);
if (empty($nb)) {
common_log(LOG_ERR, "No bookmark for notice {$notice->id}");
parent::showContent();
return;
} else {
if (empty($nb->url)) {
common_log(LOG_ERR, "No url for bookmark {$nb->id} for notice {$notice->id}");
parent::showContent();
return;
}
}
$profile = $notice->getProfile();
$out->elementStart('p', array('class' => 'entry-content'));
// Whether to nofollow
$attrs = array('href' => $nb->url, 'class' => 'bookmark-title');
$nf = common_config('nofollow', 'external');
if ($nf == 'never' || ($nf == 'sometimes' and $out instanceof ShowstreamAction)) {
$attrs['rel'] = 'external';
} else {
$attrs['rel'] = 'nofollow external';
}
$out->elementStart('h3');
$out->element('a', $attrs, $nb->title);
$out->elementEnd('h3');
// Replies look like "for:" tags
$replies = $notice->getReplies();
$tags = $notice->getTags();
if (!empty($replies) || !empty($tags)) {
$out->elementStart('ul', array('class' => 'bookmark-tags'));
foreach ($replies as $reply) {
$other = Profile::staticGet('id', $reply);
if (!empty($other)) {
$out->elementStart('li');
$out->element('a', array('rel' => 'tag', 'href' => $other->profileurl, 'title' => $other->getBestName()), sprintf('for:%s', $other->nickname));
$out->elementEnd('li');
$out->text(' ');
}
}
foreach ($tags as $tag) {
$tag = trim($tag);
if (!empty($tag)) {
$out->elementStart('li');
$out->element('a', array('rel' => 'tag', 'href' => Notice_tag::url($tag)), $tag);
$out->elementEnd('li');
$out->text(' ');
}
}
$out->elementEnd('ul');
}
if (!empty($nb->description)) {
$out->element('p', array('class' => 'bookmark-description'), $nb->description);
}
$out->elementEnd('p');
}
开发者ID:Grasia,项目名称:bolotweet,代码行数:59,代码来源:bookmarklistitem.php
示例7: beforeSave
protected function beforeSave()
{
$folderModel = Folder::model()->findByPk($this->folder_id);
$existingBookmarkModel = Bookmark::model()->findSingleByAttributes(array('user_id' => \GO::user()->id, 'folder_id' => $folderModel->id));
if (!empty($existingBookmarkModel)) {
throw new \Exception(str_replace('%fn', $folderModel->name, \GO::t('bookmarkAlreadyExists', 'files')));
}
return parent::beforeSave();
}
开发者ID:ajaboa,项目名称:crmpuan,代码行数:9,代码来源:Bookmark.php
示例8: handle
/**
* Handle the data
*
* @param array $data associative array of user & bookmark info from DeliciousBackupImporter::importBookmark()
*
* @return boolean success value
*/
function handle($data)
{
$profile = Profile::staticGet('id', $data['profile_id']);
try {
$saved = Bookmark::saveNew($profile, $data['title'], $data['url'], $data['tags'], $data['description'], array('created' => $data['created'], 'distribute' => false));
} catch (ClientException $e) {
// Most likely a duplicate -- continue on with the rest!
common_log(LOG_ERR, "Error importing delicious bookmark to {$data['url']}: " . $e->getMessage());
return true;
}
return true;
}
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:19,代码来源:deliciousbookmarkimporter.php
示例9: actionSet
public function actionSet()
{
$book_id = (int) $_POST["book_id"];
$orig_id = (int) $_POST["orig_id"];
$pk = array("user_id" => Yii::app()->user->id, "book_id" => $book_id);
if ($orig_id) {
$pk["orig_id"] = $orig_id;
}
$bm = Bookmark::model()->findByAttributes($pk);
if (!$bm) {
$bm = new Bookmark();
$bm->user_id = Yii::app()->user->id;
$bm->book_id = $book_id;
if ($orig_id) {
$bm->orig_id = $orig_id;
}
}
if (isset($_POST["note"])) {
$post = $_POST;
unset($post["book_id"]);
unset($post["orig_id"]);
$bm->setAttributes($post);
$bm->watch = (int) $_POST["watch"];
$new_ord = Yii::app()->db->createCommand("SELECT MAX(ord) FROM bookmarks WHERE user_id = :user_id AND orig_id IS NULL")->queryScalar(array(":user_id" => Yii::app()->user->id)) + 1;
if ($orig_id) {
// А есть ли закладка на перевод?
if (!Yii::app()->db->createCommand("SELECT 1 FROM bookmarks WHERE user_id = :user_id AND book_id = :book_id AND orig_id IS NULL")->queryScalar(array(":user_id" => Yii::app()->user->id, ":book_id" => $book_id))) {
Yii::app()->db->createCommand("INSERT INTO bookmarks (user_id, book_id, ord) VALUES (:user_id, :book_id, :ord)")->execute(array(":user_id" => Yii::app()->user->id, ":book_id" => $book_id, ":ord" => $new_ord));
}
} else {
$bm->ord = $new_ord;
}
if (!$bm->save()) {
throw new CHttpException(500, $bm->getErrorsString());
}
echo json_encode(array("book_id" => (int) $bm->book_id, "orig_id" => (int) $bm->orig_id, "note" => $bm->note, "status" => "set"));
} else {
$this->renderPartial("set", array("bm" => $bm));
}
}
开发者ID:norayr,项目名称:notabenoid,代码行数:40,代码来源:BookmarksController.php
示例10: testIdentityMapAndRecordStatus
/**
* This test case demonstrates an issue with the identity case in the
* Doctrine_Table class. The brief summary is that if you create a
* record, then delete it, then create another record with the same
* primary keys, the record can get into a state where it is in the
* database but may appear to be marked as TCLEAN under certain
* circumstances (such as when it comes back as part of a collection).
* This makes the $record->exists() method return false, which prevents
* the record from being deleted among other things.
*/
public function testIdentityMapAndRecordStatus()
{
// load our user and our collection of pages
$user = Doctrine_Query::create()->query('SELECT * FROM BookmarkUser u WHERE u.name=?', array('Anonymous'))->getFirst();
$pages = Doctrine_Query::create()->query('SELECT * FROM Page');
// bookmark the pages (manually)
foreach ($pages as $page) {
$bookmark = new Bookmark();
$bookmark['page_id'] = $page['id'];
$bookmark['user_id'] = $user['id'];
$bookmark->save();
}
// select all bookmarks
$bookmarks = Doctrine_Manager::connection()->query('SELECT * FROM Bookmark b');
$this->assertEqual(count($bookmarks), 1);
// verify that they all exist
foreach ($bookmarks as $bookmark) {
$this->assertTrue($bookmark->exists());
}
// now delete them all.
$user['Bookmarks']->delete();
// verify count when accessed directly from database
$bookmarks = Doctrine_Query::create()->query('SELECT * FROM Bookmark');
$this->assertEqual(count($bookmarks), 0);
// now recreate bookmarks and verify they exist:
foreach ($pages as $page) {
$bookmark = new Bookmark();
$bookmark['page_id'] = $page['id'];
$bookmark['user_id'] = $user['id'];
$bookmark->save();
}
// select all bookmarks for the user
$bookmarks = Doctrine_Manager::connection()->query('SELECT * FROM Bookmark b');
$this->assertEqual(count($bookmarks), 1);
// verify that they all exist
foreach ($bookmarks as $bookmark) {
$this->assertTrue($bookmark->exists());
}
}
开发者ID:swk,项目名称:bluebox,代码行数:49,代码来源:587TestCase.php
示例11: handlePost
/**
* Add a new bookmark
*
* @return void
*/
function handlePost()
{
if (empty($this->title)) {
// TRANS: Client exception thrown when trying to create a new bookmark without a title.
throw new ClientException(_m('Bookmark must have a title.'));
}
if (empty($this->url)) {
// TRANS: Client exception thrown when trying to create a new bookmark without a URL.
throw new ClientException(_m('Bookmark must have an URL.'));
}
$options = array();
ToSelector::fillOptions($this, $options);
$saved = Bookmark::addNew($this->scoped, $this->title, $this->url, $this->tags, $this->description, $options);
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:19,代码来源:newbookmark.php
示例12: showContent
function showContent()
{
$notice = $this->nli->notice;
$out = $this->nli->out;
$out->elementStart('p', array('class' => 'entry-content'));
$nb = Bookmark::getByNotice($notice);
$profile = $notice->getProfile();
$atts = $notice->attachments();
if (count($atts) < 1) {
// Something wrong; let default code deal with it.
// TRANS: Exception thrown when a bookmark has no attachments.
// TRANS: %1$s is a bookmark ID, %2$s is a notice ID (number).
throw new Exception(sprintf(_m('Bookmark %1$s (notice %2$d) has no attachments.'), $nb->id, $notice->id));
}
$att = $atts[0];
$out->elementStart('h3');
$out->element('a', array('href' => $att->url, 'class' => 'bookmark-title'), $nb->title);
$out->elementEnd('h3');
// Replies look like "for:" tags
$replies = $notice->getReplies();
$tags = $notice->getTags();
if (!empty($replies) || !empty($tags)) {
$out->elementStart('ul', array('class' => 'bookmark-tags'));
foreach ($replies as $reply) {
$other = Profile::staticGet('id', $reply);
if (!empty($other)) {
$out->elementStart('li');
$out->element('a', array('rel' => 'tag', 'href' => $other->profileurl, 'title' => $other->getBestName()), sprintf('for:%s', $other->nickname));
$out->elementEnd('li');
$out->text(' ');
}
}
foreach ($tags as $tag) {
$tag = trim($tag);
if (!empty($tag)) {
$out->elementStart('li');
$out->element('a', array('rel' => 'tag', 'href' => Notice_tag::url($tag)), $tag);
$out->elementEnd('li');
$out->text(' ');
}
}
$out->elementEnd('ul');
}
if (!empty($nb->description)) {
$out->element('p', array('class' => 'bookmark-description'), $nb->description);
}
$out->elementEnd('p');
}
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:48,代码来源:bookmarklistitem.php
示例13: getNotice
function getNotice()
{
$this->id = $this->trimmed('id');
$this->bookmark = Bookmark::staticGet('id', $this->id);
if (empty($this->bookmark)) {
// TRANS: Client exception thrown when referring to a non-existing bookmark.
throw new ClientException(_m('No such bookmark.'), 404);
}
$notice = Notice::staticGet('uri', $this->bookmark->uri);
if (empty($notice)) {
// Did we used to have it, and it got deleted?
// TRANS: Client exception thrown when referring to a non-existing bookmark.
throw new ClientException(_m('No such bookmark.'), 404);
}
return $notice;
}
开发者ID:Grasia,项目名称:bolotweet,代码行数:16,代码来源:showbookmark.php
示例14: showMassiveActionsSubForm
/**
* @since version 0.85
*
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma)
{
global $CFG_GLPI;
switch ($ma->getAction()) {
case 'move_bookmark':
$values = array('after' => __('After'), 'before' => __('Before'));
Dropdown::showFromArray('move_type', $values, array('width' => '20%'));
$param = array('name' => "bookmarks_id_ref", 'width' => '50%');
$param['condition'] = "(`is_private`='1' AND `users_id`='" . Session::getLoginUserID() . "') ";
$param['entity'] = -1;
Bookmark::dropdown($param);
echo "<br><br>\n";
echo Html::submit(_x('button', 'Move'), array('name' => 'massiveaction')) . "</span>";
return true;
}
return parent::showMassiveActionsSubForm($ma);
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:22,代码来源:bookmark.class.php
示例15: handle
/**
* Handle the data
*
* @param array $data associative array of user & bookmark info from DeliciousBackupImporter::importBookmark()
*
* @return boolean success value
*/
function handle($data)
{
$profile = Profile::getKV('id', $data['profile_id']);
try {
$saved = Bookmark::saveNew($profile, $data['title'], $data['url'], $data['tags'], $data['description'], array('created' => $data['created'], 'distribute' => false));
} catch (ClientException $ce) {
// Most likely a duplicate -- continue on with the rest!
common_log(LOG_ERR, "Error importing delicious bookmark to {$data['url']}: " . $ce->getMessage());
return true;
} catch (Exception $ex) {
if (preg_match("/DB Error: already exists/", $ex->getMessage())) {
common_log(LOG_ERR, "Error importing delicious bookmark to {$data['url']}: " . $ce->getMessage());
return true;
} else {
throw $ex;
}
}
return true;
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:26,代码来源:deliciousbookmarkimporter.php
示例16: prepare
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
*
* @return boolean true
*/
function prepare($argarray)
{
OwnerDesignAction::prepare($argarray);
$this->id = $this->trimmed('id');
$this->bookmark = Bookmark::staticGet('id', $this->id);
if (empty($this->bookmark)) {
throw new ClientException(_('No such bookmark.'), 404);
}
$this->notice = Notice::staticGet('uri', $this->bookmark->uri);
if (empty($this->notice)) {
// Did we used to have it, and it got deleted?
throw new ClientException(_('No such bookmark.'), 404);
}
$this->user = User::staticGet('id', $this->bookmark->profile_id);
if (empty($this->user)) {
throw new ClientException(_('No such user.'), 404);
}
$this->profile = $this->user->getProfile();
if (empty($this->profile)) {
throw new ServerException(_('User without a profile.'));
}
$this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
return true;
}
开发者ID:microcosmx,项目名称:experiments,代码行数:31,代码来源:showbookmark.php
示例17: manageParams
/**
* Completion of the URL $_GET values with the $_SESSION values or define default values
*
* @param $itemtype item type to manage
* @param $params array params to parse
* @param $usesession Use datas save in session (true by default)
* @param $forcebookmark force trying to load parameters from default bookmark:
* used for global search (false by default)
*
* @return parsed params array
**/
static function manageParams($itemtype, $params = array(), $usesession = true, $forcebookmark = false)
{
global $CFG_GLPI, $DB;
$redirect = false;
$default_values = array();
$default_values["start"] = 0;
$default_values["order"] = "ASC";
$default_values["sort"] = 1;
$default_values["is_deleted"] = 0;
if ($CFG_GLPI['allow_search_view'] == 2) {
$default_criteria = 'view';
} else {
$options = self::getCleanedOptions($itemtype);
foreach ($options as $key => $val) {
if (is_array($val)) {
$default_criteria = $key;
break;
}
}
}
$default_values["criteria"] = array(0 => array('field' => $default_criteria, 'link' => 'contains', 'value' => ''));
$default_values["metacriteria"] = array();
// Reorg search array
// start
// order
// sort
// is_deleted
// itemtype
// criteria : array (0 => array (link =>
// field =>
// searchtype =>
// value => (contains)
// metacriteria : array (0 => array (itemtype =>
// link =>
// field =>
// searchtype =>
// value => (contains)
if ($itemtype != 'AllAssets' && class_exists($itemtype) && method_exists($itemtype, 'getDefaultSearchRequest')) {
$default_values = array_merge($default_values, call_user_func(array($itemtype, 'getDefaultSearchRequest')));
}
// First view of the page or force bookmark : try to load a bookmark
if ($forcebookmark || $usesession && !isset($params["reset"]) && !isset($_SESSION['glpisearch'][$itemtype])) {
$query = "SELECT `bookmarks_id`\n FROM `glpi_bookmarks_users`\n WHERE `users_id`='" . Session::getLoginUserID() . "'\n AND `itemtype` = '{$itemtype}'";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) > 0) {
$IDtoload = $DB->result($result, 0, 0);
// Set session variable
$_SESSION['glpisearch'][$itemtype] = array();
// Load bookmark on main window
$bookmark = new Bookmark();
// Only get datas for bookmarks
if ($forcebookmark) {
$params = $bookmark->getParameters($IDtoload);
} else {
$bookmark->load($IDtoload, false);
}
}
}
}
// Force reorder criterias
if (isset($params["criteria"]) && is_array($params["criteria"]) && count($params["criteria"])) {
$tmp = $params["criteria"];
$params["criteria"] = array();
foreach ($tmp as $val) {
$params["criteria"][] = $val;
}
}
if (isset($params["metacriteria"]) && is_array($params["metacriteria"]) && count($params["metacriteria"])) {
$tmp = $params["metacriteria"];
$params["metacriteria"] = array();
foreach ($tmp as $val) {
$params["metacriteria"][] = $val;
}
}
if ($usesession && isset($params["reset"])) {
if (isset($_SESSION['glpisearch'][$itemtype])) {
unset($_SESSION['glpisearch'][$itemtype]);
}
}
if (isset($params) && is_array($params) && $usesession) {
foreach ($params as $key => $val) {
$_SESSION['glpisearch'][$itemtype][$key] = $val;
}
}
foreach ($default_values as $key => $val) {
if (!isset($params[$key])) {
if ($usesession && isset($_SESSION['glpisearch'][$itemtype][$key])) {
$params[$key] = $_SESSION['glpisearch'][$itemtype][$key];
} else {
//.........这里部分代码省略.........
开发者ID:jose-martins,项目名称:glpi,代码行数:101,代码来源:search.class.php
示例18: deletebookmark
/**
* deleteBookmark
* Delete an existing bookmark.
* Takes the file id in parameter.
* Not supported.
*/
public static function deletebookmark($input)
{
self::check_version($input, "1.9.0");
$id = self::check_parameter($input, 'id');
$type = Subsonic_XML_Data::getAmpacheType($id);
$bookmark = new Bookmark(Subsonic_XML_Data::getAmpacheId($id), $type);
if ($bookmark->id) {
$bookmark->remove();
$r = Subsonic_XML_Data::createSuccessResponse();
} else {
$r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_DATA_NOTFOUND);
}
self::apiOutput($input, $r);
}
开发者ID:bl00m,项目名称:ampache,代码行数:20,代码来源:subsonic_api.class.php
示例19: Bookmark
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
if (!isset($_GET["type"])) {
$_GET["type"] = -1;
}
if (!isset($_GET["itemtype"])) {
$_GET["itemtype"] = -1;
}
if (!isset($_GET["url"])) {
$_GET["url"] = "";
}
$bookmark = new Bookmark();
if (isset($_POST["add"])) {
$bookmark->check(-1, 'w', $_POST);
$bookmark->add($_POST);
$_GET["action"] = "load";
// Force popup on load.
$_SESSION["glpipopup"]["name"] = "load_bookmark";
} else {
if (isset($_POST["update"])) {
$bookmark->check($_POST["id"], 'w');
// Right to update the bookmark
$bookmark->check(-1, 'w', $_POST);
// Right when entity change
$bookmark->update($_POST);
$_GET["action"] = "load";
} else {
开发者ID:gaforeror,项目名称:glpi,代码行数:31,代码来源:bookmark.php
示例20: showGenericSearch
//.........这里部分代码省略.........
}
if (!$first_group) {
echo "</optgroup>\n";
}
echo "<option value='all' ";
if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") {
echo "selected";
}
echo ">" . __('All') . "</option>";
echo "</select> \n";
echo "</td><td class='left'>";
echo "<div id='SearchSpan{$itemtype}{$i}'>\n";
$_POST['itemtype'] = $itemtype;
$_POST['num'] = $i;
$_POST['field'] = $selected;
$_POST['searchtype'] = is_array($p['searchtype']) && isset($p['searchtype'][$i]) ? $p['searchtype'][$i] : "";
$_POST['value'] = is_array($p['contains']) && isset($p['contains'][$i]) ? stripslashes($p['contains'][$i]) : "";
include GLPI_ROOT . "/ajax/searchoption.php";
echo "</div>\n";
$params = array('field' => '__VALUE__', 'itemtype' => $itemtype, 'num' => $i, 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype"]);
Ajax::updateItemOnSelectEvent("Search{$itemtype}{$i}", "SearchSpan{$itemtype}{$i}", $CFG_GLPI["root_doc"] . "/ajax/searchoption.php", $params, false);
echo "</td></tr>\n";
}
$metanames = array();
if (is_array($linked) && count($linked) > 0) {
for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
echo "<tr><td class='left'>";
$rand = mt_rand();
// Display link item (not for the first item)
echo "<select name='link2[{$i}]'>";
echo "<option value='AND' ";
if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND") {
echo "selected";
}
echo ">AND</option>\n";
echo "<option value='OR' ";
if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR") {
echo "selected";
}
echo ">OR</option>\n";
echo "<option value='AND NOT' ";
if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND NOT") {
echo "selected";
}
echo ">AND NOT</option>\n";
echo "<option value='OR NOT' ";
if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR NOT") {
echo "selected";
}
echo ">OR NOT</option>\n";
echo "</select> ";
// Display select of the linked item type available
echo "<select name='itemtype2[{$i}]' id='itemtype2_" . $itemtype . "_" . $i . "_{$rand}'>";
echo "<option value=''>" . Dropdown::EMPTY_VALUE . "</option>";
foreach ($linked as $key) {
if (!isset($metanames[$key])) {
$linkitem = new $key();
$metanames[$key] = $linkitem->getTypeName();
}
echo "<option value='{$key}'>" . Toolbox::substr($metanames[$key], 0, 20) . "</option>\n";
}
echo "</select> ";
echo "</td><td>";
// Ajax script for display search met& item
echo "<span id='show_" . $itemtype . "_" . $i . "_{$rand}'> </span>\n";
$params = array('itemtype' => '__VALUE__', 'num' => $i, 'field' => is_array($p['field2']) && isset($p['field2'][$i]) ? $p['field2'][$i] : "", 'value' => is_array($p['contains2']) && isset($p['contains2'][$i]) ? $p['contains2'][$i] : "", 'searchtype2' => is_array($p['searchtype2']) && isset($p['searchtype2'][$i]) ? $p['searchtype2'][$i] : "");
Ajax::updateItemOnSelectEvent("itemtype2_" . $itemtype . "_" . $i . "_{$rand}", "show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false);
if (is_array($p['itemtype2']) && isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i])) {
$params['itemtype'] = $p['itemtype2'][$i];
Ajax::updateItem("show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false);
echo "<script type='text/javascript' >";
echo "window.document.getElementById('itemtype2_" . $itemtype . "_" . $i . "_{$rand}').value='" . $p['itemtype2'][$i] . "';";
echo "</script>\n";
}
echo "</td></tr></table>";
echo "</td></tr>\n";
}
}
echo "</table>\n";
echo "</td>\n";
echo "<td width='150px'>";
echo "<table width='100%'>";
// Display deleted selection
echo "<tr>";
// Display submit button
echo "<td width='80' class='center'>";
echo "<input type='submit' value=\"" . _sx('button', 'Search') . "\" class='submit' >";
echo "</td><td>";
Bookmark::showSaveButton(Bookmark::SEARCH, $itemtype);
echo "<a href='{$target}?reset=reset' >";
echo " <img title=\"" . __s('Blank') . "\" alt=\"" . __s('Blank') . "\" src='" . $CFG_GLPI["root_doc"] . "/templates/infotel/pics/reset.png' class='calendrier'></a>";
echo "</td></tr></table>\n";
echo "</td></tr>";
echo "</table>\n";
// For dropdown
echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
// Reset to start when submit new search
echo "<input type='hidden' name='start' value='0'>";
Html::closeForm();
}
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:directory.class.php
注:本文中的Bookmark类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论