array( 'link-list'=>array( 'value' => array('__callback__'=>'get_links'), 'type' => 'template', 'id' => 'etemplate.link_widget.list' ) ), ); */ /** * Set up what we know on the server side. * * Set the options for the application select. * * @param string $cname */ public function beforeSendToClient($cname) { $attrs = $this->attrs; $form_name = self::form_name($cname, $this->id); $value =& self::get_array(self::$request->content, $form_name, true); if(!is_array($value)) { throw new egw_exception_wrong_parameter("Wrong value sent to link widget, needs to be an array. ".array2string($value)); } $app = $value['to_app']; $id = $value['to_id']; // ToDo: implement on client-side if (!$attrs['help']) self::setElementAttribute($form_name, 'help', 'view this linked entry in its application'); if($attrs['type'] == 'link-list') { $links = egw_link::get_links($app,$id,'','link_lastmod DESC',true, $value['show_deleted']); _debug_array($links); foreach($links as $link) { $value[] = $link; } } } /** * Find links that match the given parameters */ public static function ajax_link_search($app, $type, $pattern, $options=array()) { $options['type'] = $type ? $type : $options['type']; error_log("$app, $pattern, $options"); $links = egw_link::query($app, $pattern, $options); $response = egw_json_response::get(); $response->data($links); } /** * Create links */ public static function ajax_link($app, $id, Array $links) { // Files need to know full path in tmp directory foreach($links as &$link) { if($link['app'] == egw_link::VFS_APPNAME) { if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) { $path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . $link['id']; } else { $path = $link['id'].'+'; } $link['tmp_name'] = $path; $link['id'] = $link; } } $result = egw_link::link($app, $id, $links); $response = egw_json_response::get(); $response->data($result !== false); } public function get_links($value) { $app = $value['to_app']; $id = $value['to_id']; $links = egw_link::get_links($app,$id,'','link_lastmod DESC',true, $value['show_deleted']); _debug_array($links); return $links; } }