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


PHP url::title方法代码示例

本文整理汇总了PHP中url::title方法的典型用法代码示例。如果您正苦于以下问题:PHP url::title方法的具体用法?PHP url::title怎么用?PHP url::title使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在url的用法示例。


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

示例1: __set

 public function __set($prop, $value)
 {
     if ('name' == $prop) {
         $value = url::title($value);
     }
     parent::__set($prop, $value);
 }
开发者ID:hdragomir,项目名称:ProjectsLounge,代码行数:7,代码来源:tag.php

示例2: radio

 public static function radio($name, $value = NULL, $checked = FALSE, array $attributes = NULL)
 {
     if (!isset($attributes['id']) and self::$auto_id) {
         $attributes['id'] = 'field-' . $name . '-' . url::title($value);
     }
     return parent::radio($name, $value, $checked, $attributes) . PHP_EOL;
 }
开发者ID:TdroL,项目名称:hurtex,代码行数:7,代码来源:form.php

示例3: action_index

 public function action_index()
 {
     $this->template->content = View::factory('admin/projects/create')->bind('post', $post)->bind('errors', $errors)->bind('associates', $assoc);
     $assoc = DB::query(Database::SELECT, 'SELECT id, name FROM associates ORDER BY name')->execute()->as_array('id', 'name');
     // Add an option for "no associate"
     arr::unshift($assoc, 0, '- none -');
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('title', 'not_empty')->rule('title', 'regex', array('/^[\\pL\\pP\\s]{4,255}$/iu'))->rule('associate_id', 'not_empty')->rule('associate_id', 'in_array', array(array_keys($assoc)))->rule('completed', 'not_empty')->rule('completed', 'date')->rule('website', 'regex', array('#^https?://.+$#'));
     if ($post->check($errors)) {
         if (empty($post['associate_id'])) {
             // Make the associate NULL
             $post['associate_id'] = NULL;
             // Use only the title for the slug
             $post['slug'] = url::title($post['title']);
         } else {
             // Use the title with associate for the slug
             $post['slug'] = url::title($post['title']) . '/with/' . url::title($assoc[$post['associate_id']]);
         }
         if (empty($post['website'])) {
             // Make the website value NULL
             $post['website'] = NULL;
         }
         // Get the values of the array
         $values = $post->as_array();
         // Convert the completed date into a timestamp
         $values['completed'] = strtotime($values['completed']);
         $query = DB::query(Database::INSERT, 'INSERT INTO projects (title, associate_id, completed, website, slug) VALUES (:values)')->bind(':values', $values)->execute();
         // Set a cookie message
         cookie::set('message', 'Created new project with an ID of ' . $query);
         // Redirect back to the same page
         $this->request->redirect(url::site($this->request->uri));
     }
 }
开发者ID:pitchinvasion,项目名称:monobrow,代码行数:32,代码来源:projects.php

示例4: __set

 public function __set($key, $value)
 {
     if ($key === 'tags') {
         // Set tag to url-safe format
         $value = url::title($value);
     }
     parent::__set($key, $value);
 }
开发者ID:kolanos,项目名称:kohana-tags,代码行数:8,代码来源:tag.php

示例5: action_slug

 /**
  * TODO: Add check to enforce ajax request
  */
 public function action_slug()
 {
     $title = isset($_POST['title']) ? $_POST['title'] : '';
     $slug = url::title($title);
     /**
      * TODO: Add check to ensure unique slug
      */
     $this->request->response = json_encode(array('slug' => $slug));
 }
开发者ID:kerkness,项目名称:shindig,代码行数:12,代码来源:ajax.php

示例6: make_url_identifier

 public static function make_url_identifier(Comment_Model $comment)
 {
     $url_identifier = '';
     if (isset($comment->commented_object->url_identifier)) {
         $url_identifier = $comment->commented_object->url_identifier;
     } else {
         $url_identifier = url::title($comment->underlying_object_name . "-" . $comment->underlying_object_id . "-" . $comment->title);
     }
     return $url_identifier;
 }
开发者ID:vitrinephp,项目名称:Vitrine-PHP,代码行数:10,代码来源:comments.php

示例7: set_tags

 public function set_tags($tags_string)
 {
     $tag_strings = preg_split('/[^\\w\\-\\.\\_]+/', $tags_string);
     $tags = array();
     foreach ($tag_strings as $tag_string) {
         $tag = ORM::factory('tag', url::title($tag_string));
         if (!$tag->loaded) {
             $tag->name = $tag_string;
             $tag->save();
         }
         $tags[] = $tag->id;
     }
     $this->__set('tags', $tags);
 }
开发者ID:hdragomir,项目名称:ProjectsLounge,代码行数:14,代码来源:project.php

示例8: unique_title

 public static function unique_title($title)
 {
     $uri = url::title($title);
     $result = Database::instance()->select('uri')->like('uri', $uri . '%', FALSE)->get('blog_posts');
     if (count($result) > 0) {
         $max = 0;
         foreach ($result as $row) {
             $suffix = substr($row->uri, strlen($uri) + 1);
             if (ctype_digit($suffix) and $suffix > $max) {
                 $max = $suffix;
             }
         }
         if ($max === 0) {
             $uri .= '-2';
         } else {
             $uri .= '-' . ($max + 1);
         }
     }
     return $uri;
 }
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:20,代码来源:blog.php

示例9: role

 /**
  * Single role view
  *
  * @param  string  $role_id
  * @param  string  $action
  */
 public function role($role_id, $action = null)
 {
     if ($action) {
         switch ($action) {
             // Delete role
             case 'delete':
                 $this->_role_delete($role_id);
                 return;
         }
     }
     $this->history = false;
     $role = new Role_Model((int) $role_id);
     $form_values = $role->as_array();
     $form_errors = $errors = array();
     // Check post
     if ($post = $this->input->post()) {
         $role->name = $post['name'];
         $role->description = $post['description'];
         try {
             $role->save();
             url::redirect('/roles');
         } catch (ORM_Validation_Exception $e) {
             $form_errors = $e->validation->errors();
         }
         $form_values = arr::overwrite($form_values, $post);
     }
     // show form
     if ($role->id) {
         $this->breadcrumb[] = html::anchor('role/' . url::title($role->id, $role->name), html::specialchars($role->name));
         $this->page_title = text::title($role->name);
         $this->page_actions[] = array('link' => 'role/' . url::title($role->id, $role->name) . '/delete', 'text' => __('Delete role'), 'class' => 'role-delete');
     } else {
         $this->page_title = __('Role');
     }
     if (empty($errors)) {
         widget::add('main', View_Mod::factory('roles/role_edit', array('values' => $form_values, 'errors' => $form_errors)));
     } else {
         $this->_error(Kohana::lang('generic.error'), $errors);
     }
 }
开发者ID:anqqa,项目名称:Anqh,代码行数:46,代码来源:roles.php

示例10: edit

 public function edit($album_id = NULL)
 {
     $album = new Album_Model($album_id);
     if (!$album->id) {
         Event::run('system.404');
     }
     $this->template->content = new View('admin/album/form');
     $this->template->content->errors = '';
     $this->template->content->action = 'Edit';
     if ($_POST) {
         try {
             $old_name = $album->album_name;
             $album->set_fields($_POST);
             $album->url_name = url::title($_POST['album_name']);
             $album->save();
             // Rename the album folder too
             rename(APPPATH . 'views/media/photos/' . url::title($old_name), APPPATH . 'views/media/photos/' . $album->url_name);
             url::redirect('admin/album/index');
         } catch (Kohana_User_Exception $e) {
             $this->template->content->errors = $e;
         }
     }
     $this->template->content->album = $album;
 }
开发者ID:peebeebee,项目名称:Simple-Photo-Gallery,代码行数:24,代码来源:album.php

示例11: _venue_edit

 /**
  * Edit venue
  *
  * @param  integer|string  $venue_id
  * @param  integer|string  $category_id
  */
 public function _venue_edit($venue_id = false, $category_id = false)
 {
     $this->history = false;
     $venue = new Venue_Model((int) $venue_id);
     // Check access
     if (!($venue->loaded() && $venue->has_access(Venue_Model::ACCESS_EDIT)) && !(!$venue->loaded() && $this->visitor->logged_in(array('admin', 'venue moderator', 'venue')))) {
         url::back('venues');
     }
     $errors = $form_errors = array();
     $form_values = $venue->as_array();
     // check post
     if (request::method() == 'post') {
         $post = array_merge($this->input->post(), $_FILES);
         $extra = array('author_id' => $this->user->id);
         // got address, get geocode
         if (!empty($post['address']) && !empty($post['city_name'])) {
             list($extra['latitude'], $extra['longitude']) = Gmap::address_to_ll(implode(', ', array($post['address'], $post['zip'], $post['city_name'])));
         }
         if (csrf::valid() && $venue->validate($post, true, $extra)) {
             // handle logo upload
             if (isset($post->logo) && empty($post->logo['error'])) {
                 $logo = Image_Model::factory('venues.logo', $post->logo, $this->user->id);
                 if ($logo->id) {
                     $venue->add($logo);
                     $venue->default_image_id = $logo->id;
                     $venue->save();
                 }
             }
             // handle picture uploads
             foreach (array($post->picture1, $post->picture2) as $picture) {
                 if (isset($picture) && empty($picture['error'])) {
                     $image = Image_Model::factory('venues.image', $picture, $this->user->id);
                     if ($image->id) {
                         $venue->add($image);
                         $venue->save();
                     }
                 }
             }
             // update tags
             $venue->remove(ORM::factory('tag'));
             if (!empty($post->tags)) {
                 foreach ($post->tags as $tag_id => $tag) {
                     $venue->add(ORM::factory('tag', $tag_id));
                 }
             }
             url::redirect(url::model($venue));
         } else {
             $form_errors = $post->errors();
         }
         $form_values = arr::overwrite($form_values, $post->as_array());
     }
     // editing old?
     if ($venue_id) {
         if ($venue->has_access(Venue_Model::ACCESS_DELETE)) {
             $this->page_actions[] = array('link' => 'venue/' . url::title($venue->id, $venue->name) . '/delete/?token=' . csrf::token(), 'text' => __('Delete venue'), 'class' => 'venue-delete');
         }
         $this->page_subtitle = __('Edit venue');
         if (!$venue->id) {
             $errors = array('venues.error_venue_not_found');
         } else {
             $venue_category = $venue->venue_category;
         }
     } else {
         $this->page_subtitle = __('Add venue');
         if ($category_id) {
             $venue_category = new Venue_Category_Model((int) $category_id);
             if ($venue_category->id) {
                 $form_values['venue_category_id'] = $venue_category->id;
             } else {
                 $errors = array('venues.error_venue_category_not_found');
             }
         }
     }
     $this->page_actions[] = array('link' => 'venue/' . url::title($venue->id, $venue->name), 'text' => __('Cancel'), 'class' => 'cancel');
     $this->breadcrumb[] = html::anchor('/venues/' . url::title($venue_category->id, $venue_category->name), $venue_category->name);
     if ($venue->id) {
         $this->breadcrumb[] = html::anchor('/venue/' . url::title($venue->id, $venue->name), $venue->name);
     }
     // show form
     if (empty($errors)) {
         $form = array();
         // tags
         if ($venue_category->tag_group_id) {
             $form['tags'] = $form_values['tags'] = array();
             foreach ($venue_category->tag_group->tags as $tag) {
                 $form['tags'][$tag->id] = $tag->name;
                 if ($venue->has($tag)) {
                     $form_values['tags'][$tag->id] = $tag->name;
                 }
             }
         }
         $venue_categories = ORM::factory('venue_category')->find_all()->select_list('id', 'name');
         $form['venue_category_id'] = $venue_categories;
         widget::add('main', View_Mod::factory('venues/venue_edit', array('form' => $form, 'values' => $form_values, 'errors' => $form_errors)));
//.........这里部分代码省略.........
开发者ID:anqqa,项目名称:Anqh,代码行数:101,代码来源:venues.php

示例12: attach_associated_file

 protected function attach_associated_file($field, $file, $type)
 {
     switch ($type) {
         case 'upload':
         case 'stash':
             $path = $file['tmp_name'];
             $name = $file['name'];
             break;
         case 'copy':
         case 'move':
             $path = $file;
             $name = $file;
             break;
         default:
             throw new Kohana_User_Exception('!!!', '');
     }
     // Get original filename and extension
     $pathinfo = pathinfo($name) + array('extension' => NULL);
     // Limit filename and sanatise
     $filename = text::limit_chars($pathinfo['filename'], 15, '');
     $filename = url::title($filename, '_');
     // Sanatise extension
     $extension = trim(preg_replace('#[^a-z0-9]#', '', strtolower($pathinfo['extension'])));
     $directory = $this->associated_files_path();
     // Check that the directory exists, create it if not
     if (!is_dir($directory)) {
         mkdir($directory, 0777, TRUE);
     }
     // Check it's writable
     if (!is_writable($directory)) {
         throw new Kohana_Exception('upload.not_writable', $directory);
     }
     $prefix = $directory . $this->object[$this->primary_key] . '-' . $field . '-';
     $name = time() . '-' . $filename . ($extension ? ".{$extension}" : '');
     switch ($type) {
         case 'upload':
             move_uploaded_file($path, $prefix . $name);
             break;
         case 'move':
         case 'stash':
             rename($path, $prefix . $name);
             break;
         case 'copy':
             copy($path, $prefix . $name);
             break;
     }
     $this->{$field} = $name;
 }
开发者ID:evansd-archive,项目名称:kohana-module--files,代码行数:48,代码来源:ORM_Files.php

示例13:

?>

<br/>

<?php 
echo url::site('controller/action');
?>

<br/>

<?php 
echo url::site('controller/action', 'ftp');
?>

<br/>

<?php 
echo url::query();
?>

<br/>

<?php 
echo url::query(array('bar' => 'foo'));
?>

<br/>

<?php 
echo url::title('This is my title');
开发者ID:ChangLeoplod,项目名称:kohana-demo,代码行数:30,代码来源:url.php

示例14: make_heading_id

 /**
  * Makes a heading id from the heading text
  * If any heading share the same name then subsequent headings will have an integer appended
  *
  * @param  string The heading text
  * @return string ID for the heading
  */
 function make_heading_id($heading)
 {
     $id = url::title($heading, '-', TRUE);
     if (isset($this->_heading_ids[$id])) {
         $id .= '-';
         $count = 0;
         while (isset($this->_heading_ids[$id]) and ++$count) {
             $id .= $count;
         }
     }
     return $id;
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:19,代码来源:markdown.php

示例15: edit

 public function edit($id)
 {
     $page = ORM::factory('page', (int) $id);
     if (!$page->loaded) {
         message::error(__('Invalid ID'), 'admin/page');
     }
     $form = Formo::factory()->plugin('csrf')->add_group('type', array('none' => __('Do nothing'), 'module' => __('Load module'), 'redirect' => __('Redirect to')))->add_select('module', module::installed_as_array(), array('value' => $page->target))->add_select('redirect', $page->paths(), array('value' => $page->target))->add('submit', 'submit', array('label' => __('Save')));
     foreach (Kohana::config('locale.languages') as $key => $value) {
         $page_content = ORM::factory('page_content')->where(array('page_id' => $page->id, 'language' => $key))->find();
         $form->add('text', 'title_' . $key, array('label' => __('Title'), 'value' => $page_content->title))->add('text', 'content_' . $key, array('label' => __('Content'), 'value' => $page_content->content))->add_rule('title_' . $key, 'required', __('Please choose a title'));
     }
     if ($form->validate()) {
         $title = array();
         foreach (Kohana::config('locale.languages') as $key => $value) {
             $page_content = ORM::factory('page_content')->where(array('page_id' => $page->id, 'language' => $key))->find();
             if (!$page_content->loaded) {
                 $page_content->page_id = $page->id;
                 $page_content->language = $key;
                 $page_content->date = date("Y-m-d H:i:s");
             }
             $page_content->title = $form->{'title_' . $key}->value;
             $page_content->uri = url::title($form->{'title_' . $key}->value);
             $page_content->content = $form->{'content_' . $key}->value;
             $page_content->modified = date("Y-m-d H:i:s");
             $page_content->save();
             $title[] = $page_content->title;
         }
         $type = NULL;
         $target = NULL;
         /*
          * TODO workaround for:
          * http://projects.kohanaphp.com/boards/5/topics/114
          * and
          * http://projects.kohanaphp.com/issues/1697
          *
          * fixed in Formo 1.2
          *
          */
         $_type = NULL;
         foreach ($form->type->elements as $key => $value) {
             if ($form->type->{$key}->checked) {
                 $_type = $value;
                 break;
             }
         }
         if ($_type == 'redirect') {
             $redirect = trim($form->redirect->value);
             if (!empty($redirect)) {
                 $type = 'redirect';
                 $target = $redirect;
             }
         } elseif ($_type == 'module') {
             $module = trim($form->module->value);
             if (!empty($module)) {
                 $type = 'module';
                 $target = $module;
             }
         }
         $page->type = $type;
         $page->target = $target;
         $page->title = implode(' / ', $title);
         $page->save();
         Cache::instance()->delete_tag('menu');
         Cache::instance()->delete_tag('route');
         message::info(__('Page edited successfully'), 'admin/page');
     }
     $this->template->content = View::factory('page/edit', $form->get(TRUE));
     $this->template->content->page = $page;
     $this->template->content->modules = module::installed();
 }
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:70,代码来源:page.php


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