Skip to content

Commit

Permalink
Общ начин за уникално ИД
Browse files Browse the repository at this point in the history
  • Loading branch information
milengg committed Jan 20, 2022
1 parent 50106bc commit b4717e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions core/Html.class.php
Expand Up @@ -1340,6 +1340,17 @@ public static function arrayToHtml($arr, $openLevels = 3, $viewLevels = 5)

return $result;
}

/**
* Връща уникално id за хита започващо с подадения префикс
*/
public static function getUniqId($prefix = '')
{
static $id;
$id++;

return $prefix . base_convert($id . rand(1000, 9999), 10, 36);
}


/**
Expand All @@ -1348,11 +1359,9 @@ public static function arrayToHtml($arr, $openLevels = 3, $viewLevels = 5)
public static function setUniqId(&$attr)
{
if (!$attr['id']) {
static $id;
$id++;
$name = $attr['name'] ? $attr['name'] : 'autoElement';
$name = str_replace(array('[', ']'), array('_', '_'), $name);
$attr['id'] = $name . rand(1000, 9999) . '_' .$id;
$attr['id'] = self::getUniqId($name);
}
}

Expand Down
2 changes: 1 addition & 1 deletion hclean/JSSanitizer.class.php
Expand Up @@ -35,7 +35,7 @@ public static function sanitizeHtml($tpl, $link)
$tpl->replace($sanitizer, 'SANITIZEJS');

// Генерираме уникално id за атрибута
$uniqId = core_Os::getUniqId('emb');
$uniqId = ht::getUniqId('emb');

// Заместваме уникалното id
$tpl->replace($uniqId, 'SANITIZEID');
Expand Down
2 changes: 1 addition & 1 deletion mejs/Adapter.class.php
Expand Up @@ -75,7 +75,7 @@ public static function create($source, $type = 'video', $params = null, $fileTyp
}

// Генерираме уникално id
$id = core_Os::getUniqId('mejs');
$id = ht::getUniqId('mejs');

// Шаблона, който ще връщаме
$mTpl = new ET("<div>
Expand Down

0 comments on commit b4717e3

Please sign in to comment.