Api

Version

mediamosa-21

Class

mediamosa_rest_call_asset_metadata_property_list

Code

File: /sites/all/modules/mediamosa/modules/asset/metadata/property/mediamosa_asset_metadata_property.rest.inc
<?php?php
// $Id$

/**
 * MediaMosa is Open Source Software to build a Full Featured, Webservice
 * Oriented Media Management and Distribution platform (http://mediamosa.org)
 *
 * Copyright (C) 2010 SURFnet BV (http://www.surfnet.nl) and Kennisnet
 * (http://www.kennisnet.nl)
 *
 * MediaMosa is based on the open source Drupal platform and
 * was originally developed by Madcap BV (http://www.madcap.nl)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, you can find it at:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */

 /**
  * @file
  * The Asset Metadata Property REST calls.
  */

/**
 * URI: /metadata_tag
 * Get a listing of the current asset media metadata define
 *
 * 1.x: media_management_metadata_definition_get
 */
class mediamosa_rest_call_asset_metadata_property_list extends mediamosa_rest_call {

  
// ------------------------------------------------------------------ Consts.
  // REST vars.
  
const INCLUDE_DEFAULT_DEFINITIONS 'include_default_definitions'// Switch if we need to get all the default definitions that are 'global' over all apps.
  
const NAME 'name';  // Search on specific name.

  // ------------------------------------------------------------------ Get Var Setup.
  
public function get_var_setup() {
    
$a_var_setup = array(
      
self::VARS => array(
        
self::INCLUDE_DEFAULT_DEFINITIONS => array(
          
self::VAR_TYPE => mediamosa_type::TYPE_BOOL,
          
self::VAR_DEFAULT_VALUE => 'TRUE',
          
self::DESCRIPTION => "Switch if we need to get all the default definitions that are 'global' over all apps.",
        ),
        
self::NAME => array(
          
self::VAR_TYPE => mediamosa_type::TYPE_ALPHA_NUM_UNDERSCORE,
          
self::DESCRIPTION => 'Optional property name to search on.',
        ),
      ),
    );

    
// Enrich with default REST vars limit / offset.
    
$a_var_setup self::get_var_setup_range($a_var_setup);

    
// Add order by stuff.
    
$a_var_setup self::get_var_setup_order_by(
      
$a_var_setup,
      
''// No default.
      
array(
        
mediamosa_asset_metadata_property_db::ID,
        
mediamosa_asset_metadata_property_db::NAME,
        
mediamosa_asset_metadata_property_db::TYPE,
        
mediamosa_asset_metadata_property_db::CREATED,
        
mediamosa_asset_metadata_property_db::CHANGED,
      ),
      
mediamosa_type::ORDER_DIRECTION_ASC
    
);

    
// Enrich with required REST vars.
    
return self::get_var_setup_default($a_var_setup);
  }

  
// ------------------------------------------------------------------ Do Call.
  
public function do_call() {
    
$o_mediamosa mediamosa::get();

    
$a_app_ids $this->get_param_value(self::APP_ID);

    
// limit, offset.
    
$limit $this->get_param_value(self::LIMIT);
    
$offset $this->get_param_value(self::OFFSET);

    
// Order by, order direction.
    
$order_by $this->get_param_value(self::ORDER_BY);
    
$order_direction $this->get_param_value(self::ORDER_DIRECTION);

    
// Include all default properties?
    
$include_default_definitions $this->get_param_value(self::INCLUDE_DEFAULT_DEFINITIONS);

    
// Name to search on.
    
$name $this->get_param_value(self::NAME);

    
// Get all properties.
    
$a_properties mediamosa_asset_metadata_property::property_list(
      
$a_app_ids,
      
$include_default_definitions,
      
$name,
      
$offset,
      
$limit,
      
$order_by,
      
$order_direction
    
);

    foreach (
$a_properties as $a_property) {
      
$o_mediamosa->add_item(
        array(
          
'prop_id' => $a_property[mediamosa_asset_metadata_property_db::ID],
          
'name' => $a_property[mediamosa_asset_metadata_property_db::NAME],
          
'prop_group' => $a_property[mediamosa_asset_metadata_property_group_db::NAME],
          
'type' => $a_property[mediamosa_asset_metadata_property_db::TYPE],
          
'created' => $a_property[mediamosa_asset_metadata_property_db::CREATED],
          
'changed' => $a_property[mediamosa_asset_metadata_property_db::CHANGED],
        )
      );
    }
  }
}