MediaSearch_Index
[ class tree: MediaSearch_Index ] [ index: MediaSearch_Index ] [ all elements ]

Source for file KeyWords.php

Documentation is available at KeyWords.php

  1. <?php
  2. /**
  3.  * MediaSearch
  4.  *
  5.  * LICENSE
  6.  *
  7.  * "THE BEER-WARE LICENSE" (Revision 42):
  8.  * "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
  9.  * As long as you retain this notice you can do whatever you want with
  10.  * this stuff. If we meet some day, and you think this stuff is worth it,
  11.  * you can buy me a beer in return.
  12.  *
  13.  * $Author$
  14.  * $Revision$
  15.  *
  16.  * @category    MediaSearch
  17.  * @package     MediaSearch_Index
  18.  * @copyright   Copyright (c) 2009 Sven Strittmatter
  19.  */
  20.  
  21. /**
  22.   * @todo Write apidoc.
  23.   *
  24.   * @category   MediaSearch
  25.   * @package    MediaSearch_Index
  26.   * @copyright  Copyright (c) 2009 Sven Strittmatter
  27.   */
  28.     const TRACE_LELVEL 45;
  29.  
  30.     protected $keyWords;
  31.  
  32.     public function __construct({
  33.         $this->keyWords = array();
  34.     }
  35.  
  36.     public function addFileCriteria(MediaSearch_Model_FileMeta $fileMeta{
  37.         $keyWords explode(','$fileMeta->getKeyWords());
  38.  
  39.         foreach ($keyWords as $keyWord{
  40.             $this->addKeyWord($keyWord$fileMeta->getId());
  41.         }
  42.     }
  43.  
  44.     public function convertToModels({
  45.         $models array();
  46.  
  47.         foreach ($this->keyWords as $keyWord => $fileMetaIds{
  48.             $models[new MediaSearch_Model_KeyWord(array(
  49.                 'keyWord' => $keyWord,
  50.                 'fileMetaIds' => implode(','$fileMetaIds)
  51.             ));
  52.         }
  53.  
  54.         return $models;
  55.     }
  56.  
  57.     private function addKeyWord($keyWord$fileMetaId{
  58.         $keyWord strtolower($keyWord);
  59.         
  60.         if (!array_key_exists($keyWord$this->keyWords)) {
  61.             $this->keyWords[$keyWordarray();
  62.         }
  63.  
  64.         if (!in_array($fileMetaId$this->keyWords[$keyWord])) {
  65.             $this->keyWords[$keyWord][$fileMetaId;
  66.         }
  67.     }
  68. }

Documentation generated on Mon, 17 Aug 2009 14:53:27 +0200 by phpDocumentor 1.4.2