asset_load

Versions
5 – 6
asset_load($param = array(), $reset = NULL)

Load an asset object from db and set some default properties. Taken almost exactly from node_load to utilize caching and assetapi load hook

Parameters

$aid id of asset to load

▾ 30 functions call asset_load()

asset_check_directory in contributions/asset/inc/asset.routines.inc
Wrapper for file_check_directory that also checks/adds a matching asset
asset_directory_view in contributions/asset/asset.types.inc
Implementation of hook_asset_type('view') for directory asset type
asset_field in contributions/asset/modules/asset_content.inc
Implementation of hook_field().
asset_img_preview in contributions/asset/asset.module
Callback function to output an image for preview of an asset.
asset_js_preview in contributions/asset/asset.module
Menu Callback from javascript to print an assets preview
asset_lightbox in contributions/asset/asset.module
Integrate asset with lightbox
asset_nodeapi in contributions/asset/inc/asset.node.inc
Implementation of hook_nodeapi() This is where we build the asset_node records.
asset_panels_content_gallery in contributions/asset/asset_panels/asset_panels.module
Output function for the 'node' content type. Outputs a node based on the module and delta supplied in the configuration.
asset_preview in contributions/asset/asset.module
Build a preview of an asset based on module and format options. If no module and format info is given then the default teaser formatter is used.
asset_process in contributions/asset/inc/modules/asset_content.inc
asset_render_macro in contributions/asset/asset.module
build html from atrributes array.
asset_save in contributions/asset/inc/asset.node.inc
Persist an asset object to the db
asset_views_handler_field_asset in contributions/asset/asset_views.inc
asset_views_handler_field_asset_link in contributions/asset/asset_views.inc
asset_widget in contributions/asset/inc/modules/asset_content.inc
Implementation of hook_widget().
asset_wizard_browse in contributions/asset/asset_wizard.module
Step 1: Display a browsable list of assets
asset_wizard_default_fields in contributions/asset/asset_wizard.inc
This is the base form for asset types.
asset_wizard_directory_options in contributions/asset/asset_wizard.inc
asset_wizard_form in contributions/asset/asset_wizard.inc
Main form builder function for the asset wizard.
asset_wizard_form_asset_selection in contributions/asset/asset_wizard.inc
Form builder for step 1 of the asset wizard. This step is the most intensive so it has been separated out for clarity.
asset_wizard_form_validate in contributions/asset/asset_wizard.inc
Validate callback for asset_wizard_form().
asset_wizard_get_path in contributions/asset/asset_wizard.module
asset_wizard_location_bar in contributions/asset/asset_wizard.inc
asset_wizard_menu in contributions/asset/asset_wizard.module
Implementation of hook_menu().
asset_wizard_set_breadcrumb in contributions/asset/asset_wizard.module
Set breadcrumb based on asset heirarchy
asset_youtube_save_asset in contributions/asset/asset_youtube/asset_youtube.module
theme_assetfield in contributions/asset/asset_wizard.module
Format an assetfield.
theme_asset_wizard_links in contributions/asset/asset_wizard.module
theme_asset_wizard_selected in contributions/asset/asset_wizard.module
theme_asset_wizard_textfield_preview in contributions/asset/asset_wizard.module

Code

contributions/asset/inc/asset.node.inc, line 65

<?php
function asset_load($param = array(), $reset = NULL) {
	static $assets = array();
	if ($reset) {
		$assets = array();
	}
	$arguments = array();
	if (is_numeric($param)) {
		if (isset ($assets[$param])) {
			return is_object($assets[$param]) ? drupal_clone($assets[$param]) : $assets[$param];
		}
		$cond ='a.aid = %d';
		$arguments[] = $param;
	} elseif (is_array($param)) {
		// Turn the conditions into a query.
		foreach ($param as $key => $value) {
			$cond[] ='a.'. db_escape_string($key) ." = '%s'";
			$arguments[] = $value;
		}
		$cond = implode(' AND ', $cond);
	} else {
		return false;
	}
	// Retrieve the asset.
	$asset = db_fetch_object(db_query('SELECT a.* FROM {asset} a WHERE ' . $cond, $arguments));
	if (!$asset) {
		return false;
	}
	$dirname_tmp = $asset->dirname ? $asset->dirname . '/' : $asset->dirname;
	$result = db_query('SELECT * FROM {asset_role} WHERE aid = %d', $asset->aid);
	while ($role = db_fetch_array($result)) {
		$asset->roles[$role['rid']] = $role['status'] ? $role['rid'] : 0;
	}
	$asset->filepath = file_create_path($dirname_tmp . $asset->filename);
	$asset->url = file_create_url($dirname_tmp . $asset->filename);
	$asset->extension = strtolower($asset->extension);
	$asset->title = $asset->title ? $asset->title : $asset->filename;
	if ($asset->type == 'directory' && $asset->dirname == '' && $asset->filename == $GLOBALS['user']->name) {
		$asset->title = t('My Assets');
	}
	if ($asset->aid) {
		if ($extra = module_invoke_all('assetapi', 'load', $asset)) {
			foreach ($extra as $key => $value) {
				$asset->$key = $value;
			}
		}
		$assets[$asset->aid] = is_object($asset) ? drupal_clone($asset) : $asset;
	}
	return $asset;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.