本文整理汇总了PHP中Sprig类的典型用法代码示例。如果您正苦于以下问题:PHP Sprig类的具体用法?PHP Sprig怎么用?PHP Sprig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sprig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Overload Sprig::delete() to update child articles
* to become children of the uncategorized subcategory
*/
public function delete(Database_Query_Builder_Delete $query = NULL) {
Kohana::$log->add(Kohana::DEBUG, 'Beginning subcategory deletion for subcategory_id='.$this->id);
if (Kohana::$profiling === TRUE)
{
$benchmark = Profiler::start('blog', 'delete subcategory');
}
$uncategorized = Sprig::factory('subcategory', array('name'=>'uncategorized'))->load();
// Modify category IDs for all child articles
try
{
DB::update('articles')->value('subcategory_id', $uncategorized->id)
->where('subcategory_id', '=', $this->id)->execute();
}
catch (Database_Exception $e)
{
Kohana::$log->add(Kohana::ERROR, 'Exception occured while modifying deleted subcategory\'s articles. '.$e->getMessage());
return $this;
}
if (isset($benchmark))
{
Profiler::stop($benchmark);
}
return parent::delete($query);
}
开发者ID:nagius,项目名称:kohana-blog,代码行数:32,代码来源:subcategory.php
示例2: revoke
/**
* Revoke access to $role for resource
*
* @param mixed string role name or Model_Role object
* @param string resource identifier
* @param string action [optional]
* @param string condition [optional]
* @return void
*/
public static function revoke($role, $resource, $action = NULL, $condition = NULL)
{
// Normalise $role
if (!$role instanceof Model_Role) {
$role = Sprig::factory('role', array('name' => $role))->load();
}
// Check role exists
if (!$role->loaded()) {
// Just return without deleting anything
return;
}
$model = Sprig::factory('aacl_rule', array('role' => $role->id));
if ($resource !== '*') {
// Add normal reources, resource '*' will delete all rules for this role
$model->resource = $resource;
}
if ($resource !== '*' and !is_null($action)) {
$model->action = $action;
}
if ($resource !== '*' and !is_null($condition)) {
$model->condition = $condition;
}
// Delete rule
$model->delete();
}
开发者ID:azuya,项目名称:Wi3,代码行数:34,代码来源:acl.php
示例3: __construct
public function __construct(array $options = NULL)
{
parent::__construct($options);
if ($this->choices === NULL) {
$this->choices = Sprig::factory($this->model)->select_list();
}
}
开发者ID:vitch,项目名称:sprig,代码行数:7,代码来源:hasone.php
示例4: ajax_response
public function ajax_response()
{
session_start();
// Проверяем, что форма была разблокирована
if (isset($_SESSION['qaptcha_key']) and $_SESSION['qaptcha_key'] == 'iqaptcha' and isset($_POST['iqaptcha']) and empty($_POST['iqaptcha'])) {
// Проверяем заполненность всех обязательных полей
if (!empty($_POST['fio']) and !empty($_POST['phone']) and !empty($_POST['message'])) {
// Обезопасим входные данные
$this->set_safe($_POST, FALSE);
// Сохраняем в админке
// Создаем запрос
$feedback = Sprig::factory('feedback');
$feedback->values($_POST);
$feedback->create();
// Если в настройках задан email администратора - отправляем письмо
if (!empty($this->fos_email)) {
// Создаем объект PHPMailer и задаем начальные настройки
$mail = new PHPMailer();
$mail->CharSet = 'utf-8';
$mail->From = 'no-reply@' . $_SERVER['HTTP_HOST'];
$mail->FromName = $_SERVER['HTTP_HOST'];
$mail->AddAddress($this->fos_email, 'Получатель запросов');
$mail->Subject = 'Сообщение с сайта от: ' . $_POST['fio'];
$mail->Body = $this->email_tpl_render('feedbackadminmail', $_POST);
$mail->Send();
}
return 'true';
}
}
return 'false';
}
开发者ID:bosoy83,项目名称:progtest,代码行数:31,代码来源:feedback.php
示例5: ajax_response
public function ajax_response()
{
session_start();
// Проверяем, что форма была разблокирована
if (isset($_SESSION['qaptcha_key']) and $_SESSION['qaptcha_key'] == 'iqaptcha' and isset($_POST['iqaptcha']) and empty($_POST['iqaptcha'])) {
// Проверяем заполненность всех обязательных полей
if (!empty($_POST['fio']) and !empty($_POST['phone']) and !empty($_POST['catalog_id']) and !empty($_POST['object_data'])) {
// Обезопасим входные данные
$this->set_safe($_POST, FALSE);
// Добавим переводы строк
$_POST['object_data'] = str_replace(';', "\r\n", $_POST['object_data']);
// Сохраняем в админке
// Создаем запрос
$reqbuy = Sprig::factory('reqbuy');
$reqbuy->values($_POST);
$reqbuy->create();
// Если в настройках задан email администратора - отправляем письмо
if (!empty($this->reqbuy_email)) {
// Создаем объект PHPMailer и задаем начальные настройки
$mail = new PHPMailer();
$mail->CharSet = 'utf-8';
$mail->From = 'no-reply@' . $_SERVER['HTTP_HOST'];
$mail->FromName = $_SERVER['HTTP_HOST'];
$mail->AddAddress($this->reqbuy_email, 'Получатель запросов');
$mail->Subject = 'Заявка на покупку объекта от: ' . $_POST['fio'];
$mail->Body = $this->email_tpl_render('reqbuyadminmail', $_POST);
$mail->Send();
}
return 'true';
}
}
return 'false';
}
开发者ID:bosoy83,项目名称:progtest,代码行数:33,代码来源:reqbuy.php
示例6: action_new
/**
* Create a new article
*/
public function action_new()
{
Kohana::$log->add(Kohana::DEBUG, 'Executing Controller_Admin_Article::action_new');
$this->template->content = View::factory('blog/admin/article_form')->set('legend', __('Create Article'))->set('submit', __('Save'))->set('slug_editable', FALSE)->set('comment_needed', FALSE)->bind('article', $article)->bind('errors', $errors);
$article = Sprig::factory('article')->values($_POST);
$article->author = $this->a1->get_user();
if ($_POST) {
try {
$article->create();
//$article->load();
$statistic = Sprig::factory('statistic', array('article' => $article))->create();
Message::instance()->info('The article, :title, has been created.', array(':title' => $article->title));
if (!$this->_internal) {
$this->request->redirect($this->request->uri(array('action' => 'list')));
}
} catch (Validate_Exception $e) {
$errors = $e->array->errors('admin');
}
}
// Set template scripts and styles
$this->template->scripts[] = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js';
$this->template->scripts[] = Route::get('media')->uri(array('file' => 'js/markitup/jquery.markitup.js'));
$this->template->scripts[] = Route::get('media')->uri(array('file' => 'js/markitup/sets/html/set.js'));
$this->template->styles[Route::get('media')->uri(array('file' => 'js/markitup/skins/markitup/style.css'))] = 'screen';
$this->template->styles[Route::get('media')->uri(array('file' => 'js/markitup/sets/html/style.css'))] = 'screen';
}
开发者ID:vimofthevine,项目名称:kohana-blog,代码行数:29,代码来源:article.php
示例7: action_update
/**
* Update an existing post
*
*/
public function action_update()
{
$this->request->response = View::factory('shindig/admin/edit_post')->set('form_title', __('Update Post'))->bind('use_authors', $use_authors)->bind('site_url', $site_url)->bind('errors', $errors)->bind('post', $post);
$use_authors = Kohana::config('shindig.use_authors');
$site_url = URL::site('blog', TRUE) . '/';
$post = Sprig::factory('shindig_post')->values(array('id' => $this->request->param('id')))->load();
if (isset($_POST['shindig_post'])) {
try {
/*
if ($tags = Arr::get($_POST, 'tags'))
{
foreach ($tags as $tag)
{
// check to see if tag exsists.
// Get id if it does, create it if it doesn't
}
}
*/
$post->values($_POST)->update();
Request::instance()->redirect(Route::get(Kohana::config('shindig.post_create_redirect.route'))->uri(array('action' => Kohana::config('shindig.post_create_redirect.action'), 'id' => $post->id)));
} catch (Validate_Exception $e) {
$errors = $e->array->errors('shindig/crud');
}
}
}
开发者ID:kerkness,项目名称:shindig,代码行数:29,代码来源:post.php
示例8: factory
/**
* Loads the “Invite” model with the given primary key
*
* @param primary key to load
* @param dummy value to conform with Sprig
* @return Model_Invite
*/
public static function factory($token, array $dummy = array())
{
if (Model_Invite::valid($token)) {
$dummy['token'] = $token;
}
return parent::factory('invite', $dummy);
}
开发者ID:Burgestrand,项目名称:Anglarna-Stockholm,代码行数:14,代码来源:invite.php
示例9: load
public function load(Database_Query_Builder_Select $query = NULL, $limit = NULL)
{
if (!$query) {
$query = DB::select()->order_by('id', 'DESC')->order_by('created_on', 'DESC');
}
return Sprig::factory('Shindig_Post')->load($query, $limit);
}
开发者ID:kerkness,项目名称:shindig,代码行数:7,代码来源:search.php
示例10: action_recent_comments
/**
* Show recent comments
*/
public function action_recent_comments()
{
Kohana::$log->add(Kohana::DEBUG, 'Executing Controller_Blog_Stats::action_recent_comments');
$this->template->content = View::factory('blog/stats/comments')->set('legend', __('Recent Comments'))->bind('comments', $comments);
$limit = $this->request->param('limit', NULL);
$search = Sprig::factory('blog_search');
$comments = $search->get_recent_comments($limit);
}
开发者ID:vimofthevine,项目名称:kohana-blog,代码行数:11,代码来源:stats.php
示例11: action_stats_reset
/**
* Reset daily statistics
*/
public function action_stats_reset()
{
$search = Sprig::factory('blog_search');
$articles = $search->search_by_state('published');
foreach ($articles as $article) {
$article->statistic->load()->reset()->update();
}
}
开发者ID:vimofthevine,项目名称:kohana-blog,代码行数:11,代码来源:cron.php
示例12: __construct
public function __construct($template = NULL, array $partials = NULL)
{
// Шаблон берем от метода Add
$template = 'admin/benefits/add';
parent::__construct($template, $partials);
// Создаем объект текущего преимущества
$this->cur_benefit = Sprig::factory('benefits', array('id' => $this->id))->load()->as_array();
}
开发者ID:bosoy83,项目名称:progtest,代码行数:8,代码来源:edit.php
示例13: __set
/**
* Overload Sprig::__set() to serialize comments
*
* @param string variable name
* @param string variable value
* @return void
*/
public function __set($key, $value)
{
if ($key == 'comments') {
$this->comment = serialize($value);
return;
}
parent::__set($key, $value);
}
开发者ID:vimofthevine,项目名称:versioned,代码行数:15,代码来源:revision.php
示例14: action_details
public function action_details()
{
$plugin = Sprig::factory('plugin', array('id' => $this->request->param('id')))->load();
if (!$plugin->loaded()) {
notice::add(__('Invalid Plugin'), 'error');
Request::instance()->redirect(Request::instance('admin')->uri(array('action' => 'list')));
}
}
开发者ID:Zeelot,项目名称:yuriko_cms,代码行数:8,代码来源:plugin.php
示例15: action_view
/**
* Attempt to find a page in the CMS, return the response
*
* @param string The url to load, will be autodetected if needed
* @return void
*/
public function action_view($url = NULL)
{
if (Kohana::$profiling === TRUE) {
// Start a new benchmark
$benchmark = Profiler::start('Kohanut', 'Kohanut Controller');
}
// If no $url is passed, default to the server request uri
if ($url === NULL) {
$url = $_SERVER['REQUEST_URI'];
}
// Trim off Kohana::$base_url
$url = preg_replace('#^' . Kohana::$base_url . '#', '', $url);
// Ensure no trailing slash
$url = preg_replace('/\\/$/', '', $url);
// Ensure no leading slash
$url = preg_replace('/^\\//', '', $url);
// Remove anything ofter a ? or #
$url = preg_replace('/[\\?#].+/', '', $url);
// Try to find what to do on this url
try {
// Make sure the url is clean. See http://www.faqs.org/rfcs/rfc2396.html see section 2.3
// TODO - this needs to be better
if (preg_match("/[^\\/A-Za-z0-9-_\\.!~\\*\\(\\)]/", $url)) {
Kohana::$log->add('INFO', "Kohanut - Request had unknown characters. '{$url}'");
throw new Kohanut_Exception("Url request had unknown characters '{$url}'", array(), 404);
}
// Check for a redirect on this url
Sprig::factory('kohanut_redirect', array('url', $url))->go();
// Find the page that matches this url, and isn't an external link
$query = DB::select()->where('url', '=', $url)->where('islink', '=', 0);
$page = Sprig::factory('kohanut_page')->load($query);
if (!$page->loaded()) {
// Could not find page in database, throw a 404
Kohana::$log->add('INFO', "Kohanut - Could not find '{$url}' (404)");
throw new Kohanut_Exception("Could not find '{$page->url}'", array(), 404);
}
// Set the status to 200, rather than 404, which was set by the router with the reflectionexception
Kohanut::status(200);
$out = $page->render();
} catch (Kohanut_Exception $e) {
// Find the error page
$error = Sprig::factory('kohanut_page', array('url' => 'error'))->load();
// If i couldn't find the error page, just give a generic message
if (!$error->loaded()) {
Kohanut::status(404);
$this->request->response = View::factory('kohanut/generic404');
return;
}
// Set the response
$out = $error->render();
}
if (isset($benchmark)) {
// Stop the benchmark
Profiler::stop($benchmark);
}
// Set the response
$this->request->response = $out;
}
开发者ID:bluehawk,项目名称:kohanut-core,代码行数:64,代码来源:kohanut.php
示例16: input
public function input($name, $value, array $attr = NULL)
{
$model = Sprig::factory($this->model);
$choices = $model->select_list($model->pk());
if ($this->empty) {
Arr::unshift($choices, '', '-- ' . __('None'));
}
return Form::select($name, $choices, $this->verbose($value), $attr);
}
开发者ID:bosoy83,项目名称:progtest,代码行数:9,代码来源:belongsto.php
示例17: __get
/**
* Overload Sprig::__get() to return
*
* - email md5 hash for gravatar
*/
public function __get($name)
{
if ($name == 'gravatar') {
$email = md5(strtolower(trim($this->email)));
return $email;
} else {
return parent::__get($name);
}
}
开发者ID:vimofthevine,项目名称:kohana-blog,代码行数:14,代码来源:comment.php
示例18: update_infoblock
private function update_infoblock(array $post_arr)
{
// Привязываем POST данные
$this->cur_infoblock->values($post_arr);
$this->cur_infoblock->update();
// После обновления инфоблока перегружаем его для вывода актуальной информации
$this->cur_infoblock = Sprig::factory('infoblock', array('id' => $post_arr['id']))->load();
return array('text' => 'Блок информации обновлен', 'error' => 0);
}
开发者ID:bosoy83,项目名称:progtest,代码行数:9,代码来源:edit.php
示例19: load_user
/**
* Loading user by name
*
* @param string $username
* @param string $password
* @return object / NULL
*/
public function load_user($username, $password)
{
$user = Sprig::factory($this->_config['user_model'], array($this->_config['columns']['username'] => $username, $this->_config['columns']['password'] => $password));
$user->load();
if ($user->loaded()) {
return $user;
} else {
return NULL;
}
}
开发者ID:smgladkovskiy,项目名称:A1,代码行数:17,代码来源:sprig.php
示例20: action_list
/**
* Display list of pages
*/
public function action_list()
{
Kohana::$log->add(Kohana::DEBUG, 'Executing Controller_Admin_Page::action_list');
if ($this->_internal) {
$this->template->content = View::factory('cms/pages/list_widget')->bind('pages', $pages);
} else {
$this->template->content = View::factory('cms/pages/list')->bind('pages', $pages);
}
$pages = Sprig::factory('page')->load(NULL, FALSE);
}
开发者ID:vimofthevine,项目名称:kohana-cms,代码行数:13,代码来源:page.php
注:本文中的Sprig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论