Some improvements

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-05-22 13:04:30 +02:00
parent b6648215b8
commit 291af19f25
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78

View file

@ -1550,7 +1550,8 @@ function get_cats_and_terms($item) {
$categories = array();
$folders = array();
$matches = false; $first = true;
$matches = false;
$first = true;
$cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) {
@ -1570,7 +1571,8 @@ function get_cats_and_terms($item) {
}
if (local_user() == $item['uid']) {
$matches = false; $first = true;
$matches = false;
$first = true;
$cnt = preg_match_all('/\[(.*?)\]/', $item['file'], $matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) {
@ -1626,9 +1628,7 @@ function get_plink($item) {
$ret = array();
}
//if (x($item,'plink') && ($item['private'] != 1))
return($ret);
return $ret;
}}
if (! function_exists('unamp')) {
@ -1918,10 +1918,11 @@ function file_tag_decode($s) {
function file_tag_file_query($table,$s,$type = 'file') {
if ($type == 'file')
if ($type == 'file') {
$str = preg_quote( '[' . str_replace('%', '%%', file_tag_encode($s)) . ']' );
else
} else {
$str = preg_quote( '<' . str_replace('%', '%%', file_tag_encode($s)) . '>' );
}
return " AND " . (($table) ? dbesc($table) . '.' : '') . "file regexp '" . dbesc($str) . "' ";
}
@ -1954,8 +1955,7 @@ function file_tag_file_to_list($file,$type = 'file') {
$list = '';
if ($type == 'file') {
$cnt = preg_match_all('/\[(.*?)\]/', $file, $matches, PREG_SET_ORDER);
}
else {
} else {
$cnt = preg_match_all('/<(.*?)>/', $file, $matches, PREG_SET_ORDER);
}
if ($cnt) {
@ -2021,10 +2021,6 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
intval($termtype),
intval($uid));
//$r = q("select file from item where uid = %d " . file_tag_file_query('item',$tag,$type),
// intval($uid)
//);
if (dbm::is_result($r)) {
unset($deleted_tags[$key]);
}
@ -2046,7 +2042,7 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
}
function file_tag_save_file($uid, $item, $file) {
require_once("include/files.php");
require_once "include/files.php";
$result = false;
if (! intval($uid))
@ -2056,25 +2052,27 @@ function file_tag_save_file($uid,$item,$file) {
intval($uid)
);
if (dbm::is_result($r)) {
if (! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']'))
if (! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']')) {
q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($r[0]['file'] . '[' . file_tag_encode($file) . ']'),
intval($item),
intval($uid)
);
}
create_files_from_item($item);
$saved = get_pconfig($uid,'system','filetags');
if ((! strlen($saved)) || (! stristr($saved,'[' . file_tag_encode($file) . ']')))
if ((! strlen($saved)) || (! stristr($saved, '[' . file_tag_encode($file) . ']'))) {
set_pconfig($uid, 'system', 'filetags', $saved . '[' . file_tag_encode($file) . ']');
}
info( t('Item filed') );
}
return true;
}
function file_tag_unsave_file($uid, $item, $file, $cat = false) {
require_once("include/files.php");
require_once "include/files.php";
$result = false;
if (! intval($uid))
@ -2111,9 +2109,6 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
intval($termtype),
intval($uid));
//$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')),
//);
if (! dbm::is_result($r)) {
$saved = get_pconfig($uid,'system','filetags');
set_pconfig($uid, 'system', 'filetags', str_replace($pattern, '', $saved));
@ -2200,11 +2195,12 @@ function formatBytes($bytes, $precision = 2) {
*/
function format_network_name($network, $url = 0) {
if ($network != "") {
require_once('include/contact_selectors.php');
if ($url != "")
require_once 'include/contact_selectors.php';
if ($url != "") {
$network_name = '<a href="'.$url.'">'.network_to_name($network, $url)."</a>";
else
} else {
$network_name = network_to_name($network);
}
return $network_name;
}