1
0
Fork 0

rework autocomplete: polishing class and methods naming

This commit is contained in:
rabuzarus 2016-02-05 14:26:22 +01:00
parent ad5be2901e
commit 30c375d238
5 changed files with 17 additions and 17 deletions

View file

@ -1,14 +1,14 @@
<?php <?php
/** /**
* @file include/dir_fns.php * @file include/dir.php
*/ */
/** /**
* @brief This class handels directory related functions * @brief This class handels directory related functions
*/ */
class dir { class DirSearch {
/** /**
* @brief Search global contact table by nick or name * @brief Search global contact table by nick or name

View file

@ -8,7 +8,7 @@
* This class contains functions to handle smiles * This class contains functions to handle smiles
*/ */
class smilies { class Smilies {
/** /**
* @brief Function to list all smilies * @brief Function to list all smilies
@ -21,7 +21,7 @@ class smilies {
* *
* @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array) * @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array)
*/ */
public static function list_smilies() { public static function get_list() {
$texts = array( $texts = array(
'&lt;3', '&lt;3',
@ -128,10 +128,10 @@ class smilies {
|| (local_user() && intval(get_pconfig(local_user(),'system','no_smilies')))) || (local_user() && intval(get_pconfig(local_user(),'system','no_smilies'))))
return $s; return $s;
$s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism','self::smile_encode',$s); $s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism','self::encode',$s);
$s = preg_replace_callback('/<code>(.*?)<\/code>/ism','self::smile_encode',$s); $s = preg_replace_callback('/<code>(.*?)<\/code>/ism','self::encode',$s);
$params = self::list_smilies(); $params = self::get_list();
$params['string'] = $s; $params['string'] = $s;
if($sample) { if($sample) {
@ -145,17 +145,17 @@ class smilies {
$s = str_replace($params['texts'],$params['icons'],$params['string']); $s = str_replace($params['texts'],$params['icons'],$params['string']);
} }
$s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism','self::smile_decode',$s); $s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism','self::decode',$s);
$s = preg_replace_callback('/<code>(.*?)<\/code>/ism','self::smile_decode',$s); $s = preg_replace_callback('/<code>(.*?)<\/code>/ism','self::decode',$s);
return $s; return $s;
} }
private function smile_encode($m) { private function encode($m) {
return(str_replace($m[1],base64url_encode($m[1]),$m[0])); return(str_replace($m[1],base64url_encode($m[1]),$m[0]));
} }
private function smile_decode($m) { private function decode($m) {
return(str_replace($m[1],base64url_decode($m[1]),$m[0])); return(str_replace($m[1],base64url_decode($m[1]),$m[0]));
} }

View file

@ -6,7 +6,7 @@
require_once("include/contact_selectors.php"); require_once("include/contact_selectors.php");
require_once("include/contact_widgets.php"); require_once("include/contact_widgets.php");
require_once("include/dir_fns.php"); require_once("include/DirSearch.php");
require_once("include/features.php"); require_once("include/features.php");
require_once("mod/proxy.php"); require_once("mod/proxy.php");
@ -687,7 +687,7 @@ function navbar_complete(&$a) {
$search = substr($search,1); $search = substr($search,1);
if($localsearch) { if($localsearch) {
$x = dir::global_search_by_name($search, $mode); $x = DirSearch::global_search_by_name($search, $mode);
return $x; return $x;
} }

View file

@ -2,7 +2,7 @@
require_once("include/template_processor.php"); require_once("include/template_processor.php");
require_once("include/friendica_smarty.php"); require_once("include/friendica_smarty.php");
require_once("include/smilies.php"); require_once("include/Smilies.php");
require_once("include/map.php"); require_once("include/map.php");
require_once("mod/proxy.php"); require_once("mod/proxy.php");
@ -1396,7 +1396,7 @@ function prepare_text($text) {
if(stristr($text,'[nosmile]')) if(stristr($text,'[nosmile]'))
$s = bbcode($text); $s = bbcode($text);
else else
$s = smilies::replace(bbcode($text)); $s = Smilies::replace(bbcode($text));
return trim($s); return trim($s);
}} }}

View file

@ -4,11 +4,11 @@
* @file mod/smilies.php * @file mod/smilies.php
*/ */
require_once("include/smilies.php"); require_once("include/Smilies.php");
function smilies_content(&$a) { function smilies_content(&$a) {
if ($a->argv[1]==="json"){ if ($a->argv[1]==="json"){
$tmp = smilies::list_smilies(); $tmp = Smilies::get_list();
$results = array(); $results = array();
for($i = 0; $i < count($tmp['texts']); $i++) { for($i = 0; $i < count($tmp['texts']); $i++) {
$results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]); $results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);