当前位置: 首页>>代码示例>>PHP>>正文


PHP make_slug函数代码示例

本文整理汇总了PHP中make_slug函数的典型用法代码示例。如果您正苦于以下问题:PHP make_slug函数的具体用法?PHP make_slug怎么用?PHP make_slug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了make_slug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit_note

function edit_note($id)
{
    if ((string) (int) $id != $id) {
        _die("Invalid ID");
    }
    include "lib/tags.php";
    $post_data =& $_POST;
    foreach (array('ID', 'title', 'contents', 'tags', 'time', 'slug') as $key) {
        $post_data[$key] = pg_escape_string(@$post_data[$key]);
    }
    $post_data['tags'] = clean_tags($post_data['tags']);
    if (trim($post_data['slug']) == '') {
        $post_data['slug'] = make_slug($post_data['title']);
    }
    if (!($time = strtotime(@$post_data['time']))) {
        $time = date("Y-m-d H:i:s O", time());
    } else {
        $time = date("Y-m-d H:i:s O", $time);
    }
    $result = db("UPDATE public.\"notes\" SET \"title\" = '{$post_data['title']}',\n\t\t\t\"contents\" ='{$post_data['contents']}', \"tags\" = '{$post_data['tags']}',\n\t\t\t\"slug\" ='{$post_data['slug']}'\n\t\t\tWHERE \"ID\" = " . pg_escape_string($id));
    if ($result) {
        if (!rebuild_tags()) {
            _die("There was an error rebuilding the tag cloud data.\n\t\t\t\t<a href=\"" . _l("/edit/{$id}") . "\">Go back &rarr;");
        }
        _die("Edit successfull. <a href=\"" . _l("/edit/{$id}") . "\">continue editing &rarr;");
    } else {
        _die("There was an unexpected error.");
    }
}
开发者ID:shashi,项目名称:octavo,代码行数:29,代码来源:edit.php

示例2: jsonlist_url

function jsonlist_url($item, $module, $prefix = null)
{
    return absolute_link(url_for("@document_by_id_lang_slug?module={$module}&id=" . $item['id'] . '&lang=' . $item['culture'] . '&slug=' . make_slug(isset($prefix) ? $prefix . '-' . $item['name'] : $item['name'])));
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:4,代码来源:GeoJsonHelper.php

示例3: array_keys

        ?>
<div class="one_kind_association">
<div class="association_content">
<?php 
        $area_type_list = array_keys(sfConfig::get('app_areas_area_types'));
        array_shift($area_type_list);
        echo '<div class="assoc_img picto_' . $module . '" title="' . ucfirst(__($module)) . '"><span>' . ucfirst(__($module)) . __('&nbsp;:') . '</span></div>';
        foreach ($area_type_list as $area_type) {
            $element = array();
            foreach ($associated_docs as $doc) {
                if ($doc['area_type'] != $area_type) {
                    continue;
                }
                $doc_id = $doc['id'];
                $name = ucfirst($doc['name']);
                $url = "@document_by_id_lang_slug?module={$module}&id={$doc_id}" . '&lang=' . $doc['culture'] . '&slug=' . make_slug($doc['name']);
                $element[] = link_to($name, $url);
            }
            if (!empty($element)) {
                echo '<div class="linked_elt">' . implode(', ', $element) . '</div>';
            }
        }
        ?>
</div>
</div>
<?php 
    }
    $has_box = isset($box) && $box;
    $has_weather = isset($weather) && $weather;
    $has_avalanche_bulletin = isset($avalanche_bulletin) && count($avalanche_bulletin);
    $has_date = isset($date) && $date;
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:_association.php

示例4: redirectToView

 /**
  * overrides function from parent in order to correctly display slug
  * with summit name
  */
 protected function redirectToView()
 {
     sfLoader::loadHelpers(array('General'));
     $prefered_cultures = $this->getUser()->getCulturesForDocuments();
     $summits = Association::findAllWithBestName($this->document->get('id'), $prefered_cultures, 'sr');
     $summit_name = c2cTools::extractHighestName($summits);
     $this->redirect('@document_by_id_lang_slug?module=' . $this->getModuleName() . '&id=' . $this->document->get('id') . '&lang=' . $this->document->getCulture() . '&slug=' . make_slug($summit_name) . '-' . get_slug($this->document));
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:12,代码来源:actions.class.php

示例5: setSlugAttribute

 public function setSlugAttribute($title)
 {
     if (!isset($this->attributes['slug']) || $this->attributes['slug'] != str_slug($title)) {
         $this->attributes['slug'] = make_slug('contents', $title);
     }
 }
开发者ID:jeremytubbs,项目名称:vue-admin,代码行数:6,代码来源:Content.php

示例6: executeFeed

 /**
  * Executes Feed action
  * NB: cannot be cached ...
  */
 public function executeFeed()
 {
     $feed = new sfGeoRssFeed();
     $lang = $this->getRequestParameter('lang');
     $model = $this->model_class;
     $module = $this->getModuleName();
     $id = $this->getRequestParameter('id');
     $mode = $this->getRequestParameter('mode');
     if ($lang) {
         $languages = sfConfig::get('app_languages_c2c');
     }
     switch ($mode) {
         case 'editions':
             $description = $this->__($lang ? "Latest %1% editions in %2%" : "Latest %1% editions", array('%1%' => $this->__($module), '%2%' => $lang ? $this->__($languages[$lang]) : null));
             $title = $description;
             // TODO Provide better description, different from title
             $link = "@module_whatsnew?module={$module}";
             // TODO maybe we should propose lang filters for whatsnew url?
             $self_link = $lang ? "@feed_lang?module={$module}&lang={$lang}" : "@feed?module={$module}";
             break;
         case 'creations':
             $description = $this->__($lang ? "Latest %1% creations in %2%" : "Latest %1% creations", array('%1%' => $this->__($module), '%2%' => $lang ? $this->__($languages[$lang]) : null));
             $title = $description;
             // TODO Provide better description, different from title
             $link = "@default_index?module={$module}";
             // TODO can we redirect to list with lang filter once it is done?
             $self_link = $lang ? "@creations_feed_lang?module={$module}&lang={$lang}" : "@creations_feed?module={$module}";
             break;
         default:
             // editions of a specific document
             // check that document $id exists in lang $lang, and retrieve its name.
             if (!($document = DocumentI18n::findName($id, $lang, $this->model_class))) {
                 $this->setNotFoundAndRedirect();
             }
             $name = $document->get('name');
             $description = $this->__("Latest editions for \"%1%\" - %2%", array('%1%' => $name, '%2%' => $this->__($languages[$lang])));
             $title = $description;
             // TODO Provide better description, different from title
             $link = "@document_history?module={$module}&id={$id}&lang={$lang}";
             $self_link = "@document_feed?module={$module}&id={$id}&lang={$lang}";
             break;
     }
     $feed->setTitle($title);
     $feed->setLink($link);
     $feed->setFeedUrl($self_link);
     $feed->setDescription($description);
     $feed->setLanguage($lang);
     $feed->setAuthorName('Camptocamp.org');
     $max_number = sfConfig::get('app_feeds_items_limit');
     if ($module != 'documents' || !empty($id)) {
         //usage: listRecent($model, $limit, $user_id = null, $lang = null, $doc_id = null, $mode = 'editions')
         $items = Document::listRecent($this->model_class, $max_number, null, $lang, $id, $mode);
         sfLoader::loadHelpers(array('General', 'SmartFormat'));
         $model_i18n = $model . 'I18n';
         // Add best summit name for routes
         foreach ($items as $key => $item) {
             $items[$key]['module'] = $item[$model]['module'];
             $items[$key]['id'] = $item['document_id'];
             $items[$key]['name'] = $item[$model_i18n]['name'];
             $items[$key]['search_name'] = $item[$model_i18n]['search_name'];
         }
         $routes = Route::addBestSummitName(array_filter($items, array('c2cTools', 'is_route')), $this->__(' :') . ' ');
         foreach ($routes as $key => $route) {
             $items[$key] = $route;
         }
         foreach ($items as $item) {
             $item_id = $item['document_id'];
             $new = $item['version'];
             $module_name = $item[$model]['module'];
             $name = $item['name'];
             $doc_lang = $item['culture'];
             $feedItemTitle = $name . ($mode != 'creations' ? " - r{$new}" . ($lang ? '' : "/{$doc_lang}") : '');
             $feedItem = new sfGeoFeedItem();
             $feedItem->setTitle($feedItemTitle);
             if ($mode == 'creations') {
                 if ($module_name == 'users') {
                     $feedItem->setLink("@document_by_id_lang?module={$module_name}&id={$item_id}&lang={$doc_lang}");
                 } else {
                     $feedItem->setLink("@document_by_id_lang_slug?module={$module_name}&id={$item_id}&lang={$doc_lang}&slug=" . make_slug($item['name']));
                 }
             } else {
                 $feedItem->setLink("@document_by_id_lang_version?module={$module_name}&id={$item_id}&lang={$doc_lang}&version={$new}");
             }
             $feedItem->setAuthorName($item['history_metadata']['user_private_data']['topo_name']);
             //$feedItem->setAuthorEmail($item['history_metadata']['user_private_data']['email']);
             $feedItem->setPubdate(strtotime($item['created_at']));
             $feedItem->setUniqueId("{$item_id}-{$doc_lang}-{$new}");
             $feedItem->setLongitude($item[$model]['lon']);
             $feedItem->setLatitude($item[$model]['lat']);
             $comment = smart_format($item['history_metadata']['comment']);
             $feedItem->setDescription($comment);
             if ($mode != 'creations') {
                 $link = $new > 1 ? ' - ' . link_to(__('View difference between version %1% and %2%', array('%1%' => $new - 1, '%2%' => $new)), "@document_diff?module={$module_name}&id={$item_id}&lang={$doc_lang}&new={$new}&old=" . ($new - 1), array('absolute' => true)) : '';
                 $feedItem->setContent($comment . $link);
             }
             $feed->addItem($feedItem);
//.........这里部分代码省略.........
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:101,代码来源:actions.class.php

示例7: __

$use_camo = (bool) sfConfig::get('app_camo_use');
$camo_url = sfConfig::get('app_camo_url');
$camo_key = sfConfig::get('app_camo_key');
// load needed strings from PunBB
@(include PUN_ROOT . 'lang/' . __('meta_language_forum') . '/common.php');
$module = $sf_context->getModuleName();
$lang = $sf_params->get('lang');
$id = $sf_params->get('id');
$mobile_version = c2cTools::mobileVersion();
require_once PUN_ROOT . 'include/parser.php';
$nb_comments = $comments->count();
$document_name = isset($title_prefix) ? $title_prefix . __('&nbsp;:') . ' ' . $document_name : $document_name;
echo display_title($document_name, $module);
if (!$mobile_version) {
    echo '<div id="nav_space">&nbsp;</div>';
    echo tabs_list_tag($id, $lang, $exists_in_lang, 'comments', NULL, $module != 'users' ? make_slug($document_name) : '', $nb_comments);
}
echo display_content_top('doc_content');
echo start_content_tag($module . '_content');
if ($nb_comments > 0) {
    $topic_id = $comments->getFirst()->topic_id;
    $uri_anchor = explode('#', $_SERVER['REQUEST_URI'], 2);
    $post_id = 0;
    if (count($uri_anchor) > 1) {
        $post_anchor = $uri_anchor[1];
        if (strpos($post_anchor, 'p') === 0) {
            if (preg_match('#p([0-9]+)#si', $post_anchor, $post_id_match)) {
                $post_id = intval($post_id_match[1]);
            }
        }
    }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:commentSuccess.php

示例8: foreach

        </tr>
    </thead>
    <tbody>
    <?php 
$table_list_even_odd = 0;
foreach ($items as $item) {
    $table_class = $table_list_even_odd++ % 2 == 0 ? 'table_list_even' : 'table_list_odd';
    $user_link = '@document_by_id?module=users&id=' . $item['user_private_data']['id'];
    $models = c2cTools::Type2Models($item['type']);
    $main_module = c2cTools::model2module($models['main']);
    $linked_module = c2cTools::model2module($models['linked']);
    $main_item = count($item['mainI18n']) ? $item['mainI18n'][0] : null;
    $linked_item = count($item['linkedI18n']) ? $item['linkedI18n'][0] : null;
    // FIXME: routes slugs
    $main_link = '@document_by_id_lang_slug?module=' . $main_module . '&id=' . $item['main_id'] . '&lang=' . $main_item['culture'] . '&slug=' . make_slug($main_item['name']);
    $linked_link = '@document_by_id_lang_slug?module=' . $linked_module . '&id=' . $item['linked_id'] . '&lang=' . $linked_item['culture'] . '&slug=' . make_slug($linked_item['name']);
    ?>
        <tr class="<?php 
    echo $table_class;
    if ($item['is_creation']) {
        echo ' creation';
    } else {
        echo ' deletion';
    }
    ?>
">
            <td> <?php 
    echo $item['is_creation'] ? $added_pic : $deleted_pic;
    ?>
 </td>
            <td> <?php 
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:latestassociationsSuccess.php

示例9: use_helper

<?php

use_helper('General');
$feed = new sfGeoRssFeed();
$feed->setTitle('Camptocamp.org ');
$feed->setLink('http://www.camptocamp.org');
$feed->setAuthorName('Camptocamp.org');
//$feed->setLanguage($lang);
foreach ($documents as $doc) {
    $feedItem = new sfGeoFeedItem();
    $feedItem->setTitle($doc['name']);
    $id = $doc['id'];
    $module = $doc['module'];
    $lang = $doc['culture'];
    $slug = make_slug($doc['name']);
    $feedItem->setLink("@document_by_id_lang_slug?module={$module}&id={$id}&lang={$lang}&slug={$slug}");
    $feedItem->setDescription($module);
    $feed->addItem($feedItem);
}
echo $feed->asXml(ESC_RAW);
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:20,代码来源:latestSuccess.php

示例10: _die

<?php

/* Adds a post to the database */
if (!(isset($_POST) && @$_POST['title'] != '')) {
    _die("tpl/post_form.html");
}
include "lib/post.php";
include "lib/tags.php";
$post_data =& $_POST;
foreach (array('title', 'contents', 'tags', 'time', 'slug') as $key) {
    $post_data[$key] = pg_escape_string(@$post_data[$key]);
}
$post_data['tags'] = clean_tags($post_data['tags']);
if (trim($post_data['slug']) == '') {
    $post_data['slug'] = make_slug($post_data['title']);
}
if (!($time = strtotime(@$post_data['time']))) {
    $time = date("Y-m-d H:i:s O", time());
} else {
    $time = date("Y-m-d H:i:s O", $time);
}
if (db('INSERT INTO "public"."notes" ("title", "contents", "slug", "tags", "time") VALUES (' . "\n\t'{$post_data['title']}','{$post_data['contents']}','{$post_data['slug']}','{$post_data['tags']}','{$time}' )")) {
    add_tags($post_data['tags']);
    header('Location: ' . _l("/archive/{$_POST['slug']}"));
} else {
    _die("Some error occoured. Try again.");
}
开发者ID:shashi,项目名称:octavo,代码行数:27,代码来源:add.php

示例11: list_link

function list_link($item, $module, $prefix = null)
{
    return link_to(isset($prefix) ? $prefix . __('&nbsp;:') . ' ' . $item['name'] : $item['name'], "@document_by_id_lang_slug?module={$module}&id=" . $item['id'] . '&lang=' . $item['culture'] . '&slug=' . make_slug(isset($prefix) ? $prefix . '-' . $item['name'] : $item['name']), array('hreflang' => $item['culture']));
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:4,代码来源:LinkHelper.php

示例12: format_date

 } else {
     ?>
         <li class="even">
     <?php 
 }
 $list_item++;
 $timedate = $item['date'];
 if ($timedate != $date) {
     echo '<span class="date">' . format_date($timedate, $item_date_format) . '</span>';
     $date = $timedate;
 }
 echo get_paginated_activities($item['activities']) . ' ';
 $i18n = $item['OutingI18n'][0];
 $id = $item['id'];
 $lang = $i18n['culture'];
 echo link_to($i18n['name'], "@document_by_id_lang_slug?module=outings&id={$id}&lang={$lang}&slug=" . make_slug($i18n['name']), array('hreflang' => $lang));
 $outing_data = array();
 $max_elevation = displayWithSuffix($item['max_elevation'], 'meters');
 if (!empty($max_elevation)) {
     $outing_data[] = $max_elevation;
 }
 $area_name = Area::getBestRegionDescription($item['geoassociations'], true);
 if (!empty($area_name)) {
     $outing_data[] = $area_name;
 }
 if (count($outing_data) > 0) {
     echo ' <span class="meta">(' . implode(' - ', $outing_data) . ')</span>';
 }
 if (isset($item['nb_images'])) {
     $images = picto_tag('picto_images_light', format_number_choice('[1]1 image|(1,+Inf]%1% images', array('%1%' => $item['nb_images']), $item['nb_images'])) . ' ';
     echo $images;
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:_latest.php

示例13: trim

        $price = $child->find($price_xpath, 0)->innertext;
        $sku = $child->find($sku_xpath, 0)->innertext;
        echo $sku . '<br>';
        $img = $child->find($img_xpath, 0)->src;
        $content = '';
        $content = $child->find($content_xpath, 0)->innertext;
        //
        $title = trim($title);
        $price = str_replace(',', '', trim($price));
        $price = str_replace(' VND', '', $price);
        $sku = trim($sku);
        $img = 'http://haicaubeo.com' . str_replace(' ', '%20', trim($img));
        $content = trim($content);
        $store_url = '/img/uploads/2015/06/' . strtolower(str_replace('%20', '-', basename($img)));
        //
        $sql = "INSERT INTO `products`(\n        `sku`, `provider_id`,\n        `name`, `slug`, `price`,\n        `retail_price`, `source_price`, `excert`,\n        `descriptions`,\n        `category_id`, `type`)\n        VALUES (\n        " . $sku . ",1,\n        '" . $title . "', '" . make_slug($title) . "'," . ($price + 20000) . ",\n        " . $price . "," . $price . ",'',\n        '" . $content . "',\n        " . $l['cat'] . ",1)";
        $sql2 = "INSERT INTO `medias`(`ref`, `ref_id`, `file`, `position`) VALUES ('Product','[p_id]','{$store_url}',0)";
        $sql3 = "UPDATE `products` SET `media_id` = [media_id] WHERE `id` = [p_id] ";
        $buildQuery[$sku] = array('product' => $sql, 'media' => $sql2, 'update' => $sql3);
        $imgSavePath = getcwd() . '\\img\\uploads\\2015\\06\\' . strtolower(str_replace('%20', '-', basename($img)));
        file_put_contents($imgSavePath, file_get_contents($img));
    }
}
krsort($buildQuery);
foreach ($buildQuery as $query) {
    if (mysqli_query($conn, $query['product'])) {
        $product_id = $conn->insert_id;
        $query['media'] = str_replace('[p_id]', $product_id, $query['media']);
        if (mysqli_query($conn, $query['media'])) {
            $media_id = $conn->insert_id;
            $query['update'] = str_replace('[p_id]', $product_id, $query['update']);
开发者ID:CaoLP,项目名称:cwr_web,代码行数:31,代码来源:index_.php

示例14: foreach

<?php

if (!isset($use_keys)) {
    $use_keys = false;
}
foreach ($parkings as $parking) {
    $i18n = $parking['ParkingI18n'][0];
    $url = $use_keys ? array() : array('url' => absolute_link(url_for('@document_by_id_lang_slug?module=parkings&id=' . $parking['id'] . '&lang=' . $i18n['culture'] . '&slug=' . make_slug($i18n['name']))));
    $a[] = array_merge(array('id' => $parking['id'], 'name' => $i18n->getRaw('name')), $url);
}
if (isset($a)) {
    krsort($a);
    echo json_encode(array_values($a));
} else {
    echo '[]';
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:16,代码来源:_parkings4jsonlist.php

示例15: use_helper

<?php

use_helper('Date', 'History', 'MyForm', 'Language', 'Viewer', 'WikiTabs', 'SmartFormat', 'sfBBCode');
use_javascript('/static/js/diff.js', 'last');
use_javascript('/static/js/history_tools.js', 'last');
$is_moderator = $sf_user->hasCredential(sfConfig::get('app_credentials_moderator'));
$module = $sf_context->getModuleName();
$model = c2cTools::module2model($module);
$i18n_archive = $model . 'I18nArchive';
$lang = $sf_params->get('lang');
$id = $sf_params->get('id');
$table_list_even_odd = 0;
$slug = make_slug($document[$i18n_archive]['name']);
echo display_title(isset($title_prefix) ? $title_prefix . __('&nbsp;:') . ' ' . $document_name : $document_name, $module);
echo '<div id="nav_space">&nbsp;</div>';
echo tabs_list_tag($id, $lang, $exists_in_lang, 'history', null, $slug, $nb_comments);
echo display_content_top('doc_content');
echo start_content_tag($module . '_content');
?>
<p><?php 
echo __('Viewing history from %1% in %2%', array('%1%' => $document_name, '%2%' => format_language_c2c($lang)));
?>
</p>

<p><?php 
echo __('Legend:') . ' * = ' . __('current version') . ', <strong>' . __('minor_tag') . '</strong> = ' . __('minor modification');
?>
</p>

<?php 
echo form_tag("@document_diff_post?module={$module}&id={$id}&lang={$lang}", array('method' => 'post'));
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:31,代码来源:historySuccess.php


注:本文中的make_slug函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。