Служит для отображения одного случайного баннера из указанного баннерного места

    Пример использования::

        {% one_banner 'place_slug' %}

    :param slug: символьный код баннерного места
    :return:
4441
def one_banner(slug):
    
    place = BannerPlace.objects.published().get(slug=slug)
    banner = place.banner_set.published().order_by('?').first()
    renderer = get_renderer(banner)
    return renderer(banner)
902110
protected function _canonicalizeSlug()
    {
        $table = $this->getTable();

        //If the slug needs to be unique and it already exists, make it unique
        $query = $this->getObject('lib:database.query.select');
        $query->where('slug = :slug')->bind(array('slug' => $this->slug));

        if (!$this->isNew())
        {
            $query->where($table->getIdentityColumn().' <> :id')
                ->bind(array('id' => $this->id));
        }

        if($table->count($query))
        {
            $length = $this->_length ? $this->_length : $table->getColumn('slug')->length;

            // Cut 4 characters to make space for slug-1 slug-23 etc
            if ($length && strlen($this->slug) > $length-4) {
                $this->slug = substr($this->slug, 0, $length-4);
            }

            $query = $this->getObject('lib:database.query.select')
                ->columns('slug')
                ->where('slug LIKE :slug')
                ->bind(array('slug' => $this->slug . '-%'));

            $slugs = $table->select($query, Database::FETCH_FIELD_LIST);

            $i = 1;
            while(in_array($this->slug.'-'.$i, $slugs)) {
                $i++;
            }

            $this->slug = $this->slug.'-'.$i;
        }
    }
33780
function slug($text) {
		return trim(strtolower(preg_replace('/([^\pL\pN])+/u','-',
			trim(strtr(str_replace('\'','',$text),
			array(
				'Ǎ'=>'A','А'=>'A','Ā'=>'A','Ă'=>'A','Ą'=>'A','Å'=>'A',
				'Ǻ'=>'A','Ä'=>'Ae','Á'=>'A','À'=>'A','Ã'=>'A','Â'=>'A',
				'Æ'=>'AE','Ǽ'=>'AE','Б'=>'B','Ç'=>'C','Ć'=>'C','Ĉ'=>'C',
				'Č'=>'C','Ċ'=>'C','Ц'=>'C','Ч'=>'Ch','Ð'=>'Dj','Đ'=>'Dj',
				'Ď'=>'Dj','Д'=>'Dj','É'=>'E','Ę'=>'E','Ё'=>'E','Ė'=>'E',
				'Ê'=>'E','Ě'=>'E','Ē'=>'E','È'=>'E','Е'=>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Zh','á'=>'a',
				'ă'=>'a','â'=>'a','à'=>'a','ā'=>'a','ǻ'=>'a','å'=>'a',
				'ä'=>'ae','ą'=>'a','ǎ'=>'a','ã'=>'a','а'=>'a','ª'=>'a',
				'æ'=>'ae','ǽ'=>'ae','б'=>'b','č'=>'c','ç'=>'c','ц'=>'c',
				'ċ'=>'c','ĉ'=>'c','ć'=>'c','ч'=>'ch','ð'=>'dj','ď'=>'dj',
				'д'=>'dj','đ'=>'dj','э'=>'e','é'=>'e','ё'=>'e','ë'=>'e',
				'ê'=>'e','е'=>'e','ĕ'=>'e','è'=>'e','ę'=>'e','ě'=>'e',
				'ė'=>'e','ē'=>'e','ƒ'=>'f','ф'=>'f','ġ'=>'g','ĝ'=>'g',
				'ğ'=>'g','г'=>'g','ģ'=>'g','х'=>'h','ĥ'=>'h','ħ'=>'h',
				'ǐ'=>'i','ĭ'=>'i','и'=>'i','ī'=>'i','ĩ'=>'i','į'=>'i',
				'ı'=>'i','ì'=>'i','î'=>'i','í'=>'i','ï'=>'i','ĳ'=>'ij',
				'ĵ'=>'j','й'=>'j','я'=>'ja','ю'=>'ju','ķ'=>'k','к'=>'k',
				'ľ'=>'l','ł'=>'l','ŀ'=>'l','ĺ'=>'l','ļ'=>'l','л'=>'l',
				'м'=>'m','ņ'=>'n','ñ'=>'n','ń'=>'n','н'=>'n','ň'=>'n',
				'ŉ'=>'n','ó'=>'o','ò'=>'o','ǒ'=>'o','ő'=>'o','о'=>'o',
				'ō'=>'o','º'=>'o','ơ'=>'o','ŏ'=>'o','ô'=>'o','ö'=>'oe',
				'õ'=>'o','ø'=>'o','ǿ'=>'o','œ'=>'oe','п'=>'p','р'=>'r',
				'ř'=>'r','ŕ'=>'r','ŗ'=>'r','ſ'=>'s','ŝ'=>'s','ș'=>'s',
				'š'=>'s','ś'=>'s','с'=>'s','ş'=>'s','ш'=>'sh','щ'=>'shch',
				'ß'=>'ss','ţ'=>'t','т'=>'t','ŧ'=>'t','ť'=>'t','ț'=>'t',
				'у'=>'u','ǘ'=>'u','ŭ'=>'u','û'=>'u','ú'=>'u','ų'=>'u',
				'ù'=>'u','ű'=>'u','ů'=>'u','ư'=>'u','ū'=>'u','ǚ'=>'u',
				'ǜ'=>'u','ǔ'=>'u','ǖ'=>'u','ũ'=>'u','ü'=>'ue','в'=>'v',
				'ŵ'=>'w','ы'=>'y','ÿ'=>'y','ý'=>'y','ŷ'=>'y','ź'=>'z',
				'ž'=>'z','з'=>'z','ż'=>'z','ж'=>'zh'
			)+Base::instance()->get('DIACRITICS'))))),'-');
	}
104057
def get_post(self, slug):
        
        cache_key = self.get_cache_key(post_slug=slug)
        content = cache.get(cache_key)
        if not content:
            post = Post.objects.get(slug=slug)
            content = self._format(post)
            cache_duration = conf.GOSCALE_CACHE_DURATION if post else 1
            cache.set(cache_key, content, cache_duration)
        return content
1257626
def slugify(self, name):
        
        slug = ''
        last = ''
        for char in name.replace('#', '').lower().strip():
            if not char.isalnum():
                char = '_'

            if last == '_' and char == '_':
                continue

            slug += char
            last = char

        return slug
852276
public static function slug()
    {
        $timestamp = Cuid::timestamp(Cuid::SMALL_BLOCK);
        $count = Cuid::count(Cuid::SMALL_BLOCK);
        $fingerprint = Cuid::fingerprint(Cuid::SMALL_BLOCK);
        $random = Cuid::random(Cuid::SMALL_BLOCK);

        return $timestamp .
            $count .
            $fingerprint .
            $random;
    }
389513
protected function seed($slug)
    {
        $package = $this->packages->where('slug', $slug);

        $className = $package['namespace'] .'\Database\Seeds\DatabaseSeeder';

        if (! class_exists($className)) {
            return;
        }

        // Prepare the call parameters.
        $params = array();

        if ($this->option('class')) {
            $params['--class'] = $this->option('class');
        } else {
            $params['--class'] = $className;
        }

        if ($option = $this->option('database')) {
            $params['--database'] = $option;
        }

        if ($option = $this->option('force')) {
            $params['--force'] = $option;
        }

        $this->call('db:seed', $params);
    }
611704
public static function slug(string $slug): string
    {
        $lettersNumbersSpacesHyphens = '/[^\-\s\pN\pL]+/u';
        $spacesDuplicateHypens = '/[\-\s]+/';

        $slug = preg_replace($lettersNumbersSpacesHyphens, '', $slug);
        $slug = preg_replace($spacesDuplicateHypens, '-', $slug);
        $slug = trim($slug, '-');

        return mb_strtolower($slug, 'UTF-8');
    }
410643
protected function makeSlugUnique(string $slug, array $config, string $attribute): string
    {
        if (!$config['unique']) {
            return $slug;
        }

        $separator = $config['separator'];

        // find all models where the slug is like the current one
        $list = $this->getExistingSlugs($slug, $attribute, $config);

        // if ...
        // 	a) the list is empty, or
        // 	b) our slug isn't in the list
        // ... we are okay
        if (
            $list->count() === 0 ||
            $list->contains($slug) === false
        ) {
            return $slug;
        }

        // if our slug is in the list, but
        // 	a) it's for our model, or
        //  b) it looks like a suffixed version of our slug
        // ... we are also okay (use the current slug)
        if ($list->has($this->model->getKey())) {
            $currentSlug = $list->get($this->model->getKey());

            if (
                $currentSlug === $slug ||
                strpos($currentSlug, $slug) === 0
            ) {
                return $currentSlug;
            }
        }

        $method = $config['uniqueSuffix'];
        if ($method === null) {
            $suffix = $this->generateSuffix($slug, $separator, $list);
        } elseif (is_callable($method)) {
            $suffix = $method($slug, $separator, $list);
        } else {
            throw new \UnexpectedValueException('Sluggable "uniqueSuffix" for ' . get_class($this->model) . ':' . $attribute . ' is not null, or a closure.');
        }

        return $slug . $separator . $suffix;
    }
703132
protected function installUrl(string $slug, string $type): string
    {
        $qualifier           = $slug; // Same as slug.
        $identifier          = $type; // Same as type.
        $nonce_action_prefix = 'install'; // Same for both.

        $args = [
            'action'        => 'install-'.$type,
            '___action_via' => $this->App->Config->©brand['©slug'],
            $identifier     => $qualifier, // Dependency.
        ];
        $admin_url = $this->Wp->is_multisite ? 'network_admin_url' : 'self_admin_url';

        $url = $admin_url('/update.php');
        $url = $this->c::addUrlQueryArgs($args, $url);
        $url = $this->s::addUrlNonce($url, $nonce_action_prefix.'-'.$type.'_'.$qualifier);

        return $url;
    }
146814
protected function activateUrl(string $slug, string $type): string
    {
        $qualifier           = $type === 'theme' ? $slug : null;
        $identifier          = $type === 'theme' ? 'stylesheet' : 'plugin';
        $nonce_action_prefix = $type === 'theme' ? 'switch' : 'activate';

        if ($type === 'plugin' && !($qualifier = $this->s::installedPluginData($slug, 'basename'))) {
            return ''; // Not installed or no basename.
        } // Possible empty string on failure. Please check return value.

        $args = [
            'action'        => 'activate',
            '___action_via' => $this->App->Config->©brand['©slug'],
            $identifier     => $qualifier, // Dependency.
        ];
        // Activations always use `self_admin_url()`.

        $url = self_admin_url('/'.$type.'s.php');
        $url = $this->c::addUrlQueryArgs($args, $url);
        $url = $this->s::addUrlNonce($url, $nonce_action_prefix.'-'.$type.'_'.$qualifier);

        return $url;
    }
90952
def get_by_slug(slug):
        '''
        
        '''
        rec = TabTag.select().where(TabTag.slug == slug)
        if rec.count() > 0:
            return rec.get()
        return None
101172
public function maybeRequestViaNotice(string $app_slug)
    {
        if (!($App = $this->s::getAppsBySlug()[$app_slug] ?? null)) {
            return; // Not possible.
        } elseif ($App->Config->§specs['§in_wp']) {
            return; // Not necessary.
        } elseif ($App->s::getOption('§license_key')) {
            return; // Already have a license key.
        } elseif (!in_array($App->Config->§specs['§type'], ['theme', 'plugin'], true)) {
            return; // Only applies to themes & plugins.
        }
        $is_trial_expired     = $App->s::isTrialExpired();
        $trial_days_remaining = $App->s::trialDaysRemaining();

        $App->s::enqueueNotice('', [
            'id'   => '§license-key-request',
            'type' => $is_trial_expired ? 'warning' : 'info',

            'is_persistent'  => true,
            'is_dismissable' => $is_trial_expired ? false : true,

            'recurs_every' => $trial_days_remaining >= 0 ? $this::SECONDS_IN_DAY * 7 : 0,
            'recurs_times' => $trial_days_remaining >= 0 ? PHP_INT_MAX : 0,

            'for_context' => $App->Config->§specs['§is_network_wide']
                && $this->Wp->is_multisite ? 'network' : 'admin',

            'is_applicable' => function (Classes\App $App) {
                return $App->Parent->s::licenseKeyRequestViaNoticeIsApplicable($App->Config->©brand['©slug']);
            },
            'markup' => function (Classes\App $App) {
                return $App->Parent->s::licenseKeyRequestViaNoticeMarkup($App->Config->©brand['©slug']);
            },
        ]);
    }
1262567
public function runAction(Request $request, $slug, array $options = null)
    {
        $twig       = $this->get('twig');
        $cmsContext = $this->get('cms.context');

        // Кеширование роутера.
        $cache_key = md5('cms_router'.$request->getBaseUrl().$slug);
        if (false == $router_data = $this->get('tagcache')->get($cache_key)) {
            $router_data = $this->get('cms.router')->match($request->getBaseUrl(), $slug, HttpKernelInterface::MASTER_REQUEST, $options);
            $this->get('tagcache')->set($cache_key, $router_data, ['folder', 'node']);
        }

        if ($router_data['status'] == 301 and $router_data['redirect_to']) {
            return new RedirectResponse($router_data['redirect_to'], $router_data['status']);
        }

        $cmsContext->setTemplate($router_data['template']);
        if (empty($router_data['folders'])) { // Случай пустой инсталляции, когда еще ни одна папка не создана.
            $this->get('cms.toolbar')->prepare();

            return $twig->render('CMSBundle::welcome.html.twig');
        }

        if ($router_data['status'] == 404) {
            throw new NotFoundHttpException('Page not found.');
        } elseif ($router_data['status'] == 403) {
            throw new AccessDeniedHttpException('Access Denied.');
        }

        $this->get('html')->setMetas($router_data['meta']);

        foreach ($router_data['folders'] as $folder) {
            $this->get('cms.breadcrumbs')->add($this->get('cms.folder')->getUri($folder), $folder->getTitle(), $folder->getDescription());
        }

        $cmsContext->setCurrentFolderId($router_data['current_folder_id']);
        $cmsContext->setCurrentFolderPath($router_data['current_folder_path']);

        // Список нод кешируется только при GET запросах.
        $router_data['http_method'] = $request->getMethod();

        $nodes = $this->get('cms.node')->buildList($router_data);

        \Profiler::start('buildModulesData');
        $nodesResponses = $this->buildModulesData($request, $nodes);
        \Profiler::end('buildModulesData');

        if ($nodesResponses instanceof Response) {
            return $nodesResponses;
        }

        $this->get('cms.toolbar')->prepare(isset($this->front_controls['node']) ? $this->front_controls['node'] : null);

        try {
            return $twig->render("SiteBundle::{$cmsContext->getTemplate()}.html.twig", $nodesResponses);
        } catch (\Twig_Error_Loader $e) {
            if ($this->get('kernel')->isDebug()) {
                return $twig->render('CMSBundle::error.html.twig', ['errors' => [$e->getMessage()]]);
            }
        }

        return $twig->render('CMSBundle::welcome.html.twig');
    }
423888
def comp(request, slug, directory_slug=None):
    
    context = {}
    path = settings.COMPS_DIR
    comp_dir = os.path.split(path)[1]
    template = "{0}/{1}".format(comp_dir, slug)
    if directory_slug:
        template = "{0}/{1}/{2}".format(comp_dir, directory_slug, slug)
    working_dir = os.path.join(path, slug)
    if os.path.isdir(working_dir):
        return redirect('comp-listing', directory_slug=slug)

    try:
        t = get_template(template)
    except TemplateDoesNotExist:
        return redirect('comp-listing')

    c = RequestContext(request, context)
    return HttpResponse(t.render(c))
613563
def set_slug(apps, schema_editor):
    
    Event = apps.get_model('spectator_events', 'Event')

    for e in Event.objects.all():
        e.slug = generate_slug(e.pk)
        e.save(update_fields=['slug'])
338443
protected function createSlug()
    {
        $slug = $this->generateNonUniqueSlug();

        if ($this->slugOptions->generateUniqueSlug) {
            $slug = $this->makeSlugUnique($slug);
        }

        $this->attributes[$this->slugOptions->slugField] = $slug;
    }