diff --git a/apps.manifest.inc b/apps.manifest.inc index 975572c..db7a54d 100755 --- a/apps.manifest.inc +++ b/apps.manifest.inc @@ -1,3 +1,5 @@ + if (!$manifest) { + if (!isset($server['manifest']) || !$server['manifest']) { info['apps']['manifests'] as $mfile) { $mfile = drupal_get_path("module", $module) . "/" .$mfile; $app = drupal_parse_info_file($mfile); - foreach($app['screenshots'] as $id=>$image) { - $app['screenshots'][$id] = url(dirname($mfile) . "/" . $image); - } - $app['logo'] = url(dirname($mfile) . "/" . $app['logo']); + if (isset($app['screenshots'])) { + foreach($app['screenshots'] as $id => $image) { + $app['screenshots'][$id] = url(dirname($mfile) . "/" . $image); + } + } + $app['logo'] = url(dirname($mfile) . "/" . $app['logo']); $apps[] = $app; } } @@ -31,10 +41,11 @@ function apps_server_local($server) { } return $apps; } -/* - * returns all servers/server defined by the current profile - * PARAM server_name: the name of a server - * RETURN : an array of server arrays one server array if $server_name has a value + +/** + * Returns all servers/server defined by the current profile + * @param server_name: the name of a server + * @return : an array of server arrays one server array if $server_name has a value * * TODO: Turn Store Objects in to Object instead of arrays OPIC-372 */ @@ -75,12 +86,14 @@ function apps_servers($server_name = FALSE) { } return FALSE; } + /** - * retrieve apps from the manifest - * PARAM $server: a server object return from apps_servers - * PARAM $condition: and array of key and values to match in the app arrays - * PARAM $add_theme: if True apps_apps_add_theme will be called when done getting apps - * RETURN : an array of app info arrays + * Retrieve apps from the manifest. + * + * @param $server: a server object return from apps_servers. + * @param $condition: and array of key and values to match in the app arrays. + * @param $add_theme: if True apps_apps_add_theme will be called when done getting apps. + * @return : an array of app info arrays. */ function apps_apps($server, $condition = array(), $add_theme=FALSE) { if (!is_array($server)) { @@ -109,11 +122,12 @@ function apps_apps($server, $condition = array(), $add_theme=FALSE) { } /** - * takes an array of apps and ands #theme properties so that - * it can be drupal rendered - * PARAM $apps: an array of apps from apps_apps - * RETURN : the apps array with add #theme settings for a list - * view of the apps + * Takes an array of apps and ands #theme properties so that + * it can be drupal rendered. + * + * @param $apps: an array of apps from apps_apps. + * @return : the apps array with add #theme settings for a list + * view of the apps. */ function apps_apps_add_theme(&$apps) { foreach($apps as $id=> $app) { @@ -139,10 +153,11 @@ function apps_client_id() { } /** - * Request manifest and media assets from the app server - * PARAM $server: a server object return from apps_servers - * RETURN : an array represntation of the json manifest, with images - * relpaced by file objects + * Request manifest and media assets from the app server. + * + * @param $server: a server object return from apps_servers. + * @return : an array represntation of the json manifest, with images + * relpaced by file objects. * * TODO: Handle lack of server presense OPIC-374 */ @@ -192,40 +207,38 @@ function apps_request_manifest($server) { return $manifest; } -/* - * Downloads images so that they can be sized with image styles +/** + * Downloads images so that they can be sized with image styles. */ function apps_request_manifest_image_process(&$manifest) { foreach($manifest['apps'] as $id => $app) { - //Get Logo - $logo_uri = $app['logo']; + // Get logo. $logo = (array) apps_retrieve_app_image($app['logo'], "{$app['name']} Logo"); - $manifest['apps'][$id]['logo'] = !empty($logo) ? $logo : FALSE; - //Get screenshots - foreach ($app['screenshots'] as $ss_id => $ss) { - $screenshot = (array) apps_retrieve_app_image($ss, "{$app['name']} Screenshot $id"); - - if(!empty($screenshot)) { - $manifest['apps'][$id]['screenshots'][$ss_id] = $screenshot; - } - else { - unset($manifest['apps'][$id]['screenshots'][$ss_id]); + // Get screenshots. + if (isset($app['screenshots'])) { + foreach ($app['screenshots'] as $ss_id => $ss) { + $screenshot = (array) apps_retrieve_app_image($ss, "{$app['name']} Screenshot $id"); + + if(!empty($screenshot)) { + $manifest['apps'][$id]['screenshots'][$ss_id] = $screenshot; + } + else { + unset($manifest['apps'][$id]['screenshots'][$ss_id]); + } } } } - } /** - * Download a image from the manifest - * - * PARAM url: the url of the image - * PARAM title: the title of the image - * PARAM alt: the alt text of the image - * RETURN : a file object for the download file or FALSE if no image was downloaded + * Download a image from the manifest. * + * @param url: the url of the image. + * @param title: the title of the image. + * @param alt: the alt text of the image. + * @return : a file object for the download file or FALSE if no image was downloaded. */ function apps_retrieve_app_image($url, $title = FALSE, $alt = FALSE) { //allow for local files from the development server type @@ -286,15 +299,15 @@ function apps_retrieve_app_image($url, $title = FALSE, $alt = FALSE) { } /** - * Produce the Process Manifest + * Produce the Process Manifest. * * Starting with the json manifest and adding data around the current status of the app - * in this install + * in this install. * - * PARAM $server: a server object return from apps_servers - * RETURN : an array of the process json manifest + * @param $server: a server object return from apps_servers. + * @return : an array of the process json manifest. * - *TODO: Cache status data and clear on changes to any module status + * TODO: Cache status data and clear on changes to any module status. */ function apps_manifest($server) { $manifests = &drupal_static(__FUNCTION__); @@ -315,7 +328,7 @@ function apps_manifest($server) { $app['installed'] = (bool) $current_app_module; $app['dep_installed'] = TRUE; $app['disabled'] = $current_app_module && empty($current_app_module->status) && $current_app_module->schema_version > SCHEMA_UNINSTALLED; - $app['featured'] = ($app['machine_name'] == $manifest['featured app']); + $app['featured'] = (isset($manifest['featured app']) && $app['machine_name'] == $manifest['featured app']); $app['server'] = $server; $app['dependencies'] = isset($app['dependencies']) ? $app['dependencies'] : array(); $app['libraries'] = isset($app['libraries']) ? $app['libraries'] : array(); @@ -423,22 +436,19 @@ function apps_app_callback($app, $key) { } } - /** - * default demo content enabled callback + * Default demo content enabled callback. * - * check to see if the apps demo content module is enabled + * Check to see if the apps demo content module is enabled. */ function apps_demo_content_enabled($app) { return (module_exists($app['demo content module'])); } /** - * default demo content enable callback - * - * enables the app's demo content module - * PARAM $app: an app array - * RETURN : bool if the module was enabled + * Default demo content enable callback. Enables the app's demo content module. + * @param $app: an app array. + * @return : bool if the module was enabled. */ function apps_demo_content_enable($app) { $success = module_enable(array($app['demo content module'])); @@ -447,11 +457,9 @@ function apps_demo_content_enable($app) { } /** - * default demo content disable callback - * - * disables the app's demo content module - * PARAM $app: an app array - * RETURN : bool if the module was disabled + * Default demo content disable callback. Disables the app's demo content module. + * @param $app : an app array. + * @return : bool if the module was disabled. */ function apps_demo_content_disable($app) { $success = module_disable(array($app['demo content module'])); @@ -460,7 +468,7 @@ function apps_demo_content_disable($app) { } /** - * formcall back for demo content + * Form callback for demo content. */ function apps_demo_content_form($form, &$form_state, $app) { $form = array(); @@ -494,7 +502,7 @@ function apps_demo_content_form($form, &$form_state, $app) { } /** - * callback for demp content form + * Callback for demo content form. */ function apps_demo_content_form_submit($form, &$form_state) { $app = $form_state['values']['app'];