示例#1
0
 /**
  * Get tags for a list of IDs
  * 
  * @param      array   $ids       Bulletin ids
  * @param      integer $admin     Admin flag
  * @return     array
  */
 public function getTagsForIds($ids = array(), $admin = 0)
 {
     $tt = Tag::blank();
     $tj = Object::blank();
     if (!is_array($ids) || empty($ids)) {
         return false;
     }
     $ids = array_map('intval', $ids);
     $sql = "SELECT t.tag, t.raw_tag, t.admin, rt.objectid\n\t\t\t\tFROM " . $tt->getTableName() . " AS t \n\t\t\t\tINNER JOIN " . $tj->getTableName() . " AS rt ON (rt.tagid = t.id) AND rt.tbl='" . $this->_scope . "' \n\t\t\t\tWHERE rt.objectid IN (" . implode(',', $ids) . ") ";
     switch ($admin) {
         case 1:
             $sql .= "";
             break;
         case 0:
         default:
             $sql .= "AND t.admin=0 ";
             break;
     }
     $sql .= "ORDER BY raw_tag ASC";
     $db = \App::get('db');
     $db->setQuery($sql);
     $tags = array();
     if ($items = $db->loadObjectList()) {
         foreach ($items as $item) {
             if (!isset($tags[$item->objectid])) {
                 $tags[$item->objectid] = array();
             }
             $tags[$item->objectid][] = $item;
         }
     }
     return $tags;
 }
示例#2
0
 /**
  * Normalize a tag
  * Strips spaces, punctuation, makes lowercase, and allows only alpha-numeric chars
  *
  * @param      string $tag Raw tag
  * @return     string Normalized tag
  */
 public function normalize_tag($tag)
 {
     $t = \Components\Tags\Models\Tag::blank();
     return $t->normalize($tag);
 }
示例#3
0
 /**
  * Generates automatic tag field
  *
  * @param   array   $data  the data being saved
  * @return  string
  */
 public function automaticTag($data)
 {
     $tag = isset($data['raw_tag']) && $data['raw_tag'] ? $data['raw_tag'] : $data['tag'];
     return Tag::blank()->normalize($tag);
 }
示例#4
0
 /**
  * Normalize a raw tag
  * Strips all non-alphanumeric characters
  *
  * @param   string  $tag  Raw tag
  * @return  string
  */
 public function normalize($tag)
 {
     return Tag::blank()->normalize($tag);
 }