本文整理汇总了PHP中href_to函数的典型用法代码示例。如果您正苦于以下问题:PHP href_to函数的具体用法?PHP href_to怎么用?PHP href_to使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了href_to函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAuthRedirectUrl
public function getAuthRedirectUrl($value)
{
$url = href_to_home();
$user_id = cmsUser::sessionGet('user:id');
if (!$user_id) {
return $url;
}
$back_url = $this->getBackURL();
if (strpos($back_url, href_to('auth', 'login')) !== false) {
$back_url = $url;
}
switch ($value) {
case 'none':
$url = $back_url;
break;
case 'index':
$url = href_to_home();
break;
case 'profile':
$url = href_to('users', $user_id);
break;
case 'profileedit':
$url = href_to('users', $user_id, 'edit');
break;
}
return $url;
}
示例2: run
public function run($data)
{
list($ctype, $album, $fields) = $data;
$is_allow = $album['is_public'] || $album['user_id'] == $this->cms_user->id || $this->cms_user->is_admin;
if ($is_allow && cmsUser::isAllowed($ctype['name'], 'add')) {
$this->cms_template->addToolButton(array('class' => 'images', 'title' => LANG_PHOTOS_UPLOAD, 'href' => href_to($this->name, 'upload', $album['id'])));
}
$album['filter_panel'] = array('ordering' => modelPhotos::getOrderList(), 'types' => !empty($this->options['types']) ? array('' => LANG_PHOTOS_ALL) + $this->options['types'] : array(), 'orientation' => modelPhotos::getOrientationList(), 'width' => '', 'height' => '');
$album['filter_values'] = array('ordering' => $this->cms_core->request->get('ordering', $this->options['ordering']), 'types' => $this->cms_core->request->get('types', ''), 'orientation' => $this->cms_core->request->get('orientation', ''), 'width' => $this->cms_core->request->get('width', 0) ?: '', 'height' => $this->cms_core->request->get('height', 0) ?: '');
$album['url_params'] = array_filter($album['filter_values']);
$album['filter_selected'] = $album['url_params'];
if ($album['filter_selected']['ordering'] == $this->options['ordering']) {
unset($album['filter_selected']['ordering']);
}
if (!in_array($album['filter_values']['ordering'], array_keys($album['filter_panel']['ordering']))) {
$album['filter_values']['ordering'] = 'date_pub';
}
if ($album['filter_values']['types'] && !in_array($album['filter_values']['types'], array_keys($album['filter_panel']['types']))) {
$album['filter_values']['types'] = '';
}
if ($album['filter_values']['orientation'] && !in_array($album['filter_values']['orientation'], array_keys($album['filter_panel']['orientation']))) {
$album['filter_values']['orientation'] = '';
}
$album['base_url'] = href_to($ctype['name'], $album['slug'] . '.html') . '?' . http_build_query($album['url_params']);
foreach ($album['filter_selected'] as $key => $value) {
if (isset($album['filter_panel'][$key][$value])) {
$title[] = $album['filter_panel'][$key][$value];
}
}
if (!empty($title)) {
$album['title'] .= ' — ' . mb_strtolower(implode(', ', $title));
$album['seo_desc'] .= ' ' . $album['title'];
}
return array($ctype, $album, $fields);
}
示例3: run
public function run($tab = 'all')
{
$user = cmsUser::getInstance();
$dataset_name = false;
$datasets = $this->getDatasets();
if ($tab && isset($datasets[$tab])) {
$dataset_name = $tab;
$dataset = $datasets[$tab];
if (isset($dataset['filter']) && is_callable($dataset['filter'])) {
$this->model = $dataset['filter']($this->model, $dataset);
}
} else {
if ($tab) {
cmsCore::error404();
}
}
// Сортировка
if ($dataset_name) {
$this->model->orderBy($datasets[$dataset_name]['order'][0], $datasets[$dataset_name]['order'][1]);
}
// Формируем базовые URL для страниц
$page_url = array('base' => href_to($this->name, $dataset_name ? 'index/' . $dataset_name : ''), 'first' => href_to($this->name, $dataset_name ? 'index/' . $dataset_name : ''));
// Получаем HTML списка записей
$profiles_list_html = $this->renderProfilesList($page_url, $dataset_name);
return cmsTemplate::getInstance()->render('index', array('datasets' => $datasets, 'dataset_name' => $dataset_name, 'dataset' => $dataset, 'user' => $user, 'profiles_list_html' => $profiles_list_html), $this->request);
}
示例4: run
public function run($ctype_name = false)
{
$user = cmsUser::getInstance();
$template = cmsTemplate::getInstance();
$counts = $this->model->getTasksCounts($user->id);
$is_moderator = $this->model->isUserModerator($user->id);
if (!$is_moderator) {
cmsCore::error404();
}
if (!$counts) {
return $template->render('empty');
}
$is_index = false;
$ctypes_list = array_keys($counts);
if (!$ctype_name) {
$ctype_name = $ctypes_list[0];
$is_index = true;
}
$content_controller = cmsCore::getController('content');
$ctypes = $content_controller->model->filterIn('name', $ctypes_list)->getContentTypesFiltered();
$ctypes = array_collection_to_list($ctypes, 'name', 'title');
$ctype = $content_controller->model->getContentTypeByName($ctype_name);
$content_controller->model->filterByModeratorTask($user->id, $ctype_name);
$page_url = $is_index ? href_to($this->name) : href_to($this->name, $ctype_name);
$content_controller->model->disableApprovedFilter();
$list_html = $content_controller->renderItemsList($ctype, $page_url, true);
return $template->render('index', array('is_index' => $is_index, 'counts' => $counts, 'ctype' => $ctype, 'ctypes' => $ctypes, 'ctype_name' => $ctype_name, 'list_html' => $list_html, 'user' => $user));
}
示例5: grid_tags
function grid_tags($controller)
{
$options = array('order_by' => 'tag', 'order_to' => 'asc');
$columns = array('tag' => array('title' => LANG_TAGS_TAG, 'href' => href_to($controller->root_url, 'edit', array('{id}')), 'filter' => 'like'), 'frequency' => array('title' => LANG_TAGS_TAG_FREQUENCY));
$actions = array(array('title' => LANG_VIEW, 'class' => 'view', 'href' => href_to('tags', 'search') . "?q={tag}"), array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->root_url, 'edit', array('{id}'))), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->root_url, 'delete', array('{id}')), 'confirm' => LANG_TAGS_TAG_DELETE_CONFIRM));
return array('options' => $options, 'columns' => $columns, 'actions' => $actions);
}
示例6: grid_menu_items
function grid_menu_items($controller)
{
$options = array('is_auto_init' => false, 'is_sortable' => false, 'is_filter' => false, 'is_pagination' => false, 'is_draggable' => true, 'order_by' => 'ordering', 'order_to' => 'asc', 'show_id' => false);
$columns = array('id' => array('title' => 'id', 'width' => 30), 'title' => array('title' => LANG_CP_MENU_ITEM_TITLE, 'width' => 200, 'href' => href_to($controller->name, 'menu', array('item_edit', '{id}'))), 'url' => array('title' => LANG_CP_MENU_ITEM_URL));
$actions = array(array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->name, 'menu', array('item_edit', '{id}'))), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->name, 'menu', array('item_delete', '{id}')), 'confirm' => LANG_CP_MENU_ITEM_DELETE_CONFIRM));
return array('options' => $options, 'columns' => $columns, 'actions' => $actions);
}
示例7: run
public function run()
{
$user = cmsUser::getInstance();
$id = $this->request->get('id', 0);
if (!$id) {
cmsCore::error404();
}
$folder = $this->model->getContentFolder($id);
if (!$folder) {
cmsCore::error404();
}
if ($folder['user_id'] != $user->id && !$user->is_admin) {
cmsCore::error404();
}
$ctype = $this->model->getContentType($folder['ctype_id']);
$form = $this->getForm('folder');
// Форма отправлена?
$is_submitted = $this->request->has('submit');
if ($is_submitted) {
// Парсим форму и получаем поля записи
$updated_folder = $form->parse($this->request, $is_submitted);
// Проверям правильность заполнения
$errors = $form->validate($this, $updated_folder);
if (!$errors) {
// Обновляем папку и редиректим на ее просмотр
$this->model->updateContentFolder($id, $updated_folder);
$this->redirect(href_to('users', $folder['user_id'], array('content', $ctype['name'], $folder['id'])));
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return cmsTemplate::getInstance()->render('folder_form', array('ctype' => $ctype, 'folder' => $folder, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例8: grid_log
function grid_log($controller)
{
$options = array('order_by' => 'id', 'order_to' => 'asc');
$columns = array('id' => array('title' => 'id', 'width' => 20), 'orfo' => array('title' => 'Текст ошибки', 'width' => 300, 'href' => '{url}'), 'comment' => array('title' => 'Комментарий', 'width' => 300), 'date' => array('title' => 'Дата', 'width' => 120), 'author' => array('title' => 'Автор', 'width' => 100));
$actions = array(array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->root_url, 'delete', '{id}'), 'confirm' => LANG_COMPLAINTS_CP_FORM_DELETE_CONFIRM));
return array('options' => $options, 'columns' => $columns, 'actions' => $actions);
}
示例9: run
public function run($data)
{
$ctype_name = $data['ctype_name'];
$item = $data['item'];
$this->addEntry('content', "add.{$ctype_name}", array('user_id' => $item['user_id'], 'subject_title' => $item['title'], 'subject_id' => $item['id'], 'subject_url' => href_to($ctype_name, $item['slug'] . '.html'), 'is_private' => isset($item['is_private']) ? $item['is_private'] : 0, 'group_id' => isset($item['parent_id']) ? $item['parent_id'] : null, 'is_parent_hidden' => $item['is_parent_hidden'], 'is_pub' => $item['is_pub']));
return $data;
}
示例10: grid_feeds
function grid_feeds($controller)
{
$options = array('order_by' => 'title', 'order_to' => 'asc');
$columns = array('title' => array('title' => LANG_RSS_FEED_TITLE, 'href' => href_to($controller->root_url, 'edit', array('{id}')), 'filter' => 'like'), 'is_enabled' => array('title' => LANG_IS_ENABLED, 'flag' => true, 'width' => 60), 'is_cache' => array('title' => LANG_RSS_FEED_IS_CACHE, 'flag' => true, 'width' => 60));
$actions = array(array('title' => LANG_VIEW, 'class' => 'rss', 'href' => href_to('rss', 'feed', '{ctype_name}')), array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->root_url, 'edit', array('{id}'))));
return array('options' => $options, 'columns' => $columns, 'actions' => $actions);
}
示例11: run
public function run()
{
$camera = urldecode($this->request->get('name', ''));
if (!$camera) {
cmsCore::error404();
}
if (cmsUser::isAllowed('albums', 'view_all')) {
$this->model->disablePrivacyFilter();
}
$this->model->filterEqual('camera', $camera);
$page = $this->request->get('photo_page', 1);
$perpage = empty($this->options['limit']) ? 16 : $this->options['limit'];
$this->model->limitPagePlus($page, $perpage);
$this->model->orderBy($this->options['ordering'], 'desc');
$photos = $this->getPhotosList();
if (!$photos) {
cmsCore::error404();
}
if ($photos && count($photos) > $perpage) {
$has_next = true;
array_pop($photos);
} else {
$has_next = false;
}
$ctype = cmsCore::getModel('content')->getContentTypeByName('albums');
$this->cms_template->render('camera', array('page_title' => sprintf(LANG_PHOTOS_CAMERA_TITLE, $camera), 'ctype' => $ctype, 'page' => $page, 'row_height' => $this->getRowHeight(), 'user' => $this->cms_user, 'item' => array('id' => 0, 'user_id' => 0, 'url_params' => array('camera' => $camera), 'base_url' => href_to('photos', 'camera-' . urlencode($camera))), 'item_type' => 'camera', 'photos' => $photos, 'is_owner' => cmsUser::isAllowed('albums', 'delete', 'all'), 'has_next' => $has_next, 'hooks_html' => cmsEventsManager::hookAll('photo_camera_html', $camera), 'preset_small' => $this->options['preset_small']));
}
示例12: run
public function run($id)
{
if (!$id) {
cmsCore::error404();
}
$users_model = cmsCore::getModel('users');
$group = $users_model->getGroup($id);
if (!$group) {
cmsCore::error404();
}
$form = $this->getForm('users_group', array('edit'));
$is_submitted = $this->request->has('submit');
if ($is_submitted) {
$group = $form->parse($this->request, $is_submitted);
$errors = $form->validate($this, $group);
if (!$errors) {
$users_model->updateGroup($id, $group);
$this->redirectToAction('users');
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
$template = cmsTemplate::getInstance();
$template->setMenuItems('users_group', array(array('title' => LANG_CONFIG, 'url' => href_to($this->name, 'users', array('group_edit', $id))), array('title' => LANG_PERMISSIONS, 'url' => href_to($this->name, 'users', array('group_perms', $id)))));
return $template->render('users_group', array('do' => 'edit', 'group' => $group, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例13: run
public function run($ctype_name = false)
{
$query = $this->request->get('q', false);
$type = $this->request->get('type', 'words');
$date = $this->request->get('date', 'all');
$page = $this->request->get('page', 1);
if (!in_array($type, array('words', 'exact'))) {
cmsCore::error404();
}
if (!in_array($date, array('all', 'w', 'm', 'y'))) {
cmsCore::error404();
}
if (!is_numeric($page)) {
cmsCore::error404();
}
if ($this->request->has('q')) {
if (!$query) {
$this->redirectToAction('');
}
$results = $this->search($query, $type, $date, $ctype_name, $page);
if ($results && !$ctype_name) {
$ctype_name = $results[0]['name'];
$page_url = href_to($this->name);
} else {
$page_url = href_to($this->name, 'index', $ctype_name);
}
}
return cmsTemplate::getInstance()->render('index', array('query' => $query, 'type' => $type, 'date' => $date, 'ctype_name' => $ctype_name, 'page' => $page, 'perpage' => $this->options['perpage'], 'results' => isset($results) ? $results : false, 'page_url' => isset($page_url) ? $page_url : false));
}
示例14: grid_comments_list
function grid_comments_list($controller)
{
$options = array('is_sortable' => true, 'is_filter' => true, 'is_pagination' => true, 'is_draggable' => false, 'order_by' => 'date_pub', 'order_to' => 'desc', 'show_id' => true);
$columns = array('id' => array('title' => 'id', 'width' => 30), 'date_pub' => array('title' => LANG_DATE, 'width' => 110, 'handler' => function ($value, $item) {
return html_date($value, true);
}, 'filter' => 'date'), 'target_id' => array('title' => LANG_COMMENTS_TEXT, 'handler' => function ($value, $row) use($controller) {
return '<a title="' . LANG_COMMENTS_EDIT_TEXT . '" class="ajax-modal comment_text_edit" href="' . href_to($controller->root_url, 'text_edit', array($row['id'])) . '">' . string_short($row['content_html'], 350) . '</a>';
}), 'user_id' => array('title' => LANG_AUTHOR, 'width' => 180, 'handler' => function ($value, $row) {
if ($row['user_id']) {
$v = '<a target="_blank" href="' . href_to('users', $row['user_id']) . '">' . $row['user_nickname'] . '</a>';
} else {
$v = '<span class="guest_name">' . $row['author_name'] . '</span>';
if (!empty($row['author_email'])) {
$v .= '<span>, ' . $row['author_email'] . '</span>';
}
}
return $v;
}), 'author_url' => array('title' => LANG_COMMENTS_IP, 'width' => 120, 'filter' => 'like', 'handler' => function ($value) {
if ($value) {
return '<a href="#" class="ajaxlink filter_ip tooltip" title="' . LANG_CP_USER_FIND_BYIP . '">' . $value . '</a> <a class="view_target tooltip" href="https://apps.db.ripe.net/search/query.html?searchtext=' . $value . '#resultsAnchor" target="_blank" title="' . LANG_CP_USER_RIPE_SEARCH . '"></a>';
}
return '';
}), 'rating' => array('title' => LANG_RATING, 'width' => 50, 'handler' => function ($value, $row) {
return '<span class="' . html_signed_class($value) . '">' . html_signed_num($value) . '</span>';
}, 'filter' => 'exact'), 'is_deleted' => array('title' => LANG_COMMENTS_IS_DELETED, 'flag' => 'flag_lock', 'flag_toggle' => href_to($controller->root_url, 'toggle_item', array('{id}', 'comments', 'is_deleted')), 'width' => 50, 'filter' => 'exact'), 'is_approved' => array('title' => LANG_MODERATION, 'flag' => true, 'width' => 50, 'filter' => 'exact', 'handler' => function ($value, $item) {
if (!$item['is_approved']) {
return '<div class="flag_trigger flag_off"><span><a class="approve_comment" title="' . LANG_COMMENTS_APPROVE . '" href="#" data-approve-url="' . href_to('comments', 'approve') . '?id=' . $item['id'] . '"></a></span></div>';
}
return '<div class="flag_trigger flag_on"></div>';
}), 'is_private' => array('title' => LANG_COMMENTS_IS_PRIVATE, 'flag' => true, 'width' => 50, 'filter' => 'exact'));
$actions = array(array('title' => LANG_COMMENTS_VIEW, 'class' => 'view tooltip', 'href' => href_to('{target_url}', '#comment_{id}')), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->root_url, 'comments_delete', array('{id}')), 'confirm' => LANG_COMMENTS_DELETE_CONFIRM));
return array('options' => $options, 'columns' => $columns, 'actions' => $actions);
}
示例15: grid_regions
function grid_regions($controller)
{
$options = array('is_sortable' => true, 'is_filter' => true, 'is_pagination' => true, 'is_draggable' => false, 'order_by' => 'name', 'order_to' => 'asc', 'show_id' => true);
$columns = array('id' => array('title' => 'ID', 'width' => 20, 'filter' => 'exact'), 'name' => array('title' => LANG_TITLE, 'href' => href_to($controller->root_url, 'cities', array('{id}', '{country_id}')), 'filter' => 'like', 'editable' => array('table' => 'geo_regions')));
$actions = array(array('title' => LANG_EDIT, 'class' => 'edit', 'href' => href_to($controller->root_url, 'region', array('{country_id}', '{id}'))), array('title' => LANG_DELETE, 'class' => 'delete', 'href' => href_to($controller->root_url, 'delete', array('region', '{id}')), 'confirm' => LANG_GEO_DELETE_REGION));
return array('options' => $options, 'columns' => $columns, 'actions' => $actions);
}