Example #1
0
 public function get()
 {
     $this->_requireLogin();
     $session = new Model_Session();
     $tagModel = new Model_Tag();
     $tagModel->setUserId($session->getUserId());
     $tags = ORM::for_table('insightengine_tags')->where_equal('user_id', $session->getUserId())->where_null('send_count_30_days')->order_by_desc('send_count_30_days')->find_many();
     $parameters = array_merge(parent::_getTwigParameters(), array('tags_menu_selected' => true, 'tags' => $tags, 'tag_model' => $tagModel));
     echo $this->_getTwig()->render('manage/import_tags.html.twig', $parameters);
 }
Example #2
0
 /**
  * 
  * @param integer|Model_Page_Front $page_id
  * @param array $tags
  */
 public static function save_by_page($page_id, $tags)
 {
     if (is_string($tags)) {
         $tags = explode(Model_Tag::SEPARATOR, $tags);
     }
     $tags = array_unique(array_map('trim', $tags));
     $current_tags = Model_Page_Tag::find_by_page($page_id);
     if ($page_id instanceof Model_Page_Front) {
         $page_id = $page_id->id();
     }
     // no tag before! no tag now! ... nothing to do!
     if (empty($tags) and empty($current_tags)) {
         return NULL;
     }
     // delete all tags
     if (empty($tags)) {
         // update count (-1) of those tags
         foreach ($current_tags as $tag) {
             DB::update(Model_Tag::tableName())->set(array('count' => DB::expr('count - 1')))->where('name', '=', $tag)->execute();
         }
         Record::deleteWhere(self::tableName(), array('where' => array(array('page_id', '=', (int) $page_id))));
         Cache::instance()->delete_tag('page_tags');
     } else {
         $old_tags = array_diff($current_tags, $tags);
         $new_tags = array_diff($tags, $current_tags);
         // insert all tags in the tag table and then populate the page_tag table
         foreach ($new_tags as $index => $tag_name) {
             if (empty($tag_name)) {
                 continue;
             }
             $tag = Record::findOneFrom('Model_Tag', array('where' => array(array('name', '=', $tag_name))));
             // try to get it from tag list, if not we add it to the list
             if (!$tag instanceof Model_Tag) {
                 $tag = new Model_Tag(array('name' => trim($tag_name)));
             }
             $tag->count++;
             $tag->save();
             // create the relation between the page and the tag
             $page_tag = new Model_Page_Tag(array('page_id' => (int) $page_id, 'tag_id' => $tag->id));
             $page_tag->save();
         }
         // remove all old tag
         foreach ($old_tags as $index => $tag_name) {
             // get the id of the tag
             $tag = Record::findOneFrom('Model_Tag', array('where' => array(array('name', '=', $tag_name))));
             Record::deleteWhere(self::tableName(), array('where' => array(array('page_id', '=', (int) $page_id), array('tag_id', '=', $tag->id))));
             $tag->count--;
             $tag->save();
         }
         Cache::instance()->delete_tag('page_tags');
     }
 }
Example #3
0
 public function action_showtag()
 {
     $url = $this->request->param('id');
     $data = array();
     $tag = new Model_Tag();
     $data['tag'] = $tag->tagInfoByUrl($url);
     if (!$data['tag']) {
         throw new HTTP_Exception_404('Запрашиваемый тег не найден!');
         return;
     }
     $data['materials'] = $tag->contentTagById($data['tag']['id']);
     $this->template->content = View::factory('tagview', $data);
 }
Example #4
0
 /**
  * 
  * @return array
  */
 public function get_tags()
 {
     $query = DB::select()->from(Model_Tag::tableName())->where('count', '>', 0);
     if (!empty($this->_ids) and is_array($this->_ids)) {
         $query->where('id', 'in', $this->_ids);
     }
     switch ($this->order_by) {
         case 'name_asc':
             $query->order_by('name', 'asc');
             break;
         case 'name_desc':
             $query->order_by('name', 'desc');
             break;
         case 'count_asc':
             $query->order_by('count', 'asc');
             break;
         case 'count_desc':
             $query->order_by('count', 'desc');
             break;
         default:
             $query->order_by('name', 'asc');
             break;
     }
     return $query->execute()->as_array('name', 'count');
 }
Example #5
0
 /**
  * Checks if a given tag already exists. 
  * The parameter $tag is a hash containing the tag name and type as below
  * E.g: $tag = array('tag_name' => 'bubba', tag_type => 'junk');
  *
  * @param string $tag Has containing the tag name and tag type
  * @param bool $save Optionally saves the tag if does not exist
  * @return mixed Model_Tag if the tag exists, FALSE otherwise
  */
 public static function get_tag_by_name($tag, $save = FALSE)
 {
     $result = ORM::factory('tag')->where('tag', '=', $tag['tag_name'])->where('tag_type', '=', $tag['tag_type'])->find();
     if ($result->loaded()) {
         return $result;
     } elseif (!$result->loaded() and $save == TRUE) {
         try {
             // Save the tag
             $orm_tag = new Model_Tag();
             $orm_tag->tag = $tag['tag_name'];
             $orm_tag->tag_type = $tag['tag_type'];
             return $orm_tag->save();
         } catch (Database_Exception $e) {
             Kohana::$log->add(Log::ERROR, $e->getMessage());
             return FALSE;
         }
     } else {
         return FALSE;
     }
 }
Example #6
0
 public function rest_get()
 {
     $name = $this->param('term', NULL, TRUE);
     if (empty($name)) {
         return NULL;
     }
     $tags = Model_Tag::findAllLike($name);
     $array = array();
     foreach ($tags as $tag) {
         $array[] = array('id' => $tag->name, 'text' => $tag->name);
     }
     $this->response($array);
 }
Example #7
0
File: Tag.php Project: kstep/pnut
 public function actionRemove($params)
 {
     $view = $this->ajaxView('tag');
     $view->state = 'failed';
     if ($params["id"]) {
         $tag = new Model_Tag($this->getStorage(), $params["id"]);
         $view->id = $tag->getId();
         if ($view->id) {
             $this->canPerform($tag, "delete");
             $view->state = "removed";
             try {
                 $tag->remove();
             } catch (Exception $e) {
                 $view->state = "failed";
                 $view->error = $e->getMessage();
             }
         } else {
             $view->error = "Tag not found.";
         }
     } else {
         $view->error = "Tag ID is not set.";
     }
     return $view;
 }
Example #8
0
 public static function save_tags($tag_names, $news_id)
 {
     $saved_ids = array();
     if (!is_array($tag_names)) {
         $tag_names = (array) $tag_names;
     }
     if (!$tag_names) {
         return $saved_ids;
     }
     $news_tag_ids4delete = self::get_assoc('tag_id', 'id', array('news_id' => $news_id));
     $tag_ids = \Model_Tag::get_assoc('name', 'id', array('name', 'in', $tag_names));
     foreach ($tag_names as $name) {
         if (!empty($tag_ids[$name])) {
             $tag_id = $tag_ids[$name];
         } else {
             $tag = \Model_Tag::forge(array('name' => $name));
             $tag->save();
             $tag_id = $tag->id;
         }
         if (!($news_tag = self::get_one4news_id_and_tag_id($news_id, $tag_id))) {
             $news_tag = self::forge(array('news_id' => $news_id, 'tag_id' => $tag_id));
             $news_tag->save();
             $saved_ids[] = $news_tag->id;
         }
         if (isset($news_tag_ids4delete[$tag_id])) {
             unset($news_tag_ids4delete[$tag_id]);
         }
     }
     // delete records
     if ($news_tag_ids4delete) {
         foreach ($news_tag_ids4delete as $news_tag_id4delete) {
             if ($news_tag = self::find($news_tag_id4delete)) {
                 $news_tag->delete();
             }
         }
     }
     return $saved_ids;
 }
Example #9
0
 private function saveArticle(Model_Article $article, View_Html $view)
 {
     if (isset($_REQUEST['save'])) {
         foreach (array("published", "archived") as $name) {
             $_POST[$name] = Filter_Date::fromString($_POST[$name]);
         }
         if (!isset($_POST['flags'])) {
             $_POST['flags'] = array();
         }
         $article->setData($_POST);
         if (!($errors = $article->validate())) {
             $article->save();
             $article->getRights()->setRights($_POST['rights'], $_POST['owner'], $_POST['group'])->save();
             $article->dropTags();
             $tags = isset($_POST['tag']) ? $_POST['tag'] : (isset($_POST['tags']) ? explode(", ", $_POST['tags']) : null);
             Model_Tag::setAutoCreate();
             if ($tags) {
                 $article->addTags($tags);
             }
             if ($_FILES && $_FILES["attach"]) {
                 $store = $this->getStorage();
                 foreach ($_FILES["attach"]["name"] as $index => $name) {
                     $attachment = new Model_Attachment($store);
                     $file = array('name' => $name, 'tmp_name' => $_FILES['attach']['tmp_name'][$index], 'error' => $_FILES['attach']['error'][$index], 'size' => $_FILES['attach']['size'][$index], 'type' => $_FILES['attach']['type'][$index]);
                     if ($attachment->uploadFile($file)) {
                         $attachment->attachTo($article);
                         $attachment->save();
                     }
                 }
             }
             $view->redir('Admin_Topic', 'default', array('id' => $article->topic));
             return true;
         }
         $view->errors = $errors;
     }
     return false;
 }
Example #10
0
 protected function _get($tag)
 {
     $tag = urldecode($tag);
     $this->_requireLogin();
     $session = new Model_Session();
     $tagModel = new Model_Tag();
     $user = new Model_User();
     $user->loadByApiKey($session->getKey());
     if (!$user->isActive()) {
         throw new Exception("Not logged in yet");
     }
     $tagModel->loadByTagId($session->getUserId(), $tag);
     $tagModel->processTag();
     if (!$tagModel->getSubject()) {
         $tagModel->processSubjectLine();
     }
     $this->_jsonResponse(array('success' => true, 'tag' => $tag, 'biggest_gap_last_30_days' => $tagModel->getBiggestGap(), 'last_sent' => $tagModel->getLastSent(), 'last_sent_friendly' => $tagModel->formatLastSent($tagModel->getLastSent()), 'is_active' => $tagModel->defaultToActive(), 'subject' => $tagModel->getSubject(), 'summary' => $tagModel->getSummary($tagModel->getTagRecord()), 'last_sent_status' => $tagModel->lastSentStatus($tagModel->getTagRecord())));
 }
Example #11
0
 /**
  * Set event tags.
  *
  * @param   array  $tags
  * @return  Model_Event
  */
 public function set_tags(array $tags = null)
 {
     $old_tags = $this->tags();
     $new_tags = (array) $tags;
     // Delete removed tags
     foreach (array_diff(array_keys($old_tags), $new_tags) as $tag_id) {
         $this->remove('tag', (int) $tag_id);
     }
     // Add new tags
     $add = array();
     foreach (array_diff($new_tags, array_keys($old_tags)) as $tag_id) {
         $tag = Model_Tag::factory((int) $tag_id);
         if ($tag && $tag->loaded()) {
             $add[] = (int) $tag->id;
         }
     }
     if ($add) {
         $this->relate('tags', $add);
     }
     // Normalized tags for old version, to be deprecated
     if ($this->music != ($music = implode(', ', $this->tags()))) {
         $this->music = $music;
         $this->save();
     }
     return $this;
 }
Example #12
0
File: tags.php Project: anqh/anqh
 /**
  * Action: tag
  *
  * @param  integer  $group_id
  */
 public function action_tag($group_id = null)
 {
     $this->history = false;
     if ($group_id && $this->request->action() !== 'tag') {
         // Add new tag
         $group = Model_Tag_Group::factory($group_id);
         if (!$group->loaded()) {
             throw new Model_Exception($group, $group_id);
         }
         $tag = Model_Tag::factory();
         $tag->tag_group_id = $group_id;
         $tag->author_id = Visitor::$user->id;
         $tag->created = time();
         $this->view = View_Page::factory($group->name);
         $this->view->subtitle = HTML::chars($group->description);
     } else {
         if ($tag_id = (int) $this->request->param('id')) {
             // Edit old tag
             $tag = Model_Tag::factory($tag_id);
             if (!$tag->loaded()) {
                 throw new Model_Exception($tag, $tag_id);
             }
             $this->view = View_Page::factory($tag->name);
             $this->view->subtitle = HTML::chars($tag->description);
             $this->page_actions[] = array('link' => Route::model($tag, 'delete') . '?' . Security::csrf_query(), 'text' => '<i class="icon-trash icon-white"></i> ' . __('Delete tag'), 'class' => 'btn btn-danger tag-delete');
         } else {
             Request::back(Route::url('tags'));
         }
     }
     $errors = array();
     if ($_POST) {
         $tag->name = Arr::get($_POST, 'name');
         $tag->description = Arr::get($_POST, 'description');
         try {
             $tag->save();
             $this->request->redirect(Route::model($tag));
         } catch (Validation_Exception $e) {
             $errors = $e->array->errors('validate');
         }
     }
     $this->view->add(View_Page::COLUMN_CENTER, $this->section_tag($tag, $errors));
 }
Example #13
0
 /**
  * Creates a droplets from the given array
  *
  * @param array $droplet
  * @return array
  */
 public static function create_from_array($droplets)
 {
     if (!count($droplets)) {
         return;
     }
     // Populate identities
     Model_Identity::get_identities($droplets);
     // Hash array with droplet_hash as key and index in droplets array that contain that hash
     $droplets_idx = array();
     foreach ($droplets as $key => &$droplet) {
         if (!isset($droplet['id'])) {
             $hash = md5($droplet['identity_orig_id'] . $droplet['channel'] . $droplet['droplet_orig_id']);
             $droplet['droplet_hash'] = $hash;
             if (empty($droplets_idx[$hash])) {
                 $droplets_idx[$hash] = array();
             }
             $droplets_idx[$hash][] = $key;
         }
     }
     // Insert new drops
     $new_droplets = array();
     if (!empty($droplets_idx)) {
         Swiftriver_Mutex::obtain(get_class(), 3600);
         // Find the drops that already exist by their droplet_hash
         $found_query = DB::select('droplet_hash', 'id')->from('droplets')->where('droplet_hash', 'IN', array_keys($droplets_idx));
         $found = $found_query->execute()->as_array();
         // Update the ids of existing drops found in the db and
         // remove them from droplets_idx to leave new drops
         $new_droplet_count = count($droplets_idx);
         foreach ($found as $hash) {
             foreach ($droplets_idx[$hash['droplet_hash']] as $key) {
                 $droplets[$key]['id'] = $hash['id'];
             }
             $new_droplet_count--;
             unset($droplets_idx[$hash['droplet_hash']]);
         }
         if (!empty($droplets_idx)) {
             // Get a range of IDs to be used in inserting the new drops
             $base_id = Model_Droplet::get_ids($new_droplet_count);
             // Insert into the droplets table
             $query = DB::insert('droplets', array('id', 'channel', 'droplet_hash', 'droplet_orig_id', 'droplet_type', 'droplet_title', 'droplet_content', 'droplet_date_pub', 'droplet_date_add', 'identity_id', 'processing_status'));
             foreach ($droplets_idx as $hash => $keys) {
                 foreach ($keys as $key) {
                     $droplets[$key]['id'] = $base_id;
                 }
                 // PHP has reference issues with array so
                 // we cannot copy the element we have but
                 // refeference it in place as below $droplets[$keys[0]]
                 // otherwise the element will be overwriten if we use a
                 // copy. Sigh.
                 $new_droplets[] = $droplets[$keys[0]];
                 $query->values(array('id' => $base_id++, 'channel' => $droplets[$keys[0]]['channel'], 'droplet_hash' => $droplets[$keys[0]]['droplet_hash'], 'droplet_orig_id' => $droplets[$keys[0]]['droplet_orig_id'], 'droplet_type' => $droplets[$keys[0]]['droplet_type'], 'droplet_title' => $droplets[$keys[0]]['droplet_title'], 'droplet_content' => $droplets[$keys[0]]['droplet_content'], 'droplet_date_pub' => $droplets[$keys[0]]['droplet_date_pub'], 'droplet_date_add' => gmdate("Y-m-d H:i:s", time()), 'identity_id' => $droplets[$keys[0]]['identity_id'], 'processing_status' => self::PROCESSING_STATUS_NEW));
             }
             $query->execute();
         }
         Swiftriver_Mutex::release(get_class());
     }
     // Populate metadata IDs into the drops array
     Model_Tag::get_tags($droplets);
     Model_Link::get_links($droplets);
     Model_Place::get_places($droplets);
     Model_Media::get_media($droplets);
     // Populate the drop's metadata tables
     self::add_metadata($droplets);
     return array($droplets, $new_droplets);
 }
Example #14
0
 protected function _getTagList()
 {
     $iTypeID = $this->_getTypeID();
     $iCityID = $this->_getCityID();
     if ($iCityID > 0) {
         $aCityID = [$iCityID, 0];
     } else {
         $aCityID = $iCityID;
     }
     return Model_Tag::getNewsTag($aCityID, $iTypeID);
 }
Example #15
0
File: Tag.php Project: kstep/pnut
 public function setAutoCreate($value = true)
 {
     self::$_auto_create = (bool) $value;
 }
Example #16
0
 public function action_index()
 {
     //ビューに渡すデータの配列を初期化
     $data = array();
     //県のセレクト用のオプション配列の作成
     $prefectures = Model_Prefecture::find('all');
     $pref_op = array();
     foreach ($prefectures as $pref) {
         $pref_op[$pref->pref_num] = $pref->pref_name;
     }
     $data['prefs'] = $pref_op;
     //カテゴリのチェックボックス用のオプション配列の作成
     $categories = Model_Category::find('all');
     $catego_op = array();
     foreach ($categories as $catego) {
         $catego_op[$catego->cate_num] = $catego->cate_name;
     }
     $data['categories'] = $catego_op;
     //タグのセレクト用のオプション配列の作成
     $tags = Model_Tag::find('all');
     $tag_op = array();
     foreach ($tags as $tag) {
         $tag_op[$tag->tag_num] = $tag->tag_name;
     }
     $data['tags'] = $tag_op;
     if (Input::method() == 'POST') {
         /*-------
           ユーザが入力した値とその時の時刻を保持
           --------*/
         $data['input_pref'] = Input::post('pref');
         $data['input_place'] = Input::post('place');
         $data['input_title'] = Input::post('title');
         $data['input_content'] = Input::post('content');
         $data['input_category'] = Input::post('category');
         $data['input_tag1'] = Input::post('tag1');
         $data['input_tag2'] = Input::post('tag2');
         $data['input_rating'] = Input::post('rating');
         $time = Date::forge()->get_timestamp();
     }
     /*--------
        Validationの準備
       ---------*/
     //Validationオブジェクトを呼び出す
     $val = Validation::forge();
     //フォームのルール設定
     $val->add('pref', '県名')->add_rule('required');
     $val->add('place', '場所')->add_rule('required');
     $val->add('title', 'タイトル')->add_rule('required');
     //->add_rule('max_length', 30)
     $val->add('content', '記事内容')->add_rule('required');
     //->add_rule('max_length', 200)
     $val->add('category', 'カテゴリ')->add_rule('required');
     $val->add('tag1', 'タグ1')->add_rule('required');
     $val->add('tag2', 'タグ2')->add_rule('required');
     $val->add('rating', '評価')->add_rule('required');
     /*-----------
       画像ファイルの入力があったらアップロード
       ---------------*/
     //データ保存用変数 初期化
     $upload_file = '';
     if (Input::file('upload.name')) {
         //アップロード用初期設定
         $config = array('path' => DOCROOT . DS . '/assets/img/uimg', 'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'));
         //アップロード基本プロセス
         Upload::process($config);
         //検証
         if (Upload::is_valid()) {
             //設定を元に保存
             Upload::save();
             //保存されたファイル名を変数に入れる
             $getfile = Upload::get_files();
             $upload_file = $getfile[0]['name'];
         } else {
             //ファイルがアップロードできなかったとき、
             //メッセージをフラッシュセッションにセット
             Session::set_flash('uerr', 'ファイルが正しくアップできませんでした。');
             //投稿を中断して入力画面にもどる。
             return View::forge('members/post2', $data, false);
             //Response::redirect(View::forge('members/post2', $data, false));
         }
     }
     //Validationチェック
     if ($val->run()) {
         //ファイルがアップロードされてなかったらダメ
         if ($upload_file == '') {
             $data['error'] = 'ファイルを選択してください。';
             return View::forge('members/post2', $data);
         }
         /*------
           postされた各データをDBに保存
           ----------*/
         //各送信データを配列
         $props = array('uid' => 1, 'pref_num' => $data['input_pref'], 'place' => $data['input_place'], 'title' => $data['input_title'], 'contents' => $data['input_content'], 'category' => $data['input_category'], 'tag1' => $data['input_tag1'], 'tag2' => $data['input_tag2'], 'rating' => $data['input_rating'], 'image' => $upload_file, 'datetime' => $time);
         //モデルオブジェクト作成
         $new = Model_Post::forge();
         $new->set($props);
         //データを保存する
         if (!$new->save()) {
             //保存失敗
             $data['save'] = '正しく投稿できませんでした。';
         } else {
             //保存成功
             /* 本当はユーザの投稿りすとページに飛びたい */
             Response::redirect('members/top');
         }
     }
     //$val->run()ここまで
     //validationオブジェクトをviewに渡す
     $data['val'] = $val;
     return View::forge('members/post2', $data, false);
 }
Example #17
0
 public function action_index()
 {
     require $_SERVER['DOCUMENT_ROOT'] . "/application/vendor/vimeo/autoload.php";
     $client_id = '';
     $client_secret = '';
     $token = '';
     $token_secret = '';
     $vimeo = new \Vimeo\Vimeo($client_id, $client_secret, $token);
     $categories = $vimeo->request("/categories");
     foreach ($categories['body']['data'] as $category) {
         // $categoryArray = array('Animation', 'Arts & Design', 'Cameras & Techniques', 'Comedy', 'Documentary', 'Experimental', 'Fashion', 'Food', 'Instructionals', 'Music', 'Narrative', 'Personal', 'Reporting & Journalism', 'Sports', 'Talks'));
         // if (in_array($category['name'], $categoryArray)) {
         // 	continue;
         // }
         $categoryShortName = str_replace('/categories/', '', $category['uri']);
         for ($i = 1; $i <= 20; $i++) {
             sleep(1);
             echo 'page ' . $i . ' of ' . $category['uri'];
             $videos = $vimeo->request($category['uri'] . '/videos', array('sort' => 'plays', 'per_page' => 50, 'page' => $i));
             // echo '<pre>'; print_r($videos); echo '</pre>'; exit;
             foreach ($videos['body']['data'] as $video) {
                 // Prepares video data array
                 $videoSpecs['uri'] = $video['uri'];
                 $videoSpecs['name'] = $video['name'];
                 $videoSpecs['description'] = $video['description'];
                 $videoSpecs['link'] = $video['link'];
                 $videoSpecs['duration'] = $video['duration'];
                 $videoSpecs['width'] = $video['width'];
                 $videoSpecs['height'] = $video['height'];
                 $videoSpecs['create_time'] = $video['created_time'];
                 $videoSpecs['plays'] = $video['stats']['plays'];
                 $videoSpecs['likes'] = $video['metadata']['connections']['likes']['total'];
                 $videoSpecs['comments'] = $video['metadata']['connections']['comments']['total'];
                 if ($video['privacy']['embed'] === 'public') {
                     $videoSpecs['embeddable'] = true;
                 } else {
                     $videoSpecs['embeddable'] = false;
                 }
                 // Look for existing record
                 $videoOrm = ORM::factory('Video')->where('uri', '=', $video['uri'])->find_all()->as_array();
                 if (sizeOf($videoOrm) === 0) {
                     // Add record to DB if it doesn't exist
                     $videoRecord = new Model_Video();
                     $videoRecord->values($videoSpecs);
                     $videoRecord->save();
                     $videoId = $videoRecord->id;
                     $videoOrm = ORM::factory('Video')->where('uri', '=', $video['uri'])->find();
                     // Populate tags table with video data
                     foreach ($video['tags'] as $tag) {
                         $tagRecord = new Model_Tag();
                         $tagRecord->values(array('video_id' => $videoId, 'name' => $tag['name']));
                         $tagRecord->save();
                     }
                 } else {
                     // Update record if it exists
                     $videoOrm[0]->values($videoSpecs);
                     $videoOrm[0]->save();
                     $videoId = $videoOrm[0]->id;
                 }
                 // Populate categories table category data if that video and category association is not already stored
                 $categoryOrm = ORM::factory('Category')->where('video_id', '=', $videoId)->and_where('short_name', '=', $categoryShortName)->find_all();
                 if ($categoryOrm->count() === 0) {
                     $categoryRecord = new Model_Category();
                     $categoryRecord->values(array('video_id' => $videoId, 'name' => $category['name'], 'short_name' => $categoryShortName));
                     $categoryRecord->save();
                 }
             }
         }
     }
 }
Example #18
0
 public function dropTags($tag = null)
 {
     $isnull = $tag === null;
     if (!$tag instanceof Model_Tag) {
         if (is_array($tag) or $tag instanceof Model_List_Tag) {
             foreach ($tag as $item) {
                 $this->removeTag($item);
             }
             return true;
         } else {
             $tag = new Model_Tag($this->_db, $tag);
         }
     }
     return $tag->untagModel($this, $isnull);
 }
Example #19
0
 private static function get_validation_object(\News\Model_News $news)
 {
     $val = \Validation::forge();
     $val->add_model($news);
     $val->add('published_at_time', '公開日時')->add_rule('datetime_except_second');
     if (empty($news->is_published)) {
         $val->add('is_draft', term('form.draft'))->add_rule('valid_string', 'numeric')->add_rule('in_array', array(0, 1));
     }
     if (\Config::get('news.tags.isEnabled')) {
         $options = \Model_Tag::get_assoc('name', 'name');
         $val->add('tags', term('site.tag'))->set_options($options)->add_rule('array_trim')->add_rule('array_max_length', 128);
     }
     return $val;
 }