Exemplo n.º 1
0
 /**
  * コンテンツデータを登録する
  * コンテンツデータを次のように作成して引き渡す
  * array('Content' =>
  * 			array(	'model_id'	=> 'モデルでのID'
  * 					'category'	=> 'カテゴリ名',
  * 					'title'		=> 'コンテンツタイトル',		// 検索対象
  * 					'detail'	=> 'コンテンツ内容',		// 検索対象
  * 					'url'		=> 'URL',
  * 					'status' => '公開ステータス'
  * ))
  *
  * @param Model $model
  * @param array $data
  * @return boolean
  * @access public
  */
 public function saveContent(Model $model, $data)
 {
     if (!$data) {
         return;
     }
     $data['Content']['model'] = $model->alias;
     // タグ、空白を除外
     $data['Content']['detail'] = str_replace(array("\r\n", "\r", "\n", "\t", "\\s"), '', trim(strip_tags($data['Content']['detail'])));
     // 検索用データとして保存
     $id = '';
     $this->Content = ClassRegistry::init('Content');
     if (!empty($data['Content']['model_id'])) {
         $before = $this->Content->find('first', array('fields' => array('Content.id', 'Content.category'), 'conditions' => array('Content.model' => $data['Content']['model'], 'Content.model_id' => $data['Content']['model_id'])));
     }
     if ($before) {
         $data['Content']['id'] = $before['Content']['id'];
         $this->Content->set($data);
     } else {
         if (empty($data['Content']['priority'])) {
             $data['Content']['priority'] = '0.5';
         }
         $this->Content->create($data);
     }
     $result = $this->Content->save();
     // カテゴリを site_configsに保存
     if ($result) {
         return $this->updateContentMeta($model, $data['Content']['category']);
     }
     return $result;
 }
Exemplo n.º 2
0
 public function create($user_id, $post = array())
 {
     if (!isset($post['id']) || $post['id'] != $this->user_id) {
         $post['id'] = $user_id;
     }
     parent::create($user_id, $post);
 }
Exemplo n.º 3
0
 public function create()
 {
     $content = new Content();
     $company = $this->user->getCompany() ? "(" . $this->user->getCompany() . ")" : " ";
     $_POST["description"] .= " -- " . $this->user->getUsername() . $company;
     $result = $content->create();
     header("Location: " . $_GET["id"]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('content')->delete();
     Content::create(array('body' => 'first sentence', 'type' => 'homepage'));
     Content::create(array('body' => 'second sentence', 'type' => 'homepage'));
     Content::create(array('body' => 'third sentence', 'type' => 'homepage'));
     Content::create(array('body' => 'forth sentence', 'type' => 'homepage'));
 }
Exemplo n.º 5
0
<?php

/**
 * Created by PhpStorm.
 * User: munabste
 * Date: 8/24/2015
 * Time: 10:31 AM
 */
require_once 'php-activerecord/ActiveRecord.php';
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory('models');
    $cfg->set_connections(array('development' => 'mysql://root:@localhost/xapp_base'));
});
# create Tito
$content = Content::create(array('name' => 'about', 'discription' => 'this page describes the about info', 'content' => 'This is the content for this page'));
# read Tito
//$user = User::find_by_id('2');
# update Tito
//$user->name = 'Tito Jr';
//$user->save();
# delete Tito
//$user->delete();
Exemplo n.º 6
0
 public function storeContent()
 {
     $v = Validator::make(Input::all(), ['title' => 'required|min:5', 'content' => 'required|min:10']);
     if ($v->fails()) {
         return Redirect::back()->withErrors($v->messages())->withInput();
     }
     $content = Content::create(Input::all());
     if ($content->save()) {
         return Redirect::back()->with('flash_message', 'Content successfully created');
     }
     return Redirect::back()->withErrors('An error occured. Please contact server administrator');
 }