本文整理汇总了PHP中Lib::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Lib::load方法的具体用法?PHP Lib::load怎么用?PHP Lib::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lib
的用法示例。
在下文中一共展示了Lib::load方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLatestPosts
public function getLatestPosts()
{
Lib::load('pagination');
$query = "\r\nSELECT\r\n\t[blog_posts]p.[post_id] AS [post_id],\r\n\t[blog_posts]p.[post_slug] AS [post_slug],\r\n\t[blog_posts]p.[post_date] AS [post_date],\r\n\t[blog_posts]p.[post_header] AS [post_header],\r\n\t[blog_posts]p.[category_id] AS [category_id],\r\n\t[blog_categories]p.[category_slug] AS [category_slug],\r\n\t[blog_categories]p.[category_header] AS [category_header],\r\n\t[blog_posts_contents]p.[post_prologue] AS [post_prologue],\r\n\tcount([blog_comments]p.[comment_id]) AS [comments_count]\r\nFROM [blog_posts]p\r\nLEFT JOIN [blog_categories]p\r\n\tON [blog_posts]p.[category_id] == [blog_categories]p.[category_id]\r\nLEFT JOIN [blog_posts_contents]p\r\n\tON [blog_posts]p.[post_id] == [blog_posts_contents]p.[post_id]\r\nLEFT JOIN [blog_comments]p\r\n\tON [blog_posts]p.[post_id] == [blog_comments]p.[post_id]\r\nGROUP BY [blog_posts]p.[post_id]\r\nORDER BY [blog_posts]p.[post_date]";
$p = new Pagination(array('query' => $query, 'url' => './archive/%page/', 'perPage' => 1, 'urlFirst' => './'));
if (!$p->make()) {
throw new Exception('The latest posts could not be selected.');
} else {
$this->fetchPosts($p, false);
}
}
示例2: getInstance
public static function getInstance($name)
{
$state = Lib::load('router', $name);
if (!$state) {
return false;
}
if (!isset(self::$instances[$name])) {
$classname = ucfirst($name) . 'Router';
self::$instances[$name] = new $classname();
self::$instances[$name]->name = $name;
}
return self::$instances[$name];
}
示例3: getInstance
public static function getInstance($name, $options = array())
{
$state = Lib::load('api', $name);
if (!$state) {
return false;
}
if (!isset(self::$instances[$name])) {
$classname = ucfirst($name) . 'Api';
self::$instances[$name] = new $classname();
}
self::$instances[$name]->config($options);
return self::$instances[$name];
}
示例4: validateCommentAdd
public function validateCommentAdd()
{
Lib::load('openid');
$openid = new OpenID_Client();
$openid->returnTo = SITE_ROOT_PATH . 'action.php?c=blog§ion=comment&mode=add&openid';
$openid->trustRoot = SITE_ROOT_PATH;
$openid->addFields(array('nickname', 'email'));
if (!($fields = $openid->validate())) {
Debug::header(403, 'Invalid OpenID authentication.');
}
if (!isset($_COOKIE['escms_comment_handle'])) {
Debug::header(400, 'The comment cookie is not available.');
}
$this->addComment(unserialize(stripslashes($_COOKIE['escms_comment_handle'])), $fields);
}
示例5: getInstance
public static function getInstance($name)
{
if (!isset(self::$instances[$name])) {
Lib::load('helper', $name);
$classname = ucfirst($name) . 'Helper';
$class = new $classname();
if (method_exists($class, 'init')) {
$args = func_get_args();
array_shift($args);
call_user_func_array(array($class, 'init'), $args);
}
self::$instances[$name] = $class;
}
return self::$instances[$name];
}
示例6: getInstance
public static function getInstance($name = null)
{
if (empty($name)) {
if (!isset(self::$instances['self'])) {
self::$instances['self'] = new Controller();
}
return self::$instances['self'];
}
if (!isset(self::$instances[$name])) {
Lib::load('controller', $name);
$classname = ucfirst($name) . 'Controller';
self::$instances[$name] = new $classname();
}
return self::$instances[$name];
}
示例7: getInstance
public static function getInstance($name)
{
$key = trim(strtolower(preg_replace('/[' . preg_quote('-_', '/') . ']/', '', $name)));
$state = Lib::load('router', $key);
if (!$state) {
return false;
}
if (!isset(self::$instances[$key])) {
$classname = ucfirst($key) . 'Router';
self::$instances[$key] = new $classname();
self::$instances[$key]->key = $key;
self::$instances[$key]->base = $name;
}
return self::$instances[$key];
}
示例8: getInstance
public static function getInstance($name = null)
{
if (empty($name)) {
if (!isset(self::$instances['self'])) {
self::$instances['self'] = new Model();
}
return self::$instances['self'];
}
if (!isset(self::$instances[$name])) {
Lib::load('model', $name);
$classname = ucfirst($name) . 'Model';
self::$instances[$name] = new $classname();
self::$instances[$name]->tablename = $name;
}
return self::$instances[$name];
}
示例9: url
public static function url($key, $options = array(), $external = false)
{
$values = array();
$link = $external ? Config::getHTMLBase() : '';
if (Req::hasget('environment')) {
$options['environment'] = Req::get('environment');
}
if (Config::$sef) {
Lib::load('router');
$segments = array();
foreach (Router::getRouters() as $router) {
if (is_string($router->allowedBuild) && $key !== $router->allowedBuild) {
continue;
}
if (is_array($router->allowedBuild) && !in_array($key, $router->allowedBuild)) {
continue;
}
$router->encode($key, $options, $segments);
}
if (!empty($segments)) {
$link .= implode('/', $segments);
}
} else {
$link .= 'index.php';
}
if (!empty($options)) {
$values = array();
foreach ($options as $k => $v) {
$values[] = urlencode($k) . '=' . urlencode($v);
}
$queries = implode('&', $values);
if (!empty($queries)) {
$queries = '?' . $queries;
}
$link .= $queries;
}
return $link;
}
示例10: helper
public static function helper($name)
{
Lib::load('helper');
return call_user_func_array(array('Helper', 'getInstance'), func_get_args());
}
示例11: assign
public function assign()
{
$keys = array('id', 'assigneeid');
if (!Req::haspost($keys)) {
return $this->fail('Insufficient data.');
}
$identifier = Lib::cookie(Lib::hash(Config::$userkey));
$user = Lib::table('user');
$isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
if (!$isLoggedIn) {
return $this->fail('You are not authorized.');
}
$post = Req::post($keys);
$reportTable = Lib::table('report');
if (!$reportTable->load($post['id'])) {
return $this->fail('No such report.');
}
$reportTable->assignee_id = $post['assigneeid'];
$reportTable->store();
if (!empty($post['assigneeid']) && $post['assigneeid'] != $user->id) {
$projectTable = Lib::table('project');
$projectTable->load($reportTable->project_id);
$targetUser = Lib::table('user');
$targetUser->load($post['assigneeid']);
$targetUserSettings = $targetUser->getSettings($projectTable)->getData();
if ($targetUserSettings['assign']) {
$notificationData = ['to' => $targetUser->email, 'text' => $user->nick . ' assigned you a report ticket.', 'username' => 'Project Report Assignment', 'icon_emoji' => ':gift:', 'attachments' => [['fallback' => '<' . $reportTable->getLink() . '|Report ticket ID ' . $reportTable->id . '>.', 'color' => '#00bcd4', 'title' => $projectTable->name, 'title_link' => $reportTable->getLink(), 'text' => $reportTable->content]]];
Lib::load('helper/notification');
NotificationHelper::send($notificationData);
// $slackMessage = Lib::helper('slack')->newMessage();
// $slackMessage->to($post['assigneeid']);
// $slackMessage->message($user->nick . ' assigned you a report ticket.');
// $slackMessage->username = 'Project Report Assignment';
// $slackMessage->icon_emoji = ':gift:';
// $attachment = $slackMessage->newAttachment();
// $attachment->fallback = '<' . $reportTable->getLink() . '|Report ticket ID ' . $reportTable->id . '>.';
// $attachment->color = '#00bcd4';
// $attachment->title = $projectTable->name;
// $attachment->title_link = $reportTable->getLink();
// $attachment->text = $reportTable->content;
// $slackMessage->send();
}
}
return $this->success();
}
示例12: submit
public function submit()
{
$keys = array('id', 'content');
if (!Req::haspost($keys)) {
return $this->fail('Insufficient data.');
}
$identifier = Lib::cookie(Lib::hash(Config::$userkey));
$user = Lib::table('user');
$isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
if (!$isLoggedIn) {
return $this->fail('You are not authorized.');
}
$post = Req::post($keys);
$commentTable = Lib::table('comment');
$commentTable->link($user);
$commentTable->report_id = $post['id'];
$commentTable->content = $post['content'];
$commentTable->store();
$files = Req::file();
if (!empty($files)) {
foreach ($files as $key => $file) {
$commentTable->attach($key, $file);
}
}
$commentModel = Lib::model('comment');
$recipients = $commentModel->getUsersByReportId($post['id']);
$reportTable = Lib::table('report');
$reportTable->load($post['id']);
$projectTable = Lib::table('project');
$projectTable->load($reportTable->project_id);
if (!in_array($reportTable->user_id, $recipients)) {
$recipients[] = $reportTable->user_id;
}
if (!in_array($reportTable->assignee_id, $recipients)) {
$recipients[] = $reportTable->assignee_id;
}
$userSettingsModel = Lib::model('user_settings');
$userProjectsSettings = $userSettingsModel->getSettings(array('project_id' => $projectTable->id, 'user_id' => $recipients));
$userProjectsSettings = $userSettingsModel->assignByKey($userProjectsSettings, 'user_id');
$userAllSettings = $userSettingsModel->getSettings(array('project_id' => 0, 'user_id' => array_diff($recipients, array_keys($userProjectsSettings))));
$userAllSettings = $userSettingsModel->assignByKey($userAllSettings, 'user_id');
$defaultSettings = unserialize(USER_SETTINGS);
$ownerSettings = isset($userProjectsSettings[$reportTable->user_id]) ? $userProjectSettings : (isset($userAllSettings[$reportTable->user_id]) ? $userAllSettings : $defaultSettings);
if (!$ownerSettings['comment-owner']) {
$recipients = array_diff($recipients, array($reportTable->user_id));
}
foreach ($recipients as $userid) {
if ($userid == $user->id) {
continue;
}
$settings = isset($userProjectsSettings[$userid]) ? $userProjectSettings : (isset($userAllSettings[$userid]) ? $userAllSettings : $defaultSettings);
// If is owner, the fact that we reach here means the owner wants notification
// Or if not owner, then check for settings
if ($reportTable->user_id == $userid || $settings['comment-participant']) {
$notificationFields = ['Comment' => $post['content']];
if (!empty($files)) {
foreach ($files as $key => $file) {
$notificationFields[$file['name']] = Config::getHTMLBase() . Config::$attachmentFolder . '/' . $key . '-' . $file['name'];
}
}
$targetUser = Lib::table('user');
$targetUser->load($userid);
$notificationData = ['to' => $targetUser->email, 'text' => $user->nick . ' posted a new comment.', 'username' => 'Project Report Comment', 'icon_emoji' => ':speech_balloon', 'attachments' => [['fallback' => 'New comment in <' . $reportTable->getLink() . '|Report ticket ID ' . $reportTable->id . '>.', 'color' => '#FFEB3B', 'title' => $projectTable->name, 'title_link' => $reportTable->getLink(), 'text' => $reportTable->content, 'fields' => $notificationFields]]];
Lib::load('helper/notification');
NotificationHelper::send($notificationData);
// $slackMessage = Lib::helper('slack')->newMessage();
// $slackMessage->to($userid);
// $slackMessage->message($user->nick . ' posted a new comment.');
// $slackMessage->username = 'Project Report Comment';
// $slackMessage->icon_emoji = ':speech_balloon:';
// $attachment = $slackMessage->newAttachment();
// $attachment->fallback = 'New comment in <' . $reportTable->getLink() . '|Report ticket ID ' . $reportTable->id . '>.';
// $attachment->color = '#FFEB3B';
// $attachment->title = $projectTable->name;
// $attachment->title_link = $reportTable->getLink();
// $attachment->text = $reportTable->content;
// $attachment->newField('Comment', $post['content']);
// if (!empty($files)) {
// foreach ($files as $key => $file) {
// $attachment->newField($file['name'], Config::getHTMLBase() . Config::$attachmentFolder . '/' . $key . '-' . $file['name']);
// }
// }
// $slackMessage->send();
}
}
return $this->success($commentTable->id);
}