예제 #1
0
function amp_badge_tag_cloud($options = array())
{
    $qty_set = isset($options['qty_set']) && $options['qty_set'] ? $options['qty_set'] : false;
    if (!$qty_set && !isset($options['section'])) {
        $qty_set = AMP_lookup('tag_totals_articles_by_section_live', AMP_current_section_id());
    }
    if (!$qty_set && !$options['section']) {
        $qty_set = AMP_lookup('tag_totals_articles_live');
    }
    if (!$qty_set && $options['section']) {
        $qty_set = AMP_lookup('tag_totals_articles_by_section_live', $options['section']);
    }
    if (!$qty_set) {
        return false;
    }
    $display_url = isset($options['display_url']) && $options['display_url'] ? $options['display_url'] : false;
    $source_item = new AMP_Content_Tag(AMP_Registry::getDbcon());
    $source = $source_item->find(array('displayable' => 1));
    if (!$source) {
        return false;
    }
    $display = new AMP_Display_Cloud($source, $qty_set);
    if ($display_url) {
        $display->set_url_method($display_url);
    }
    $renderer = AMP_get_renderer();
    return $renderer->div($display->execute(), array('class' => 'tagcloud_badge'));
}
예제 #2
0
function AMP_display_nav_tag_cloud()
{
    $qty_set = AMPSystem_Lookup::instance('tagTotals');
    if (!$qty_set) {
        return false;
    }
    $source_item = new AMP_Content_Tag(AMP_Registry::getDbcon());
    $source = $source_item->find(array('live' => AMP_CONTENT_STATUS_LIVE));
    $display = new AMP_Display_Cloud($source, $qty_set);
    return $display->execute();
}
예제 #3
0
 function _validate_source($source)
 {
     $source_array = array();
     foreach ($source as $item) {
         if (is_object($item)) {
             $source_array[] = $item;
             continue;
         }
         if (is_numeric($item)) {
             $tag = new AMP_Content_Tag(AMP_Registry::getDbcon(), $item);
             if ($tag->hasData()) {
                 $source_array[] = $tag;
                 continue;
             }
         }
     }
     return $source_array;
 }
예제 #4
0
파일: Tag.php 프로젝트: radicaldesigns/amp
 function _create($tag_name, $description = false)
 {
     $tag = new AMP_Content_Tag(AMP_Registry::getDbcon());
     $tag->setDefaults();
     $tag->mergeData(array('name' => $tag_name, 'description' => $description));
     $result = $tag->save();
     if (!$result) {
         return false;
     }
     AMP_Content_Tag::findByName($tag_name, $tag->id);
     return $tag->id;
 }
예제 #5
0
 function tag($tag_id = false, $tag_names = false)
 {
     if ($tag_names) {
         require_once 'AMP/Content/Tag/Tag.php';
         $new_tag_set = AMP_Content_Tag::create_many($tag_names);
         $new_tag_results = true;
         foreach ($new_tag_set as $new_tag_id) {
             $new_tag_results = $new_tag_results && $this->tag($new_tag_id);
         }
         if (!$tag_id) {
             return $new_tag_results;
         }
     }
     if (!$tag_id) {
         return false;
     }
     $related_tags = AMPSystem_Lookup::instance('tagsByArticle', $this->id);
     if (isset($related_tags[$tag_id])) {
         return false;
     }
     require_once 'AMP/Content/Tag/Item/Item.php';
     $action_item = new AMP_Content_Tag_Item(AMP_Registry::getDbcon());
     $create_values = array('item_type' => 'article', 'item_id' => $this->id, 'user_id' => AMP_SYSTEM_USER_ID, 'tag_id' => $tag_id);
     $action_item->setData($create_values);
     return $action_item->save();
 }
예제 #6
0
 /**
  * setTag 
  * 
  * @param   mixed     $tag    a string or integer denoting a tag 
  * @access public
  * @since  3.7.3
  * @return void
  */
 function setTag($tag)
 {
     require_once 'AMP/Content/Tag/Tag.php';
     $tag = new AMP_Content_Tag($this->dbcon, $tag);
     if (!$tag->hasData()) {
         return false;
     }
     $this->tag =& $tag;
 }
예제 #7
0
function AMP_add_tags($tag_ids = false, $tag_names = false, $item_id, $item_type)
{
    if ($tag_names) {
        require_once 'AMP/Content/Tag/Tag.php';
        $new_tag_set = AMP_Content_Tag::create_many($tag_names);
        $new_tag_results = AMP_add_tags($new_tag_set, false, $item_id, $item_type);
        if (!$tag_ids) {
            return $new_tag_results;
        }
    }
    if (!$tag_ids) {
        return false;
    }
    if (!is_array($tag_ids)) {
        $tag_id_set = array($tag_ids);
    } else {
        $tag_id_set = $tag_ids;
    }
    $related_tags = AMPSystem_Lookup::instance('tagsBy' . ucfirst($item_type), $item_id);
    if ($related_tags) {
        $new_tags = array_diff($tag_id_set, array_keys($related_tags));
    } else {
        $new_tags = $tag_id_set;
    }
    if (!$new_tags || empty($new_tags)) {
        return false;
    }
    require_once 'AMP/Content/Tag/Item/Item.php';
    $action_item = new AMP_Content_Tag_Item(AMP_Registry::getDbcon());
    $create_values = array('item_type' => $item_type, 'item_id' => $item_id, 'user_id' => AMP_SYSTEM_USER_ID);
    $results = 0;
    foreach ($new_tags as $new_tag_id) {
        $create_values['tag_id'] = $new_tag_id;
        $action_item->dropID();
        $action_item->setData($create_values);
        $results += $action_item->save();
    }
    return $results;
}
예제 #8
0
 function _checkNewTags($data, $fieldname)
 {
     if (!(isset($data['new_tags']) && $data['new_tags'])) {
         return array();
     }
     require_once 'AMP/Content/Tag/Tag.php';
     return AMP_Content_Tag::create_many($data['new_tags']);
     /*
     $tags_set = preg_split( '/\s?,\s?/', $data['new_tags']);
     $tag_names = AMPSystem_Lookup::instance( 'tags' );
     $simple_tag_names = array( );
     $new_tags_verified = array( );
     
     foreach( $tag_names as $tag_id => $tag_name ) {
         $simple_tag_names[$tag_id] = strtolower( $tag_name );
     }
     
     foreach( $tags_set as $raw_new_tag ) {
         $new_tag = trim( $raw_new_tag );
         if ( !$new_tag ) continue;
     
         //see if an existing tag matches the new one
         $new_tag_id = array_search( strtolower( $new_tag ), $simple_tag_names );
     
         //create new tag
         if ( !$new_tag_id ) {
             $new_tag_id = $this->_createTag( $new_tag );
         }
         if ( !$new_tag_id ) continue;
         
         //add the id to the results list
         $new_tags_verified[] = $new_tag_id;
     }
     return $new_tags_verified;
     */
 }