本文整理汇总了PHP中Links::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Links::put方法的具体用法?PHP Links::put怎么用?PHP Links::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Links
的用法示例。
在下文中一共展示了Links::put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: have
/**
* check for link existence
*
* This function can be used either to see if a link exists in the database, or to check if one link has been
* attached to a particular anchor.
*
* To query the whole database, use:
* [php]
* if(Links::have($that_beautiful_url))
* ...
* [/php]
*
* To check that an article has a link attached, use:
* [php]
* $anchor = 'article:'.$article['id'];
* if(Links::have($that_beautiful_url, $anchor))
* ...
* [/php]
*
* If additional attributes are provided, they are used to update
* link description if one exists.
*
* @param string the external url that is targeted
* @param string an internal anchor, if any
* @param array updated link attributes, if any
* @return either TRUE or FALSE
*
* @see feeds/feeds.php
* @see links/trackback.php
* @see services/ping.php
*/
public static function have($url, $anchor = NULL, $attributes = NULL)
{
global $context;
// does this (link, anchor) tupple exists?
$query = "SELECT id FROM " . SQL::table_name('links') . " AS links " . " WHERE links.link_url LIKE '" . SQL::escape($url) . "'";
if ($anchor) {
$query .= " AND links.anchor = '{$anchor}'";
}
$query .= " LIMIT 1";
// no, this does not exist
if (!($row = SQL::query_first($query))) {
return FALSE;
}
// update the link, if any
if (isset($row['id']) && is_array($attributes)) {
$attributes['id'] = $row['id'];
Links::put($attributes);
}
// the link does exist
return TRUE;
}
示例2: array_merge
$menu = array_merge($menu, array('links/edit.php?anchor=' . $anchor->get_reference() => i18n::s('Submit another link')));
}
$follow_up .= Skin::build_list($menu, 'menu_bar');
$context['text'] .= Skin::build_block($follow_up, 'bottom');
// log the submission of a new link by a non-associate
if (!Surfer::is_associate() && is_object($anchor)) {
$label = sprintf(i18n::c('New link at %s'), strip_tags($anchor->get_title()));
$link = $context['url_to_home'] . $context['url_to_root'] . $anchor->get_url() . '#_attachments';
$description = $_REQUEST['link_url'] . "\n" . sprintf(i18n::c('at %s'), '<a href="' . $link . '">' . $link . '</a>');
Logger::notify('links/edit.php: ' . $label, $description);
}
}
// update an existing link
} else {
// display the form on error
if (!Links::put($_REQUEST)) {
$item = $_REQUEST;
$with_form = TRUE;
// follow-up
} else {
// touch the related anchor
$anchor->touch('link:update', $_REQUEST['id'], isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y');
// clear cache
Links::clear($_REQUEST);
// forward to the updated anchor page
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url() . '#_attachments');
}
}
// display the form on GET
} else {
$with_form = TRUE;