function get() { if (argc() == 2 && argv(1) == 'edit') { $mode = 'edit'; } else { $mode = 'list'; } $_SESSION['return_url'] = \App::$cmd; $apps = array(); if (local_channel()) { import_system_apps(); $syslist = array(); $list = app_list(local_channel(), false, $_GET['cat']); if ($list) { foreach ($list as $x) { $syslist[] = app_encode($x); } } translate_system_apps($syslist); } else { $syslist = get_system_apps(true); } usort($syslist, 'app_name_compare'); // logger('apps: ' . print_r($syslist,true)); foreach ($syslist as $app) { $apps[] = app_render($app, $mode); } return replace_macros(get_markup_template('myapps.tpl'), array('$sitename' => get_config('system', 'sitename'), '$cat' => array_key_exists('cat', $_GET) && $_GET['cat'] ? ' - ' . escape_tags($_GET['cat']) : '', '$title' => t('Apps'), '$apps' => $apps)); }
function parse_app_description($f) { $ret = array(); $baseurl = z_root(); $channel = get_app()->get_channel(); $address = $channel ? $channel['channel_address'] : ''; //future expansion $observer = get_app()->get_observer(); $lines = @file($f); if ($lines) { foreach ($lines as $x) { if (preg_match('/^([a-zA-Z].*?):(.*?)$/ism', $x, $matches)) { $ret[$matches[1]] = trim(str_replace(array('$baseurl', '$nick'), array($baseurl, $address), $matches[2])); } } } if (!$ret['photo']) { $ret['photo'] = $baseurl . '/' . get_default_profile_photo(80); } $ret['type'] = 'system'; foreach ($ret as $k => $v) { if (strpos($v, 'http') === 0) { $ret[$k] = zid($v); } } if (array_key_exists('desc', $ret)) { $ret['desc'] = str_replace(array('\'', '"'), array(''', '&dquot;'), $ret['desc']); } if (array_key_exists('target', $ret)) { $ret['target'] = str_replace(array('\'', '"'), array(''', '&dquot;'), $ret['target']); } if (array_key_exists('requires', $ret)) { $require = trim(strtolower($ret['requires'])); switch ($require) { case 'nologin': if (local_user()) { unset($ret); } break; case 'admin': if (!is_site_admin()) { unset($ret); } break; case 'local_user': if (!local_user()) { unset($ret); } break; case 'public_profile': if (!is_public_profile()) { unset($ret); } break; case 'observer': if (!$observer) { unset($ret); } break; default: if (!local_user() && feature_enabled(local_user(), $require)) { unset($ret); } break; } // logger('require: ' . print_r($ret,true)); } if ($ret) { translate_system_apps($ret); return $ret; } return false; }