当前位置: 首页>>代码示例>>PHP>>正文


PHP Sprig::factory方法代码示例

本文整理汇总了PHP中Sprig::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Sprig::factory方法的具体用法?PHP Sprig::factory怎么用?PHP Sprig::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sprig的用法示例。


在下文中一共展示了Sprig::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * Overload Sprig::update() to save revision change
  * @param bump  whether to bump the version number
  */
 public function update($bump = TRUE)
 {
     Kohana::$log->add(Kohana::DEBUG, 'Executing Versioned_Sprig::update');
     $updated = FALSE;
     foreach ($this->_fields as $field => $object) {
         if ($object instanceof Sprig_Field_Tracked and $this->changed($field)) {
             $this->comment = UTF8::ucwords($object->label) . ' changed from "' . $this->_original[$field] . '" to "' . $this->_changed[$field] . '".';
         }
         if ($object instanceof Sprig_Field_Versioned and $this->changed($field) and $bump) {
             $diff = '';
             if ($this->version != 0) {
                 $diff = Versioned::diff($this->_original[$field], $this->_changed[$field]);
                 $diff = Versioned::clean_array($diff);
                 $diff = serialize($diff);
             }
             $this->version++;
             $revision = Sprig::factory($this->_model . '_revision');
             $revision->values(array('entry' => $this->id, 'version' => $this->version, 'editor' => $this->editor, 'diff' => $diff));
             $revision->comments = $this->comments;
             $revision->create();
             $updated = TRUE;
             $this->comments = array();
         }
     }
     if (!$updated and count($this->comments) > 0) {
         $revision = Sprig::factory($this->_model . '_revision');
         $revision->entry = $this->id;
         $revision->version = $this->version;
         $revision->load();
         $revision->comments = array_merge($revision->comments, $this->comments);
         $revision->update();
     }
     return parent::update();
 }
开发者ID:vimofthevine,项目名称:versioned,代码行数:38,代码来源:sprig.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: 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

示例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['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

示例5: 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

示例6: __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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: published

 /**
  * Get all published articles containing this tag
  */
 public function published(Database_Query_Builder_Select $query = NULL, $limit = 1)
 {
     $field = $this->_fields['articles'];
     $model = Sprig::factory($field->model);
     $query = !$query ? DB::select() : $query;
     $query->join($field->through)->on($model->fk($field->through), '=', $model->pk(TRUE))->where($this->fk($field->through), '=', $this->{$this->_primary_key});
     return $model->load($query, $limit);
 }
开发者ID:vimofthevine,项目名称:kohana-blog,代码行数:11,代码来源:tag.php

示例12: 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

示例13: __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

示例14: 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

示例15: 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


注:本文中的Sprig::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。