本文整理汇总了PHP中view::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP view::assign方法的具体用法?PHP view::assign怎么用?PHP view::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类view
的用法示例。
在下文中一共展示了view::assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
static function show($msg, $title = '操作失败', $cacheId = 'null', $cacheTime = -1)
{
$error = new view();
$error->template_dir = _FFPHP_ . 'extend';
$error->assign('title', $title);
$error->assign('msg', $msg);
$error->display('template/error');
exit;
}
示例2: edit
public function edit()
{
// Get URI vars
$subjectID = (int) uri::segment(6);
// Get subject
$subject = array();
if ($subjectID && !($subject = $this->reports_subjects_model->getSubject($subjectID, false))) {
view::setError(__('no_subject', 'reports_subjects'));
router::redirect('cp/content/reports/subjects');
}
// Assign vars
view::assign(array('subjectID' => $subjectID, 'subject' => $subject));
// Process form values
if (input::post('do_save_subject')) {
$this->_saveSubject($subjectID);
}
// Set title
view::setTitle($subjectID ? __('subject_edit', 'reports_subjects') : __('subject_new', 'reports_subjects'));
// Set trail
view::setTrail('cp/content/reports/subjects/edit/' . ($subjectID ? $subjectID : ''), $subjectID ? __('subject_edit', 'reports_subjects') . ' - ' . text_helper::entities($subject['name']) : __('subject_new', 'reports_subjects'));
// Set actions
if (count(config::item('languages', 'core', 'keywords')) > 1) {
view::setAction('translate', '');
}
// Load view
view::load('cp/content/reports/subjects/edit');
}
示例3: getPictures
public static function getPictures($params = array())
{
if (!session::permission('users_groups_browse', 'users') && !session::permission('users_types_browse', 'users')) {
return '';
}
loader::model('pictures/pictures');
$template = isset($params['template']) ? $params['template'] : 'pictures/helpers/pictures';
$user = isset($params['user']) && $params['user'] ? $params['user'] : array();
$userID = $user ? $user['user_id'] : (isset($params['user_id']) ? $params['user_id'] : 0);
$params['albums'] = true;
if ($userID) {
$params['join_columns'][] = '`p`.`user_id`=' . $userID;
}
if (!$userID || $userID != session::item('user_id')) {
if ($userID) {
$params['privacy'] = $userID;
} else {
$params['join_columns'][] = '`a`.`public`=1';
$params['join_columns'][] = '`u`.`verified`=1';
$params['join_columns'][] = '`u`.`active`=1';
$params['join_columns'][] = '`u`.`group_id` IN (' . implode(',', session::permission('users_groups_browse', 'users')) . ')';
$params['join_columns'][] = '`u`.`type_id` IN (' . implode(',', session::permission('users_types_browse', 'users')) . ')';
}
}
$params['limit'] = isset($params['limit']) ? $params['limit'] : 10;
$params['order'] = isset($params['order']) ? $params['order'] : '';
$pictures = codebreeder::instance()->pictures_model->getPictures('in_list', $params['join_columns'], array(), $params['order'], $params['limit'], $params);
view::assign(array('pictures' => $pictures, 'user' => $user, 'params' => $params), '', $template);
return view::load($template, array(), 1);
}
示例4: edit
public function edit()
{
// Get URI vars
$groupID = (int) uri::segment(6);
// Get group
$group = array();
if ($groupID && !($group = $this->banners_groups_model->getGroup($groupID))) {
view::setError(__('no_group', 'banners'));
router::redirect('cp/content/banners/groups');
}
// Assign vars
view::assign(array('groupID' => $groupID, 'group' => $group));
// Process form values
if (input::post('do_save_group')) {
$this->_saveGroup($groupID);
}
// Set title
view::setTitle($groupID ? __('group_edit', 'banners') : __('group_new', 'banners'));
// Set trail
view::setTrail('cp/content/banners/groups/edit/' . ($groupID ? $groupID : ''), $groupID ? __('group_edit', 'banners') . ' - ' . text_helper::entities($group['name']) : __('group_new', 'banners'));
// Assign actions
if ($groupID) {
view::setAction('cp/content/banners/browse/' . $groupID, __('banners', 'banners'), array('class' => 'icon-text icon-banners'));
}
// Load view
view::load('cp/content/banners/groups/edit');
}
示例5: edit
public function edit()
{
// Get URI vars
$templateID = (int) uri::segment(6);
// Get template
$template = array();
if ($templateID && !($template = $this->newsletters_templates_model->getTemplate($templateID, false))) {
view::setError(__('no_template', 'newsletters_templates'));
router::redirect('cp/content/newsletters/templates');
}
// Assign vars
view::assign(array('templateID' => $templateID, 'template' => $template));
// Process form values
if (input::post('do_save_template')) {
$this->_saveTemplate($templateID);
}
// Set title
view::setTitle($templateID ? __('template_edit', 'newsletters_templates') : __('template_new', 'newsletters_templates'));
// Set trail
view::setTrail('cp/content/newsletters/templates/edit/' . ($templateID ? $templateID : ''), $templateID ? __('template_edit', 'newsletters_templates') . ' - ' . text_helper::entities($template['name']) : __('template_new', 'newsletters_templates'));
// Load ckeditor
view::includeJavascript('externals/ckeditor/ckeditor.js');
// Load view
view::load('cp/content/newsletters/templates/edit');
}
示例6: searchData
public function searchData($resource, $fields, $columns, $values, $params = array())
{
// Parse filter values
if ($fields) {
list($_columns, $items, $_values) = $this->fields_model->parseSearch($resource, $fields, $params);
// Merge values
$columns = $columns && is_array($columns) ? array_merge($_columns, $columns) : $_columns;
$values = $values && is_array($values) ? array_merge($_values, $values) : $_values;
} else {
$items = $columns['items'];
$columns = $columns['columns'];
}
// Assign vars
view::assign(array('values' => $values));
// Do we have any values?
if ($values) {
// Count data
$total = $this->counters_model->countData($resource, 0, 0, $columns, $items, $params, 0);
if ($total) {
// Save search
$searchID = $this->search_model->saveSearch(array('columns' => $columns, 'items' => $items), $values, $total);
// Return search ID
return $searchID;
} else {
return 'no_results';
}
} else {
return 'no_terms';
}
}
示例7: payment
public function payment()
{
// Get URI vars
$planID = (int) uri::segment(4);
// Get plan
if (!$planID || !($plan = $this->plans_model->getPlan($planID)) || !$plan['active']) {
view::setError(__('no_plan', 'billing_plans'));
router::redirect('billing/plans');
}
// Get gateways
if (!($gateways = $this->gateways_model->getGateways())) {
view::setError(__('no_gateways_user', 'billing_gateways'));
router::redirect('billing/plans');
}
// Product
$plan['product_id'] = $planID;
$plan['type'] = 'plans';
// Assign vars
view::assign(array('product' => $plan, 'gateways' => $gateways, 'location' => 'billing/plans/payment/' . $planID));
// Set title
view::setTitle(__('payment', 'billing_transactions'));
// Set trail
view::setTrail('billing/plans', __('plans', 'billing_plans'));
// Load view
view::load('billing/payment');
}
示例8: md
/**
* md文件解析
*/
public function md()
{
$file = $this->get('file');
$p = $this->get('p');
// 目录
$directory = MD_FILE_ROOT_PATH . $p . '/';
// 如果不存在自动创建
filesystem::mkdir($directory);
// 遍历文件夹所有内容
$path = array();
$dir = filesystem::ls($directory);
usort($dir, 'compare');
foreach ($dir as $d) {
$path[] = trim($d);
}
// 解析mk文件
$file = $directory . $file;
if (is_file($file)) {
$md = new markdown($file);
$html = $md->parse();
view::assign('html', $html);
}
view::assign('path', $path);
view::assign('p', $p);
view::assign('file', str_replace($directory, '', $file));
}
示例9: payment
public function payment()
{
// Get URI vars
$packageID = (int) uri::segment(4);
// Get package
if (!$packageID || !($package = $this->credits_model->getPackage($packageID)) || !$package['active']) {
view::setError(__('no_package', 'billing_credits'));
router::redirect('billing/credits');
}
// Get gateways
if (!($gateways = $this->gateways_model->getGateways())) {
view::setError(__('no_gateways_user', 'billing_gateways'));
router::redirect('billing/credits');
}
// Product
$package['product_id'] = $packageID;
$package['name'] = __('credits_info', 'billing_credits', array('%s' => $package['credits']));
$package['type'] = 'credits';
// Assign vars
view::assign(array('product' => $package, 'gateways' => $gateways, 'location' => 'billing/credits/payment/' . $packageID));
// Set title
view::setTitle(__('payment', 'billing_transactions'));
// Set trail
view::setTrail('billing/credits', __('credits', 'billing_credits'));
// Load view
view::load('billing/payment');
}
示例10: edit
public function edit()
{
// Get URI vars
$templateID = (int) uri::segment(6);
// Get template
$template = array();
if ($templateID && !($template = $this->messages_templates_model->getTemplate($templateID, false))) {
view::setError(__('no_template', 'messages_templates'));
router::redirect('cp/plugins/messages/templates');
}
// Assign vars
view::assign(array('templateID' => $templateID, 'template' => $template));
// Process form values
if (input::post('do_save_template')) {
$this->_saveTemplate($templateID);
}
// Set title
view::setTitle($templateID ? __('template_edit', 'messages_templates') : __('template_new', 'messages_templates'));
// Set trail
view::setTrail('cp/plugins/messages/templates/edit/' . ($templateID ? $templateID : ''), $templateID ? __('template_edit', 'messages_templates') . ' - ' . text_helper::entities($template['name']) : __('template_new', 'messages_templates'));
// Set actions
if (count(config::item('languages', 'core', 'keywords')) > 1) {
view::setAction('translate', '');
}
// Load view
view::load('cp/plugins/messages/templates/edit');
}
示例11: settings
public function settings()
{
// Get URI vars
$keyword = uri::segment(5);
// Get service
if (!$keyword || !($service = $this->users_authentication_model->getService($keyword))) {
view::setError(__('no_service', 'users_authentication'));
router::redirect('cp/users/authentication');
}
// Get manifest
$manifest = $this->users_authentication_model->getManifest($keyword);
// Is demo mode enabled?
if (input::demo(0)) {
foreach ($service['settings'] as $k => $v) {
if ($v) {
$service['settings'][$k] = 'hidden in this demo';
}
}
}
// Assign vars
view::assign(array('manifest' => $manifest, 'service' => $service));
// Process form values
if (input::post('do_save_settings')) {
$this->_saveSettings($keyword, $manifest, $service);
}
// Set title
view::setTitle(__('settings', 'system'));
// Set trail
view::setTrail('cp/users/authentication/settings/' . $keyword, __('settings', 'system') . ' - ' . text_helper::entities($service['name']));
// Load view
view::load('cp/users/authentication/settings');
}
示例12: getTimeline
public static function getTimeline($user = array(), $privacy = 2, $template = 'timeline/helpers/timeline')
{
loader::model('timeline/timeline');
// Get actions
$actions = codebreeder::instance()->timeline_model->getActions($user ? $user['user_id'] : 0, true, 0, config::item('actions_per_page', 'timeline'));
$ratings = array();
// Do we have actions and are we logged in?
if ($actions && users_helper::isLoggedin()) {
foreach ($actions as $action) {
if ($action['rating']) {
$ratings[$action['relative_resource']][] = $action['item_id'];
} else {
$ratings['timeline'][] = $action['action_id'];
}
}
// Load votes and like models
loader::model('comments/votes');
loader::model('comments/likes');
// Get likes and votes
$likes = codebreeder::instance()->likes_model->getMultiLikes($ratings);
$votes = codebreeder::instance()->votes_model->getMultiVotes($ratings);
$ratings = $likes + $votes;
}
// Can we post messages?
$post = session::permission('messages_post', 'timeline') && codebreeder::instance()->users_model->getPrivacyAccess($user['user_id'], $privacy, false) ? true : false;
view::assign(array('actions' => $actions, 'user' => $user, 'post' => $post, 'ratings' => $ratings), '', $template);
// Update comments pagination
config::set('comments_per_page', config::item('comments_per_page', 'timeline'), 'comments');
return view::load($template, array(), 1);
}
示例13: ip
/**
* ip地址查询
*/
public function ip()
{
$ip = $this->post('ip');
if (!$ip) {
return;
}
$result = $ip_address = array();
// tool.lu
$toollu = curl::post('http://tool.lu/netcard/ajax.html', array('ip' => $ip));
$toollu = json_decode($toollu, true);
$result['tool.lu'] = trim($toollu['text'][2]);
$result['纯真数据库'] = trim($toollu['text'][1]);
// 站长工具
$chinaz = curl::post('http://ip.chinaz.com', array('ip' => $ip));
$chinaz = trim(preg_replace('/<.+?>/', '', $chinaz));
$chinaz = explode('查询结果', $chinaz);
if ($chinaz) {
unset($chinaz[0]);
$size = intval(count($chinaz));
$chinaz[$size] = trim(substr($chinaz[$size], 0, strpos($chinaz[$size], 'document')));
$address = '';
foreach ($chinaz as $c) {
$c = explode('==>>', $c);
$ip_address_ = explode(':', trim($c[0]));
$ip_address[] = trim($ip_address_[1]);
$tmp_arr = explode("\r\n", trim($c[2]));
$address .= trim($tmp_arr[0]) . ' ';
}
$result['站长工具'] = trim($address);
}
// 淘宝
if ($ip_address) {
$taobao = curl::get('http://ip.taobao.com/service/getIpInfo.php', array('ip' => $ip_address[0]));
$taobao = json_decode($taobao, true);
if (intval($taobao['code']) === 0) {
$taobao = $taobao['data'];
$result['淘宝'] = $taobao['country'] . '|' . $taobao['area'] . '|' . $taobao['region'] . '|' . $taobao['city'] . '|' . $taobao['isp'];
}
}
// ipip.net
if ($ip_address) {
$ipip = curl::get('http://freeapi.ipip.net/' . $ip_address[0]);
$ipip = json_decode($ipip, true);
if (is_array($ipip)) {
$ipipstr = '';
foreach ($ipip as $str) {
$str = trim($str);
if (empty($str)) {
continue;
}
$ipipstr .= $str . ' ';
}
$result['ipip.net'] = $ipipstr;
}
}
view::assign('input', $ip);
view::assign('ip', $ip_address);
view::assign('result', $result);
}
示例14: assign
/**
* 模板变量赋值
* @access protected
* @param mixed $name 要显示的模板变量
* @param mixed $value 变量的值
* @return Action
*/
protected function assign($name, $value = '')
{
if ($this->view == null) {
$this->view = new \Think\View();
}
$this->view->assign($name, $value);
return $this;
}
示例15: indexAction
public function indexAction($args)
{
$v = new view("dashboard");
$v->assign("mesargs", $args);
if (!isset($_SESSION['role']) || $_SESSION['role'] != "admin") {
$this->redirect("index", "");
}
}