* @file include/text.php
*/
use Friendica\App;
+use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Content\Smilies;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
+use Friendica\Model\Profile;
+use Friendica\Model\Term;
use Friendica\Util\Map;
require_once "include/friendica_smarty.php";
$url = $redirect_url;
$sparkle = ' sparkle';
} else {
- $url = zrl($url);
+ $url = Profile::zrl($url);
}
}
}
/**
- * search box
+ * Search box.
*
- * @param string $s search query
- * @param string $id html id
- * @param string $url search url
- * @param boolean $savedsearch show save search button
+ * @param string $s Search query.
+ * @param string $id HTML id
+ * @param string $url Search url.
+ * @param bool $save Show save search button.
+ * @param bool $aside Display the search widgit aside.
+ *
+ * @return string Formatted HTML.
*/
-function search($s, $id = 'search-box', $url = 'search', $save = false, $aside = true) {
+function search($s, $id = 'search-box', $url = 'search', $save = false, $aside = true)
+{
+ $mode = 'text';
+
+ if (strpos($s, '#') === 0) {
+ $mode = 'tag';
+ }
+ $save_label = $mode === 'text' ? t('Save') : t('Follow');
+
$values = array(
'$s' => htmlspecialchars($s),
'$id' => $id,
'$action_url' => $url,
'$search_label' => t('Search'),
- '$save_label' => t('Save'),
+ '$save_label' => $save_label,
'$savedsearch' => Feature::isEnabled(local_user(),'savedsearch'),
'$search_hint' => t('@name, !forum, #tags, content'),
+ '$mode' => $mode
);
if (!$aside) {
return true;
}
-function file_tag_save_file($uid, $item, $file) {
- require_once "include/files.php";
-
+function file_tag_save_file($uid, $item, $file)
+{
if (! intval($uid)) {
return false;
}
);
}
- create_files_from_item($item);
+ Term::createFromItem($item);
$saved = PConfig::get($uid, 'system', 'filetags');
if (!strlen($saved) || !stristr($saved, '[' . file_tag_encode($file) . ']')) {
return true;
}
-function file_tag_unsave_file($uid, $item, $file, $cat = false) {
- require_once "include/files.php";
-
+function file_tag_unsave_file($uid, $item, $file, $cat = false)
+{
if (! intval($uid)) {
return false;
}
intval($uid)
);
- create_files_from_item($item);
+ Term::createFromItem($item);
$r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",
dbesc($file),
*/
function format_network_name($network, $url = 0) {
if ($network != "") {
- require_once 'include/contact_selectors.php';
if ($url != "") {
- $network_name = '<a href="'.$url.'">'.network_to_name($network, $url)."</a>";
+ $network_name = '<a href="'.$url.'">'.ContactSelector::networkToName($network, $url)."</a>";
} else {
- $network_name = network_to_name($network);
+ $network_name = ContactSelector::networkToName($network);
}
return $network_name;
}
-
}
/**
}
$renderer = new Text_Highlighter_Renderer_Html($options);
- $hl = Text_Highlighter::factory($lang);
+ $factory = new Text_Highlighter();
+ $hl = $factory->factory($lang);
$hl->setRenderer($renderer);
$o = $hl->highlight($s);
$o = str_replace("\n", '', $o);