本文整理汇总了PHP中URL::title方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::title方法的具体用法?PHP URL::title怎么用?PHP URL::title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::title方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
/**
* Executed before rendering.
*/
public function before()
{
// Generate section title if none set
if (is_null($this->title) && $this->date) {
if ($this->date == date('Y-m-d')) {
$this->title = __('Today');
$this->class .= ' today';
} else {
if ($this->date == date('Y-m-d', strtotime('tomorrow'))) {
$this->title = __('Tomorrow');
$this->class .= ' tomorrow';
} else {
$date = Date::split($this->date);
$this->title = $date['weekday_short'] . ' ' . $date['day'] . ' ' . $date['month_short'];
}
}
}
// Add articles
foreach ((array) $this->events as $city => $events) {
foreach ($events as $event) {
$article = new View_Event_Day($event);
$article->class .= ' city-' . URL::title($city);
$this->articles[] = $article;
}
}
}
示例2: action_new
public function action_new()
{
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('New field')));
$this->template->title = __('New Custom Field for Users');
if ($_POST) {
if (count(Model_UserField::get_all(FALSE)) > 65) {
Alert::set(Alert::ERROR, __('You have reached the maximum number of custom fields allowed.'));
HTTP::redirect(Route::url('oc-panel', array('controller' => 'userfields', 'action' => 'index')));
}
$name = URL::title(Core::post('name'));
if (strlen($name) >= 60) {
$name = Text::limit_chars($name, 60, '');
}
$field = new Model_UserField();
try {
$options = array('label' => Core::post('label'), 'tooltip' => Core::post('tooltip'), 'required' => Core::post('required') == 'on' ? TRUE : FALSE, 'searchable' => Core::post('searchable') == 'on' ? TRUE : FALSE, 'show_profile' => Core::post('show_profile') == 'on' ? TRUE : FALSE, 'show_register' => Core::post('show_register') == 'on' ? TRUE : FALSE, 'admin_privilege' => Core::post('admin_privilege') == 'on' ? TRUE : FALSE);
if ($field->create($name, Core::post('type'), Core::post('values'), $options)) {
Core::delete_cache();
Alert::set(Alert::SUCCESS, sprintf(__('Field %s created'), $name));
} else {
Alert::set(Alert::ERROR, sprintf(__('Field %s already exists'), $name));
}
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
HTTP::redirect(Route::url('oc-panel', array('controller' => 'userfields', 'action' => 'index')));
}
$this->template->content = View::factory('oc-panel/pages/userfields/new');
}
示例3: gen_seotitle
/**
* return the title formatted for the URL
*
* @param string $title
*
*/
public function gen_seotitle($seotitle)
{
//in case seotitle is really small or null
if (strlen($seotitle) < 3) {
$seotitle = $this->title;
}
$seotitle = URL::title($seotitle);
if ($seotitle != $this->seotitle) {
$post = new self();
//find a user same seotitle
$s = $post->where('seotitle', '=', $seotitle)->limit(1)->find();
//found, increment the last digit of the seotitle
if ($s->loaded()) {
$cont = 2;
$loop = TRUE;
while ($loop) {
$attempt = $seotitle . '-' . $cont;
$post = new self();
unset($s);
$s = $post->where('seotitle', '=', $attempt)->limit(1)->find();
if (!$s->loaded()) {
$loop = FALSE;
$seotitle = $attempt;
} else {
$cont++;
}
}
}
}
return $seotitle;
}
示例4: action_write
public function action_write()
{
$this->template->page_title = 'Write Article';
$user = new Model_User();
$session = Session::instance()->get('user');
$view = View::factory('cp/entries/write');
$view->author = $users->get_user_by_session_id($session);
if ($this->request->method() === Request::POST) {
if (!Security::check($this->request->post('csrf_token'))) {
throw new HTTP_Exception_401("Bad token!");
}
$post_title = $this->request->post('title');
$post_slug = $this->request->post('slug');
$post_content = $this->request->post('content');
$post_author = $this->request->post('author');
$post_date = time();
if (empty($post_title) and empty($post_content) and empty($post_author) and empty($post_date)) {
throw new Exception('Please don`t make empty fields!');
}
if (empty($post_slug)) {
$post_slug = URL::title($post_title, '_');
}
$entry = new Model_Entry();
$data = array('title' => $post_title, 'slug' => $post_slug, 'content' => $post_content, 'author' => $post_author, 'date' => $post_date);
$insert_entry = $entry->insert_entry($data);
if (!$insert_entry) {
throw new Exception('Check if you are connected to database!');
}
$this->request->redirect('cp/entries/write/');
}
$this->template->content = $view->render();
}
示例5: valid
/**
* Validation rule for checking a valid token
*
* @param string $namespace - the token string to check for
* @return bool
*/
public static function valid($namespace = NULL)
{
if ($namespace === NULL) {
$namespace = URL::title(Request::current()->uri());
}
return Request::$current->post('csrf_' . $namespace) === self::token($namespace);
}
示例6: before
/**
* Automatically executed before the widget action. Can be used to set
* class properties, do authorization checks, and execute other custom code.
*
* @return void
*/
public function before()
{
$loc = new Model_Location();
// loaded locations
if (Model_Location::current()->loaded()) {
$location = Model_Location::current()->id_location;
// id_location
//list of children of current location
// if list_loc dosent have siblings take brothers //
$list_loc = $loc->where('id_location_parent', '=', $location)->order_by('order', 'asc')->cached()->find_all();
if (count($list_loc) == 0) {
$list_loc = $loc->where('id_location_parent', '=', Model_Location::current()->id_location_parent)->order_by('order', 'asc')->cached()->find_all();
}
//parent of current location
$loc_parent_deep = $loc->where('id_location', '=', Model_Location::current()->id_location_parent)->limit(1)->find();
// array with name and seoname of a location and his parent. Is to build breadcrumb in widget
$current_and_parent = array('name' => Model_Location::current()->name, 'id' => Model_Location::current()->id_location, 'seoname' => Model_Location::current()->seoname, 'parent_name' => $loc_parent_deep->name, 'id_parent' => $loc_parent_deep->id_location_parent, 'parent_seoname' => $loc_parent_deep->seoname);
} else {
$list_loc = $loc->where('id_location_parent', '=', 1)->order_by('order', 'asc')->cached()->find_all();
$current_and_parent = NULL;
}
$this->locations = $this->locations;
$this->loc_items = $list_loc;
$this->loc_breadcrumb = $current_and_parent;
$this->cat_seoname = URL::title(__('all'));
if (Model_Category::current()->loaded()) {
$this->cat_seoname = Model_Category::current()->seoname;
}
}
示例7: action_new
public function action_new()
{
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('New')));
$this->template->title = __('New Custom Field for Advertisement');
//find all, for populating form select fields
list($categories) = Model_Category::get_all();
if ($_POST) {
$name = URL::title(Core::post('name'));
$field = new Model_Field();
try {
$options = array('label' => Core::post('label'), 'tooltip' => Core::post('tooltip'), 'required' => Core::post('required') == 'on' ? TRUE : FALSE, 'searchable' => Core::post('searchable') == 'on' ? TRUE : FALSE);
if ($field->create($name, Core::post('type'), Core::post('values'), Core::post('categories'), $options)) {
Cache::instance()->delete_all();
Theme::delete_minified();
Alert::set(Alert::SUCCESS, __('Field created ' . $name));
Request::current()->redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
} else {
Alert::set(Alert::ERROR, __('Field already exists ' . $name));
}
} catch (Exception $e) {
throw new HTTP_Exception_500();
}
}
$this->template->content = View::factory('oc-panel/pages/fields/new', array('categories' => $categories));
}
示例8: set_values
public function set_values(array $data)
{
if (!Valid::url($data['next_url'])) {
$data['next_url'] = NULL;
}
$data['fields'] = array();
if (!empty($data['field']) and is_array($data['field'])) {
foreach ($data['field'] as $key => $values) {
foreach ($values as $index => $value) {
if ($index == 0) {
continue;
}
if ($key == 'source') {
$value = URL::title($value, '_');
}
$data['fields'][$index][$key] = $value;
}
}
$data['field'] = NULL;
}
$email_type_fields = array();
foreach ($data['fields'] as $field) {
$email_type_fields['key'][] = $field['id'];
$email_type_fields['value'][] = !empty($field['name']) ? $field['name'] : Inflector::humanize($field['id']);
}
$this->create_email_type($email_type_fields);
return parent::set_values($data);
}
示例9: action_new
public function action_new()
{
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('New field')));
$this->template->title = __('New Custom Field for Advertisement');
//find all, for populating form select fields
$categories = Model_Category::get_as_array();
$order_categories = Model_Category::get_multidimensional();
if ($_POST) {
if (count(Model_Field::get_all()) > 65) {
Alert::set(Alert::ERROR, __('You have reached the maximum number of custom fields allowed.'));
HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
}
$name = URL::title(Core::post('name'));
$field = new Model_Field();
try {
$options = array('label' => Core::post('label'), 'tooltip' => Core::post('tooltip'), 'required' => Core::post('required') == 'on' ? TRUE : FALSE, 'searchable' => Core::post('searchable') == 'on' ? TRUE : FALSE, 'admin_privilege' => Core::post('admin_privilege') == 'on' ? TRUE : FALSE, 'show_listing' => Core::post('show_listing') == 'on' ? TRUE : FALSE);
if ($field->create($name, Core::post('type'), Core::post('values'), Core::post('categories'), $options)) {
Core::delete_cache();
Alert::set(Alert::SUCCESS, sprintf(__('Field %s created'), $name));
} else {
Alert::set(Alert::WARNING, sprintf(__('Field %s already exists'), $name));
}
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
}
$this->template->content = View::factory('oc-panel/pages/fields/new', array('categories' => $categories, 'order_categories' => $order_categories));
}
示例10: slug
public static function slug($string, $replacement = '-')
{
$slug = UTF8::trim(UTF8::strtolower($string));
$map = array('/ä/' => 'ae', '/ö/' => 'oe', '/ü/' => 'ue', '/щ/' => 'sch', '/ш/' => 'sh', '/ч/' => 'ch', '/ц/' => 'c', '/ю/' => 'yu', '/я/' => 'ya', '/ж/' => 'zh', '/а/' => 'a', '/б/' => 'b', '/в/' => 'v', '/г|ґ/' => 'g', '/д/' => 'd', '/е/' => 'e', '/ё/' => 'yo', '/з/' => 'z', '/и|і/' => 'i', '/й/' => 'y', '/к/' => 'k', '/л/' => 'l', '/м/' => 'm', '/н/' => 'n', '/о/' => 'o', '/п/' => 'p', '/р/' => 'r', '/с/' => 's', '/т/' => 't', '/у/' => 'u', '/ф/' => 'f', '/х/' => 'h', '/ы/' => 'y', '/э/' => 'e', '/є/' => 'ye', '/ї/' => 'yi', '/º|°/' => 0, '/¹/' => 1, '/²/' => 2, '/³/' => 3, '/à|á|å|â|ã|ä|ą|ă|ā|ª/' => 'a', '/@/' => 'at', '/æ/' => 'ae', '/ḃ/' => 'b', '/č|ç|¢|ć|ċ|ĉ|©/' => 'c', '/ď|ḋ|đ/' => 'd', '/€/' => 'euro', '/è|é|ê|ě|ẽ|ë|ę|ē|ė|ĕ/' => 'e', '/ƒ|ḟ/' => 'f', '/ģ|ğ|ĝ|ġ/' => 'g', '/ĥ|ħ/' => 'h', '/Ì|Í|Î|Ï/' => 'I', '/ì|í|î|ï|ĩ|ī|į|ı/' => 'i', '/ĵ/' => 'j', '/ķ/' => 'k', '/ł|ľ|ĺ|ļ/' => 'l', '/Ł/' => 'L', '/ṁ/' => 'm', '/ñ|ń|ņ|ň/' => 'n', '/ò|ó|ô|ø|õ|ö|ō|ð|ơ|ő/' => 'o', '/œ/' => 'oe', '/ṗ/' => 'p', '/ř|ŗ|ŕ|®/' => 'r', '/š|ś|ṡ|ş|ș/' => 's', '/ť|ț|ŧ|ţ|ṫ/' => 't', '/þ/' => 'th', '/ß/' => 'ss', '/™/' => 'tm', '/ù|ú|ů|û|ü|ū|ũ|ű|ŭ|ư|ų|µ/' => 'u', '/ẃ|ẅ|ẁ|ŵ/' => 'w', '/×/' => 'x', '/ÿ|ý|ỳ|ŷ|¥/' => 'y', '/Ž|Ż|Ź/' => 'Z', '/ž|ż|ź/' => 'z', '/\\s+/' => $replacement);
$slug = preg_replace(array_keys($map), array_values($map), $slug);
return URL::title($slug, $replacement);
}
示例11: action_create
public function action_create()
{
if (Auth::is_admin_signed_in() === true) {
$view = View::factory('acp/categories/create');
$categories = new Model_Category();
if ($this->request->method() === Request::POST) {
$name = $this->request->post('name');
$slug = $this->request->post('slug');
$token = $this->request->param('id');
if (!Security::check($token)) {
$this->request->redirect('acp/categories/create');
}
if (empty($slug)) {
$slug = URL::title($name, '_');
}
if (empty($name) && empty($slug)) {
$this->request->redirect('acp/categories/create');
}
$categories = new Model_Category();
$create_category = $categories->create_category($name, $slug);
if (!$create_category) {
$this->request->redirect('acp/categories/create');
}
$this->request->redirect('acp/categories');
}
$this->template->content = $view->render();
} else {
$this->request->redirect('acp');
}
}
示例12: set_inject_key
public function set_inject_key($key)
{
if (empty($key)) {
$this->inject_key = 'ids';
return;
}
$this->inject_key = URL::title($key, '_');
}
示例13: content
/**
*
* @param string $part
* @param boolean $inherit
* @param integer $cache_lifetime
*/
public function content($part = 'body', $inherit = FALSE, $cache_lifetime = NULL, array $tags = array())
{
$method = 'content_' . URL::title($part, '_');
if (method_exists($this, $method)) {
return $this->{$method}($cache_lifetime, $tags);
}
return parent::content($part, $inherit, $cache_lifetime, $tags);
}
示例14: load_page
/**
* Load a behavior and return it
*
* @param behavior_id string The Behavior plugin folder name
*
* @return string class name of the page
*/
public static function load_page($behavior_id)
{
$behavior_page_class = 'Model_Page_Behavior_' . URL::title($behavior_id, '');
if (class_exists($behavior_page_class)) {
return $behavior_page_class;
} else {
return 'Model_Page_Behavior';
}
}
示例15: tabs
public function tabs()
{
$tabs = array();
foreach ($this->tabs as $tab) {
$tabs[] = array('name' => $tab->name, 'machine-name' => URL::title($tab->name), 'content' => $tab->render(), 'active' => FALSE);
}
isset($tabs[0]) and $tabs[0]['active'] = TRUE;
return $tabs;
}