本文整理汇总了PHP中core::lib方法的典型用法代码示例。如果您正苦于以下问题:PHP core::lib方法的具体用法?PHP core::lib怎么用?PHP core::lib使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core
的用法示例。
在下文中一共展示了core::lib方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_api_editor_menu
/**
* Editor nav menu
*/
function action_api_editor_menu()
{
/** @var tf_editor $ed */
$ed = core::lib('editor');
$menu = array();
// dies on get_editor_actions
$menu['core'] = core::get_instance()->get_editor_actions();
foreach (core::modules() as $module) {
$menu[$module->get_name()] = $module->get_editor_actions();
}
$menuNormalized = array();
foreach ($menu as $key => $actions) {
$submenuNormalized = array();
if (!empty($actions)) {
foreach ($actions as $subKey => $subMenu) {
if (!empty($subMenu['url'])) {
$subMenu['url'] = $ed->make_url($subMenu['url'], 1);
}
$submenuNormalized[] = !$subMenu ? array() : array_merge(array('id' => $subKey), $subMenu);
}
$menuNormalized[] = array('id' => $key, 'title' => i18n::T(array($key, '_name')), 'actions' => $submenuNormalized);
}
}
$this->renderer->set_ajax_answer($menuNormalized)->ajax_flush();
}
示例2: activate
/**
* Activate filter
*/
function activate()
{
core::dprint('Activate RSS');
// tpl_loader::set_template('');
core::lib('renderer')->set_page_template('root.embed');
tf_request::set_ident('embed', 'yes');
}
示例3: activate
/**
* Activate filter
*/
function activate()
{
core::dprint('Activate RSS');
tpl_loader::set_template('rss');
core::lib('renderer')->set_content_type('text/xml');
// 'application/rss+xml'
}
示例4: notify_user
function notify_user($email, $text)
{
if (!$this->get_container()->get_notify_user()) {
return;
}
core::lib('mailer')->email(array('from' => 'info@' . ($domain = core::module('sat')->get_current_site()->get_domain()), 'to' => $email, 'subject' => 'Пользователь заполнил анкету на сайте ' . $domain, 'msg' => $text, 'is_html' => true));
}
示例5: __get
/**
* Get lib (IOC)
* $module->renderer etc.
* @param $key
*/
function __get($key)
{
if (isset($this->dependencies[$key])) {
return $this->resolve_dependency($key);
}
// fallback to libs
return core::lib($key);
}
示例6: render_before
function render_before()
{
if (isset($_POST['filter'])) {
$key = core::lib('db')->escape($_POST['filter']['title']);
$this->set_where("LCASE(p1.nick) like '%{$key}%' OR LCASE(p1.login) like '%{$key}%'");
$this->renderer->set_data('_filter', array('title' => $key));
}
}
示例7: create_after
/**
* Notify user about
* @param $data
*/
function create_after($data)
{
$notify_tpl = $this->container->config->get('notify_template');
if ($notify_tpl) {
/** @var tf_mailer */
$mailer = core::lib('mailer');
$mailer->email_template($notify_tpl, $data['email'] ? $data['email'] : 'test@domain.ru', $data, true);
}
}
示例8: run
/**
* Remember!
* Assign current item in controller for comment linking!
*/
function run()
{
if (loader::in_ajax() !== true) {
throw new controller_exception('Cant touch this ' . __METHOD__);
return false;
}
core::dprint('run comment modify');
$pctl = core::modules()->get_router()->get_controller();
$user = core::lib('auth')->get_user();
/**
* Parent item, must be assigned thru @see module_controller::set_current_item()
* @var abs_collection_item
*/
$post = $pctl->get_current_item();
// var_dump(get_class($post), core::get_modules()->get_router()->get_name());
if (!$post) {
throw new controller_exception('No item assigned');
}
if (!$post->has_behavior('sat.commentable')) {
throw new controller_exception('Not commentable');
}
$comments = $post->behavior('sat.commentable')->get_attach_model();
//get_comments();
$request = core::lib('request');
$renderer = core::lib('renderer');
$user_id = core::lib('auth')->get_user()->id;
$pid = (int) $request->post('pid', 0);
$limit = core::selfie()->cfg('comment_interval', 60);
$auth = core::lib('auth');
/** @var aregistry $sd */
$sd = $auth->get_current_session()->get_storage();
$time = $sd->comments_last_time;
//$time = $comments->get_last_time($pid, $user_id);
// disallow by interval
if ($time && $time + $limit > time()) {
$pctl->set_null_template();
$renderer->set_ajax_answer(array('status' => false, 'id' => 0, 'message' => vsprintf(i18n::T('sat\\comment_interval_restriction'), $time + $limit - time())))->ajax_flush();
// else core::get_instance()->set_message(array('content', 'comment_interval_restriction'));
return;
// exit
}
$sd->comments_last_time = time();
$username = functions::request_var('username', '');
$text = functions::request_var('text', '');
$api = functions::request_var('api');
$id = $comments->modify(array('user_ip' => core::lib('auth')->get_user_ip(true), 'user_id' => $user_id, 'ctype_id' => $post->get_ctype_id(), 'username' => $username, 'pid' => $pid, 'text' => $text, 'type' => functions::request_var('type', 0), 'tpid' => functions::request_var('tpid', 0), 'api' => $api));
$comment = $comments->get_item_by_id($id);
if (!$comment) {
throw new controller_exception('[ajax] Comment create failed');
}
$comment->load_secondary();
$renderer->set_data('comment', $comment->render())->set_ajax_answer(array('status' => true, 'id' => $id))->set_ajax_message(i18n::T('sat\\comment_posted'));
//->set_main_template('content/comment/view');
$renderer->ajax_flush('shared/comments/comment');
// alright, update counter
return $id;
}
示例9: send_feedback
private function send_feedback()
{
$template = 'feedback';
$vars = $this->request->post();
$to = $vars['email'];
/** @var tf_mailer */
$mailer = core::lib('mailer');
$result = $mailer->email_template($template, $to, $vars, true);
$this->set_message('Отправка сообщения', $result)->set_message_data($vars);
}
示例10: notify_user
function notify_user($data, $result)
{
/*
$mtpl = core::get_instance()->get_mail_tpl_handle()->get_mail_template('edu_request');
*/
$data['test_result'] = $result ? $result->text : '';
/** @var tf_mailer */
$mailer = core::lib('mailer');
$mailer->email_template('edu_request', $data['email'] ? $data['email'] : 'test@domain.ru', $data, true);
}
示例11: parse_data
/**
* Parse smarty data
*/
function parse_data()
{
if ($this->plain) {
return;
}
$pre = 'string: ' . $this->text;
/** @var smarty */
$tpl = core::lib('tpl_parser');
//tpl_loader::get_parser();
$this->content = !empty($this->text) ? $tpl->fetch($pre) : '';
}
示例12: set_current
/**
* Doamin matched in initial_route
*/
function set_current()
{
$this->_current = true;
if (0 != $this->template) {
$core = core::get_instance();
$templates = $core->get_cfg_var('templates');
if (isset($templates[$this->template])) {
core::dprint(array('SITE_LAYOUT : %s', $templates[$this->template]), core::E_DEBUG1);
core::lib('renderer')->set_layout($templates[$this->template]);
}
}
}
示例13: elFinderIsAuthed
/**
* Transler bridge
*/
function elFinderIsAuthed()
{
if (!defined('ELFIINDER_AUTHED')) {
require_once dirname(__FILE__) . '/../../../modules/core/loader.php';
loader::bootstrap();
/** @var users_item */
$user = core::lib('auth')->get_user();
$authed = $user->level >= 50;
define('ELFIINDER_AUTHED', $authed);
}
return ELFIINDER_AUTHED;
}
示例14: run
function run()
{
$q = trim(urldecode($this->request->get('q')));
$q = core::lib('db')->escape($q);
if (strings::strlen($q) < 2) {
$this->renderer->set_ajax_result(false)->set_ajax_message('Короткое сообщение')->ajax_flush(false);
return;
}
$pmod = $this->_controller->get_context();
$ph = $pmod->get_search_handle()->set_working_fields('keyword')->set_limit(10);
if (!empty($q)) {
$ph->set_where("keyword like '%{$q}%' AND c_count > 0");
}
$sugg = $ph->load()->render();
core::get_instance()->ajax_answer($sugg);
}
示例15: run
function run()
{
$name = functions::request_var('template', '');
$name = $name ? $name : 'default';
if (empty($name) || !preg_match('@^[a-z\\d]+$@i', $name)) {
throw new controller_exception('Bad id');
}
$domain = preg_replace('@^www\\.@', '', $_SERVER['HTTP_HOST']);
$vars = $this->request->post();
$to = $vars['email'];
/** @var tf_mailer */
$mailer = core::lib('mailer');
$result = $mailer->email_template($name, $to, $vars, true);
$this->renderer->set_ajax_result($result)->set_ajax_message('ok')->ajax_flush();
return;
}