本文整理汇总了PHP中View::get方法的典型用法代码示例。如果您正苦于以下问题:PHP View::get方法的具体用法?PHP View::get怎么用?PHP View::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类View
的用法示例。
在下文中一共展示了View::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: after
/**
* This method gets called after the action is called.
*
* @param mixed $response Value returned from the action method.
*
* @return Response $response
*/
public function after($response)
{
// Return if passed a response.
if ($response instanceof Response) {
return parent::after($response);
}
if ($this->autorender) {
try {
$this->view->set_filename(Str::lower(str_replace('_', '/', Inflector::denamespace(str_replace('controller_', '', Str::lower($this->request->controller)))) . DS . str_replace('_', '/', $this->request->action)));
} catch (FuelException $e) {
}
}
// Inject view into the layout if the main request.
if ($this->layout instanceof View) {
if ($this->autorender) {
try {
// Throws exception if there is no view template found.
$this->layout->content = $this->view->render();
} catch (FuelException $e) {
}
}
$this->layout->content_data = $this->view->get();
$this->response->body($this->layout);
} else {
$this->response->body($this->view);
}
return parent::after($this->response);
}
示例2: allowed_in_view
public static function allowed_in_view(View $view)
{
if ($view->get('title') == gcr::defaultDashboardTemplateTitle) {
return true;
} else {
return $view->get('owner') != null;
}
}
示例3: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER;
require_once get_config('docroot') . 'lib/view.php';
$configdata = $instance->get('configdata');
// this will make sure to unserialize it for us
$configdata['viewid'] = $instance->get('view');
$view = new View($configdata['viewid']);
$group = $view->get('group');
$result = '';
$artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null;
if ($artefactid) {
$artefact = $instance->get_artefact_instance($configdata['artefactid']);
if (!file_exists($artefact->get_path())) {
return '';
}
$urlbase = get_config('wwwroot');
// edit view doesn't use subdomains, neither do groups
if (get_config('cleanurls') && get_config('cleanurlusersubdomains') && !$editing && empty($group)) {
$viewauthor = new User();
$viewauthor->find_by_id($view->get('owner'));
$viewauthorurlid = $viewauthor->get('urlid');
if ($urlallowed = !is_null($viewauthorurlid) && strlen($viewauthorurlid)) {
$urlbase = profile_url($viewauthor) . '/';
}
}
// Send the current language to the pdf viewer
$language = current_language();
$language = str_replace('_', '-', substr($language, 0, substr_count($language, '_') > 0 ? 5 : 2));
if ($language != 'en' && !file_exists(get_config('docroot') . 'artefact/file/blocktype/pdf/js/pdfjs/web/locale/' . $language . '/viewer.properties')) {
// In case the language file exists as a string with both lower and upper case, eg fr_FR we test for this
$language = substr($language, 0, 2) . '-' . strtoupper(substr($language, 0, 2));
if (!file_exists(get_config('docroot') . 'artefact/file/blocktype/pdf/js/pdfjs/web/locale/' . $language . '/viewer.properties')) {
// In case we fail to find a language of 5 chars, eg pt_BR (Portugese, Brazil) we try the 'parent' pt (Portugese)
$language = substr($language, 0, 2);
if ($language != 'en' && !file_exists(get_config('docroot') . 'artefact/file/blocktype/pdf/js/pdfjs/web/locale/' . $language . '/viewer.properties')) {
$language = 'en-GB';
}
}
}
$result = '<iframe src="' . $urlbase . 'artefact/file/blocktype/pdf/viewer.php?editing=' . $editing . '&ingroup=' . !empty($group) . '&file=' . $artefactid . '&lang=' . $language . '&view=' . $instance->get('view') . '" width="100%" height="500" frameborder="0"></iframe>';
require_once get_config('docroot') . 'artefact/comment/lib.php';
require_once get_config('docroot') . 'lib/view.php';
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
}
$smarty = smarty_core();
if ($artefactid) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:pdf:pdfrender.tpl');
}
示例4: handle_exception
/**
* Maneja las excepciones no capturadas
*
* @param Exception $e
* */
public static function handle_exception($e)
{
if (isset($e->_view) && ($e->_view == 'no_controller' || $e->_view == 'no_action')) {
header('HTTP/1.1 404 Not Found');
} else {
header('HTTP/1.1 500 Internal Server Error');
}
extract(Router::get(), EXTR_OVERWRITE);
$Controller = Util::camelcase($controller);
ob_start();
if (PRODUCTION) {
include APP_PATH . 'views/_shared/errors/404.phtml';
return;
} else {
$Template = 'views/templates/exception.phtml';
if (isset($e->_view)) {
include CORE_PATH . "views/errors/{$e->_view}.phtml";
} else {
include CORE_PATH . "views/errors/exception.phtml";
}
}
$content = ob_get_clean();
// termina los buffers abiertos
while (ob_get_level()) {
ob_end_clean();
}
// verifica si esta cargado el View
if (class_exists('View')) {
if (View::get('template') === NULL) {
echo $content;
exit;
}
}
include CORE_PATH . $Template;
}
示例5: edit_comment_submit
function edit_comment_submit(Pieform $form, $values)
{
global $viewid, $comment, $SESSION, $goto, $USER;
require_once 'embeddedimage.php';
db_begin();
$comment->set('rating', valid_rating($values['rating']));
require_once get_config('libroot') . 'view.php';
$view = new View($viewid);
$owner = $view->get('owner');
$group = $comment->get('group');
$newdescription = EmbeddedImage::prepare_embedded_images($values['message'], 'comment', $comment->get('id'), $group);
$comment->set('description', $newdescription);
$approvecomments = $view->get('approvecomments');
if (!empty($group) && ($approvecomments || !$approvecomments && $view->user_comments_allowed($USER) == 'private') && $values['ispublic'] && !$USER->can_edit_view($view)) {
$comment->set('requestpublic', 'author');
} else {
if (($approvecomments || !$approvecomments && $view->user_comments_allowed($USER) == 'private') && $values['ispublic'] && (!empty($owner) && $owner != $comment->get('author'))) {
$comment->set('requestpublic', 'author');
} else {
$comment->set('private', 1 - (int) $values['ispublic']);
$comment->set('requestpublic', null);
}
}
$comment->commit();
require_once 'activity.php';
$data = (object) array('commentid' => $comment->get('id'), 'viewid' => $viewid);
activity_occurred('feedback', $data, 'artefact', 'comment');
if ($comment->get('requestpublic') == 'author') {
if (!empty($owner)) {
edit_comment_notify($view, $comment->get('author'), $owner);
} else {
if (!empty($group)) {
$group_admins = group_get_admin_ids($group);
// TODO: need to notify the group admins bug #1197197
}
}
}
db_commit();
$SESSION->add_ok_msg(get_string('commentupdated', 'artefact.comment'));
redirect($goto);
}
示例6: testViewCommitting
/**
* test that the setters work and commit to the db
* and when we get the view back it matches
*/
public function testViewCommitting()
{
// now commit to db and test again
foreach ($this->fields as $field => $values) {
$this->view->set($field, $values[1]);
}
$this->view->commit();
$createdview = new View($this->view->get('id'));
foreach ($this->fields as $field => $values) {
$this->assertEquals($values[1], $createdview->get($field));
}
}
示例7: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $USER;
if ($editing) {
$smarty = smarty_core();
$smarty->assign('editing', get_string('ineditordescription1', 'blocktype.comment/comment'));
$html = $smarty->fetch('blocktype:comment:comment.tpl');
return $html;
}
// Feedback list pagination requires limit/offset params
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$showcomment = param_integer('showcomment', null);
// Create the "make feedback private form" now if it's been submitted
if (param_variable('make_public_submit', null)) {
pieform(ArtefactTypeComment::make_public_form(param_integer('comment')));
} else {
if (param_variable('delete_comment_submit_x', null)) {
pieform(ArtefactTypeComment::delete_comment_form(param_integer('comment')));
}
}
$view = new View($instance->get('view'));
$submittedgroup = (int) $view->get('submittedgroup');
if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_views($submittedgroup, $USER->get('id'))) {
$releaseform = true;
} else {
$releaseform = false;
}
// If the view has comments turned off, tutors can still leave
// comments if the view is submitted to their group.
if (!empty($releaseform) || $view->user_comments_allowed($USER)) {
$addfeedbackpopup = true;
}
safe_require('artefact', 'comment');
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->limit = $limit;
$commentoptions->offset = $offset;
$commentoptions->showcomment = $showcomment;
$commentoptions->view = $instance->get_view();
$feedback = ArtefactTypeComment::get_comments($commentoptions);
$smarty = smarty_core();
$smarty->assign('feedback', $feedback);
if (isset($addfeedbackpopup)) {
$smarty->assign('enablecomments', 1);
$smarty->assign('addfeedbackpopup', $addfeedbackpopup);
}
$html = $smarty->fetch('blocktype:comment:comment.tpl');
return $html;
}
示例8: index
public static function index($params)
{
$page = intval(Helpers::select("page", $params, 1));
$per_page = Config::get("posts.per_page");
$posts = DB::getAll("select * from posts " . "order by posted_at desc " . "limit :limit offset :offset", array("limit" => $per_page, "offset" => ($page - 1) * $per_page));
View::set("posts", $posts);
View::set("total", DB::getValue("select count(*) from posts"));
View::set("first", ($page - 1) * $per_page + 1);
View::set("last", min(View::get("first") + $per_page - 1, View::get("total")));
View::set("page", $page);
View::set("pages", ceil(View::get("total") / $per_page));
View::set("highlight", Session::getFlash("highlight"));
if ($page > 1 && count($posts) === 0) {
Helpers::notFound();
}
View::render("post/index");
}
示例9: deleteview_submit
function deleteview_submit(Pieform $form, $values)
{
global $SESSION, $USER, $viewid, $groupid, $institution, $goto;
$view = new View($viewid, null);
if (View::can_remove_viewtype($view->get('type')) || $USER->get('admin')) {
$view->delete();
$SESSION->add_ok_msg(get_string('viewdeleted', 'view'));
} else {
$SESSION->add_error_msg(get_string('cantdeleteview', 'view'));
}
if ($groupid) {
redirect('/view/groupviews.php?group=' . $groupid);
}
if ($institution) {
redirect('/view/institutionviews.php?institution=' . $institution);
}
redirect('/view/' . $goto);
}
示例10: testPageTag
public function testPageTag()
{
Template::render('page-lookup-test.html');
$pageTagTestLookUp = View::get('pageTagTestLookUp');
$pageTagTestPaginate = View::get('pageTagTestPaginate');
$this->assertTrue(is_array($pageTagTestLookUp));
$this->assertEquals(1, count($pageTagTestLookUp));
$this->assertTrue($pageTagTestPaginate instanceof \Disco\classes\Paginate);
$this->assertEquals(2, $pageTagTestPaginate->totalPages);
Template::render('page-model-test.html');
$pageTagTestModel = View::get('pageTagTestModel');
$pageTagTestPaginate = View::get('pageTagTestPaginate');
$this->assertTrue(is_array($pageTagTestModel));
$this->assertEquals(1, count($pageTagTestModel));
$this->assertEquals('Person Two', $pageTagTestModel[0]['name']);
$this->assertTrue($pageTagTestPaginate instanceof \Disco\classes\Paginate);
$this->assertEquals(5, $pageTagTestPaginate->totalPages);
}
示例11: __construct
public function __construct($path, $data, $root = "")
{
if ($root != "") {
View::$root = $root;
}
$cache = View::get($path);
if (!$cache) {
$path = View::$root . $path;
$fh = @fopen($path, "r");
if (!$fh) {
throw new ErrorException("Missing file '" . $path . "'.");
}
$this->tplFileContent = fread($fh, filesize($path));
fclose($fh);
View::add($path, $this->tplFileContent);
} else {
$this->tplFileContent = $cache;
}
$this->vars = $data;
}
示例12: send
public static function send($view, $array, $callback)
{
include "../core/Associates/PHPMailer/class.phpmailer.php";
//
$selfmail = new self();
$callback($selfmail);
//
$mail = new PHPMailer();
//
//
if ($selfmail->type == "text") {
$view2 = $view;
$mail->IsHTML(false);
} else {
if ($selfmail->type == "html") {
$view2 = View::get($view, $array);
$mail->IsHTML(true);
}
}
//
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = Config::get("mail.encryption");
$mail->Host = Config::get("mail.host");
$mail->Port = Config::get("mail.port");
$mail->Username = Config::get("mail.username");
$mail->Password = Config::get("mail.password");
if (is_null($selfmail->froms)) {
$selfmail->froms = Config::get("mail.from.adresse");
}
$mail->SetFrom($selfmail->froms);
$mail->Subject = $selfmail->subject;
$mail->Body = $view2;
//
foreach ($selfmail->too as $key => $value) {
$name = "";
$maile = "";
//
foreach ($value as $key2 => $value2) {
if ($key2 == "name") {
$name = $value2;
} else {
if ($key2 == "mail") {
$maile = $value2;
}
}
}
//
if (empty($name)) {
$mail->AddAddress($maile);
} else {
$mail->AddAddress($maile, $name);
}
}
//
// atachement
if (!is_null($selfmail->atachmnt) && count($selfmail->atachmnt) > 0) {
foreach ($selfmail->atachmnt as $key => $value) {
$name = "";
$filee = "";
//
foreach ($value as $key2 => $value2) {
if ($key2 == 1) {
$name = $value2;
} else {
if ($key2 == 0) {
$filee = $value2;
}
}
}
//
if (empty($name)) {
$mail->addAttachment($filee);
} else {
$mail->addAttachment($filee, $name);
}
}
}
//
// CC
if (!is_null($selfmail->cc)) {
foreach ($selfmail->cc as $key => $value) {
$mail->addCC($value);
}
}
//
// CCB
if (!is_null($selfmail->cci)) {
foreach ($selfmail->cci as $key => $value) {
$mail->addBCC($value);
}
}
if (!$mail->Send()) {
self::$error = $mail->ErrorInfo;
return false;
} else {
return true;
}
}
示例13: redirect
$views = $collection->views();
if (empty($views)) {
$SESSION->add_error_msg(get_string('emptycollectionnoeditaccess', 'collection'));
redirect('/collection/views.php?id=' . $collectionid);
}
// Pick any old view, they all have the same access records.
$viewid = $views['views'][0]->view;
} else {
$viewid = param_integer('id');
}
$view = new View($viewid);
if (empty($collection)) {
$collection = $view->get_collection();
}
define('TITLE', get_string('editaccess', 'view'));
$group = $view->get('group');
$institution = $view->get('institution');
View::set_nav($group, $institution, true);
if (!$USER->can_edit_view($view) || $view->get('owner') == "0") {
throw new AccessDeniedException();
}
if ($group && !group_within_edit_window($group)) {
throw new AccessDeniedException();
}
$form = array('name' => 'editaccess', 'renderer' => 'div', 'plugintype' => 'core', 'pluginname' => 'view', 'viewid' => $view->get('id'), 'userview' => (int) $view->get('owner'), 'elements' => array('id' => array('type' => 'hidden', 'value' => $view->get('id'))));
// Create checkboxes to allow the user to apply these access rules to
// any of their views/collections.
// For institution views, force edit access of one view at a time for now. Editing multiple
// institution views requires doing some tricky stuff with the 'copy for new users/groups'
// options, and there's not much room for the 'Share' tab in the admin area anyway
if ($view->get('type') != 'profile') {
示例14: can_view_view
/**
* Given a view id, and a user id (defaults to currently logged in user if not
* specified) will return wether this user is allowed to look at this view.
*
* @param mixed $view viewid or View to check
* @param integer $user_id User trying to look at the view (defaults to
* currently logged in user, or null if user isn't logged in)
*
* @returns boolean Wether the specified user can look at the specified view.
*/
function can_view_view($view, $user_id = null)
{
global $USER, $SESSION;
if (defined('BULKEXPORT')) {
return true;
}
$now = time();
$dbnow = db_format_timestamp($now);
if ($user_id === null) {
$user = $USER;
$user_id = $USER->get('id');
} else {
$user = new User();
if ($user_id) {
try {
$user->find_by_id($user_id);
} catch (AuthUnknownUserException $e) {
}
}
}
$publicviews = get_config('allowpublicviews');
$publicprofiles = get_config('allowpublicprofiles');
// If the user is logged out and the publicviews & publicprofiles sitewide configs are false,
// we can deny access without having to hit the database at all
if (!$user_id && !$publicviews && !$publicprofiles) {
return false;
}
require_once get_config('libroot') . 'view.php';
if ($view instanceof View) {
$view_id = $view->get('id');
} else {
$view = new View($view_id = $view);
}
// If the page belongs to an individual, check for individual-specific overrides
if ($view->get('owner')) {
$ownerobj = $view->get_owner_object();
// Suspended user
if ($ownerobj->suspendedctime) {
return false;
}
// Probationary user (no public pages or profiles)
// (setting these here instead of doing a return-false, so that we can do checks for
// logged-in users later)
require_once get_config('libroot') . 'antispam.php';
$onprobation = is_probationary_user($ownerobj->id);
$publicviews = $publicviews && !$onprobation;
$publicprofiles = $publicprofiles && !$onprobation;
// Member of an institution that prohibits public pages
// (group views and logged in users are not affected by
// the institution level config for public views)
$owner = new User();
$owner->find_by_id($ownerobj->id);
$publicviews = $publicviews && $owner->institution_allows_public_views();
}
// Now that we've examined the page owner, check again for whether it can be viewed by a logged-out user
if (!$user_id && !$publicviews && !$publicprofiles) {
return false;
}
if ($user_id && $user->can_edit_view($view)) {
return true;
}
// If the view's owner is suspended, deny access to the view
if ($view->get('owner')) {
if (!($owner = $view->get_owner_object()) || $owner->suspendedctime) {
return false;
}
}
if ($SESSION->get('mnetuser')) {
$mnettoken = get_cookie('mviewaccess:' . $view_id);
}
// If the page has been marked "objectionable" admins should be able to view
// it for review purposes.
if ($view->is_objectionable()) {
if ($owner = $view->get('owner')) {
if ($user->is_admin_for_user($owner)) {
return true;
}
} else {
if ($view->get('group') && $user->get('admin')) {
return true;
}
}
}
// Overriding start/stop dates are set by the owner to deny access
// to users who would otherwise be allowed to see the view. However,
// for some kinds of access (e.g. objectionable content, submitted
// views), we have to override the override and let the logged in
// user see it anyway. So we can't return false now, we have to wait
// till we find out what kind of view_access record is being used.
$overridestart = $view->get('startdate');
//.........这里部分代码省略.........
示例15: edit_annotation_feedback_submit
function edit_annotation_feedback_submit(Pieform $form, $values)
{
global $viewid, $annotationfeedback, $annotation, $SESSION, $goto, $USER;
db_begin();
$annotationfeedback->set('description', $values['message']);
require_once get_config('libroot') . 'view.php';
$view = new View($viewid);
$owner = $view->get('owner');
$group = $annotationfeedback->get('group');
$oldispublic = !$annotationfeedback->get('private');
$approvecomments = $view->get('approvecomments');
// We need to figure out what to set the 'requestpublic' field in the artefact_annotation_feedback table.
// Then, set who is requesting to make it public - if the public flag has changed.
if (!empty($group) && ($approvecomments || !$approvecomments && $view->user_comments_allowed($USER) == 'private') && $values['ispublic'] && !$USER->can_edit_view($view) && $values['ispublic'] != $oldispublic) {
// This annotation belongs to a group - but this shouldn't really happen - keeping in case
// we allow annotations in group views.
// 1. If approvecomments on this view is switched on and
// the author of the feedback wants to make it public and
// the author of the feeback can't edit the group view and
// the auther of the feedback has changed the public setting,
// the owner of the view needs to approve the feedback before it's made public.
// 2. If approvecomments on this view is switched off and
// the access (for the author of the feedback) of the view forces private comments and
// the author of the feeback can't edit the view and
// the auther of the feedback has changed the public setting,
// the owner of the view needs to approve the feedback before it's made public.
// The author of the feedback wants to make the feedback public.
$annotationfeedback->set('requestpublic', 'author');
} else {
if (($approvecomments || !$approvecomments && $view->user_comments_allowed($USER) == 'private') && $values['ispublic'] && !empty($owner) && $owner != $annotationfeedback->get('author') && $values['ispublic'] != $oldispublic) {
// 1. If approvecomments on this view is switched on and
// the author of the feedback would like to make this public and
// the author of the feeback is not the owner of the view and
// the auther of the feedback has changed the public setting,
// the owner of the view needs to approve the feedback before it's made public.
// 2. If approvecomments on this view is switched off and
// the access (for the author of the feedback) of the view forces private feedback and
// the author of the feeback is not the owner of the view and
// the auther of the feedback has changed the public setting,
// the owner of the view needs to approve the feedback before it's made public.
// The author of the feedback wants to make the feedback public.
$annotationfeedback->set('requestpublic', 'author');
} else {
// Otherwise, the owner of the feedback is editing the feedback.
// Set the privacy setting of the feedback - based on the 'ispublic' flag set by the user.
// And, clear the request to make the feedback public.
$annotationfeedback->set('private', 1 - (int) $values['ispublic']);
$annotationfeedback->set('requestpublic', null);
}
}
$annotationfeedback->commit();
require_once 'activity.php';
$data = (object) array('annotationfeedbackid' => $annotationfeedback->get('id'), 'annotationid' => $annotation->get('id'), 'viewid' => $viewid, 'artefactid' => '');
activity_occurred('annotationfeedback', $data, 'artefact', 'annotation');
if ($annotationfeedback->get('requestpublic') == 'author') {
if (!empty($owner)) {
edit_annotation_feedback_notify($view, $annotationfeedback->get('author'), $owner);
} else {
if (!empty($group)) {
$group_admins = group_get_admin_ids($group);
// TODO: need to notify the group admins bug #1197197
}
}
}
db_commit();
$SESSION->add_ok_msg(get_string('annotationfeedbackupdated', 'artefact.annotation'));
redirect($goto);
}